From 6dbb5d2120f3bd2c2bb4e065b3ab2a45ef20ab50 Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Thu, 22 Jun 2017 23:19:31 -0700 Subject: [PATCH] Add a test for diagonal tensors (#72) --- test/test_misc.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test_misc.jl b/test/test_misc.jl index ae37f5c8..ebcb137a 100644 --- a/test/test_misc.jl +++ b/test/test_misc.jl @@ -312,6 +312,16 @@ for T in (Float32, Float64, F64), dim in (1,2,3) # scale with first element of eigenvector to account for possible directions @test Φ[:, i]*Φ[1, i] ≈ Φa[:, i]*Φa[1, i] end + + # test eigenfactorizations for a diagonal tensor + v = rand(T, dim) + d_sym = diagm(SymmetricTensor{2, dim, T}, v) + E = @inferred eigfact(d_sym) + Λ, Φ = @inferred eig(d_sym) + Λa, Φa = eig(Array(d_sym)) + + @test Λ ≈ (@inferred eigvals(d_sym)) ≈ eigvals(E) ≈ Λa + @test Φ ≈ (@inferred eigvecs(d_sym)) ≈ eigvecs(E) end end # of testset