Skip to content

Commit 38441ea

Browse files
committed
Add a few more Diagonal tests for coverage
1 parent 7176114 commit 38441ea

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/TensorKit.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ export leftorth, rightorth, leftnull, rightnull,
7676
qr_full, qr_compact, qr_null, lq_full, lq_compact, lq_null,
7777
qr_full!, qr_compact!, qr_null!, lq_full!, lq_compact!, lq_null!,
7878
tsvd!, tsvd, eigen, eigen!, eig, eig!, eigh, eigh!, exp, exp!,
79+
eigh_full!, eigh_full, eig_full!, eig_full, eigh_vals!, eigh_vals,
80+
eig_vals!, eig_vals,
7981
isposdef, isposdef!, ishermitian, isisometry, isunitary, sylvester, rank, cond
8082
export braid, braid!, permute, permute!, transpose, transpose!, twist, twist!, repartition,
8183
repartition!

test/diagonal.jl

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,19 @@ diagspacelist = ((ℂ^4)', ℂ[Z2Irrep](0 => 2, 1 => 3),
188188
@timedtestset "Factorization" begin
189189
for T in (Float32, ComplexF64)
190190
t = DiagonalTensorMap(rand(T, reduceddim(V)), V)
191-
@testset "eig" begin
191+
@testset "eig/eigh" begin
192+
D, W = @constinferred eig_full(t)
193+
@test t * W W * D
192194
D, W = @constinferred eig(t)
193195
@test t * W W * D
194196
t2 = t + t'
195197
D2, V2 = @constinferred eigh(t2)
196198
VdV2 = V2' * V2
197199
@test VdV2 one(VdV2)
198200
@test t2 * V2 V2 * D2
201+
202+
D3 = @constinferred eigh_vals(t2)
203+
@test D2 D3
199204

200205
@test rank(D) rank(t)
201206
@test cond(D) cond(t)
@@ -231,6 +236,26 @@ diagspacelist = ((ℂ^4)', ℂ[Z2Irrep](0 => 2, 1 => 3),
231236
@test isposdef(L)
232237
end
233238
end
239+
@testset "qr_full with $alg" for alg in (TensorKit.DiagonalAlgorithm(),)
240+
Q, R = @constinferred qr_full(t; alg=alg)
241+
@test isisometry(Q)
242+
@test Q * R t
243+
end
244+
@testset "qr_compact with $alg" for alg in (TensorKit.DiagonalAlgorithm(),)
245+
Q, R = @constinferred qr_compact(t; alg=alg)
246+
@test isisometry(Q)
247+
@test Q * R t
248+
end
249+
@testset "lq_full with $alg" for alg in (TensorKit.DiagonalAlgorithm(),)
250+
L, Q = @constinferred lq_full(t; alg=alg)
251+
@test isisometry(Q; side=:right)
252+
@test L * Q t
253+
end
254+
@testset "lq_compact with $alg" for alg in (TensorKit.DiagonalAlgorithm(),)
255+
L, Q = @constinferred lq_compact(t; alg=alg)
256+
@test isisometry(Q; side=:right)
257+
@test L * Q t
258+
end
234259
@testset "tsvd with $alg" for alg in (TensorKit.DiagonalAlgorithm(),)
235260
U, S, Vᴴ = @constinferred tsvd(t; alg=alg)
236261
UdU = U' * U

0 commit comments

Comments
 (0)