1% r = CheckDMAPRepresentation(D0, D1, prec)
3% Checks
if the input matrixes define a discrete time MAP.
5% Matrices D0 and D1 must have the same size, D0 must be a
6% transient probability matrix, D1 has only non-negative
7% elements, and the rowsum of D0+D1
is 1 (up to the numerical
12% D0 : matrix, shape (M,M)
13% The D0 matrix of the DMAP to check
14% D1 : matrix, shape (M,M)
15% The D1 matrix of the DMAP to check
16% prec : double, optional
17% Numerical precision, the default value
is 1e-14
22% The result of the check
24function r=CheckDMAPRepresentation(d0, d1, prec)
26 global BuToolsVerbose;
27 global BuToolsCheckPrecision;
28 if isempty(BuToolsCheckPrecision)
29 BuToolsCheckPrecision = 1e-12;
32 if ~exist(
'prec',
'var')
33 prec = BuToolsCheckPrecision;
36 if ~CheckProbMatrix(d0,1,prec)
38 fprintf('CheckDMAPRepresentation: D0 isn''t a transient probability matrix!\n');
44 if size(d0,1) ~= size(d1,1) || size(d0,2) ~= size(d1,2)
46 fprintf('CheckDMAPRepresentation: D0 and D1 have different sizes!\n');
52 if min(min([d0,d1])) < -prec
54 fprintf('CheckDMAPRepresentation: One of the matrices has negative element!\n');
60 if any(abs(sum(d0+d1,2)-1) > prec)
62 fprintf('CheckDMAPRepresentation: A rowsum of matrix0+matrix1
is not 1 (at precision %g)!\n',prec);