CSVD Compact singular value decomposition. s = csvd(A) [U,s,V] = csvd(A) [U,s,V] = csvd(A,'full') Computes the compact form of the SVD of A: A = U*diag(s)*V', where U is m-by-min(m,n) s is min(m,n)-by-1 V is n-by-min(m,n). If a second argument is present, the full U and V are returned.
0001 function [U,s,V] = csvd1(A,tst) 0002 %CSVD Compact singular value decomposition. 0003 % 0004 % s = csvd(A) 0005 % [U,s,V] = csvd(A) 0006 % [U,s,V] = csvd(A,'full') 0007 % 0008 % Computes the compact form of the SVD of A: 0009 % A = U*diag(s)*V', 0010 % where 0011 % U is m-by-min(m,n) 0012 % s is min(m,n)-by-1 0013 % V is n-by-min(m,n). 0014 % 0015 % If a second argument is present, the full U and V are returned. 0016 0017 % Per Christian Hansen, IMM, 06/22/93. 0018 0019 if (nargin==1) 0020 if (nargout > 1) 0021 [m,n] = size(A); 0022 if (m >= n) 0023 [U,s,V] = svd(full(A),0); s = diag(s); 0024 else 0025 [V,s,U] = svd(full(A)',0); s = diag(s); 0026 end 0027 else 0028 U = svd(full(A)); 0029 end 0030 else 0031 if (nargout > 1) 0032 [U,s,V] = svd(full(A)); s = diag(s); 0033 else 0034 U = svd(full(A)); 0035 end 0036 end 0037