From b36507d005d93c76473eaf2dfdc4a7a5dbfac9ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Wed, 8 Nov 2023 12:18:31 +0100
Subject: [PATCH] solve_two_boundaries.m: do not modify lambda when
 stack_solve_algo=4

That algorithm (optimal path length) does not use it.
---
 matlab/solve_two_boundaries.m | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/matlab/solve_two_boundaries.m b/matlab/solve_two_boundaries.m
index bc166e5910..393c11690e 100644
--- a/matlab/solve_two_boundaries.m
+++ b/matlab/solve_two_boundaries.m
@@ -70,7 +70,7 @@ ilu_setup.milu = 'off';
 ilu_setup.thresh = 1;
 ilu_setup.udiag = 0;
 max_resa=1e100;
-lambda = 1; % Length of Newton step
+lambda = 1; % Length of Newton step (unused for stack_solve_algo=4)
 reduced = 0;
 while ~(cvg || iter>maxit_)
     r = NaN(Blck_size, periods);
@@ -136,7 +136,7 @@ while ~(cvg || iter>maxit_)
                             return
                         end
                     end
-                elseif lambda>1e-8
+                elseif lambda>1e-8 && stack_solve_algo ~= 4
                     lambda=lambda/2;
                     reduced = 1;
                     if verbose
@@ -156,7 +156,7 @@ while ~(cvg || iter>maxit_)
                     return
                 end
             else
-                if lambda<1
+                if lambda<1 && stack_solve_algo ~= 4
                     lambda=max(lambda*2, 1);
                 end
             end
-- 
GitLab