diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index ccaa683715eb51ca6904f0d6b2852d8c5db62365..f214e592018b37acca44ba656bac268274e2ad2f 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -156,5 +156,20 @@ if(BUILD_TESTING_SCIPY) if(BUILD_WITH_CHOLMOD_SUPPORT) + add_python_unit_test( + "py-CholmodSimplicialLLT" + "unittest/python/decompositions/sparse/cholmod/test_CholmodSimplicialLLT.py" + "python") + + add_python_unit_test( + "py-CholmodSimplicialLDLT" + "unittest/python/decompositions/sparse/cholmod/test_CholmodSimplicialLDLT.py" + "python") + + add_python_unit_test( + "py-CholmodSupernodalLLT" + "unittest/python/decompositions/sparse/cholmod/test_CholmodSupernodalLLT.py" + "python") + endif(BUILD_WITH_CHOLMOD_SUPPORT) endif() diff --git a/unittest/python/decompositions/sparse/cholmod/test_CholdmodSimplicialLDLT.py b/unittest/python/decompositions/sparse/cholmod/test_CholdmodSimplicialLDLT.py new file mode 100644 index 0000000000000000000000000000000000000000..328518a53b217d965b47297a3cf52e0d507a609e --- /dev/null +++ b/unittest/python/decompositions/sparse/cholmod/test_CholdmodSimplicialLDLT.py @@ -0,0 +1,23 @@ +import eigenpy + +import numpy as np +from scipy.sparse import csc_matrix + +dim = 100 +A = np.random.rand(dim, dim) +A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim)) + +A = csc_matrix(A) + +llt = eigenpy.CholmodSimplicialLDLT(A) + +assert llt.info() == eigenpy.ComputationInfo.Success + +X = np.random.rand(dim, 20) +B = A.dot(X) +X_est = llt.solve(B) +assert eigenpy.is_approx(X, X_est) +assert eigenpy.is_approx(A.dot(X_est), B) + +llt.analyzePattern(A) +llt.factorize(A) diff --git a/unittest/python/decompositions/sparse/cholmod/test_CholdmodSimplicialLLT.py b/unittest/python/decompositions/sparse/cholmod/test_CholdmodSimplicialLLT.py new file mode 100644 index 0000000000000000000000000000000000000000..f2993770530e92ce6d22c6a6fe11fab7e49e003c --- /dev/null +++ b/unittest/python/decompositions/sparse/cholmod/test_CholdmodSimplicialLLT.py @@ -0,0 +1,23 @@ +import eigenpy + +import numpy as np +from scipy.sparse import csc_matrix + +dim = 100 +A = np.random.rand(dim, dim) +A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim)) + +A = csc_matrix(A) + +llt = eigenpy.CholmodSimplicialLLT(A) + +assert llt.info() == eigenpy.ComputationInfo.Success + +X = np.random.rand(dim, 20) +B = A.dot(X) +X_est = llt.solve(B) +assert eigenpy.is_approx(X, X_est) +assert eigenpy.is_approx(A.dot(X_est), B) + +llt.analyzePattern(A) +llt.factorize(A) diff --git a/unittest/python/decompositions/sparse/cholmod/test_CholdmodSupernodalLLT.py b/unittest/python/decompositions/sparse/cholmod/test_CholdmodSupernodalLLT.py new file mode 100644 index 0000000000000000000000000000000000000000..1fd9a720059736884f597a5e94f2522b4159db43 --- /dev/null +++ b/unittest/python/decompositions/sparse/cholmod/test_CholdmodSupernodalLLT.py @@ -0,0 +1,23 @@ +import eigenpy + +import numpy as np +from scipy.sparse import csc_matrix + +dim = 100 +A = np.random.rand(dim, dim) +A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim)) + +A = csc_matrix(A) + +llt = eigenpy.CholmodSupernodalLLT(A) + +assert llt.info() == eigenpy.ComputationInfo.Success + +X = np.random.rand(dim, 20) +B = A.dot(X) +X_est = llt.solve(B) +assert eigenpy.is_approx(X, X_est) +assert eigenpy.is_approx(A.dot(X_est), B) + +llt.analyzePattern(A) +llt.factorize(A)