Skip to content

Commit 314d366

Browse files
committed
Reduce repeated normalization of s when calculating Δs
1 parent 1eab6fb commit 314d366

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/algorithms/truncation/bond_truncation.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The truncation algorithm can be constructed from the following keyword arguments
1515
1616
* `trunc::TruncationStrategy`: SVD truncation strategy when initilizing the truncated tensors connected by the bond.
1717
* `maxiter::Int=50` : Maximal number of ALS iterations.
18-
* `tol::Float64=1e-9` : ALS converges when the change in bond SVD spectrum (normalized by maximum element) between two iterations is smaller than `tol`.
18+
* `tol::Float64=1e-9` : ALS converges when the relative change in bond SVD spectrum (normalized by maximum element) between two iterations is smaller than `tol`.
1919
* `check_interval::Int=0` : Set number of iterations to print information. Output is suppressed when `check_interval <= 0`.
2020
"""
2121
@kwdef struct ALSTruncation
@@ -111,8 +111,8 @@ function bond_truncate(
111111
# TODO: replace with truncated svdvals (without calculating u, vh)
112112
_, s, _ = svd_trunc!(permute(ab, perm_ab); trunc = alg.trunc)
113113
# fidelity, cost and normalized bond-s change
114-
Δs = (space(s) == space(s0)) ?
115-
_singular_value_distance((normalize(s, Inf), normalize(s0, Inf))) : NaN
114+
s_nrm = norm(s0, Inf)
115+
Δs = ((space(s) == space(s0)) ? _singular_value_distance((s, s0)) : NaN) / s_nrm
116116
Δcost = abs(cost - cost0) / cost00
117117
Δfid = abs(fid - fid0)
118118
cost0, fid0, s0 = cost, fid, s

src/algorithms/truncation/fullenv_truncation.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The truncation algorithm can be constructed from the following keyword arguments
1515
1616
* `trunc::TruncationStrategy` : SVD truncation strategy when optimizing the new bond matrix.
1717
* `maxiter::Int=50` : Maximal number of FET iterations.
18-
* `tol::Float64=1e-9` : FET converges when the change in bond SVD spectrum (normalized by maximum element) between two FET iterations is smaller than `tol`.
18+
* `tol::Float64=1e-9` : FET converges when the relative change in bond SVD spectrum between two FET iterations is smaller than `tol`.
1919
* `trunc_init::Bool=true` : Controls whether the initialization of the new bond matrix is obtained from truncated SVD of the old bond matrix.
2020
* `check_interval::Int=0` : Set number of iterations to print information. Output is suppressed when `check_interval <= 0`.
2121
@@ -255,8 +255,8 @@ function fullenv_truncate(
255255
fid = fidelity(benv, b0, b1)
256256
u, s, vh = svd_trunc!(b1; trunc = alg.trunc)
257257
# determine convergence
258-
Δs = (space(s) == space(s0)) ?
259-
_singular_value_distance((normalize(s, Inf), normalize(s0, Inf))) : NaN
258+
s_nrm = norm(s0, Inf)
259+
Δs = ((space(s) == space(s0)) ? _singular_value_distance((s, s0)) : NaN) / s_nrm
260260
Δfid = fid - fid0
261261
s0 = deepcopy(s)
262262
fid0 = fid

0 commit comments

Comments
 (0)