Skip to content

Commit 21f4ebf

Browse files
committed
test: add test for Eigen::LDLT
1 parent 775a1b7 commit 21f4ebf

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

unittest/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,6 @@ SET_TESTS_PROPERTIES("py-self-adjoint-eigen-solver" PROPERTIES DEPENDS ${PYWRAP}
5757

5858
ADD_PYTHON_UNIT_TEST("py-LLT" "unittest/python/test_LLT.py" "python/eigenpy")
5959
SET_TESTS_PROPERTIES("py-LLT" PROPERTIES DEPENDS ${PYWRAP})
60+
61+
ADD_PYTHON_UNIT_TEST("py-LDLT" "unittest/python/test_LDLT.py" "python/eigenpy")
62+
SET_TESTS_PROPERTIES("py-LDLT" PROPERTIES DEPENDS ${PYWRAP})

unittest/python/test_LDLT.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import eigenpy
2+
eigenpy.switchToNumpyArray()
3+
4+
import numpy as np
5+
import numpy.linalg as la
6+
7+
dim = 100
8+
A = np.random.rand(dim,dim)
9+
10+
A = (A + A.T)*0.5 + np.diag(10. + np.random.rand(dim))
11+
12+
ldlt = eigenpy.LDLT(A)
13+
14+
L = ldlt.matrixL()
15+
D = ldlt.vectorD()
16+
P = ldlt.transpositionsP()
17+
18+
assert eigenpy.is_approx(np.transpose(P).dot(L.dot(np.diag(D).dot(np.transpose(L).dot(P)))),A)

0 commit comments

Comments
 (0)