Skip to content

Can't cache AbstractQ on Julia v1.10 #285

Closed
@jishnub

Description

@jishnub
Member
julia> using LazyArrays, LinearAlgebra

julia> Q = qr(rand(3,4)).Q;

julia> cache(Q)
ERROR: MethodError: no method matching similar(::LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}}, ::Tuple{Int64, Int64})

Closest candidates are:
  similar(::JuliaInterpreter.Compiled, ::Any)
   @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/EsH1r/src/types.jl:7
  similar(::Type{T}, ::Tuple{Vararg{Int64, N}} where N) where T<:AbstractArray
   @ Base abstractarray.jl:874
  similar(::Type{T}, ::Tuple{Union{Integer, Base.OneTo}, Vararg{Union{Integer, Base.OneTo}}}) where T<:AbstractArray
   @ Base abstractarray.jl:873
  ...

Stacktrace:
 [1] LazyArrays.CachedArray(array::LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}})
   @ LazyArrays ~/Dropbox/JuliaPackages/LazyArrays.jl/src/cache.jl:46
 [2] _cache(::ArrayLayouts.QRCompactWYQLayout{ArrayLayouts.DenseColumnMajor, ArrayLayouts.DenseColumnMajor}, O::LinearAlgebra.QRCompactWYQ{Float64, Matrix{…}, Matrix{…}})
   @ LazyArrays ~/Dropbox/JuliaPackages/LazyArrays.jl/src/cache.jl:55
 [3] cache(A::LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}})
   @ LazyArrays ~/Dropbox/JuliaPackages/LazyArrays.jl/src/cache.jl:54
 [4] top-level scope
   @ REPL[3]:1
Some type information was truncated. Use `show(err)` to see complete types.

This is because AbstractQ isn't an AbstractArray anymore. The fix to this might require relaxing the type-signature of a CachedArray to accept non-array types that implement the array interface.

Activity

dlfivefifty

dlfivefifty commented on Jun 25, 2024

@dlfivefifty
Member

This is fixed:

julia> using LazyArrays, LinearAlgebra

┌ Warning: The project dependencies or compat requirements have changed since the manifest was last resolved.
│ It is recommended to `Pkg.resolve()` or consider `Pkg.update()` if necessary.
└ @ Pkg.API ~/Projects/julia-1.10/usr/share/julia/stdlib/v1.10/Pkg/src/API.jl:1807
Precompiling LazyArrays
  3 dependencies successfully precompiled in 9 seconds. 5 already precompiled.

julia> Q = qr(rand(3,4)).Q;

julia> cache(Q)
3×3 LazyArrays.CachedArray{Float64, 2, Matrix{Float64}, LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}}}:
 -0.180125   0.671338   0.71893
 -0.72157    0.406539  -0.560413
 -0.6685    -0.619702   0.411189
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @dlfivefifty@jishnub

        Issue actions

          Can't cache AbstractQ on Julia v1.10 · Issue #285 · JuliaArrays/LazyArrays.jl