Commit 1b3bc4a8 authored by Sébastien Villemot's avatar Sébastien Villemot

K-order DLL: removed useless stuff

parent 3b1debf9
/*
* Copyright (C) 2008-2009 Dynare Team
* Copyright (C) 2008-2010 Dynare Team
*
* This file is part of Dynare.
*
......@@ -17,18 +17,8 @@
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the K_ORDER_PERTURBATION_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// K_ORDER_PERTURBATION_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#if defined(_WIN32) || defined(__CYGWIN32__)
# include <windows.h>
# ifdef _MSC_VER
# define K_ORDER_PERTURBATION_API __declspec(dllexport)
# endif
#else
# include <dlfcn.h> // unix/linux DLL (.so) handling routines
#endif
......
......@@ -34,10 +34,10 @@
/**************************************************************************************/
KordpDynare::KordpDynare(const char **endo, int num_endo,
const char **exo, int nexog, int npar, //const char** par,
const char **exo, int nexog, int npar,
Vector *ysteady, TwoDMatrix *vcov, Vector *inParams, int nstat,
int npred, int nforw, int nboth, const int jcols, const Vector *nnzd,
const int nsteps, int norder, //const char* modName,
const int nsteps, int norder,
Journal &jr, DynamicModelDLL &dynamicDLL, double sstol,
const vector<int> *var_order, const TwoDMatrix *llincidence, double criterium) throw (TLException) :
nStat(nstat), nBoth(nboth), nPred(npred), nForw(nforw), nExog(nexog), nPar(npar),
......@@ -58,25 +58,7 @@ KordpDynare::KordpDynare(const char **endo, int num_endo,
FSSparseTensor *t = new FSSparseTensor(iord, nY+nYs+nYss+nExog, nY);
md.insert(t);
}
}
KordpDynare::KordpDynare(const KordpDynare &dynare) :
nStat(dynare.nStat), nBoth(dynare.nBoth), nPred(dynare.nPred),
nForw(dynare.nForw), nExog(dynare.nExog), nPar(dynare.nPar),
nYs(dynare.nYs), nYss(dynare.nYss), nY(dynare.nY), nJcols(dynare.nJcols),
NNZD(dynare.NNZD), nSteps(dynare.nSteps), nOrder(dynare.nOrder),
journal(dynare.journal), dynamicDLL(dynare.dynamicDLL),
ySteady(NULL), params(NULL), vCov(NULL), md(dynare.md),
dnl(NULL), denl(NULL), dsnl(NULL), ss_tol(dynare.ss_tol),
varOrder(dynare.varOrder), ll_Incidence(dynare.ll_Incidence),
JacobianIndices(dynare.JacobianIndices), qz_criterium(dynare.qz_criterium)
{
ySteady = new Vector(*(dynare.ySteady));
params = new Vector(*(dynare.params));
vCov = new TwoDMatrix(*(dynare.vCov));
dnl = new DynareNameList(dynare);
denl = new DynareExogNameList(dynare);
dsnl = new DynareStateNameList(*this, *dnl, *denl);
}
KordpDynare::~KordpDynare()
......@@ -103,19 +85,6 @@ KordpDynare::~KordpDynare()
delete NNZD;
}
/** This clears the container of model derivatives and initializes it
* inserting empty sparse tensors up to the given order. */
ModelDerivativeContainer::ModelDerivativeContainer(const KordpDynare &model,
TensorContainer<FSSparseTensor> &mod_ders, int order) : md(mod_ders)
{
md.clear();
for (int iord = 1; iord <= order; iord++)
{
FSSparseTensor *t = new FSSparseTensor(iord, model.ny()+model.nys()+model.nyss()+model.nexog(), model.ny());
md.insert(t);
}
}
void
KordpDynare::solveDeterministicSteady()
{
......@@ -296,26 +265,6 @@ KordpDynare::populateDerivativesContainer(TwoDMatrix *g, int ord, const vector<i
md.insert(mdTi);
}
void
KordpDynare::writeModelInfo(Journal &jr) const
{
// write info on variables
JournalRecordPair rp(journal);
rp << "Information on variables" << endrec;
JournalRecord rec1(journal);
rec1 << "Number of endogenous: " << ny() << endrec;
JournalRecord rec2(journal);
rec2 << "Number of exogenous: " << nexog() << endrec;
JournalRecord rec3(journal);
rec3 << "Number of static: " << nstat() << endrec;
JournalRecord rec4(journal);
rec4 << "Number of predetermined: " << npred()+nboth() << endrec;
JournalRecord rec5(journal);
rec5 << "Number of forward looking: " << nforw()+nboth() << endrec;
JournalRecord rec6(journal);
rec6 << "Number of both: " << nboth() << endrec;
}
/*********************************************************
* LLxSteady()
* returns ySteady extended with leads and lags suitable for
......@@ -402,96 +351,6 @@ KordpDynare::ReorderDynareJacobianIndices(const vector<int> *varOrder) throw (TL
return JacobianIndices;
}
/************************************
* Reorder first set of columns of variables in a (jacobian) matrix
* according to order given in varsOrder together with the extras
* assuming tdx ncols() - nExog is eaqual or less than length of varOrder and
* of any of its elements too.
************************************/
void
KordpDynare::ReorderCols(TwoDMatrix *tdx, const vector<int> *vOrder) throw (DynareException, TLException)
{
if (tdx->ncols() > vOrder->size())
throw DynareException(__FILE__, __LINE__, "Size of order var is too small");
TwoDMatrix tmp(*tdx); // temporary 2D matrix
TwoDMatrix &tmpR = tmp;
tdx->zeros(); // empty original matrix
// reorder the columns
for (int i = 0; i < tdx->ncols(); i++)
tdx->copyColumn(tmpR, (*vOrder)[i], i);
}
void
KordpDynare::ReorderCols(TwoDMatrix *tdx, const int *vOrder) throw (TLException)
{
TwoDMatrix tmp(*tdx); // temporary 2D matrix
TwoDMatrix &tmpR = tmp;
tdx->zeros(); // empty original matrix
// reorder the columns
for (int i = 0; i < tdx->ncols(); i++)
tdx->copyColumn(tmpR, vOrder[i], i);
}
/***********************************************************************
* Recursive hierarchical block reordering of the higher order, input model
* derivatives inc. Hessian
* This is now obsolete but kept in in case it is needed
***********************************************************************/
void
KordpDynare::ReorderBlocks(TwoDMatrix *tdx, const vector<int> *vOrder) throw (DynareException, TLException)
{
// determine order of the matrix
double dbOrder = log((double) tdx->ncols())/log((double) nJcols);
int ibOrder = (int) dbOrder;
if ((double) ibOrder != dbOrder || ibOrder > nOrder)
{
ostringstream msg;
msg << "Wrong order " << dbOrder;
throw DynareException(__FILE__, __LINE__, msg.str());
}
TwoDMatrix tmp(*tdx); // temporary 2D matrix
TwoDMatrix &tmpR = tmp;
tdx->zeros(); // empty original matrix
if (ibOrder > 1)
{
int nBlocks = tmp.ncols()/ nJcols;
int bSize = tmp.ncols()/nBlocks;
for (int j = 0; j < nBlocks; ++j)
{
TwoDMatrix subtdx(tmpR, bSize*((*vOrder)[j]), bSize);
ReorderBlocks(&subtdx, vOrder);
tdx->place(subtdx, 0, bSize*j);
}
}
else
{
if (tdx->ncols() > vOrder->size())
throw DynareException(__FILE__, __LINE__, "Size of order var is too small");
// reorder the columns
for (int i = 0; i < tdx->ncols(); i++)
tdx->copyColumn(tmpR, (*vOrder)[i], i);
}
}
void
KordpVectorFunction::eval(const ConstVector &in, Vector &out) throw (DynareException)
{
check_for_eval(in, out);
Vector xx(d.nexog());
xx.zeros();
d.evaluateSystem(out, in, xx);
}
/**************************************************************************************/
/* DynareNameList class */
/**************************************************************************************/
......
/*
* Copyright (C) 2005 Ondra Kamenik
* Copyright (C) 2008-2009 Dynare Team
* Copyright (C) 2008-2010 Dynare Team
*
* This file is part of Dynare.
*
......@@ -110,7 +110,6 @@ class KordpDynare : public DynamicModel
friend class DynareNameList;
friend class DynareExogNameList;
friend class DynareStateNameList;
friend class KordpDynareJacobian;
friend class DynamicModelDLL;
const int nStat;
......@@ -150,8 +149,6 @@ public:
const vector<int> *varOrder, const TwoDMatrix *ll_Incidence,
double qz_criterium) throw (TLException);
/** Makes a deep copy of the object. */
KordpDynare(const KordpDynare &dyn);
virtual ~KordpDynare();
int
nstat() const
......@@ -257,58 +254,11 @@ public:
{
return new KordpDynare(*this);
}
void ReorderCols(TwoDMatrix *tdx, const int *varOrder) throw (TLException);
void ReorderCols(TwoDMatrix *tdx, const vector<int> *varOrder) throw (DynareException, TLException);
Vector *LLxSteady(const Vector &yS) throw (DynareException, TLException); // returns ySteady extended with leads and lags
private:
void writeModelInfo(Journal &jr) const;
vector<int> *ReorderDynareJacobianIndices(const vector<int> *varOrder) throw (TLException);
void ReorderBlocks(TwoDMatrix *tdx, const vector<int> *vOrder) throw (DynareException, TLException);
void populateDerivativesContainer(TwoDMatrix *g, int ord, const vector<int> *vOrder);
};
/****************************
* ModelDerivativeContainer manages derivatives container
************************************/
class ModelDerivativeContainer
{
protected:
TensorContainer<FSSparseTensor> &md;
public:
ModelDerivativeContainer(const KordpDynare &model, TensorContainer<FSSparseTensor> &mod_ders,
int order);
void load(int i, int iord, const int *vars, double res);
};
/****************************
* K-Order Perturbation instance of VectorFunction:
************************************/
class KordpVectorFunction : public ogu::VectorFunction
{
protected:
KordpDynare &d;
public:
KordpVectorFunction(KordpDynare &dyn) :
d(dyn)
{
}
virtual ~KordpVectorFunction()
{
}
int
inDim() const
{
return d.ny();
}
int
outDim() const
{
return d.ny();
}
void eval(const ConstVector &in, Vector &out) throw (DynareException);
};
#endif
/*
* Copyright (C) 2008-2009 Dynare Team
* Copyright (C) 2008-2010 Dynare Team
*
* This file is part of Dynare.
*
......@@ -46,38 +46,6 @@
#include <cctype>
#include <cassert>
#ifdef _MSC_VER
BOOL APIENTRY
DllMain(HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
// Some MS Windows preambles
// This is an example of an exported variable
K_ORDER_PERTURBATION_API int nK_order_perturbation = 0;
// This is an example of an exported function.
K_ORDER_PERTURBATION_API int
fnK_order_perturbation(void)
{
return 42;
}
#endif // _MSC_VER
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE) // exclude mexFunction for other applications
const char **
......@@ -235,7 +203,7 @@ extern "C" {
const int widthExog = (int) mxGetN(mxFldp);
const char **exoNamesMX = DynareMxArrayToString(mxFldp, nexo, widthExog);
if ((nEndo != nendo) || (nExog != nexo)) //(nPar != npar)
if ((nEndo != nendo) || (nExog != nexo))
mexErrMsgTxt("Incorrect number of input parameters.");
/* Fetch time index */
......@@ -290,14 +258,8 @@ extern "C" {
app.getFoldDecisionRule().writeMMap(mm, string());
// get latest ysteady
double *dYsteady = (dynare.getSteady().base());
ySteady = (Vector *)(&dynare.getSteady());
// developement of the output.
double *dgy, *dgu, *ysteady;
int nb_row_x;
ysteady = NULL;
if (kOrder == 1)
{
/* Set the output pointer to the output matrix ysteady. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment