Minor updates

git-svn-id: https://www.dynare.org/svn/dynare/trunk@3124 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
george 2009-11-04 17:20:35 +00:00
parent 30d2f00cc2
commit 91df747554
6 changed files with 36 additions and 32 deletions

View File

@ -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) ...

View File

@ -225,6 +225,9 @@ DsgeLikelihood::~DsgeLikelihood()
delete &deepParams;
delete &ghx;
delete &ghu;
delete &dynareParams;
delete &dr;
}
double

View File

@ -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 <int> parStructBase;
vector <const mxArray*> 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<string, int>::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<string, int>::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)
{

View File

@ -22,7 +22,7 @@
#include "SylvException.h"
#include <map>
#include <string>
using namespace std;
//using namespace std;
struct charArraySt
@ -36,9 +36,8 @@ class GeneralParams
// map <string, int> 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;

View File

@ -15,6 +15,7 @@
#include <cmath>
#include <limits>
//vector<int>nullVec(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<int>&vrows, const vector<int>&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<multv;++i)
for (int j=0;j<multh;++j)
repMat.place(*this, multv*i, multh*j);
return repMat;
(*repMat).place(*this, multv*i, multh*j);
return *repMat;
};
@ -471,9 +472,9 @@ void
GeneralMatrix::AssignByVectors(GeneralMatrix& a, const vector<int>& vToRows, const vector<int>& vToCols
, const GeneralMatrix& b, const vector<int>& vrows, const vector<int>& vcols)
{
int nrows, ncols, tonrows, toncols;
const vector<int> *vpToCols, *vpToRows, *vpRows, *vpCols;
vector<int> *tmpvpToCols, *tmpvpToRows, *tmpvpRows, *tmpvpCols;
int nrows=0, ncols=0, tonrows=0, toncols=0;
const vector<int> *vpToCols=0, *vpToRows=0, *vpRows=0, *vpCols=0;
vector<int> *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<int>& 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);
}
}

View File

@ -8,7 +8,8 @@
#include "Vector.h"
#include <vector>
using namespace std;
vector<int>nullVec(0);
//#define nullVec (const vector<int>(0))
const vector<int>nullVec(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) {}