From 3eb7421fb78a098874074e459bd89fe40538c9ec Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Mon, 28 Nov 2022 16:19:05 +0100
Subject: [PATCH] sim1.m: use operation that preserves sparsity

(cherry picked from commit bbdcdc89a28ecedc2f8215113bb82649fc6f3bc4)
---
 matlab/perfect-foresight-models/sim1.m | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/matlab/perfect-foresight-models/sim1.m b/matlab/perfect-foresight-models/sim1.m
index d6382a0fbb..f5cd589a44 100644
--- a/matlab/perfect-foresight-models/sim1.m
+++ b/matlab/perfect-foresight-models/sim1.m
@@ -68,8 +68,9 @@ for iter = 1:options.simul.maxit
     % A is the stacked Jacobian with period x equations alongs the rows and
     % periods times variables (in declaration order) along the columns
     if options.debug && iter==1
-        row=find(all(A==0,2));
-        column=find(all(A==0,1));
+        [row,col]=find(A);
+        row=setdiff(1:periods*ny,row);
+        column=setdiff(1:periods*ny,col);
         if ~isempty(row) || ~isempty(column)
             fprintf('The stacked Jacobian is singular. The problem derives from:\n')
             if ~isempty(row)
-- 
GitLab