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

Some operations like inv don't work on certain matrices #5

Open
DanielVandH opened this issue Jul 2, 2024 · 10 comments
Open

Some operations like inv don't work on certain matrices #5

DanielVandH opened this issue Jul 2, 2024 · 10 comments

Comments

@DanielVandH
Copy link
Owner

These are downstream issues, but will get them here for now while I think about where the issues actually go.

julia> using InfiniteRandomArrays

julia> inv(InfRandTridiagonal())
ERROR: MethodError: no method matching Matrix{Float64}(::LinearAlgebra.UniformScaling{Bool}, ::Infinities.Infinity, ::Infinities.Infinity)

Closest candidates are:
  Array{T, N}(::Missing, ::Any...) where {T, N}
   @ Base baseext.jl:43
  Array{T, N}(::Nothing, ::Any...) where {T, N}
   @ Base baseext.jl:42
  Matrix{T}(::UndefInitializer, ::Union{Infinities.InfiniteCardinal{0}, Infinities.Infinity}, ::Union{Infinities.InfiniteCardinal{0}, Infinities.Infinity}) where T
   @ InfiniteArrays C:\Users\djv23\.julia\packages\InfiniteArrays\orKsz\src\infarrays.jl:15
  ...

Stacktrace:
 [1] inv(A::LinearAlgebra.Tridiagonal{Float64, InfRandVector{Float64, Type{Float64}, Random.Xoshiro}})
   @ LinearAlgebra C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\LinearAlgebra\src\generic.jl:1052
 [2] top-level scope
   @ REPL[3]:1

julia> inv(InfRandBidiagonal())
ERROR: MethodError: no method matching (LinearAlgebra.Bidiagonal{T, <:InfRandVector{T}} where T)()

Closest candidates are:
  (LinearAlgebra.Bidiagonal{T, <:InfRandVector{T}} where T)(::Type{T}, ::Union{AbstractChar, Symbol}) where T
   @ InfiniteRandomArrays C:\Users\djv23\.julia\packages\InfiniteRandomArrays\sXtDk\src\named.jl:15
  (LinearAlgebra.Bidiagonal{T, <:InfRandVector{T}} where T)(::Union{AbstractChar, Symbol})
   @ InfiniteRandomArrays C:\Users\djv23\.julia\packages\InfiniteRandomArrays\sXtDk\src\named.jl:16

Stacktrace:
 [1] top-level scope
   @ REPL[4]:1

julia> using BandedMatrices

julia> inv(brand(∞, 0, 2))
inv(ℵ₀×ℵ₀ BandedMatrix{Float64} with bandwidths (0, 2) with data 3×ℵ₀ InfRandMatrix{Float64, InfRandVector{Float64, Type{Float64}, Random.Xoshiro}, Int64, Infinities.Infinity} with indices Base.OneTo(3)×OneToInf() with indices 1:×OneToInf()) with indices OneToInf()×1:∞:
Error showing value of type LazyArrays.ApplyArray{Float64, 2, typeof(inv), Tuple{BandedMatrix{Float64, InfRandMatrix{Float64, InfRandVector{Float64, Type{Float64}, Random.Xoshiro}, Int64, Infinities.Infinity}, InfiniteArrays.InfUnitRange{Int64}}}}:
ERROR: MethodError: no method matching (BandedMatrix{})(::UndefInitializer, ::Tuple{…}, ::Tuple{…})

Closest candidates are:
  (BandedMatrix{T, C})(::UndefInitializer, ::Tuple{Integer, Integer}, ::Tuple{Integer, Integer}) where {T<:Union{Float32, Float64, ComplexF64, ComplexF32}, C<:AbstractMatrix{T}}
   @ BandedMatrices C:\Users\djv23\.julia\packages\BandedMatrices\d4g9c\src\banded\BandedMatrix.jl:57
  (BandedMatrix{T, C})(::UndefInitializer, ::Tuple{Integer, Integer}, ::Tuple{Integer, Integer}) where {T<:Number, C<:AbstractMatrix{T}}
   @ BandedMatrices C:\Users\djv23\.julia\packages\BandedMatrices\d4g9c\src\banded\BandedMatrix.jl:61
  (BandedMatrix{T, C})(::UndefInitializer, ::Integer, ::Colon, ::Integer, ::Integer) where {T, C<:AbstractMatrix{T}}
   @ BandedMatrices deprecated.jl:103
  ...

