Closed
Description
The code
A = [1.0 0.0;0.0 1.0;0.0 0.0]
A1 = pinv(A):
produces
[1.0 0.0 1.0;0.0 0.0 0.0]
An incorrect answer, which is due to the identification of A
as diagonal on line
https://github.com/JuliaLang/julia/blob/bf534986350a991e4a1b29126de0342ffd76205e/stdlib/LinearAlgebra/src/dense.jl#L1433
I think the solution could be to check that the matrix is square and isdiag
returns true.
Or, perhaps isdiag
does not work correctly, and the solution is to fix that function to identify matrix as diagonal only if it is square?
The svd
code below the if block would have worked correctly.
https://discourse.julialang.org/t/bug-in-linearalgebra-pinv/76663/2