From 790653bf9ae30d9c9620bcb17de30d219a00a0aa Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Wed, 1 Dec 2021 14:36:21 +0100
Subject: [PATCH] dyn_first_order_solver.m: add debugging information

(cherry picked from commit 82689795e44b91f81979155b4a795c0b8ae5e4f9)
---
 matlab/dyn_first_order_solver.m | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/matlab/dyn_first_order_solver.m b/matlab/dyn_first_order_solver.m
index e82ae536f0..8fceebbe59 100644
--- a/matlab/dyn_first_order_solver.m
+++ b/matlab/dyn_first_order_solver.m
@@ -275,6 +275,12 @@ if nstatic > 0
     b11 = b(1:nstatic, nstatic+1:end);
     temp(:,index_m) = temp(:,index_m)-A(1:nstatic,:);
     temp = b10\(temp-b11*ghx);
+    if DynareOptions.debug
+        if any(any(~isfinite(temp)))
+            fprintf('\ndyn_first_order_solver: infinite/NaN elements encountered when solving for the static variables\n')
+            fprintf('dyn_first_order_solver: This often arises if there is a singularity.\n\n')
+        end
+    end
     ghx = [temp; ghx];
     temp = [];
 end
-- 
GitLab