QRANK - Quick matrix rank estimation. r = qrank(A) Provides an estimate of rank(A) based on the QR decomposition of A. Faster than Matlab's RANK which relies on the SVD.
0001 function r = qrank(A) 0002 0003 % QRANK - Quick matrix rank estimation. 0004 % 0005 % r = qrank(A) 0006 % 0007 % Provides an estimate of rank(A) based on the QR decomposition of 0008 % A. Faster than Matlab's RANK which relies on the SVD. 0009 0010 % Compute QR decomposition. 0011 [Q1,R1,E] = qr(A',0); 0012 % The tolerance is 10 x tolerance used in \. See qr documentation. 0013 tol = max(size(A))*10*eps*abs(R1(1,1)); 0014 % Compute numerical rank. 0015 r = sum(abs(diag(R1))>tol);