Skip to content

Commit a82e0fe

Browse files
committed
test: add MINRES test
1 parent 2733b4c commit a82e0fe

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

unittest/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
22
# Copyright (c) 2014-2019 CNRS
3-
# Copyright (c) 2018-2020 INRIA
3+
# Copyright (c) 2018-2021 INRIA
44
#
55

66
MACRO(ADD_LIB_UNIT_TEST test)
@@ -62,3 +62,6 @@ SET_TESTS_PROPERTIES("py-LLT" PROPERTIES DEPENDS ${PYWRAP})
6262

6363
ADD_PYTHON_UNIT_TEST("py-LDLT" "unittest/python/test_LDLT.py" "python/eigenpy;unittest")
6464
SET_TESTS_PROPERTIES("py-LDLT" PROPERTIES DEPENDS ${PYWRAP})
65+
66+
ADD_PYTHON_UNIT_TEST("py-MINRES" "unittest/python/test_MINRES.py" "python/eigenpy;unittest")
67+
SET_TESTS_PROPERTIES("py-MINRES" PROPERTIES DEPENDS ${PYWRAP})

unittest/python/test_MINRES.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import eigenpy
2+
3+
import numpy as np
4+
import numpy.linalg as la
5+
6+
dim = 100
7+
A = np.random.rand(dim,dim)
8+
9+
A = (A + A.T)*0.5 + np.diag(10. + np.random.rand(dim))
10+
11+
minres = eigenpy.MINRES(A)
12+
13+
X = np.random.rand(dim,20)
14+
B = A.dot(X)
15+
X_est = minres.solve(B)
16+
assert eigenpy.is_approx(X,X_est)
17+
assert eigenpy.is_approx(A.dot(X_est),B)

0 commit comments

Comments
 (0)