Skip to content
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

Issues with inv(Triangular) #239

Closed
DanielVandH opened this issue Jul 3, 2024 · 1 comment
Closed

Issues with inv(Triangular) #239

DanielVandH opened this issue Jul 3, 2024 · 1 comment

Comments

@DanielVandH
Copy link
Contributor

DanielVandH commented Jul 3, 2024

Consider

julia> using LazyArrays, ArrayLayouts, LinearAlgebra

julia> A = UpperTriangular(ApplyArray(inv, rand(5, 5)))
5×5 UpperTriangular{Float64, ApplyArray{Float64, 2, typeof(inv), Tuple{Matrix{Float64}}}}:
 2.35135   1.68449   -1.84848   -0.955078  -1.85021
         -0.271777  -1.25844    0.94071   -1.27413
                   -0.124992  -1.4524     2.35783
                              0.669905  -0.609163
                                        0.840739

julia> inv(A)
inv(5×5 UpperTriangular{Float64, ApplyArray{Float64, 2, typeof(inv), Tuple{Matrix{Float64}}}}):
  0.425287   2.63595  -32.8287   -74.2701    43.1852
 -0.0       -3.67949   37.0457    85.4846   -47.5317
 -0.0       -0.0       -8.00051  -17.3457     9.86934
  0.0        0.0        0.0        1.49275    1.08158
  0.0        0.0        0.0        0.0        1.18943

julia> MemoryLayout(inv(A))
LazyArrays.InvLayout{TriangularLayout{'U', 'N', LazyArrays.LazyLayout}}()

The LazyArrays.InvLayout{TriangularLayout{'U', 'N', LazyArrays.LazyLayout}}() could maybe be TriangularLayout{'L', 'N', LazyArrays.LazyLayout}()? (Actually doing

applylayout(::Type{typeof(inv)}, ::TriangularLayout{'U', UNIT, ML}) where {UNIT, ML} = TriangularLayout{'L', UNIT, ML}()
applylayout(::Type{typeof(inv)}, ::TriangularLayout{'L', UNIT, ML}) where {UNIT, ML} = TriangularLayout{'U', UNIT, ML}()

causes more issues with stackoverflows, so I guess the Inv should stay in the layout.) One issue that the current situation causes is e.g.

julia> using BandedMatrices

julia> colsupport(inv(A), 1)
Base.OneTo(5)

which is of course more problematic for infinite matrices.

@DanielVandH
Copy link
Contributor Author

Actually this might be more on LazyArrays.jl than here since it comes from https://github.com/JuliaArrays/LazyArrays.jl/blob/8fc085dc65af7114b74c774da71a7942ffa2461f/src/linalg/inv.jl#L84

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant