parent
4a4c88de20
commit
a66594caed
|
@ -111,8 +111,13 @@ if exist('OCTAVE_VERSION')
|
||||||
else
|
else
|
||||||
% Add win32 specific paths for Dynare Windows package
|
% Add win32 specific paths for Dynare Windows package
|
||||||
if strcmp(computer, 'PCWIN')
|
if strcmp(computer, 'PCWIN')
|
||||||
if matlab_ver_less_than('7.5')
|
if matlab_ver_less_than('7.1')
|
||||||
mexpath = [dynareroot '../mex/matlab/win32-7.0-7.4'];
|
mexpath = [dynareroot '../mex/matlab/win32-7.0-7.0.4'];
|
||||||
|
if exist(mexpath, 'dir')
|
||||||
|
addpath(mexpath)
|
||||||
|
end
|
||||||
|
elseif matlab_ver_less_than('7.5')
|
||||||
|
mexpath = [dynareroot '../mex/matlab/win32-7.1-7.4'];
|
||||||
if exist(mexpath, 'dir')
|
if exist(mexpath, 'dir')
|
||||||
addpath(mexpath)
|
addpath(mexpath)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
function [dr,info] = k_order_pert(dr,M,options,oo)
|
function [dr,info] = k_order_pert(dr,M,options,oo)
|
||||||
% Compute decision rules using the k-order DLL from Dynare++
|
% Compute decision rules using the k-order DLL from Dynare++
|
||||||
|
|
||||||
% Copyright (C) 2009-2010 Dynare Team
|
% Copyright (C) 2009-2012 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -26,20 +26,17 @@ order = options.order;
|
||||||
|
|
||||||
switch(order)
|
switch(order)
|
||||||
case 1
|
case 1
|
||||||
[err, g_1] = k_order_perturbation(dr,M,options, ['.' ...
|
[err, g_1] = k_order_perturbation(dr,M,options);
|
||||||
mexext]);
|
|
||||||
mexErrCheck('k_order_perturbation', err);
|
mexErrCheck('k_order_perturbation', err);
|
||||||
dr.g_1 = g_1;
|
dr.g_1 = g_1;
|
||||||
case 2
|
case 2
|
||||||
[err, g_0, g_1, g_2] = k_order_perturbation(dr,M,options, ['.' ...
|
[err, g_0, g_1, g_2] = k_order_perturbation(dr,M,options);
|
||||||
mexext]);
|
|
||||||
mexErrCheck('k_order_perturbation', err);
|
mexErrCheck('k_order_perturbation', err);
|
||||||
dr.g_0 = g_0;
|
dr.g_0 = g_0;
|
||||||
dr.g_1 = g_1;
|
dr.g_1 = g_1;
|
||||||
dr.g_2 = g_2;
|
dr.g_2 = g_2;
|
||||||
case 3
|
case 3
|
||||||
[err, g_0, g_1, g_2, g_3] = k_order_perturbation(dr,M,options, ['.' ...
|
[err, g_0, g_1, g_2, g_3] = k_order_perturbation(dr,M,options);
|
||||||
mexext]);
|
|
||||||
mexErrCheck('k_order_perturbation', err);
|
mexErrCheck('k_order_perturbation', err);
|
||||||
dr.g_0 = g_0;
|
dr.g_0 = g_0;
|
||||||
dr.g_1 = g_1;
|
dr.g_1 = g_1;
|
||||||
|
|
|
@ -5,6 +5,7 @@ CPPFLAGS += -I$(top_srcdir)/../../sources
|
||||||
|
|
||||||
DEFS += $(MATLAB_DEFS)
|
DEFS += $(MATLAB_DEFS)
|
||||||
DEFS += -DMATLAB_MEX_FILE
|
DEFS += -DMATLAB_MEX_FILE
|
||||||
|
DEFS += -DMEXEXT=\"$(MEXEXT)\"
|
||||||
|
|
||||||
LDFLAGS += $(MATLAB_LDFLAGS)
|
LDFLAGS += $(MATLAB_LDFLAGS)
|
||||||
LIBS += $(MATLAB_LIBS)
|
LIBS += $(MATLAB_LIBS)
|
||||||
|
|
|
@ -3,6 +3,7 @@ CPPFLAGS += $(shell $(MKOCTFILE) -p INCFLAGS)
|
||||||
CPPFLAGS += -I$(top_srcdir)/../../sources
|
CPPFLAGS += -I$(top_srcdir)/../../sources
|
||||||
|
|
||||||
DEFS += -DOCTAVE_MEX_FILE
|
DEFS += -DOCTAVE_MEX_FILE
|
||||||
|
DEFS += -DMEXEXT=\".mex\"
|
||||||
|
|
||||||
CFLAGS += $(shell $(MKOCTFILE) -p CPICFLAG)
|
CFLAGS += $(shell $(MKOCTFILE) -p CPICFLAG)
|
||||||
FFLAGS += $(shell $(MKOCTFILE) -p FPICFLAG)
|
FFLAGS += $(shell $(MKOCTFILE) -p FPICFLAG)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2010-2011 Dynare Team
|
* Copyright (C) 2010-2012 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -624,7 +624,7 @@ sampleMHMC(LogPosteriorDensity &lpd, RandomWalkMetropolisHastings &rwmh,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
logMCMCposterior(const VectorConstView &estParams, const MatrixConstView &data, const std::string &mexext,
|
logMCMCposterior(const VectorConstView &estParams, const MatrixConstView &data,
|
||||||
const size_t fblock, const size_t nBlocks, const VectorConstView &nMHruns, const MatrixConstView &D)
|
const size_t fblock, const size_t nBlocks, const VectorConstView &nMHruns, const MatrixConstView &D)
|
||||||
{
|
{
|
||||||
// Retrieve pointers to global variables
|
// Retrieve pointers to global variables
|
||||||
|
@ -638,7 +638,8 @@ logMCMCposterior(const VectorConstView &estParams, const MatrixConstView &data,
|
||||||
std::string resultsFileStem(fName);
|
std::string resultsFileStem(fName);
|
||||||
std::string dynamicDllFile(fName);
|
std::string dynamicDllFile(fName);
|
||||||
mxFree(fName);
|
mxFree(fName);
|
||||||
dynamicDllFile += "_dynamic." + mexext;
|
dynamicDllFile += "_dynamic";
|
||||||
|
dynamicDllFile += MEXEXT;
|
||||||
|
|
||||||
size_t n_endo = (size_t) *mxGetPr(mxGetField(M_, 0, "endo_nbr"));
|
size_t n_endo = (size_t) *mxGetPr(mxGetField(M_, 0, "endo_nbr"));
|
||||||
size_t n_exo = (size_t) *mxGetPr(mxGetField(M_, 0, "exo_nbr"));
|
size_t n_exo = (size_t) *mxGetPr(mxGetField(M_, 0, "exo_nbr"));
|
||||||
|
@ -745,8 +746,8 @@ void
|
||||||
mexFunction(int nlhs, mxArray *plhs[],
|
mexFunction(int nlhs, mxArray *plhs[],
|
||||||
int nrhs, const mxArray *prhs[])
|
int nrhs, const mxArray *prhs[])
|
||||||
{
|
{
|
||||||
if (nrhs != 7)
|
if (nrhs != 6)
|
||||||
DYN_MEX_FUNC_ERR_MSG_TXT("logposterior: exactly seven arguments are required.");
|
DYN_MEX_FUNC_ERR_MSG_TXT("logposterior: exactly six arguments are required.");
|
||||||
if (nlhs != 2)
|
if (nlhs != 2)
|
||||||
DYN_MEX_FUNC_ERR_MSG_TXT("logposterior: exactly two return arguments are required.");
|
DYN_MEX_FUNC_ERR_MSG_TXT("logposterior: exactly two return arguments are required.");
|
||||||
|
|
||||||
|
@ -762,23 +763,16 @@ mexFunction(int nlhs, mxArray *plhs[],
|
||||||
|
|
||||||
MatrixConstView data(mxGetPr(prhs[1]), mxGetM(prhs[1]), mxGetN(prhs[1]), mxGetM(prhs[1]));
|
MatrixConstView data(mxGetPr(prhs[1]), mxGetM(prhs[1]), mxGetN(prhs[1]), mxGetM(prhs[1]));
|
||||||
|
|
||||||
if (!mxIsChar(prhs[2]))
|
size_t fblock = (size_t) mxGetScalar(prhs[2]);
|
||||||
DYN_MEX_FUNC_ERR_MSG_TXT("logposterior: Third argument must be a character string");
|
size_t nBlocks = (size_t) mxGetScalar(prhs[3]);
|
||||||
|
VectorConstView nMHruns(mxGetPr(prhs[4]), mxGetM(prhs[4]), 1);
|
||||||
char *mexext_mx = mxArrayToString(prhs[2]);
|
|
||||||
std::string mexext(mexext_mx);
|
|
||||||
mxFree(mexext_mx);
|
|
||||||
|
|
||||||
size_t fblock = (size_t) mxGetScalar(prhs[3]);
|
|
||||||
size_t nBlocks = (size_t) mxGetScalar(prhs[4]);
|
|
||||||
VectorConstView nMHruns(mxGetPr(prhs[5]), mxGetM(prhs[5]), 1);
|
|
||||||
assert(nMHruns.getSize() == nBlocks);
|
assert(nMHruns.getSize() == nBlocks);
|
||||||
|
|
||||||
MatrixConstView D(mxGetPr(prhs[6]), mxGetM(prhs[6]), mxGetN(prhs[6]), mxGetM(prhs[6]));
|
MatrixConstView D(mxGetPr(prhs[5]), mxGetM(prhs[5]), mxGetN(prhs[5]), mxGetM(prhs[5]));
|
||||||
//calculate MHMCMC draws and get get last line run in the last MH block sub-array
|
//calculate MHMCMC draws and get get last line run in the last MH block sub-array
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int lastMHblockArrayLine = logMCMCposterior(estParams, data, mexext, fblock, nBlocks, nMHruns, D);
|
int lastMHblockArrayLine = logMCMCposterior(estParams, data, fblock, nBlocks, nMHruns, D);
|
||||||
plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL);
|
plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL);
|
||||||
*mxGetPr(plhs[1]) = (double) lastMHblockArrayLine;
|
*mxGetPr(plhs[1]) = (double) lastMHblockArrayLine;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2010-2011 Dynare Team
|
* Copyright (C) 2010-2012 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -101,8 +101,7 @@ fillEstParamsInfo(const mxArray *estim_params_info, EstimatedParameter::pType ty
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
logposterior(const VectorConstView &estParams, const MatrixConstView &data,
|
logposterior(const VectorConstView &estParams, const MatrixConstView &data)
|
||||||
const std::string &mexext)
|
|
||||||
{
|
{
|
||||||
// Retrieve pointers to global variables
|
// Retrieve pointers to global variables
|
||||||
const mxArray *M_ = mexGetVariablePtr("global", "M_");
|
const mxArray *M_ = mexGetVariablePtr("global", "M_");
|
||||||
|
@ -114,7 +113,8 @@ logposterior(const VectorConstView &estParams, const MatrixConstView &data,
|
||||||
char *fName = mxArrayToString(mxGetField(M_, 0, "fname"));
|
char *fName = mxArrayToString(mxGetField(M_, 0, "fname"));
|
||||||
std::string dynamicDllFile(fName);
|
std::string dynamicDllFile(fName);
|
||||||
mxFree(fName);
|
mxFree(fName);
|
||||||
dynamicDllFile += "_dynamic." + mexext;
|
dynamicDllFile += "_dynamic";
|
||||||
|
dynamicDllFile += MEXEXT;
|
||||||
|
|
||||||
size_t n_endo = (size_t) *mxGetPr(mxGetField(M_, 0, "endo_nbr"));
|
size_t n_endo = (size_t) *mxGetPr(mxGetField(M_, 0, "endo_nbr"));
|
||||||
size_t n_exo = (size_t) *mxGetPr(mxGetField(M_, 0, "exo_nbr"));
|
size_t n_exo = (size_t) *mxGetPr(mxGetField(M_, 0, "exo_nbr"));
|
||||||
|
@ -211,8 +211,8 @@ void
|
||||||
mexFunction(int nlhs, mxArray *plhs[],
|
mexFunction(int nlhs, mxArray *plhs[],
|
||||||
int nrhs, const mxArray *prhs[])
|
int nrhs, const mxArray *prhs[])
|
||||||
{
|
{
|
||||||
if (nrhs != 3 || nlhs != 2)
|
if (nrhs != 2 || nlhs != 2)
|
||||||
DYN_MEX_FUNC_ERR_MSG_TXT("logposterior: exactly three input arguments and two output arguments are required.");
|
DYN_MEX_FUNC_ERR_MSG_TXT("logposterior: exactly two input arguments and two output arguments are required.");
|
||||||
|
|
||||||
// Check and retrieve the arguments
|
// Check and retrieve the arguments
|
||||||
|
|
||||||
|
@ -225,19 +225,11 @@ mexFunction(int nlhs, mxArray *plhs[],
|
||||||
DYN_MEX_FUNC_ERR_MSG_TXT("logposterior: Second argument must be a matrix of double-precision numbers");
|
DYN_MEX_FUNC_ERR_MSG_TXT("logposterior: Second argument must be a matrix of double-precision numbers");
|
||||||
|
|
||||||
MatrixConstView data(mxGetPr(prhs[1]), mxGetM(prhs[1]), mxGetN(prhs[1]), mxGetM(prhs[1]));
|
MatrixConstView data(mxGetPr(prhs[1]), mxGetM(prhs[1]), mxGetN(prhs[1]), mxGetM(prhs[1]));
|
||||||
|
|
||||||
if (!mxIsChar(prhs[2]))
|
|
||||||
DYN_MEX_FUNC_ERR_MSG_TXT("logposterior: Third argument must be a character string");
|
|
||||||
|
|
||||||
char *mexext_mx = mxArrayToString(prhs[2]);
|
|
||||||
std::string
|
|
||||||
mexext(mexext_mx);
|
|
||||||
mxFree(mexext_mx);
|
|
||||||
|
|
||||||
// Compute and return the value
|
// Compute and return the value
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
double lik = logposterior(estParams, data, mexext);
|
double lik = logposterior(estParams, data);
|
||||||
plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL);
|
plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL);
|
||||||
*mxGetPr(plhs[1]) = lik;
|
*mxGetPr(plhs[1]) = lik;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2008-2010 Dynare Team
|
* Copyright (C) 2008-2012 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -21,13 +21,13 @@
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
DynamicModelDLL::DynamicModelDLL(const string &modName, const string &sExt) throw (DynareException)
|
DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException)
|
||||||
{
|
{
|
||||||
string fName;
|
string fName;
|
||||||
#if !defined(__CYGWIN32__) && !defined(_WIN32)
|
#if !defined(__CYGWIN32__) && !defined(_WIN32)
|
||||||
fName = "./";
|
fName = "./";
|
||||||
#endif
|
#endif
|
||||||
fName += modName + "_dynamic" + sExt;
|
fName += modName + "_dynamic" + MEXEXT;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2008-2011 Dynare Team
|
* Copyright (C) 2008-2012 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -55,7 +55,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// construct and load Dynamic model DLL
|
// construct and load Dynamic model DLL
|
||||||
DynamicModelDLL(const string &fname, const string &sExt) throw (DynareException);
|
DynamicModelDLL(const string &fname) throw (DynareException);
|
||||||
virtual ~DynamicModelDLL();
|
virtual ~DynamicModelDLL();
|
||||||
|
|
||||||
void eval(const Vector &y, const Vector &x, const Vector ¶ms, const Vector &ySteady,
|
void eval(const Vector &y, const Vector &x, const Vector ¶ms, const Vector &ySteady,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2008-2011 Dynare Team
|
* Copyright (C) 2008-2012 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -24,7 +24,6 @@
|
||||||
1) dr
|
1) dr
|
||||||
2) M_
|
2) M_
|
||||||
3) options
|
3) options
|
||||||
4) string containing the MEX extension (with a dot at the beginning)
|
|
||||||
|
|
||||||
Outputs:
|
Outputs:
|
||||||
- if order == 1: only g_1
|
- if order == 1: only g_1
|
||||||
|
@ -69,8 +68,8 @@ extern "C" {
|
||||||
mexFunction(int nlhs, mxArray *plhs[],
|
mexFunction(int nlhs, mxArray *plhs[],
|
||||||
int nrhs, const mxArray *prhs[])
|
int nrhs, const mxArray *prhs[])
|
||||||
{
|
{
|
||||||
if (nrhs != 4 || nlhs < 2)
|
if (nrhs != 3 || nlhs < 2)
|
||||||
DYN_MEX_FUNC_ERR_MSG_TXT("Must have exactly 4 input parameters and take at least 2 output parameters.");
|
DYN_MEX_FUNC_ERR_MSG_TXT("Must have exactly 3 input parameters and take at least 2 output parameters.");
|
||||||
|
|
||||||
const mxArray *dr = prhs[0];
|
const mxArray *dr = prhs[0];
|
||||||
const mxArray *M_ = prhs[1];
|
const mxArray *M_ = prhs[1];
|
||||||
|
@ -82,8 +81,6 @@ extern "C" {
|
||||||
DYN_MEX_FUNC_ERR_MSG_TXT("Input must be of type char.");
|
DYN_MEX_FUNC_ERR_MSG_TXT("Input must be of type char.");
|
||||||
|
|
||||||
string fName = mxArrayToString(mFname);
|
string fName = mxArrayToString(mFname);
|
||||||
const mxArray *mexExt = prhs[3];
|
|
||||||
string dfExt = mxArrayToString(mexExt); // Dynamic file extension, e.g. ".dll" or ".mexw32"
|
|
||||||
|
|
||||||
int kOrder;
|
int kOrder;
|
||||||
mxArray *mxFldp = mxGetField(options_, 0, "order");
|
mxArray *mxFldp = mxGetField(options_, 0, "order");
|
||||||
|
@ -208,7 +205,7 @@ extern "C" {
|
||||||
|
|
||||||
DynamicModelAC *dynamicModelFile;
|
DynamicModelAC *dynamicModelFile;
|
||||||
if (use_dll == 1)
|
if (use_dll == 1)
|
||||||
dynamicModelFile = new DynamicModelDLL(fName, dfExt);
|
dynamicModelFile = new DynamicModelDLL(fName);
|
||||||
else
|
else
|
||||||
dynamicModelFile = new DynamicModelMFile(fName);
|
dynamicModelFile = new DynamicModelMFile(fName);
|
||||||
|
|
||||||
|
|
|
@ -75,9 +75,14 @@ SectionEnd
|
||||||
|
|
||||||
SectionGroup "MEX files for MATLAB"
|
SectionGroup "MEX files for MATLAB"
|
||||||
|
|
||||||
Section "MEX files for MATLAB 32-bit, version 7.0 to 7.4 (R14 to R2007a)"
|
Section "MEX files for MATLAB 32-bit, version 7.0 to 7.0.4 (R14 to R14SP2)"
|
||||||
SetOutPath $INSTDIR\mex\matlab\win32-7.0-7.4
|
SetOutPath $INSTDIR\mex\matlab\win32-7.0-7.0.4
|
||||||
File ..\mex\matlab\win32-7.0-7.4\*.dll
|
File ..\mex\matlab\win32-7.0-7.0.4\*.dll
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section "MEX files for MATLAB 32-bit, version 7.1 to 7.4 (R14SP3 to R2007a)"
|
||||||
|
SetOutPath $INSTDIR\mex\matlab\win32-7.1-7.4
|
||||||
|
File ..\mex\matlab\win32-7.1-7.4\*.mexw32
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
Section "MEX files for MATLAB 32-bit, version 7.5 to 7.13 (R2007b to R2011b)"
|
Section "MEX files for MATLAB 32-bit, version 7.5 to 7.13 (R2007b to R2011b)"
|
||||||
|
|
Loading…
Reference in New Issue