From d97faab09c5386ece717922d26c7f9b9ab118a6b Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Thu, 21 Nov 2024 00:09:03 +0100
Subject: [PATCH] steady: allow for non_zero option

Closes #1945
---
 doc/manual/source/the-model-file.rst |  3 +++
 matlab/default_option_values.m       |  1 +
 matlab/display_static_residuals.m    | 11 ++++-------
 preprocessor                         |  2 +-
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst
index af3a37f45a..a1bb5afb57 100644
--- a/doc/manual/source/the-model-file.rst
+++ b/doc/manual/source/the-model-file.rst
@@ -2915,6 +2915,9 @@ Finding the steady state with Dynare nonlinear solver
        along. Iteration will cease when the attempted step size is smaller than
        ``tolx``. Default: ``eps^(2/3)``
 
+    .. option:: non_zero
+
+       See :opt:`non_zero`.
 
     .. _solvalg:
 
diff --git a/matlab/default_option_values.m b/matlab/default_option_values.m
index d3773fc937..7b0ef485c8 100644
--- a/matlab/default_option_values.m
+++ b/matlab/default_option_values.m
@@ -57,6 +57,7 @@ options_.trust_region_initial_step_bound_factor = 1;
 options_.dr_display_tol=1e-6;
 options_.dp.maxit = 3000;
 options_.steady.maxit = 50;
+options_.steady.non_zero = false;
 options_.simul.maxit = 50;
 options_.simul.robust_lin_solve = false;
 
diff --git a/matlab/display_static_residuals.m b/matlab/display_static_residuals.m
index 331d4a67a8..ed03f8b695 100644
--- a/matlab/display_static_residuals.m
+++ b/matlab/display_static_residuals.m
@@ -1,5 +1,5 @@
-function z = display_static_residuals(M_, options_, oo_,options_resid_)
-% function z = display_static_residuals(M_, options_, oo_,options_resid_)
+function z = display_static_residuals(M_, options_, oo_)
+% function z = display_static_residuals(M_, options_, oo_)
 %
 % Computes static residuals associated with the guess values.
 %
@@ -7,7 +7,6 @@ function z = display_static_residuals(M_, options_, oo_,options_resid_)
 %   M:              [structure] storing the model information
 %   options:        [structure] storing the options
 %   oo:             [structure] storing the results
-%   options_resid_:             options to resid
 %
 % OUTPUTS
 %    z:      residuals
@@ -32,8 +31,6 @@ function z = display_static_residuals(M_, options_, oo_,options_resid_)
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
 
-non_zero = (nargin > 3 && isfield(options_resid_, 'non_zero') && options_resid_.non_zero);
-
 tags  = M_.equations_tags;
 istag = 0;
 if ~isempty(tags)
@@ -104,7 +101,7 @@ if nargout == 0
             tg = tags(cell2mat(tags(:,1)) == i,2:3); % all tags for equation i
             ind = strmatch('name', cellstr( tg(:,1) ) );
         end
-        if ~(non_zero && tmp == 0)
+        if ~(options_.steady.non_zero && tmp == 0)
             if ~istag || length(ind) == 0
                 if ~isreal(z)
                     fprintf('Equation number %u: %g (imaginary part: %g)\n', i, real(tmp), imag(tmp));
@@ -120,7 +117,7 @@ if nargout == 0
             end
         end
     end
-    if non_zero && ~any_non_zero_residual
+    if options_.steady.non_zero && ~any_non_zero_residual
         disp('All residuals are zero')
     end
     skipline(2)
diff --git a/preprocessor b/preprocessor
index a091c26ced..2746a21702 160000
--- a/preprocessor
+++ b/preprocessor
@@ -1 +1 @@
-Subproject commit a091c26ced0fba215851485e824502230fccb73f
+Subproject commit 2746a21702a1bcc89a25083d3e7b3ab3c925edd5
-- 
GitLab