Skip to content

Commit 8549b2a

Browse files
authored
Merge pull request #271 from kshyatt/matrixalgebra
Added a few more eig/eigh/svd tests
2 parents dd820ff + 6813a77 commit 8549b2a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

test/diagonal.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@ diagspacelist = ((ℂ^4)', ℂ[Z2Irrep](0 => 2, 1 => 3),
200200
@test all(((s, t),) -> isapprox(s, t),
201201
zip(values(LinearAlgebra.eigvals(D)),
202202
values(LinearAlgebra.eigvals(t))))
203+
D, W = @constinferred eig!(t)
204+
@test D === t
205+
@test W == one(t)
206+
@test t * W W * D
207+
D2, V2 = @constinferred eigh!(t2)
208+
if T <: Real
209+
@test D2 === t2
210+
end
211+
@test V2 == one(t)
212+
@test t2 * V2 V2 * D2
203213
end
204214
@testset "leftorth with $alg" for alg in (TensorKit.QR(), TensorKit.QL())
205215
Q, R = @constinferred leftorth(t; alg=alg)

test/tensors.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,11 @@ for V in spacelist
490490
for (c, b) in s
491491
@test b s′[c]
492492
end
493+
s = LinearAlgebra.svdvals(t2')
494+
s′ = LinearAlgebra.diag(S')
495+
for (c, b) in s
496+
@test b s′[c]
497+
end
493498
end
494499
@testset "cond and rank" begin
495500
t2 = permute(t, ((3, 4, 2), (1, 5)))
@@ -507,6 +512,10 @@ for V in spacelist
507512
λmax = maximum(s -> maximum(abs, s), values(vals))
508513
λmin = minimum(s -> minimum(abs, s), values(vals))
509514
@test cond(t4) λmax / λmin
515+
vals = LinearAlgebra.eigvals(t4')
516+
λmax = maximum(s -> maximum(abs, s), values(vals))
517+
λmin = minimum(s -> minimum(abs, s), values(vals))
518+
@test cond(t4') λmax / λmin
510519
end
511520
end
512521
@testset "empty tensor" begin

0 commit comments

Comments
 (0)