[bug #68238] linsolve: 2nd output should return rcond for square matrix, rank for nonsquare

Rik <[email protected]> Fri, 17 Apr 2026 03:39:22 -0400 (EDT)
Newsgroups gmane.comp.gnu.octave.bugs
Message-ID <[email protected]>
Please use the bug tracker to post updates to a bug report.  The mailing list is intended as a read-only notification stream.  Info posted to this mailing list address won't appear in the tracker database where it is most useful.

Update of bug #68238 (group octave):

                  Status:         Patch Submitted => Ready For Test
           Fixed Release:                    None => 12.1.0 (current default)

    _______________________________________________________

Follow-up Comment #5:

@Nicholas: We are on the same wavelength.  I checked in a change at
https://hg.savannah.gnu.org/hgweb/octave/rev/b84f0f85f2a7.

Octave calculates the rank only if the number of elements is <= 1e6.  The
runtime for *rank()* can become excessive above that point in which case
Octave just returns *NaN*.  Really, I think that's a corner case.  In almost
all cases programmers should not be using this function at all and just let
Octave determine the matrix type.  The documentation change I made on stable
is much clearer about that.

If we really want *rank()* to be fast we should probably rewrite rank.m to use
Rank-Revealing QR factorization
(https://en.wikipedia.org/wiki/Rank-revealing_QR_factorization) rather than
SVD decomposition and a test on size of singular values.  That is a much
bigger project though.

Besides the change to return the rank of a rectangular matrix, I also disabled
the warning *"Octave:singular-matrix"* when a second output is requested.
This is also a change for Matlab compatibility.



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68238>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaeHjqgAKCRCqLAuaBUf3
TpGlAQCSVjXzwT20DQjB9FO4ISTflOoK/+TRYZMRyV+UST6vagD7B+3ud7mYrEoy
aKBEkQnE/6YkfKQrvgOTXc9WW0GvCAY=
=9+zg
-----END PGP SIGNATURE-----