ITensor / ITensor/TensorAlgebra.jl

[BUG] `TensorAlgebra.qr(::SparseArrays.SparseMatrixCSC, ...)` broken

Open
#21 3 comments 0 reactions 1 assignee View on GitHub

@lkdvos is already working on this.

Since Feb 6, 2025.

bug
Dominant language
Julia
Stars
3
Forks
2
Avg merge
1h 11m
Merged PRs (30d)
4

Description

For example:

julia> using TensorAlgebra

julia> using SparseArrays

julia> TensorAlgebra.qr(sprandn(2, 2, 0.5), ("i", "j"), ("i",), ("j",))
ERROR: MethodError: no method matching iterate(::SparseArrays.SPQR.QRSparse{Float64, Int64})
The function `iterate` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  iterate(::SimpleTraits.GenerateTypeVars{:upcase})
   @ SimpleTraits ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:445
  iterate(::SimpleTraits.GenerateTypeVars{:lcase})
   @ SimpleTraits ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:446
  iterate(::SimpleTraits.GenerateTypeVars{:upcase}, ::Any)
   @ SimpleTraits ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:445
  ...

Stacktrace:
 [1] indexed_iterate(I::SparseArrays.SPQR.QRSparse{Float64, Int64}, i::Int64)
   @ Base ./tuple.jl:162
 [2] qr(a::SparseMatrixCSC{Float64, Int64}, biperm::TensorAlgebra.BlockedPermutation{2, (1, 1), Tuple{Int64, Int64}})
   @ TensorAlgebra ~/.julia/packages/TensorAlgebra/p4Ouf/src/factorizations.jl:8
 [3] qr(a::SparseMatrixCSC{Float64, Int64}, labels_a::Tuple{String, String}, labels_codomain::Tuple{String}, labels_domain::Tuple{String})
   @ TensorAlgebra ~/.julia/packages/TensorAlgebra/p4Ouf/src/factorizations.jl:20
 [4] top-level scope
   @ REPL[10]:1

julia> pkgversion(TensorAlgebra)
v"0.1.7"

The reason for the error is that LinearAlgebra.qr(::SparseArrays.SparseMatrixCSC) outputs a factorization object that can't be unpacked as a tuple:

julia> using LinearAlgebra

julia> using SparseArrays

julia> q, r = qr(sprandn(2, 2, 0.5))
ERROR: MethodError: no method matching iterate(::SparseArrays.SPQR.QRSparse{Float64, Int64})
The function `iterate` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  iterate(::SimpleTraits.GenerateTypeVars{:upcase})
   @ SimpleTraits ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:445
  iterate(::SimpleTraits.GenerateTypeVars{:lcase})
   @ SimpleTraits ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:446
  iterate(::SimpleTraits.GenerateTypeVars{:upcase}, ::Any)
   @ SimpleTraits ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:445
  ...

Stacktrace:
 [1] indexed_iterate(I::SparseArrays.SPQR.QRSparse{Float64, Int64}, i::Int64)
   @ Base ./tuple.jl:162
 [2] top-level scope
   @ REPL[16]:1

which is being used inside TensorAlgebra.qr.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.