From cb94d87dac967975ef4d3e41f527681a4044c910 Mon Sep 17 00:00:00 2001 From: Paul Brehmer Date: Fri, 30 May 2025 11:37:15 +0200 Subject: [PATCH 1/2] Remove `_condition_number` and replace by `LinearAlgebra.cond` --- src/utility/svd.jl | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/utility/svd.jl b/src/utility/svd.jl index d4f454fca..25033c9fb 100644 --- a/src/utility/svd.jl +++ b/src/utility/svd.jl @@ -146,13 +146,6 @@ end ## Forward algorithms -# Compute condition number smax / smin for diagonal singular value TensorMap -function _condition_number(S::AbstractTensorMap) - smax = maximum(first ∘ last, blocks(S)) - smin = maximum(last ∘ last, blocks(S)) - return smax / smin -end - # Copy code from TensorKit but additionally return full U, S and V to make compatible with :fixed mode function _tsvd!( t::TensorMap{<:RealOrComplexFloat}, @@ -176,7 +169,7 @@ function _tsvd!( end # construct info NamedTuple - condnum = _condition_number(S) + condnum = cond(S) info = (; truncation_error=truncerr, condition_number=condnum, U_full=U, S_full=S, V_full=V⁺ ) @@ -217,7 +210,7 @@ end function _tsvd!(_, alg::FixedSVD, ::TruncationScheme, ::Real) info = (; truncation_error=0, - condition_number=_condition_number(alg.S), + condition_number=cond(alg.S), U_full=alg.U_full, S_full=alg.S_full, V_full=alg.V_full, @@ -272,7 +265,7 @@ function _tsvd!(f, alg::IterSVD, trunc::TruncationScheme, p::Real) trunc isa NoTruncation ? abs(zero(scalartype(f))) : norm(U * S * V - f, p) # construct info NamedTuple - condition_number = _condition_number(S) + condition_number = cond(S) info = (; truncation_error, condition_number, U_full=nothing, S_full=nothing, V_full=nothing ) From bc9739b32824a779295625ee2f1e82358af14674 Mon Sep 17 00:00:00 2001 From: Paul Brehmer Date: Fri, 30 May 2025 12:16:01 +0200 Subject: [PATCH 2/2] Bump TensorKit version to 0.14.6 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index a0e8fe041..cb1675223 100644 --- a/Project.toml +++ b/Project.toml @@ -41,7 +41,7 @@ Printf = "1" QuadGK = "2.11.1" Random = "1" Statistics = "1" -TensorKit = "0.14" +TensorKit = "0.14.6" TensorOperations = "5" VectorInterface = "0.4, 0.5" Zygote = "0.6, 0.7"