Skip to content

Commit

Permalink
TST: Add an infeasibility test to CARE
Browse files Browse the repository at this point in the history
  • Loading branch information
ilayn committed Nov 15, 2017
1 parent fdb3889 commit 9b737ef
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scipy/linalg/tests/test_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from scipy.linalg import solve_sylvester
from scipy.linalg import solve_continuous_lyapunov, solve_discrete_lyapunov
from scipy.linalg import solve_continuous_are, solve_discrete_are
from scipy.linalg import block_diag, solve
from scipy.linalg import block_diag, solve, LinAlgError


def _load_data(name):
Expand Down Expand Up @@ -528,6 +528,14 @@ def _test_factory(case, dec):
for ind, case in enumerate(cases):
_test_factory(case, min_decimal[ind])

# An infeasible example taken from https://arxiv.org/abs/1505.04861v1
A = np.triu(np.ones((3, 3)))
A[0, 1] = -1
B = np.array([[1, 1, 0], [0, 0, 1]]).T
Q = -2*np.ones_like(A) + np.diag([8, -1, -1.9])
R = np.diag([-10, 0.1])
assert_raises(LinAlgError, solve_continuous_are, A, B, Q, R)


def test_solve_generalized_continuous_are():
cases = [
Expand Down Expand Up @@ -757,4 +765,3 @@ def test_trivial(self):
c = np.array([2.0, 2.0]).reshape(-1, 1)
x = solve_sylvester(a, b, c)
assert_array_almost_equal(x, np.array([1.0, 1.0]).reshape(-1, 1))

0 comments on commit 9b737ef

Please sign in to comment.