LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
CheckDRAPRepresentation.m
1% r = CheckDRAPRepresentation(H, prec)
2%
3% Checks if the input matrixes define a discrete time RAP.
4%
5% Matrices H0 and H1 must have the same size, the dominant
6% eigenvalue of H0 is real and less than 1, and the rowsum of
7% H0+H1 is 1 (up to the numerical precision).
8%
9% Parameters
10% ----------
11% H0 : matrix, shape (M,M)
12% The H0 matrix of the DRAP to check
13% H1 : matrix, shape (M,M)
14% The H1 matrix of the DRAP to check
15% prec : double, optional
16% Numerical precision, the default value is 1e-14
17%
18% Returns
19% -------
20% r : bool
21% The result of the check
22
23function r=CheckDRAPRepresentation(d0, d1, prec)
24
25 global BuToolsVerbose;
26 global BuToolsCheckPrecision;
27 if isempty(BuToolsCheckPrecision)
28 BuToolsCheckPrecision = 1e-12;
29 end
30
31 if ~exist('prec','var')
32 prec = BuToolsCheckPrecision;
33 end
34
35 r = false;
36 if size(d0,1) ~= size(d1,1) || size(d0,2) ~= size(d1,2) || size(d0,1) ~= size(d0,2)
37 if BuToolsVerbose
38 fprintf('CheckDRAPRepresentation: D0 and D1 have different sizes!\n');
39 end
40 return
41 end
42
43 if any(abs(sum(d0+d1,2)-1) > prec)
44 if BuToolsVerbose
45 fprintf('CheckDRAPRepresentation: A rowsum of D0+D1 is not 1 (at precision %g)!\n',prec);
46 end
47 return
48 end
49
50 ev = EigSort(eig(d0));
51 maxev = ev(1);
52
53 if ~isreal(maxev)
54 if BuToolsVerbose
55 fprintf('CheckDRAPRepresentation: The dominant eigenvalue of the D0 is complex!\n');
56 end
57 return
58 end
59
60 if maxev > 1+prec
61 if BuToolsVerbose
62 fprintf('CheckDRAPRepresentation: The dominant eigenvalue of D0 is greater than 1!\n');
63 end
64 return
65 end
66
67 if sum(abs(ev(1:end))==abs(maxev)) > 1
68 if BuToolsVerbose
69 fprintf('CheckDRAPRepresentation Warning: D0 has more than one eigenvalue with the same absolute value as the dominant eigenvalue!\n');
70 end
71 end
72
73 r=true;
74end