1% r = CheckRAPRepresentation(H0, H1, prec)
3% Checks
if the input matrixes define a continuous time RAP.
5% Matrices H0 and H1 must have the same size, the dominant
6% eigenvalue of H0
is negative and real, and the rowsum of
7% H0+H1
is 0 (up to the numerical precision).
11% H0 : matrix, shape (M,M)
12% The H0 matrix of the RAP to check
13% H1 : matrix, shape (M,M)
14% The H1 matrix of the RAP to check
15% prec : double, optional
16% Numerical precision, the default value
is 1e-14
21% The result of the check
23function r = CheckRAPRepresentation (D0, D1, prec)
25 global BuToolsVerbose;
27 global BuToolsCheckPrecision;
28 if isempty(BuToolsCheckPrecision)
29 BuToolsCheckPrecision = 1e-12;
32 if ~exist(
'prec',
'var')
33 prec = BuToolsCheckPrecision;
36 if size(D0,1)~=size(D0,2)
38 fprintf ('CheckRAPRepresentation: D0
is not a quadratic matrix!\n');
44 if size(D1,1)~=size(D1,2)
46 fprintf ('CheckRAPRepresentation: D1
is not a quadratic matrix!\n');
54 fprintf ('CheckRAPRepresentation: D0 and D1 have different sizes!\n');
60 if max(abs((D0+D1)*ones(size(D0,1),1))) > prec
62 fprintf ('CheckRAPRepresentation: A rowsum of D0+D1
is not 0!(precision: %g)\n',prec);
70 if max(real(ev))>=-prec
72 fprintf ('CheckRAPRepresentation: there
is an eigenvalue of D0 with non-negative real part (at precision %g)\n',prec);
90 if max(reig) < max(ceig)
92 fprintf ('CheckRAPRepresentation: The dominant eigenvalue of D0
is not real!\n');
98 if max(reig)==max(ceig)
100 fprintf('CheckRAPRepresentation: The dominant and a complex eigenvalue of D0 has the same real part!\n');