Verified Commit 4e7cbeb3 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

test: add test of EigenSolver

parent 339241f8
......@@ -48,3 +48,6 @@ SET_TESTS_PROPERTIES("py-dimensions" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-version" "unittest/python/test_version.py" "python/eigenpy")
SET_TESTS_PROPERTIES("py-version" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-eigen-solver" "unittest/python/test_eigen_solver.py" "python/eigenpy")
SET_TESTS_PROPERTIES("py-eigen-solver" PROPERTIES DEPENDS ${PYWRAP})
import eigenpy
eigenpy.switchToNumpyArray()
import numpy as np
import numpy.linalg as la
dim = 100
A = np.random.rand(dim,dim)
es = eigenpy.EigenSolver(A)
V = es.eigenvectors()
D = es.eigenvalues()
assert eigenpy.is_approx(A.dot(V).real,V.dot(np.diag(D)).real)
assert eigenpy.is_approx(A.dot(V).imag,V.dot(np.diag(D)).imag)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment