-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pinv bug: matrix misdiagnosed as diagonal #911
Comments
I think the problem is the indexing operation in |
That might work. |
Note that this bug doesn't exist on Julia v1.6.6. v1.6.6 julia> A = [1.0 0.0;0.0 1.0;0.0 0.0]
3×2 Matrix{Float64}:
1.0 0.0
0.0 1.0
0.0 0.0
julia> A1 = pinv(A)
2×3 Matrix{Float64}:
1.0 0.0 0.0
0.0 1.0 0.0 v1.7.2 julia> A = [1.0 0.0;0.0 1.0;0.0 0.0]
3×2 Matrix{Float64}:
1.0 0.0
0.0 1.0
0.0 0.0
julia> A1 = pinv(A)
2×3 Matrix{Float64}:
1.0 0.0 1.0
0.0 0.0 0.0 Maybe JuliaLang/julia#39756 is related? |
The code
produces
An incorrect answer, which is due to the identification of
A
as diagonal on linehttps://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
The text was updated successfully, but these errors were encountered: