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

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

Closed
jishnub opened this issue Jan 2, 2024 · 1 comment
Closed

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

jishnub opened this issue Jan 2, 2024 · 1 comment

Comments

@jishnub
Copy link
Member

jishnub commented Jan 2, 2024

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.

@dlfivefifty
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants