From 81b0ea39728e4e99850fd12db9f14e30a157d121 Mon Sep 17 00:00:00 2001
From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Tue, 31 Mar 2009 09:09:11 +0000
Subject: [PATCH] 4.0: merged r2539,2540,2541 changesets from trunk (fixes for
 mjdgges on Matlab 7.8/R2009a for 64 bits platforms)

git-svn-id: https://www.dynare.org/svn/dynare/branches/4.0@2542 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 mex/sources/build_matlab.m    |  2 +-
 mex/sources/mjdgges/mjdgges.c | 14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/mex/sources/build_matlab.m b/mex/sources/build_matlab.m
index 208167bbc8..1138f75515 100644
--- a/mex/sources/build_matlab.m
+++ b/mex/sources/build_matlab.m
@@ -49,7 +49,7 @@ else
     error('Unsupported platform')
 end
 
-% mwSize and mwIndex appeared in Matlab 7.3
+% mwSize, mwIndex and mwSignedIndex appeared in Matlab 7.3
 if matlab_ver_less_than('7.3')
     COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -DMWTYPES_NOT_DEFINED' ];
 end
diff --git a/mex/sources/mjdgges/mjdgges.c b/mex/sources/mjdgges/mjdgges.c
index a24995608f..77c4337cfe 100644
--- a/mex/sources/mjdgges/mjdgges.c
+++ b/mex/sources/mjdgges/mjdgges.c
@@ -20,6 +20,10 @@
 #include <string.h>
 #include "mex.h"
 
+#if defined(MWTYPES_NOT_DEFINED) || defined(OCTAVE)
+typedef int mwSignedIndex;
+#endif
+
 #ifdef NO_LAPACK_H
 # if defined(__linux__) || defined(OCTAVE)
 #  define dgges dgges_
@@ -32,26 +36,26 @@ void dgges(char *, char *, char *, int (*)(), int *, double *, int *, double *,
 
 double criterium;
 
-int my_criteria(double *alphar, double *alphai, double *beta)
+mwSignedIndex my_criteria(double *alphar, double *alphai, double *beta)
 {
   return( (*alphar * *alphar + *alphai * *alphai) < criterium * *beta * *beta);
 }
 
 void mjdgges(double *a, double *b, double *z, double *n, double *sdim, double *eval_r, double *eval_i, double *info)
 {
-  int i_n, i_info, i_sdim, one, lwork;
+  mwSignedIndex i_n, i_info, i_sdim, one, lwork;
   double *alphar, *alphai, *beta, *work, *par, *pai, *pb, *per, *pei;
   double *junk;
-  int *bwork;
+  mwSignedIndex *bwork;
 
   one = 1;
-  i_n = (int)*n;
+  i_n = (mwSignedIndex)*n;
   alphar = mxCalloc(i_n,sizeof(double));
   alphai = mxCalloc(i_n,sizeof(double));
   beta = mxCalloc(i_n,sizeof(double));
   lwork = 16*i_n+16;
   work = mxCalloc(lwork,sizeof(double));
-  bwork = mxCalloc(i_n,sizeof(int));
+  bwork = mxCalloc(i_n,sizeof(mwSignedIndex));
   /* made necessary by bug in Lapack */
   junk = mxCalloc(i_n*i_n,sizeof(double));
 
-- 
GitLab