1function ISFEAS=map_isfeasible(MAP, TOL)
2% ISFEAS=map_isfeasible(MAP) - Evaluate feasibility of a MAP process
5% MAP: a MAP in the form of {D0,D1}
8% ISFEAS:
boolean 1=feasible, 0=infeasible. Numerical tolerance
is based
9% on the standard toolbox value in map_feastol.m
12% - map_isfeasible({[0,0;0,0],[1,2;3,4]})
is an infeasible MAP
17 ISFEAS=map_checkfeasible(MAP,TOL);
20 for k=TOLMAGNITUDE:-1:1
21 check=map_checkfeasible(MAP,10^-k);
24 ISFEAS=ISFEAS>map_feastol;
34function isfeas=map_checkfeasible(MAP,TOL)
46if any(isinf(D0),
'all') || any(isinf(D1),
'all') || any(isnan(D0),
'all') || any(isnan(D1),
'all')
50if any(imag(D0)>10^-4, 'all') || any(imag(D1)>10^-4, 'all')
59% set very small values to zero
60D0(find(abs(D0)<TOL))=0;
61D1(find(abs(D1)<TOL))=0;
65% assume initially the MAP
is feasible
89 %% validate stochasticity
90 if abs(sum(
P(i,:)))<1-n*TOL
93 if abs(sum(
P(i,:)))>1+n*TOL
96 if abs(sum(Q(i,:)))<0-n*TOL
99 if abs(sum(Q(i,:)))>0+n*TOL
107%% validate irreducibility
108if n<map_largemap % compute eigenvalues only if the MAP
is not too large
110 if length(find(eigQ>0-TOL))>1
114 if length(find(eigP>1-TOL))>1