Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Replace np.isfinite(cn) with cn * EPS < 1 in solve_discrete_riccati #361

Merged
merged 1 commit into from
Oct 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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