1% r = CheckGenerator(Q, transient, prec)
3% Checks
if the matrix
is a valid generator matrix: the
4% matrix
is a square matrix, the matrix has positive or
5% zero off-diagonal elements, the diagonal of the matrix
6%
is negative, the rowsum of the matrix
is 0.
8% If the
"transient" parameter
is set to
false, it checks
9%
if the real part of the maximum absolute eigenvalue
is
10% less than zero and the rowsum
is equal or less than 0.
14% Q : matrix, shape (M,M)
15% The generator to check.
16% transient : bool, optional
17% If
true, the procedure checks
if Q
is a transient
18% generator, otherwise it checks
if it
is a valid
19% generator. The
default value
is false.
20% prec : double, optional
21% Entries with absolute value less than prec are
22% considered to be zeros. The
default value
is 1e-14.
27% The result of the check.
29function r = CheckGenerator (Q,transient,prec)
31 global BuToolsVerbose;
32 global BuToolsCheckInput;
33 if isempty(BuToolsCheckInput)
34 BuToolsCheckInput =
true;
36 global BuToolsCheckPrecision;
37 if isempty(BuToolsCheckPrecision)
38 BuToolsCheckPrecision = 1e-14;
41 if ~exist(
'prec',
'var')
42 prec = BuToolsCheckPrecision;
45 if ~exist('transient','var')
51 if size(Q,1)~=size(Q,2)
53 fprintf ('CheckGenerator: Generator
is not a square matrix!\n');
60 fprintf ('CheckGenerator: The diagonal of the generator
is not negative (precision: %g)!\n', prec);
73 fprintf ('CheckGenerator: The generator has negative off-diagonal element (precision: %g)!\n', prec);
81 fprintf ('CheckGenerator: The rowsum of the transient generator
is greater than 0 (precision: %g)!\n', prec);
86 if max(real(eig(Q)))>=prec
88 fprintf ('CheckGenerator: The transient generator has non-negative eigenvalue (precision: %g)!\n', prec);
93 if any(abs(sum(Q,2))>prec)
95 fprintf ('CheckGenerator: The rowsum of the generator
is not 0 (precision: %g)!\n', prec);