From be0f6230ad7d89403c6e349fa1a90eb0840c7846 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Hermes=29?=
 <stephane.adjemian@univ-lemans.fr>
Date: Mon, 28 Dec 2015 17:40:58 +0100
Subject: [PATCH] Cosmetic changes.

 - Use a switch-case block.
 - Added a warning when the user tries to solve a linear(ized) model
with solve_algo different from 0 (for a linear model).
 - Added an error message if the user try to solve a linearized model
with stack_solve_algo=6 (not implemented).
---
 .../perfect_foresight_solver_core.m               | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/matlab/perfect-foresight-models/perfect_foresight_solver_core.m b/matlab/perfect-foresight-models/perfect_foresight_solver_core.m
index 774754bd26..5e0452892c 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_solver_core.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_solver_core.m
@@ -74,7 +74,8 @@ else
             [oo_.endo_simul, oo_.deterministic_simulation] = ...
                 sim1_purely_forward(oo_.endo_simul, oo_.exo_simul, oo_.steady_state, M_, options_);
         else % General case
-            if options_.stack_solve_algo == 0
+            switch options_.stack_solve_algo
+              case 0
                 if options_.linear_approximation
                     [oo_.endo_simul, oo_.deterministic_simulation] = ...
                         sim1_linear(oo_.endo_simul, oo_.exo_simul, oo_.steady_state, oo_.exo_steady_state, M_, options_);
@@ -82,17 +83,25 @@ else
                     [oo_.endo_simul, oo_.deterministic_simulation] = ...
                         sim1(oo_.endo_simul, oo_.exo_simul, oo_.steady_state, M_, options_);
                 end
-            elseif options_.stack_solve_algo == 6
+              case 6
+                if option_.linear_approximation
+                    error('Invalid value of stack_solve_algo option!')
+                end
                 [oo_.endo_simul, oo_.deterministic_simulation] = ...
                     sim1_lbj(oo_.endo_simul, oo_.exo_simul, oo_.steady_state, M_, options_);
-            elseif options_.stack_solve_algo == 7
+              case 7
                 if options_.linear_approximation
+                    if isequal(options_.solve_algo, 10)
+                        warning('It would be more efficient to set option solve_algo equal to 0!')
+                    end
                     [oo_.endo_simul, oo_.deterministic_simulation] = ...
                         solve_stacked_linear_problem(oo_.endo_simul, oo_.exo_simul, oo_.steady_state, oo_.exo_steady_state, M_, options_);
                 else
                     [oo_.endo_simul, oo_.deterministic_simulation] = ...
                         solve_stacked_problem(oo_.endo_simul, oo_.exo_simul, oo_.steady_state, M_, options_);
                 end
+              otherwise
+                error('Invalid value of stack_solve_algo option!')
             end
         end
     end
-- 
GitLab