Skip to content

Commit 36fdab2

Browse files
committed
test/decompositions: add test for sparse Cholmod Cholesky
1 parent 7b26346 commit 36fdab2

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

unittest/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,20 @@ if(BUILD_TESTING_SCIPY)
156156

157157
if(BUILD_WITH_CHOLMOD_SUPPORT)
158158

159+
add_python_unit_test(
160+
"py-CholmodSimplicialLLT"
161+
"unittest/python/decompositions/sparse/cholmod/test_CholmodSimplicialLLT.py"
162+
"python")
163+
164+
add_python_unit_test(
165+
"py-CholmodSimplicialLDLT"
166+
"unittest/python/decompositions/sparse/cholmod/test_CholmodSimplicialLDLT.py"
167+
"python")
168+
169+
add_python_unit_test(
170+
"py-CholmodSupernodalLLT"
171+
"unittest/python/decompositions/sparse/cholmod/test_CholmodSupernodalLLT.py"
172+
"python")
173+
159174
endif(BUILD_WITH_CHOLMOD_SUPPORT)
160175
endif()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import eigenpy
2+
3+
import numpy as np
4+
from scipy.sparse import csc_matrix
5+
6+
dim = 100
7+
A = np.random.rand(dim, dim)
8+
A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim))
9+
10+
A = csc_matrix(A)
11+
12+
llt = eigenpy.CholmodSimplicialLDLT(A)
13+
14+
assert llt.info() == eigenpy.ComputationInfo.Success
15+
16+
X = np.random.rand(dim, 20)
17+
B = A.dot(X)
18+
X_est = llt.solve(B)
19+
assert eigenpy.is_approx(X, X_est)
20+
assert eigenpy.is_approx(A.dot(X_est), B)
21+
22+
llt.analyzePattern(A)
23+
llt.factorize(A)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import eigenpy
2+
3+
import numpy as np
4+
from scipy.sparse import csc_matrix
5+
6+
dim = 100
7+
A = np.random.rand(dim, dim)
8+
A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim))
9+
10+
A = csc_matrix(A)
11+
12+
llt = eigenpy.CholmodSimplicialLLT(A)
13+
14+
assert llt.info() == eigenpy.ComputationInfo.Success
15+
16+
X = np.random.rand(dim, 20)
17+
B = A.dot(X)
18+
X_est = llt.solve(B)
19+
assert eigenpy.is_approx(X, X_est)
20+
assert eigenpy.is_approx(A.dot(X_est), B)
21+
22+
llt.analyzePattern(A)
23+
llt.factorize(A)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import eigenpy
2+
3+
import numpy as np
4+
from scipy.sparse import csc_matrix
5+
6+
dim = 100
7+
A = np.random.rand(dim, dim)
8+
A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim))
9+
10+
A = csc_matrix(A)
11+
12+
llt = eigenpy.CholmodSupernodalLLT(A)
13+
14+
assert llt.info() == eigenpy.ComputationInfo.Success
15+
16+
X = np.random.rand(dim, 20)
17+
B = A.dot(X)
18+
X_est = llt.solve(B)
19+
assert eigenpy.is_approx(X, X_est)
20+
assert eigenpy.is_approx(A.dot(X_est), B)
21+
22+
llt.analyzePattern(A)
23+
llt.factorize(A)

0 commit comments

Comments
 (0)