Skip to content

Commit 155aa89

Browse files
authored
Small fixes and changelog updates (#331)
* fix #314 (again) * avoid warning in precompilation * update changelog * add LinearAlgebra.svd overload
1 parent d60855e commit 155aa89

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

docs/src/Changelog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ When releasing a new version, move the "Unreleased" changes to a new version sec
2020

2121
## [Unreleased](https://github.com/QuantumKitHub/TensorKit.jl/compare/v0.16.0...HEAD)
2222

23+
### Added
24+
25+
- Extended support for selecting storage types in the `TensorMap` constructors ([#327](https://github.com/QuantumKitHub/TensorKit.jl/pull/327))
26+
- `similar_diagonal` to handle storage types when constructing diagonals ([#330](https://github.com/QuantumKitHub/TensorKit.jl/pull/330))
27+
- `LinearAlgebra.svd` overloads
28+
29+
### Fixed
30+
31+
- Issue with using relative tolerances in truncation schemes ([#314](https://github.com/QuantumKitHub/TensorKit.jl/issues/314))
32+
- Using `scalartype` instead of `eltype` in BLAS contraction ([#326](https://github.com/QuantumKitHub/TensorKit.jl/pull/326))
33+
- Divide by zero error in `show` for empty tensors ([#329](https://github.com/QuantumKitHub/TensorKit.jl/pull/329))
34+
2335
## [0.16.0](https://github.com/QuantumKitHub/TensorKit.jl/releases/tag/v0.16.0) - 2025-12-08
2436

2537
### Added

src/factorizations/factorizations.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using ..TensorKit: AdjointTensorMap, SectorDict, SectorVector,
1212

1313
using LinearAlgebra: LinearAlgebra, BlasFloat, Diagonal,
1414
svdvals, svdvals!, eigen, eigen!,
15-
isposdef, isposdef!, ishermitian
15+
isposdef, isposdef!
1616

1717
using TensorOperations: Index2Tuple
1818

@@ -37,10 +37,10 @@ TensorKit.one!(A::AbstractMatrix) = MatrixAlgebraKit.one!(A)
3737
#------------------------------#
3838

3939
function LinearAlgebra.eigen(t::AbstractTensorMap; kwargs...)
40-
return ishermitian(t) ? eigh_full(t; kwargs...) : eig_full(t; kwargs...)
40+
return LinearAlgebra.ishermitian(t) ? eigh_full(t; kwargs...) : eig_full(t; kwargs...)
4141
end
4242
function LinearAlgebra.eigen!(t::AbstractTensorMap; kwargs...)
43-
return ishermitian(t) ? eigh_full!(t; kwargs...) : eig_full!(t; kwargs...)
43+
return LinearAlgebra.ishermitian(t) ? eigh_full!(t; kwargs...) : eig_full!(t; kwargs...)
4444
end
4545

4646
function LinearAlgebra.eigvals(t::AbstractTensorMap; kwargs...)
@@ -49,6 +49,11 @@ function LinearAlgebra.eigvals(t::AbstractTensorMap; kwargs...)
4949
end
5050
LinearAlgebra.eigvals!(t::AbstractTensorMap; kwargs...) = eig_vals!(t)
5151

52+
LinearAlgebra.svd(t::AbstractTensorMap; full::Bool = false) =
53+
full ? svd_full(t) : svd_compact(t)
54+
LinearAlgebra.svd!(t::AbstractTensorMap; full::Bool = false) =
55+
full ? svd_full!(t) : svd_compact!(t)
56+
5257
function LinearAlgebra.svdvals(t::AbstractTensorMap)
5358
tcopy = copy_oftype(t, factorisation_scalartype(svd_vals!, t))
5459
return LinearAlgebra.svdvals!(tcopy)

src/factorizations/truncation.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ end
145145
# Find truncation
146146
# ---------------
147147
# auxiliary functions
148-
rtol_to_atol(S, p, atol, rtol) =
149-
rtol == 0 ? atol : max(atol, TensorKit._norm(S, p, norm(zero(scalartype(valtype(S))))) * rtol)
148+
rtol_to_atol(S, p, atol, rtol) = rtol == 0 ? atol : max(atol, norm(S, p) * rtol)
150149

151150
function _compute_truncerr(Σdata, truncdim, p = 2)
152151
I = keytype(Σdata)

test/tensors/factorizations.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,14 @@ for V in spacelist
282282
@test norm(t - U3 * S3 * Vᴴ3) ϵ3 atol = eps(real(T))^(4 / 5)
283283
@test space(S3, 1) space(S2, 1)
284284

285-
trunc = truncerror(; atol = ϵ2)
286-
U4, S4, Vᴴ4, ϵ4 = @constinferred svd_trunc(t; trunc)
287-
@test t * Vᴴ4' U4 * S4
288-
@test isisometric(U4)
289-
@test isisometric(Vᴴ4; side = :right)
290-
@test norm(t - U4 * S4 * Vᴴ4) ϵ4 atol = eps(real(T))^(4 / 5)
291-
@test ϵ4 ϵ2
285+
for trunc in (truncerror(; atol = ϵ2), truncerror(; rtol = ϵ2 / norm(t)))
286+
U4, S4, Vᴴ4, ϵ4 = @constinferred svd_trunc(t; trunc)
287+
@test t * Vᴴ4' U4 * S4
288+
@test isisometric(U4)
289+
@test isisometric(Vᴴ4; side = :right)
290+
@test norm(t - U4 * S4 * Vᴴ4) ϵ4 atol = eps(real(T))^(4 / 5)
291+
@test ϵ4 ϵ2
292+
end
292293

293294
trunc = truncrank(nvals) & trunctol(; atol = λ - 10eps(λ))
294295
U5, S5, Vᴴ5, ϵ5 = @constinferred svd_trunc(t; trunc)

0 commit comments

Comments
 (0)