1% r = CheckMERepresentation(alpha, A, prec)
3% Checks
if the given vector and matrix define a valid matrix-
4% exponential representation.
8% alpha : matrix, shape (1,M)
9% Initial vector of the matrix-exponential distribution
11% A : matrix, shape (M,M)
12% Matrix parameter of the matrix-exponential distribution
14% prec : double, optional
15% Numerical precision. The
default value
is 1e-14.
20% True,
if the matrix
is a square matrix, the vector and
21% the matrix have the same size, the dominant eigenvalue
26% This procedure does not check the positivity of the density!
27% Call
'CheckMEPositiveDensity' if it
is needed, but keep in
28% mind that it can be time-consuming,
while this procedure
31function r = CheckMERepresentation (alpha, A, prec)
33 global BuToolsVerbose;
34 global BuToolsCheckPrecision;
35 if isempty(BuToolsCheckPrecision)
36 BuToolsCheckPrecision = 1e-14;
39 if ~exist(
'prec',
'var')
40 prec = BuToolsCheckPrecision;
43 if size(A,1)~=size(A,2)
45 fprintf ('CheckMERepresentation: The matrix
is not a square matrix!\n');
51 if length(alpha)~=size(A,1)
53 fprintf ('CheckMERepresentation: The vector and the matrix have different sizes!\n');
59 if sum(alpha)<-prec*length(alpha) || sum(alpha)>1+prec*length(alpha)
61 fprintf ('CheckMERepresentation: The sum of the vector elements
is less than zero or greater than one (precision: %g)!\n',prec);
67 if max(real(eig(A)))>=prec
69 fprintf ('CheckMERepresentation: There
is an eigenvalue of the matrix with non-negative real part (at precision %g)!\n',prec);
76 [~,ix] = sort(abs(real(ev)));
81 fprintf ('CheckMERepresentation: The dominant eigenvalue of the matrix
is not real!\n');
87 if sum(abs(ev(1:end))==abs(maxev)) > 1 && BuToolsVerbose
88 fprintf ('CheckMERepresentation warning: There are more than one eigenvalue with the same absolute value as the largest eigenvalue!\n');