Reference-LAPACK / lapack

LAPACK development repository
Other
1.51k stars 439 forks source link

GESVD returns zero matrix for degenerate matrices #269

Open amigalemming opened 6 years ago

amigalemming commented 6 years ago

For M=0 or M=0, GESVD returns a zero matrix for VT or U, respectively. Mathematically correct would be to return an identity matrix.

amigalemming commented 6 years ago

Seems to be duplicate of #187.

ilayn commented 6 years ago

Numerically returning an identity matrix is a waste and it will take time to create that identity matrix for no reason if the matrix is empty.

This would make many computations slower for no functional benefit.

amigalemming commented 6 years ago

On Sat, 4 Aug 2018, Ilhan Polat wrote:

Numerically returning an identity matrix is a waste and it will take time to create that identity matrix for no reason if the matrix is empty.

This would make many computations slower for no functional benefit.

It should at least be documented.

amigalemming commented 6 years ago

I still think, if the programmer requests all orthogonal vectors (JOB='A') then he wants to do something with them. For a 1000x1 matrix GESVD will also compute 999 orthogonal padding vectors, why should it behave differently for 1000x0? Doing nothing for 1000x0 would be correct for the other JOB types.

ilayn commented 6 years ago

Ah indeed you are right, my bad. I've overlooked the JOB types issue. It still feels awkward but I see the point for cases where singular vectors are requested.

However checking for zero-size and branching off seems to be a more efficient way in my opinion.