LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
CheckMGRepresentation.m
1% r = CheckMGRepresentation(alpha, A, prec)
2%
3% Checks if the given vector and matrix define a valid matrix-
4% geometric representation.
5%
6% Parameters
7% ----------
8% alpha : matrix, shape (1,M)
9% Initial vector of the matrix-geometric distribution
10% to check
11% A : matrix, shape (M,M)
12% Matrix parameter of the matrix-geometric distribution
13% to check
14% prec : double, optional
15% Numerical precision. The default value is 1e-14.
16%
17% Returns
18% -------
19% r : bool
20% True, if the matrix is a square matrix, the vector and
21% the matrix have the same size, the dominant eigenvalue
22% is positive, less than 1 and real.
23%
24% Notes
25% -----
26% This procedure does not check the positivity of the density!
27% The discrete counterpart of 'CheckMEPositiveDensity' does
28% not exist yet (research is needed).
29
30function r = CheckMGRepresentation(alpha, A, prec)
31
32 global BuToolsVerbose
33 global BuToolsCheckPrecision;
34 if isempty(BuToolsCheckPrecision)
35 BuToolsCheckPrecision = 1e-14;
36 end
37
38 if ~exist('prec','var')
39 prec = BuToolsCheckPrecision;
40 end
41
42 if size(A,1) ~= size(A,2)
43 if BuToolsVerbose
44 fprintf('CheckMGRepresentation: The matrix is not a quadratic matrix!\n');
45 end
46 r = false;
47 return;
48 end
49
50 if size(alpha,2) ~= size(A,1)
51 if BuToolsVerbose
52 fprintf('CheckMGRepresentation: The vector and the matrix have different sizes!\n');
53 end
54 r = false;
55 return;
56 end
57
58 if sum(alpha)<-prec || sum(alpha)>1+prec
59 if BuToolsVerbose
60 fprintf ('CheckMGRepresentation: The sum of the vector elements is less than zero or greater than one (precision: %g)!\n',prec);
61 end
62 r = false;
63 return;
64 end
65
66 ev = EigSort(eig(A));
67 maxev = ev(1);
68
69 if ~isreal(maxev)
70 if BuToolsVerbose
71 fprintf('CheckMGRepresentation: The largest eigenvalue of the matrix is complex!\n');
72 end
73 r = false;
74 return;
75 end
76
77 if maxev > 1+prec
78 if BuToolsVerbose
79 fprintf('CheckMGRepresentation: The largest eigenvalue of the matrix is greater than 1 (precision: %g)!\n',prec);
80 end
81 r = false;
82 return;
83 end
84
85 if sum(abs(ev(1:end))==abs(maxev)) > 1
86 if BuToolsVerbose
87 fprintf('CheckMGRepresentation Warning: There are more than one eigenvalue with the same absolute value as the largest eigenvalue!\n');
88 end
89 end
90
91 r = true;
92end