Stacktrace:
  [1] (BandedMatrix{})(A::BandedMatrix{…}, bnds::Tuple{…})
    @ BandedMatrices C:\Users\djv23\.julia\packages\BandedMatrices\d4g9c\src\banded\BandedMatrix.jl:212
  [2] (BandedMatrix{})(A::BandedMatrix{…}, bnds::Tuple{…})
    @ BandedMatrices C:\Users\djv23\.julia\packages\BandedMatrices\d4g9c\src\banded\BandedMatrix.jl:207
  [3] lu_layout(::BandedMatrices.BandedColumns{…}, axes::Tuple{…}, A::BandedMatrix{…}, pivot::Val{…}; check::Bool)
    @ BandedMatrices C:\Users\djv23\.julia\packages\BandedMatrices\d4g9c\src\banded\BandedLU.jl:102
  [4] lu_layout(::BandedMatrices.BandedColumns{…}, axes::Tuple{…}, A::BandedMatrix{…}, pivot::Val{…})
    @ BandedMatrices C:\Users\djv23\.julia\packages\BandedMatrices\d4g9c\src\banded\BandedLU.jl:100
  [5] lu(A::BandedMatrix{Float64, InfRandMatrix{…}, InfiniteArrays.InfUnitRange{…}}; kwds::@Kwargs{})
    @ ArrayLayouts C:\Users\djv23\.julia\packages\ArrayLayouts\70nvu\src\factorizations.jl:428
  [6] lu(A::BandedMatrix{Float64, InfRandMatrix{…}, InfiniteArrays.InfUnitRange{…}})
    @ ArrayLayouts C:\Users\djv23\.julia\packages\ArrayLayouts\70nvu\src\factorizations.jl:428
  [7] factorize_layout(::BandedMatrices.BandedColumns{…}, ::Tuple{…}, A::BandedMatrix{…})
    @ BandedMatrices C:\Users\djv23\.julia\packages\BandedMatrices\d4g9c\src\banded\linalg.jl:75
  [8] factorize(A::BandedMatrix{Float64, InfRandMatrix{…}, InfiniteArrays.InfUnitRange{…}})
    @ ArrayLayouts C:\Users\djv23\.julia\packages\ArrayLayouts\70nvu\src\factorizations.jl:430
  [9] _ldiv!
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\70nvu\src\ldiv.jl:83 [inlined]
 [10] copyto!
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\70nvu\src\ldiv.jl:113 [inlined]
 [11] copy
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\70nvu\src\ldiv.jl:21 [inlined]
 [12] copy(L::ArrayLayouts.Ldiv{…})
    @ LazyArraysBandedMatricesExt C:\Users\djv23\.julia\packages\LazyArrays\44w6E\ext\LazyArraysBandedMatricesExt.jl:588
 [13] materialize
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\70nvu\src\ldiv.jl:22 [inlined]
 [14] ldiv
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\70nvu\src\ldiv.jl:98 [inlined]
 [15] \(A::BandedMatrix{…}, x::LazyArrays.CachedArray{…}; kwds::@Kwargs{})
    @ ArrayLayouts C:\Users\djv23\.julia\packages\ArrayLayouts\70nvu\src\ldiv.jl:199
 [16] sub_materialize(::LazyArrays.InvColumnLayout, v::SubArray{…}, ::Tuple{…})
    @ LazyArrays C:\Users\djv23\.julia\packages\LazyArrays\44w6E\src\linalg\inv.jl:174
 [17] sub_materialize(lay::LazyArrays.InvColumnLayout, v::SubArray{…}, ax::Tuple{…})
    @ InfiniteArrays C:\Users\djv23\.julia\packages\InfiniteArrays\orKsz\src\infarrays.jl:399
 [18] sub_materialize
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\70nvu\src\ArrayLayouts.jl:131 [inlined]
 [19] sub_materialize
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\70nvu\src\ArrayLayouts.jl:132 [inlined]
 [20] layout_getindex
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\70nvu\src\ArrayLayouts.jl:138 [inlined]
 [21] getindex
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\70nvu\src\ArrayLayouts.jl:156 [inlined]
 [22] getindex
    @ C:\Users\djv23\.julia\packages\LazyArrays\44w6E\src\linalg\inv.jl:178 [inlined]
 [23] isassigned(::LazyArrays.ApplyArray{Float64, 2, typeof(inv), Tuple{BandedMatrix{…}}}, ::Int64, ::Int64)
    @ Base .\multidimensional.jl:1578
 [24] alignment(io::IOContext{…}, X::AbstractVecOrMat, rows::Vector{…}, cols::Vector{…}, cols_if_complete::Int64, cols_otherwise::Int64, sep::Int64, ncols::Infinities.InfiniteCardinal{…})
    @ Base .\arrayshow.jl:68
 [25] _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
 [26] print_matrix(io::IOContext{…}, X::LazyArrays.ApplyArray{…}, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64)
    @ Base .\arrayshow.jl:171
 [27] print_matrix
    @ .\arrayshow.jl:171 [inlined]
 [28] print_array
    @ .\arrayshow.jl:358 [inlined]
 [29] show(io::IOContext{Base.TTY}, ::MIME{Symbol("text/plain")}, X::LazyArrays.ApplyArray{Float64, 2, typeof(inv), Tuple{…}})
    @ Base .\arrayshow.jl:399
 [30] (::REPL.var"#55#56"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:273
 [31] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:569
 [32] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:259
 [33] display
    @ C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:278 [inlined]
 [34] display(x::Any)
    @ Base.Multimedia .\multimedia.jl:340
 [35] #invokelatest#2
    @ .\essentials.jl:892 [inlined]
 [36] invokelatest
    @ .\essentials.jl:889 [inlined]
 [37] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{…})
    @ REPL C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:315
 [38] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:284
 [39] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:569
 [40] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:282
 [41] (::REPL.var"#do_respond#80"{})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:911
 [42] #invokelatest#2
    @ .\essentials.jl:892 [inlined]
 [43] invokelatest
    @ .\essentials.jl:889 [inlined]
 [44] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:2656
 [45] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:1312
 [46] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL C:\Users\djv23\.julia\juliaup\julia-1.10.4+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> InfRandTridiagonal() - InfRandBidiagonal('L')
ERROR: MethodError: no method matching LazyArrays.BroadcastVector{Float64, typeof(-), Tuple{…}}(::InfRandVector{Float64, Type{…}, Random.Xoshiro})

Closest candidates are:
  (::Type{LazyArrays.BroadcastArray{T, N, F, Args}} where {T, N, F, Args})(::Any, ::Any)
   @ LazyArrays C:\Users\djv23\.julia\packages\LazyArrays\44w6E\src\lazybroadcasting.jl:29
  LazyArrays.BroadcastArray{T, N, F, Args}(::Base.Broadcast.Broadcasted) where {T, N, F, Args}
   @ LazyArrays C:\Users\djv23\.julia\packages\LazyArrays\44w6E\src\lazybroadcasting.jl:38

Stacktrace:
 [1] -(A::LinearAlgebra.Tridiagonal{Float64, InfRandVector{…}}, B::LinearAlgebra.Bidiagonal{Float64, InfRandVector{…}})
   @ LinearAlgebra C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\LinearAlgebra\src\special.jl:214
 [2] top-level scope
   @ REPL[8]:1
Some type information was truncated. Use `show(err)` to see complete types.
@dlfivefifty
Copy link
Collaborator

I think its actually \ and factorize that are broken. In particular you want factorize to make an adaptive QR as implemented in InfiniteLinearAlgebra.jl.

Actually does calling using InfiniteLinearAlgebra fix it?

@DanielVandH
Copy link
Owner Author

Actually does calling using InfiniteLinearAlgebra fix it?

Unfortunately not.

I think its actually \ and factorize that are broken. In particular you want factorize to make an adaptive QR as implemented in InfiniteLinearAlgebra.jl.

Makes sense. I'll look into that in ILA.jl

@DanielVandH
Copy link
Owner Author

DanielVandH commented Jul 3, 2024

Also can't do

