LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
CheckMAPRepresentation.m
1% r = CheckMAPRepresentation(D0, D1, prec)
2%
3% Checks if the input matrixes define a continuous time MAP.
4%
5% Matrices D0 and D1 must have the same size, D0 must be a
6% transient generator matrix, D1 has only non-negative
7% elements, and the rowsum of D0+D1 is 0 (up to the numerical
8% precision).
9%
10% Parameters
11% ----------
12% D0 : matrix, shape (M,M)
13% The D0 matrix of the MAP to check
14% D1 : matrix, shape (M,M)
15% The D1 matrix of the MAP to check
16% prec : double, optional
17% Numerical precision, the default value is 1e-14
18%
19% Returns
20% -------
21% r : bool
22% The result of the check
23
24function r = CheckMAPRepresentation (D0, D1, prec)
25
26 global BuToolsVerbose;
27 global BuToolsCheckPrecision;
28 if isempty(BuToolsCheckPrecision)
29 BuToolsCheckPrecision = 1e-12;
30 end
31
32 if ~exist('prec','var')
33 prec = BuToolsCheckPrecision;
34 end
35
36 if ~CheckGenerator(D0,1,prec)
37 r = false;
38 return;
39 end
40
41 if size(D0)~=size(D1)
42 if BuToolsVerbose
43 fprintf ('CheckMAPRepresentation: D0 and D1 have different sizes!\n');
44 end
45 r = false;
46 return;
47 end
48
49 if min(min(D1))<-prec
50 if BuToolsVerbose
51 fprintf ('CheckMAPRepresentation: D1 has negative element (precision: %g)!\n', prec);
52 end
53 r = false;
54 return;
55 end
56
57 if any(abs(sum(D0+D1,2))>prec)
58 if BuToolsVerbose
59 fprintf ('CheckMAPRepresentation: The rowsum of D0+D1 is not 0 (precision: %g)!\n', prec);
60 end
61 r = false;
62 return;
63 end
64
65 r = true;
66end