From bug-octave-request at che dot utexas dot edu Wed Dec 29 02:48:51 1993 Subject: bug in rank.m From: hornik at neuro dot tuwien dot ac dot at (Kurt Hornik) To: bug-octave at che dot utexas dot edu Date: Wed, 29 Dec 93 09:48 MET There is a bug in the 0.79 rank.m which causes rank not to work when invoked with TWO arguments. I enclose diffs and a fixed rank.m. -kurt ************************************************************************ diff -u --recursive --new-file rank.m rank.m.orig --- rank.m Fri Dec 24 08:24:57 1993 +++ rank.m.orig Fri Dec 24 08:24:04 1993 at @ -1,6 +1,6 @@ function retval = rank (A, tol) -# usage: rank (a, tol) +# usage: rand (a, tol) # # Return the rank of the matrix a. The rank is taken to be the number # of singular values of a that are greater than tol. at @ -12,8 +12,8 @@ # where eps is machine precision and sigma is the largest singular # value of a. - sigma = svd (A); if (nargin == 1) + sigma = svd (A); tolerance = max (size (A)) * sigma (1) * eps; elseif (nargin == 2) tolerance = tol; ************************************************************************ ************************************************************************ function retval = rank (A, tol) # usage: rank (a, tol) # # Return the rank of the matrix a. The rank is taken to be the number # of singular values of a that are greater than tol. # # If the second argument is omitted, it is taken to be # # tol = max (size (a)) * sigma (1) * eps; # # where eps is machine precision and sigma is the largest singular # value of a. sigma = svd (A); if (nargin == 1) tolerance = max (size (A)) * sigma (1) * eps; elseif (nargin == 2) tolerance = tol; else error ("usage: rank (A)"); endif retval = sum (sigma > tolerance); endfunction