1function x = cs_dmsol (A,b) 2%CS_DMSOL x=A\b using the coarse Dulmage-Mendelsohn decomposition. 3% x = cs_dmsol(A,b) computes x=A\b where A may be rectangular and/or 4% structurally rank deficient, and b is a full vector. 5% 6% Example: 7% Prob = ssget ('HB/arc130') ; A = Prob.A ; b = rand (size (A,1),1) ; 8% x = cs_dmsol (A,b) ; norm (A*x-b) 9% 10% See also CS_QRSOL, CS_LUSOL, CS_DMPERM, SPRANK, RANK. 11 12% Copyright 2006-2012, Timothy A. Davis, http://www.suitesparse.com 13 14[m n] = size (A) ; 15[p q r s cc rr] = cs_dmperm (A) ; 16C = A (p,q) ; 17b = b (p) ; 18x = zeros (n,1) ; 19if (rr(3) <= m & cc(4) <= n) %#ok 20 x (cc(4):n) = cs_qrsol (C (rr(3):m, cc(4):n), b (rr(3):m)) ; 21 b (1:rr(3)-1) = b (1:rr(3)-1) - C (1:rr(3)-1, cc(4):n) * x (cc(4):n) ; 22end 23if (rr(2) < rr (3) & cc(3) < cc(4)) %#ok 24 x (cc(3):cc(4)-1) = ... 25 cs_lusol (C (rr(2):rr(3)-1, cc(3):cc(4)-1), b (rr(2):rr(3)-1)) ; 26 b (1:rr(2)-1) = ... 27 b (1:rr(2)-1) - C (1:rr(2)-1, cc(3):cc(4)-1) * x (cc(3):cc(4)-1) ; 28end 29if (rr(2) > 1 & cc(3) > 1) %#ok 30 x (1:cc(3)-1) = cs_qrsol (C (1:rr(2)-1, 1:cc(3)-1), b (1:rr(2)-1)) ; 31end 32x (q) = x ; 33