From 2538b69e67621eee85d5f3c420efb44f24827fc6 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Wed, 31 Jan 2018 22:23:02 +0100
Subject: [PATCH] Discretion: Added catch for infinities

Comment: A user provided a file in which the Sylvester equation solved using doubling can evaluate to inf. When Doubling fails, one can try the Hessenberg-Schur algorithm.
---
 matlab/discretionary_policy_engine.m | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/matlab/discretionary_policy_engine.m b/matlab/discretionary_policy_engine.m
index 05c781ae4..bcf48267c 100644
--- a/matlab/discretionary_policy_engine.m
+++ b/matlab/discretionary_policy_engine.m
@@ -112,9 +112,9 @@ F1=F10;
 while 1
     iter=iter+1;
     P=SylvesterDoubling(W+beta*F1'*Q*F1,beta*H1',H1,discretion_tol,solve_maxit);
-    if any(any(isnan(P)))
+    if any(any(isnan(P))) || any(any(isinf(P))) 
         P=SylvesterHessenbergSchur(W+beta*F1'*Q*F1,beta*H1',H1);
-        if any(any(isnan(P)))
+        if any(any(isnan(P))) || any(any(isinf(P)))
             retcode=2;
             return
         end
-- 
GitLab