From a82e0fe0a09e9582436ce5cf3beedea60aa332bf Mon Sep 17 00:00:00 2001
From: Justin Carpentier <justin.carpentier@inria.fr>
Date: Thu, 5 Aug 2021 14:29:07 +0200
Subject: [PATCH] test: add MINRES test

---
 unittest/CMakeLists.txt        |  5 ++++-
 unittest/python/test_MINRES.py | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 unittest/python/test_MINRES.py

diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt
index ba18c9c..d8730c4 100644
--- a/unittest/CMakeLists.txt
+++ b/unittest/CMakeLists.txt
@@ -1,6 +1,6 @@
 #
 # Copyright (c) 2014-2019 CNRS
-# Copyright (c) 2018-2020 INRIA
+# Copyright (c) 2018-2021 INRIA
 #
 
 MACRO(ADD_LIB_UNIT_TEST test)
@@ -62,3 +62,6 @@ SET_TESTS_PROPERTIES("py-LLT" PROPERTIES DEPENDS ${PYWRAP})
 
 ADD_PYTHON_UNIT_TEST("py-LDLT" "unittest/python/test_LDLT.py" "python/eigenpy;unittest")
 SET_TESTS_PROPERTIES("py-LDLT" PROPERTIES DEPENDS ${PYWRAP})
+
+ADD_PYTHON_UNIT_TEST("py-MINRES" "unittest/python/test_MINRES.py" "python/eigenpy;unittest")
+SET_TESTS_PROPERTIES("py-MINRES" PROPERTIES DEPENDS ${PYWRAP})
diff --git a/unittest/python/test_MINRES.py b/unittest/python/test_MINRES.py
new file mode 100644
index 0000000..3b1daad
--- /dev/null
+++ b/unittest/python/test_MINRES.py
@@ -0,0 +1,17 @@
+import eigenpy
+
+import numpy as np
+import numpy.linalg as la
+
+dim = 100
+A = np.random.rand(dim,dim)
+
+A = (A + A.T)*0.5 + np.diag(10. + np.random.rand(dim))
+
+minres = eigenpy.MINRES(A)
+
+X = np.random.rand(dim,20)
+B = A.dot(X)
+X_est = minres.solve(B)
+assert eigenpy.is_approx(X,X_est)
+assert eigenpy.is_approx(A.dot(X_est),B)
-- 
GitLab