Hello,As the help text of xGELSD subroutine says, the rank of the A matrix is estimated via svd decomnposition as "the number of singular values which are greater than RCOND*S(1)".In GNU Octave software, xGELSD is used to solve a system of equations in the left division operator '\'. In GNU Octave a function called rank() exists too in order to determine the numerical rank of a matrix via svd decomposition. The help text of rank() function is:

-- Function File: rank (A, TOL) Compute the rank of A, using the singular value decomposition. The rank is taken to be the number of singular values of A that are greater than the specified tolerance 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(1)' is the largest singular value of A.

As we can see, rank() uses as criteria for consider a singular value as zero the expression max (size (A)) * sigma(1) * eps (in Octave, eps is the precision, equivalent to DLAMCH('P')).

As we can see, by construction the matrix has a rank of 195 because the 5 last columns are the same than the first 5 columns. The operator rank() computes exactly a rank of 195, but the function DGELSD (via \) computes a rank of 196.

If we change the function rand() by randn() in the generation of the matrix, DGELSD says that the matrix has complete rank (no warning about rank deficiency appears), but rank() function again computes the correct result