function b = isgoodA(A,P,m,n) b = 1; for i=1:n ii = setdiff(1:n,i); for xi=1:m^(n-1) x = i2c(xi,m,n-1); mux = getcondP(P,m,n,i,ii,x); for yi=xi+1:m^(n-1) y = i2c(yi,m,n-1); muy = getcondP(P,m,n,i,ii,y); lhs = TV(mux-muy); x0 = zeros(1,n); x0(ii) = x; y0 = zeros(1,n); y0(ii) = y; rhs = sum(A(i,:).*(x0~=y0)); b = b & (lhs < rhs + 1e-10); if ~b lhs rhs keyboard return end end end end return function i=c2i(c,m,n) dims = repmat(m,[1 n]); i = coord2ind(c,dims); return function c=i2c(i,m,n) dims = repmat(m,[1 n]); c = ind2coord(i,dims); return