diff --git a/mex/sources/build_matlab.m b/mex/sources/build_matlab.m index 904f7a1da..5c57970ec 100644 --- a/mex/sources/build_matlab.m +++ b/mex/sources/build_matlab.m @@ -19,8 +19,8 @@ addpath '../../matlab'; % For matlab_ver_less_than -MATLAB_PATH = matlabroot; - +%MATLAB_PATH = matlabroot; +MATLAB_PATH = regexprep(matlabroot,'\\','/'); COMPILE_OPTIONS = ''; if strcmpi('GLNX86', computer) || strcmpi('GLNXA64', computer) ... diff --git a/mex/sources/estimation/DsgeLikelihood.cpp b/mex/sources/estimation/DsgeLikelihood.cpp index b1505a462..a5ab94a4e 100644 --- a/mex/sources/estimation/DsgeLikelihood.cpp +++ b/mex/sources/estimation/DsgeLikelihood.cpp @@ -225,6 +225,9 @@ DsgeLikelihood::~DsgeLikelihood() delete &deepParams; delete &ghx; delete &ghu; + delete &dynareParams; + delete &dr; + } double diff --git a/mex/sources/estimation/MexUtils.h b/mex/sources/estimation/MexUtils.h index 51c3332de..51de463d9 100644 --- a/mex/sources/estimation/MexUtils.h +++ b/mex/sources/estimation/MexUtils.h @@ -23,7 +23,7 @@ #include "ioutils.h" #include "mex.h" #include "matrix.h" -#include "SylvException.h" +//#include "SylvException.h" #define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) #define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) @@ -31,13 +31,13 @@ //#include "k_ord_dynare.h" //using namespace std; enum {base, caller, global}; -char* mexBase[]={"base", "caller", "global"}; +enum {M_, oo_, options_,bayestopt_, estim_params_, dr}; +extern const char *DynareParamStructsNm []; +extern const char* mexBase[]; const int numParStructs=5; -#define numParStructsM 7 +//#define numParStructsM 6 -enum {M_, dr_, oo_, options_,bayestopt_, estim_params_, trend_coeff_}; -char *DynareParamStructsNm [numParStructsM]={"M_", "dr_", "oo_", "options_", "bayestopt_", "estim_params_", "trend_coeff_"}; /** struct DynareParamsStructMap @@ -61,7 +61,7 @@ char* structName; class MexStructParam; -class MexStruct :public GeneralParams +class MexStruct :public virtual GeneralParams { vector parStructBase; vector parStruct; // array of struct pointers @@ -69,7 +69,7 @@ class MexStruct :public GeneralParams const int numParStruct; const string structName; - mxArray* getMxField( const string& field) //throw (SYLV_MES_EXCEPTION) + mxArray* getMxField( const string& field) { map::iterator it=parNamStructMap.find(field); if (it==parNamStructMap.end()) @@ -77,14 +77,14 @@ class MexStruct :public GeneralParams return mxGetField(parStruct[it->second], 0, field.c_str() ); } - StructBaseNameMap* getMxFieldStruct( const string& field) //throw (SYLV_MES_EXCEPTION) + StructBaseNameMap* getMxFieldStruct( const string& field) { map::iterator it=parNamStructMap.find(field); if (it==parNamStructMap.end()) throw(SYLV_MES_EXCEPTION("no parameter with such name")); StructBaseNameMap* dpsm=new StructBaseNameMap; - dpsm->baseName=mexBase[parStructBase[it->second]]; - dpsm->structName=DynareParamStructsNm[it->second]; + dpsm->baseName=(char*)mexBase[parStructBase[it->second]]; + dpsm->structName=(char*)DynareParamStructsNm[it->second]; return dpsm; } @@ -103,7 +103,7 @@ class MexStruct :public GeneralParams mexStruct=mexGetVariable(base, structName); } **/ - ~MexStruct(); + ~MexStruct(){}; void * getMxArrayField(const string& field) { @@ -138,7 +138,7 @@ class MexStruct :public GeneralParams * holds single Matlab structure passed as parameter ***********************************************/ -class MexStructParam :public GeneralParams +class MexStructParam :public virtual GeneralParams { const mxArray* parStruct; // struct pointer const GeneralParams* parStructParent; // if any @@ -159,7 +159,7 @@ class MexStructParam :public GeneralParams parStruct(paramStruct), parStructParent(parent), structName(string("")){}; MexStructParam(const mxArray* paramStruct, const string& name): parStruct(paramStruct), parStructParent(NULL), structName(name){}; - ~MexStructParam(); + ~MexStructParam(){}; void * getMxArrayField(const string& field) { diff --git a/mex/sources/estimation/ioutils.h b/mex/sources/estimation/ioutils.h index bd1d72fe4..b7be90f17 100644 --- a/mex/sources/estimation/ioutils.h +++ b/mex/sources/estimation/ioutils.h @@ -22,7 +22,7 @@ #include "SylvException.h" #include #include -using namespace std; +//using namespace std; struct charArraySt @@ -36,9 +36,8 @@ class GeneralParams // map params; // const char *structName; public: - GeneralParams(); - GeneralParams( const string& parStructName, const string& base); - virtual ~GeneralParams(); + GeneralParams(){}; + virtual ~GeneralParams(){}; virtual string& name()=0; virtual void * getField(const string& field)=0; diff --git a/mex/sources/kalman/sylv/cc/GeneralMatrix.cpp b/mex/sources/kalman/sylv/cc/GeneralMatrix.cpp index f02f05cd0..a0ba0ccb2 100644 --- a/mex/sources/kalman/sylv/cc/GeneralMatrix.cpp +++ b/mex/sources/kalman/sylv/cc/GeneralMatrix.cpp @@ -15,6 +15,7 @@ #include #include +//vectornullVec(0); int GeneralMatrix::md_length = 32; GeneralMatrix::GeneralMatrix(const GeneralMatrix& m) @@ -87,7 +88,7 @@ It ignores non-positive elements passing zero length vector is equivalent to Matlab operator ":" = all elements of that dimension in its order */ GeneralMatrix::GeneralMatrix(const GeneralMatrix& a, const vector&vrows, const vector&vcols) { - int nrows, ncols; + int nrows=0, ncols=0; if (vrows.size()==0 && vcols.size()==0) { *this=a; @@ -175,11 +176,11 @@ GeneralMatrix::multElements(const GeneralMatrix& m) GeneralMatrix& GeneralMatrix::repmat(int multv, int multh) { - GeneralMatrix repMat=*(new GeneralMatrix ( multv*rows, multh*cols)); + GeneralMatrix* repMat=(new GeneralMatrix ( multv*rows, multh*cols)); for (int i=0;i& vToRows, const vector& vToCols , const GeneralMatrix& b, const vector& vrows, const vector& vcols) { - int nrows, ncols, tonrows, toncols; - const vector *vpToCols, *vpToRows, *vpRows, *vpCols; - vector *tmpvpToCols, *tmpvpToRows, *tmpvpRows, *tmpvpCols; + int nrows=0, ncols=0, tonrows=0, toncols=0; + const vector *vpToCols=0, *vpToRows=0, *vpRows=0, *vpCols=0; + vector *tmpvpToCols=0, *tmpvpToRows=0, *tmpvpRows=0, *tmpvpCols=0; if (vToRows.size()==0 && vToCols.size()==0 &&vrows.size()==0 && vcols.size()==0) a=b; @@ -579,10 +580,10 @@ GeneralMatrix::AssignByVectors(GeneralMatrix& a, const vector& vToRows, con a.get((*vpToRows)[i]-1,(*vpToCols)[j]-1)=b.get((*vpRows)[i]-1, (*vpCols)[j]-1); } } - delete(tmpvpToCols); - delete(tmpvpToRows); - delete(tmpvpRows); - delete(tmpvpCols); + if (tmpvpToCols) delete(tmpvpToCols); + if (tmpvpToRows) delete(tmpvpToRows); + if (tmpvpRows) delete(tmpvpRows); + if (tmpvpCols) delete(tmpvpCols); } } diff --git a/mex/sources/kalman/sylv/cc/GeneralMatrix.h b/mex/sources/kalman/sylv/cc/GeneralMatrix.h index f1f8de98b..4afd0723d 100644 --- a/mex/sources/kalman/sylv/cc/GeneralMatrix.h +++ b/mex/sources/kalman/sylv/cc/GeneralMatrix.h @@ -8,7 +8,8 @@ #include "Vector.h" #include using namespace std; -vectornullVec(0); +//#define nullVec (const vector(0)) +const vectornullVec(0); class GeneralMatrix; @@ -78,7 +79,7 @@ class GeneralMatrix { int rows; int cols; int ld; - GeneralMatrix * tmpGMp; + GeneralMatrix * tmpGMp; public: GeneralMatrix(int m, int n) : data(m*n), rows(m), cols(n), ld(m) {}