Skip to content

Commit 44c80fc

Browse files
authored
Remove _condition_number and replace by LinearAlgebra.cond (#208)
* Remove `_condition_number` and replace by `LinearAlgebra.cond` * Bump TensorKit version to 0.14.6
1 parent 6184954 commit 44c80fc

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Printf = "1"
4141
QuadGK = "2.11.1"
4242
Random = "1"
4343
Statistics = "1"
44-
TensorKit = "0.14"
44+
TensorKit = "0.14.6"
4545
TensorOperations = "5"
4646
VectorInterface = "0.4, 0.5"
4747
Zygote = "0.6, 0.7"

src/utility/svd.jl

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,6 @@ end
146146

147147
## Forward algorithms
148148

149-
# Compute condition number smax / smin for diagonal singular value TensorMap
150-
function _condition_number(S::AbstractTensorMap)
151-
smax = maximum(first last, blocks(S))
152-
smin = maximum(last last, blocks(S))
153-
return smax / smin
154-
end
155-
156149
# Copy code from TensorKit but additionally return full U, S and V to make compatible with :fixed mode
157150
function _tsvd!(
158151
t::TensorMap{<:RealOrComplexFloat},
@@ -176,7 +169,7 @@ function _tsvd!(
176169
end
177170

178171
# construct info NamedTuple
179-
condnum = _condition_number(S)
172+
condnum = cond(S)
180173
info = (;
181174
truncation_error=truncerr, condition_number=condnum, U_full=U, S_full=S, V_full=V⁺
182175
)
@@ -217,7 +210,7 @@ end
217210
function _tsvd!(_, alg::FixedSVD, ::TruncationScheme, ::Real)
218211
info = (;
219212
truncation_error=0,
220-
condition_number=_condition_number(alg.S),
213+
condition_number=cond(alg.S),
221214
U_full=alg.U_full,
222215
S_full=alg.S_full,
223216
V_full=alg.V_full,
@@ -272,7 +265,7 @@ function _tsvd!(f, alg::IterSVD, trunc::TruncationScheme, p::Real)
272265
trunc isa NoTruncation ? abs(zero(scalartype(f))) : norm(U * S * V - f, p)
273266

274267
# construct info NamedTuple
275-
condition_number = _condition_number(S)
268+
condition_number = cond(S)
276269
info = (;
277270
truncation_error, condition_number, U_full=nothing, S_full=nothing, V_full=nothing
278271
)

0 commit comments

Comments
 (0)