From bfde0280c7a8658639797c89dde2394d6a9044ac Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Tue, 29 Aug 2017 10:54:53 +0200
Subject: [PATCH] Reset order=1 for all of stoch_simul.m if the Hessian is 0

Prevents various crashes where functions called rely on fields existing at order>1

(cherry picked from commit 0f84dadb9afd6d19aaaa469812ad110910d9a879)
---
 matlab/stoch_simul.m | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/matlab/stoch_simul.m b/matlab/stoch_simul.m
index 81f8b886a..ddcdc54ca 100644
--- a/matlab/stoch_simul.m
+++ b/matlab/stoch_simul.m
@@ -36,6 +36,11 @@ if options_.order == 1
     options_.replic = 1;
 end
 
+if M_.hessian_eq_zero && options_.order~=1
+    options_.order = 1;
+    warning('stoch_simul: using order = 1 because Hessian is equal to zero');
+end
+
 if isempty(options_.qz_criterium)
     options_.qz_criterium = 1+1e-6;
 end
-- 
GitLab