Skip to content

truncation error with rtol #314

@ogauthe

Description

@ogauthe
using TensorKit

m1 = ones((2,2))
m2 = id(ℂ^2)

svd_trunc(m1; trunc=trunctol(;rtol=0.5))  # Ok
svd_trunc(m2; trunc=trunctol(;atol=0.5))  # Ok
svd_trunc(m2; trunc=trunctol(;rtol=0.5))  # MethodError
ERROR: MethodError: no method matching _norm(::TensorKit.SortedVectorDict{Trivial, SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}}, ::Int64)
The function `_norm` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  _norm(::Any, ::Real, ::Real)
   @ TensorKit ~/Documents/tensorkit/TensorKit.jl/src/tensors/linalg.jl:268

Stacktrace:
 [1] rtol_to_atol(S::TensorKit.SortedVectorDict{Trivial, SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{}}, true}}, p::Int64, atol::Float64, rtol::Float64)
   @ TensorKit.Factorizations ~/Documents/tensorkit/TensorKit.jl/src/factorizations/truncation.jl:116
 [2] findtruncated_svd
   @ ~/Documents/tensorkit/TensorKit.jl/src/factorizations/truncation.jl:189 [inlined]
 [3] truncate(::typeof(svd_trunc!), ::Tuple{…}, strategy::MatrixAlgebraKit.TruncationByValue{…})
   @ TensorKit.Factorizations ~/Documents/tensorkit/TensorKit.jl/src/factorizations/truncation.jl:65
 [4] svd_trunc!
   @ ~/.julia/packages/MatrixAlgebraKit/xv5dv/src/implementations/svd.jl:241 [inlined]
 [5] svd_trunc!
   @ ~/.julia/packages/MatrixAlgebraKit/xv5dv/src/algorithms.jl:244 [inlined]
 [6] #svd_trunc!#104
   @ ~/.julia/packages/MatrixAlgebraKit/xv5dv/src/algorithms.jl:238 [inlined]
 [7] svd_trunc!
   @ ~/.julia/packages/MatrixAlgebraKit/xv5dv/src/algorithms.jl:237 [inlined]
 [8] #svd_trunc#103
   @ ~/.julia/packages/MatrixAlgebraKit/xv5dv/src/algorithms.jl:233 [inlined]
 [9] top-level scope
   @ REPL[6]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia v"1.12.1"
TensorKit v0.15.3

The issue is in the same function truncate but this seems unrelated to #313

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

    Issue actions