julia> InfRandTridiagonal() * InfRandTridiagonal()
ERROR: InterruptException:
Stacktrace:
 [1] cache_filldata!(::LazyArrays.CachedArray{…}, ::UnitRange{…}, ::Base.OneTo{…})
   @ LazyArrays C:\Users\djv23\.julia\packages\LazyArrays\QwVhu\src\cache.jl:226
 [2] resizedata!(::ArrayLayouts.DenseColumnMajor, ::ArrayLayouts.ZerosLayout, ::LazyArrays.CachedArray{…}, ::Int64, ::Int64)
   @ LazyArrays C:\Users\djv23\.julia\packages\LazyArrays\QwVhu\src\cache.jl:267
 [3] resizedata!
   @ C:\Users\djv23\.julia\packages\LazyArrays\QwVhu\src\cache.jl:218 [inlined]
 [4] getindex
   @ C:\Users\djv23\.julia\packages\LazyArrays\QwVhu\src\cache.jl:70 [inlined]
 [5] _mul!(C::LazyArrays.CachedArray{…}, A::LinearAlgebra.Tridiagonal{…}, B::LinearAlgebra.Tridiagonal{…}, _add::LinearAlgebra.MulAddMul{…})
   @ LinearAlgebra C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\LinearAlgebra\src\bidiag.jl:496
 [6] mul!
   @ C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\LinearAlgebra\src\bidiag.jl:429 
[inlined]
 [7] mul!
   @ C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\LinearAlgebra\src\matmul.jl:237 
[inlined]
 [8] *(A::LinearAlgebra.Tridiagonal{Float64, InfRandVector{…}}, B::LinearAlgebra.Tridiagonal{Float64, InfRandVector{…}})
   @ LinearAlgebra C:\Users\djv23\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\LinearAlgebra\src\matmul.jl:106
 [9] top-level scope
   @ REPL[11]:1
Some type information was truncated. Use `show(err)` to see complete types.

Doesn't seem to interact with ArrayLayouts.jl at all for these finite matrices. Have you had to get around this previously? I could try and define LinearAlgebra.mul(A, B) = ApplyArray(*, A, B) for these matrices although maybe I'll have to keep chasing new methods as I try and do more with these matrices, in case you have another suggestion.

@dlfivefifty
Copy link
Collaborator

Need to overload *(::Tridiagonal{<:Any,<:LayoutVector}, ::Tridiagonal{<:Any,<:LayoutVector}) here:

https://github.com/JuliaLinearAlgebra/ArrayLayouts.jl/blob/318d0d8d09e3148e5cf10828ba7c12697a194512/src/mul.jl#L363

@DanielVandH
Copy link
Owner Author

So far I have (could maybe do it in a loop.. but having it written out probably helps for patching possible ambiguities later on?)

*(A::SymTridiagonal{<:Any,<:LayoutVector}, B::SymTridiagonal{<:Any,<:LayoutVector}) = mul(A, B)
*(A::SymTridiagonal{<:Any,<:LayoutVector}, B::Tridiagonal{<:Any,<:LayoutVector}) = mul(A, B)
*(A::SymTridiagonal{<:Any,<:LayoutVector}, B::Bidiagonal{<:Any,<:LayoutVector}) = mul(A, B)
*(A::SymTridiagonal{<:Any,<:LayoutVector}, B::UpperOrLowerTriangular{<:Any,<:LayoutMatrix}) = mul(A, B)
*(A::SymTridiagonal, B::Diagonal{<:Any,<:LayoutVector}) = mul(A, B) # ambiguity
*(A::Tridiagonal{<:Any,<:LayoutVector}, B::Tridiagonal{<:Any,<:LayoutVector}) = mul(A, B)
*(A::Tridiagonal{<:Any,<:LayoutVector}, B::SymTridiagonal{<:Any,<:LayoutVector}) = mul(A, B)
*(A::Tridiagonal{<:Any,<:LayoutVector}, B::Bidiagonal{<:Any,<:LayoutVector}) = mul(A, B)
*(A::Tridiagonal{<:Any,<:LayoutVector}, B::UpperOrLowerTriangular{<:Any,<:LayoutMatrix}) = mul(A, B)
*(A::Bidiagonal{<:Any,<:LayoutVector}, B::Bidiagonal{<:Any,<:LayoutVector}) = mul(A, B)
*(A::Bidiagonal{<:Any,<:LayoutVector}, B::SymTridiagonal{<:Any,<:LayoutVector}) = mul(A, B)
*(A::Bidiagonal{<:Any,<:LayoutVector}, B::Tridiagonal{<:Any,<:LayoutVector}) = mul(A, B)
*(A::Bidiagonal{<:Any,<:LayoutVector}, B::UpperOrLowerTriangular{<:Any,<:LayoutMatrix}) = mul(A, B)
*(A::UpperOrLowerTriangular{<:Any,<:LayoutMatrix}, B::SymTridiagonal{<:Any,<:LayoutVector}) = mul(A, B)
*(A::UpperOrLowerTriangular{<:Any,<:LayoutMatrix}, B::Tridiagonal{<:Any,<:LayoutVector}) = mul(A, B)
*(A::UpperOrLowerTriangular{<:Any,<:LayoutMatrix}, B::Bidiagonal{<:Any,<:LayoutVector}) = mul(A, B)
*(A::UpperOrLowerTriangular{<:Any,<:LayoutMatrix}, B::Diagonal{<:Any,<:LayoutVector}) = mul(A, B) # ambiguity
*(A::Diagonal{<:Any, <:LayoutVector}, B::SymTridiagonal{<:Any, <:LayoutVector}) = mul(A, B)
*(A::Diagonal{<:Any, <:LayoutVector}, B::UpperOrLowerTriangular{<:Any, <:LayoutMatrix}) = mul(A, B)

which fixes the mul issues. This can be a PR to ArrayLayouts later

Are there similar methods somewhere for fixing issues with +, - between types and ^? I've found

https://github.com/JuliaLinearAlgebra/ArrayLayouts.jl/blob/d315ce332beb78cdb0a7c2bd4099c6fbaefe4b29/src/mul.jl#L469-L474

which does something similar but maybe I've overlooked something simpler.

@DanielVandH
Copy link
Owner Author

DanielVandH commented Jul 4, 2024

Actually I guess that code I've linked is probably as simple as it'd get, so I'll just do that. Or I might just end up leaving it and go to fixing inv

@dlfivefifty
Copy link
Collaborator

For reasons I can't explain + and - haven't been as problematic as *. So I believe those are the only overloads that exist.

There was a point in time when ArrayLayouts.jl was just part of LazyArrays.jl and Applied(*, ...) played the role of Mul. And then Applied(+, ...) could be used for dispatching + based on AppliedStyle. But at some point I realised the current design was much simpler, and Applied is basically unused apart from some rare cases where I haven't removed it.

That is to say: I'm not sure if there's a more systematic way to deal with + or -. For *, we really need to just go through all of LinearAlgebra and deal with all the possible cases, but it's sort of low priority.

@DanielVandH
Copy link
Owner Author

DanielVandH commented Jul 4, 2024

Yeah, I gave up on the + and -. I imagine it hasn't really been needed as much.

I got to work on inv a bit, e.g. we need

inv(A::SymTridiagonal{<:Any, <:LayoutVector}) = inv_layout(MemoryLayout(A), axes(A), A)
inv(A::Tridiagonal{<:Any, <:LayoutVector}) = inv_layout(MemoryLayout(A), axes(A), A)
inv(A::Bidiagonal{<:Any, <:LayoutVector}) = inv_layout(MemoryLayout(A), axes(A), A)
# \(A::SymTridiagonal{<:Any, <:LayoutVector}, B::LayoutVector; kwds...) = ArrayLayouts.ldiv(A, B; kwds...) # ambiguity. (doesn't work)

but stopped there since I'd need to do some patching in InfiniteLinearAlgebra.jl with this so that

qr_layout(::SymTridiagonalLayout{<:AbstractLazyLayout, <:AbstractLazyLayout}, ::NTuple{2,OneToInf{Int}}, A) = adaptiveqr(A) 
qr_layout(::TridiagonalLayout{<:AbstractLazyLayout, <:AbstractLazyLayout, <:AbstractLazyLayout}, ::NTuple{2,OneToInf{Int}}, A) = adaptiveqr(A) 
qr_layout(::Bidiagonal{<:AbstractLazyLayout, <:AbstractLazyLayout}, ::NTuple{2,OneToInf{Int}}, A) = adaptiveqr(A) 

can be defined. Technically type piracy within InfiniteLinearAlgebra.jl but it's apparently fine since stuff like that's already done in that package. This needs even more patching though since AdaptiveQRData is missing some overloads. I'll get back to it eventually if/as the need comes up.

@dlfivefifty
Copy link
Collaborator

There's not a good paradigm for type piracy where a downstream package implements functionality. I just ran into this with blockkron(::Bidiagonal, ::Bidiagonal) where I needed to load using BlockBandedMatrices for it to recognise that it should be a BlockBandedMatrix.

So: don't worry about it!

@DanielVandH
Copy link
Owner Author

That makes sense. I've started the mul fixes in JuliaLinearAlgebra/ArrayLayouts.jl#241

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