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

show and getindex for matrix inversion between LowerTriangular and Bidiagonal never completes #124

Closed
DanielVandH opened this issue May 19, 2024 · 1 comment

Comments

@DanielVandH
Copy link
Contributor

DanielVandH commented May 19, 2024

julia> using LazyBandedMatrices, FillArrays, Infinities, LazyArrays, ContinuumArrays

julia> using LazyBandedMatrices: Bidiagonal, LowerTriangular

julia> R = [Vcat(1.0, Zeros(∞)) LowerTriangular(Bidiagonal(Ones(∞), Ones(∞), :L))]; # without the Vcat, we get a method ambiguity bug instead

julia> R′ = Bidiagonal(Ones(∞), Ones(∞), :U);

julia> RR = R′ \ R; # it can be computed apparently, but once you show it..

julia> RR # never ends
\(ℵ₀×ℵ₀ Bidiagonal{Float64, Ones{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, Ones{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}} with indices OneToInf()×OneToInf(), hcat(vcat(Float64, ℵ₀-element Zeros{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}} with indices OneToInf()) with indices OneToInf(), ℵ₀×ℵ₀ LowerTriangular{Float64, Bidiagonal{Float64, Ones{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, Ones{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}}} with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf():
Error showing value of type ApplyMatrix{Float64, typeof(\), Tuple{Bidiagonal{Float64, Ones{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, Ones{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}}, ApplyArray{Float64, 2, typeof(hcat), Tuple{ApplyArray{Float64, 1, typeof(vcat), Tuple{Float64, Zeros{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}}}, LowerTriangular{Float64, Bidiagonal{Float64, Ones{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, Ones{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}}}}}}}:
ERROR: InterruptException:
Stacktrace:
  [1] cache_filldata!(::LazyArrays.CachedArray{Float64, 2, Matrix{…}, Zeros{…}}, ::UnitRange{Int64}, ::Base.OneTo{Int64})
    @ LazyArrays C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\cache.jl:222
  [2] resizedata!(::ArrayLayouts.DenseColumnMajor, ::ArrayLayouts.ZerosLayout, ::LazyArrays.CachedArray{…}, ::Int64, ::Int64)
    @ LazyArrays C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\cache.jl:263
  [3] resizedata!
    @ C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\cache.jl:218 [inlined]
  [4] setindex!
    @ C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\cache.jl:82 [inlined]
  [5] Matrix{Float64}(A::Bidiagonal{Float64, Ones{Float64, 1, Tuple{…}}, Ones{Float64, 1, Tuple{…}}})
    @ LazyBandedMatrices C:\Users\User\.julia\packages\LazyBandedMatrices\59umZ\src\bidiag.jl:151
  [6] (Matrix)(A::Bidiagonal{Float64, Ones{Float64, 1, Tuple{…}}, Ones{Float64, 1, Tuple{…}}})
    @ LazyBandedMatrices C:\Users\User\.julia\packages\LazyBandedMatrices\59umZ\src\bidiag.jl:159
  [7] Array(A::Bidiagonal{Float64, Ones{Float64, 1, Tuple{…}}, Ones{Float64, 1, Tuple{…}}})
    @ LazyBandedMatrices C:\Users\User\.julia\packages\LazyBandedMatrices\59umZ\src\bidiag.jl:160
  [8] convert(::Type{Array}, a::Bidiagonal{Float64, Ones{Float64, 1, Tuple{…}}, Ones{Float64, 1, Tuple{…}}})
    @ Base .\array.jl:665
  [9] concretize(L::Bidiagonal{Float64, Ones{Float64, 1, Tuple{…}}, Ones{Float64, 1, Tuple{…}}})
    @ ArrayLayouts C:\Users\User\.julia\packages\ArrayLayouts\ccyJu\src\ldiv.jl:52
 [10] concretize(L::Ldiv{ArrayLayouts.BidiagonalLayout{…}, LazyArrays.ApplyLayout{…}, Bidiagonal{…}, SubArray{…}})
    @ ArrayLayouts C:\Users\User\.julia\packages\ArrayLayouts\ccyJu\src\ldiv.jl:53
 [11] _getindex(::Type{…}, L::Ldiv{…}, ::Tuple{…})
    @ ArrayLayouts C:\Users\User\.julia\packages\ArrayLayouts\ccyJu\src\ldiv.jl:54
 [12] getindex(L::Ldiv{ArrayLayouts.BidiagonalLayout{…}, LazyArrays.ApplyLayout{…}, Bidiagonal{…}, SubArray{…}}, k::Int64)
    @ ArrayLayouts C:\Users\User\.julia\packages\ArrayLayouts\ccyJu\src\ldiv.jl:51
 [13] getindex
    @ C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\linalg\inv.jl:103 [inlined]
 [14] getindex
    @ C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\lazyapplying.jl:254 [inlined]
 [15] getindex(L::ApplyMatrix{Float64, typeof(\), Tuple{Bidiagonal{…}, ApplyArray{…}}}, k::Int64, j::Int64)
    @ LazyArrays C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\linalg\inv.jl:180
 [16] isassigned(::ApplyMatrix{Float64, typeof(\), Tuple{Bidiagonal{…}, ApplyArray{…}}}, ::Int64, ::Int64)
    @ Base .\multidimensional.jl:1578
 [17] alignment(io::IOContext{…}, X::AbstractVecOrMat, rows::Vector{…}, cols::Vector{…}, cols_if_complete::Int64, cols_otherwise::Int64, sep::Int64, ncols::InfiniteCardinal{…})
    @ Base .\arrayshow.jl:68
 [18] _print_matrix(io::IOContext{…}, X::AbstractVecOrMat, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64, rowsA::InfiniteArrays.InfUnitRange{…}, colsA::InfiniteArrays.InfUnitRange{…})
    @ Base .\arrayshow.jl:207
 [19] print_matrix(io::IOContext{…}, X::ApplyMatrix{…}, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64)
    @ Base .\arrayshow.jl:171
 [20] print_matrix
    @ .\arrayshow.jl:171 [inlined]
 [21] print_array
    @ .\arrayshow.jl:358 [inlined]
 [22] show(io::IOContext{Base.TTY}, ::MIME{Symbol("text/plain")}, X::ApplyMatrix{Float64, typeof(\), Tuple{…}})
    @ Base .\arrayshow.jl:399
 [23] (::REPL.var"#55#56"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:273
 [24] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:569
 [25] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:259
 [26] display
    @ C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:278 [inlined]
 [27] display(x::Any)
    @ Base.Multimedia .\multimedia.jl:340
 [28] #invokelatest#2
    @ .\essentials.jl:892 [inlined]
 [29] invokelatest
    @ .\essentials.jl:889 [inlined]
 [30] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{…})
    @ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:315
 [31] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:284
 [32] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:569
 [33] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:282
 [34] (::REPL.var"#do_respond#80"{})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:911
 [35] #invokelatest#2
    @ .\essentials.jl:892 [inlined]
 [36] invokelatest
    @ .\essentials.jl:889 [inlined]
 [37] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:2656
 [38] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:1312
 [39] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:386
Some type information was truncated. Use `show(err)` to see complete types.

julia> RR[1, 1] # also can't access it
ERROR: InterruptException:
Stacktrace:
  [1] cache_filldata!(::LazyArrays.CachedArray{Float64, 2, Matrix{…}, Zeros{…}}, ::UnitRange{Int64}, ::Base.OneTo{Int64})
    @ LazyArrays C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\cache.jl:222
  [2] resizedata!(::ArrayLayouts.DenseColumnMajor, ::ArrayLayouts.ZerosLayout, ::LazyArrays.CachedArray{…}, ::Int64, ::Int64)
    @ LazyArrays C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\cache.jl:263
  [3] resizedata!
    @ C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\cache.jl:218 [inlined]
  [4] setindex!
    @ C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\cache.jl:82 [inlined]
  [5] Matrix{Float64}(A::Bidiagonal{Float64, Ones{Float64, 1, Tuple{…}}, Ones{Float64, 1, Tuple{…}}})
    @ LazyBandedMatrices C:\Users\User\.julia\packages\LazyBandedMatrices\59umZ\src\bidiag.jl:149
  [6] (Matrix)(A::Bidiagonal{Float64, Ones{Float64, 1, Tuple{…}}, Ones{Float64, 1, Tuple{…}}})
    @ LazyBandedMatrices C:\Users\User\.julia\packages\LazyBandedMatrices\59umZ\src\bidiag.jl:159
  [7] Array(A::Bidiagonal{Float64, Ones{Float64, 1, Tuple{…}}, Ones{Float64, 1, Tuple{…}}})
    @ LazyBandedMatrices C:\Users\User\.julia\packages\LazyBandedMatrices\59umZ\src\bidiag.jl:160
  [8] convert(::Type{Array}, a::Bidiagonal{Float64, Ones{Float64, 1, Tuple{…}}, Ones{Float64, 1, Tuple{…}}})
    @ Base .\array.jl:665
  [9] concretize(L::Bidiagonal{Float64, Ones{Float64, 1, Tuple{…}}, Ones{Float64, 1, Tuple{…}}})
    @ ArrayLayouts C:\Users\User\.julia\packages\ArrayLayouts\ccyJu\src\ldiv.jl:52
 [10] concretize(L::Ldiv{ArrayLayouts.BidiagonalLayout{…}, LazyArrays.ApplyLayout{…}, Bidiagonal{…}, SubArray{…}})
    @ ArrayLayouts C:\Users\User\.julia\packages\ArrayLayouts\ccyJu\src\ldiv.jl:53
 [11] _getindex(::Type{…}, L::Ldiv{…}, ::Tuple{…})
    @ ArrayLayouts C:\Users\User\.julia\packages\ArrayLayouts\ccyJu\src\ldiv.jl:54
 [12] getindex(L::Ldiv{ArrayLayouts.BidiagonalLayout{…}, LazyArrays.ApplyLayout{…}, Bidiagonal{…}, SubArray{…}}, k::Int64)
    @ ArrayLayouts C:\Users\User\.julia\packages\ArrayLayouts\ccyJu\src\ldiv.jl:51
 [13] getindex
    @ C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\linalg\inv.jl:103 [inlined]
 [14] getindex
    @ C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\lazyapplying.jl:254 [inlined]
 [15] getindex(L::ApplyMatrix{Float64, typeof(\), Tuple{Bidiagonal{…}, ApplyArray{…}}}, k::Int64, j::Int64)
    @ LazyArrays C:\Users\User\.julia\packages\LazyArrays\JNdsG\src\linalg\inv.jl:180
 [16] top-level scope
    @ REPL[44]:1
Some type information was truncated. Use `show(err)` to see complete types.
@dlfivefifty
Copy link
Member

This is implemented in InfiniteLinearAlgebra.jl:

julia> using InfiniteLinearAlgebra

julia> RR # never ends
\(ℵ₀×ℵ₀ Bidiagonal{Float64, Ones{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, Ones{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}} with indices OneToInf()×OneToInf(), hcat(vcat(Float64, ℵ₀-element Zeros{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}} with indices OneToInf()) with indices OneToInf(), ℵ₀×ℵ₀ LowerTriangular{Float64, Bidiagonal{Float64, Ones{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, Ones{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}}} with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf():
 1.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0    
     1.0  0.0  0.0  0.0  0.0  0.0  0.0     
         1.0  0.0  0.0  0.0  0.0  0.0     
             1.0  0.0  0.0  0.0  0.0     
                 1.0  0.0  0.0  0.0     
                     1.0  0.0  0.0    
                         1.0  0.0     
                             1.0     
                                    
                                    
                                         

In the future this can be changed to extensions.

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

2 participants