diff --git a/mex/sources/build_matlab.m b/mex/sources/build_matlab.m index 1138f75515f7f4bb16e7aef078d64fa56fbfce58..cb76da9ad96d2d12d7f17ab5a18b1e10f25b9e45 100644 --- a/mex/sources/build_matlab.m +++ b/mex/sources/build_matlab.m @@ -54,6 +54,11 @@ if matlab_ver_less_than('7.3') COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -DMWTYPES_NOT_DEFINED' ]; end +% Matlab Lapack expects mwSignedIndex arguments only starting with Matlab 7.8 +if ~matlab_ver_less_than('7.8') + COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -DLAPACK_USE_MWSIGNEDINDEX' ]; +end + % Large array dims for 64 bits platforms appeared in Matlab 7.3 if (strcmpi('GLNXA64', computer) || strcmpi('PCWIN64', computer)) ... && ~matlab_ver_less_than('7.3') diff --git a/mex/sources/mjdgges/mjdgges.c b/mex/sources/mjdgges/mjdgges.c index 77c4337cfe76a063630f88c939bb002b8122fec9..3686386a3d637f5650bbd5db403a17694e5025d3 100644 --- a/mex/sources/mjdgges/mjdgges.c +++ b/mex/sources/mjdgges/mjdgges.c @@ -20,8 +20,10 @@ #include <string.h> #include "mex.h" -#if defined(MWTYPES_NOT_DEFINED) || defined(OCTAVE) -typedef int mwSignedIndex; +#if !defined(LAPACK_USE_MWSIGNEDINDEX) || defined(OCTAVE) +typedef int lapack_int; +#else +typedef mwSignedIndex lapack_int; #endif #ifdef NO_LAPACK_H @@ -36,26 +38,26 @@ void dgges(char *, char *, char *, int (*)(), int *, double *, int *, double *, double criterium; -mwSignedIndex my_criteria(double *alphar, double *alphai, double *beta) +lapack_int 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) { - mwSignedIndex i_n, i_info, i_sdim, one, lwork; + lapack_int i_n, i_info, i_sdim, one, lwork; double *alphar, *alphai, *beta, *work, *par, *pai, *pb, *per, *pei; double *junk; - mwSignedIndex *bwork; + lapack_int *bwork; one = 1; - i_n = (mwSignedIndex)*n; + i_n = (lapack_int)*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(mwSignedIndex)); + bwork = mxCalloc(i_n,sizeof(lapack_int)); /* made necessary by bug in Lapack */ junk = mxCalloc(i_n*i_n,sizeof(double));