Skip to content

Commit

Permalink
FIX: Replace np.isfinite(cn) with cn * EPS < 1 (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
oyamad authored and mmcky committed Oct 23, 2017
1 parent befc673 commit 6b1f9a8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion quantecon/matrix_eqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
from scipy.linalg import solve_discrete_lyapunov as sp_solve_discrete_lyapunov


EPS = np.finfo(float).eps


def solve_discrete_lyapunov(A, B, max_it=50, method="doubling"):
r"""
Computes the solution to the discrete lyapunov equation
Expand Down Expand Up @@ -163,7 +166,7 @@ def solve_discrete_riccati(A, B, Q, R, N=None, tolerance=1e-10, max_iter=500):
for gamma in candidates:
Z = R + gamma * BB
cn = np.linalg.cond(Z)
if np.isfinite(cn):
if cn * EPS < 1:
Q_tilde = - Q + dot(N.T, solve(Z, N + gamma * BTA)) + gamma * I
G0 = dot(B, solve(Z, B.T))
A0 = dot(I - gamma * G0, A) - dot(B, solve(Z, N))
Expand Down

0 comments on commit 6b1f9a8

Please sign in to comment.