Skip to content

Commit

Permalink
Add a test for diagonal tensors (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt authored and fredrikekre committed Jun 23, 2017
1 parent b72cad7 commit 6dbb5d2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/test_misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6dbb5d2

Please sign in to comment.