From fa6cb980ef1e4183246b7d9c2091d095c3cefd7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 7 Apr 2023 10:24:05 +0200
Subject: [PATCH] Octave compatibility: qz() will be MATLAB-compatible in
 version 9

[skip ci]
---
 matlab/missing/mex/mjdgges/mjdgges.m   | 2 +-
 matlab/partial_information/PI_gensys.m | 6 +++---
 matlab/sylvester3.m                    | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/matlab/missing/mex/mjdgges/mjdgges.m b/matlab/missing/mex/mjdgges/mjdgges.m
index 5695618069..b28214e923 100644
--- a/matlab/missing/mex/mjdgges/mjdgges.m
+++ b/matlab/missing/mex/mjdgges/mjdgges.m
@@ -56,7 +56,7 @@ end
 info = 0;
 
 try
-    if isoctave
+    if isoctave && octave_ver_less_than('9')
         [ss, tt, qq, zz] = qz(e, d);
     else
         [ss, tt, qq, zz] = qz(e, d, 'real');
diff --git a/matlab/partial_information/PI_gensys.m b/matlab/partial_information/PI_gensys.m
index 3fe2c16ba4..42ee00f8ab 100644
--- a/matlab/partial_information/PI_gensys.m
+++ b/matlab/partial_information/PI_gensys.m
@@ -16,7 +16,7 @@ function [G1pi,C,impact,nmat,TT1,TT2,gev,eu, DD, E2, E5, GAMMA, FL_RANK ]=PI_gen
 % Corrected 10/28/96 by CAS
 
 % Copyright © 1996-2009 Christopher Sims
-% Copyright © 2010-2017 Dynare Team
+% Copyright © 2010-2023 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -176,8 +176,8 @@ end
 
 G0pi=eye(n+FL_RANK+NX);
 try
-    if isoctave
-        % Need to force QZ complex on Octave (otherwise it returns the real one)
+    if isoctave && octave_ver_less_than('9')
+        % Need to force QZ complex on Octave ⩽ 8 (otherwise it returns the real one)
         [a b q z]=qz(complex(G0pi),complex(G1pi));
     else
         [a b q z]=qz(G0pi,G1pi);
diff --git a/matlab/sylvester3.m b/matlab/sylvester3.m
index b290b6220c..88e7af7326 100644
--- a/matlab/sylvester3.m
+++ b/matlab/sylvester3.m
@@ -1,7 +1,7 @@
 function x=sylvester3(a,b,c,d)
 % solves a*x+b*x*c=d where d is [n x m x p]
 
-% Copyright © 2005-2017 Dynare Team
+% Copyright © 2005-2023 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -35,13 +35,13 @@ if m == 1
     return
 end
 [u,t]=schur(c);
-if isoctave
+if isoctave && octave_ver_less_than('9')
     [aa,bb,qq,zz]=qz(full(a),full(b));
     for j=1:p
         d(:,:,j)=qq*d(:,:,j)*u;
     end
 else
-    [aa,bb,qq,zz]=qz(full(a),full(b),'real'); % available in Matlab version 6.0
+    [aa,bb,qq,zz]=qz(full(a),full(b),'real');
     for j=1:p
         d(:,:,j)=qq*d(:,:,j)*u;
     end
-- 
GitLab