Update: test main which writes MAT file too
git-svn-id: https://www.dynare.org/svn/dynare/trunk@2379 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
ad1608c9af
commit
88afe87f0c
|
@ -197,39 +197,44 @@ int main(int argc, char* argv[])
|
||||||
, ySteady, vCov, modParams, nStat, nPred, nForw, nBoth
|
, ySteady, vCov, modParams, nStat, nPred, nForw, nBoth
|
||||||
, jcols, nSteps, kOrder, journal, dynamicDLL, sstol, var_order
|
, jcols, nSteps, kOrder, journal, dynamicDLL, sstol, var_order
|
||||||
, llincidence );
|
, llincidence );
|
||||||
try {
|
// intiate tensor library
|
||||||
// intiate tensor library
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mexPrintf("k_order_perturbation: Call tls init\n");
|
mexPrintf("k_order_perturbation: Call tls init\n");
|
||||||
#endif
|
#endif
|
||||||
tls.init(dynare.order(),
|
tls.init(dynare.order(),
|
||||||
dynare.nstat()+2*dynare.npred()+3*dynare.nboth()+
|
dynare.nstat()+2*dynare.npred()+3*dynare.nboth()+
|
||||||
2*dynare.nforw()+dynare.nexog());
|
2*dynare.nforw()+dynare.nexog());
|
||||||
// construct main K-order approximation class
|
// construct main K-order approximation class
|
||||||
// FistOrderApproximation app(dynare, journal, nSteps);
|
// FistOrderApproximation app(dynare, journal, nSteps);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mexPrintf("k_order_perturbation: Call Approximation constructor \n");
|
mexPrintf("k_order_perturbation: Call Approximation constructor \n");
|
||||||
#endif
|
#endif
|
||||||
Approximation app(dynare, journal, nSteps);
|
Approximation app(dynare, journal, nSteps);
|
||||||
// run stochastic steady
|
// run stochastic steady
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mexPrintf("k_order_perturbation: Calling walkStochSteady.\n");
|
mexPrintf("k_order_perturbation: Calling walkStochSteady.\n");
|
||||||
#endif
|
#endif
|
||||||
app.walkStochSteady();
|
app.walkStochSteady();
|
||||||
|
|
||||||
} catch (const KordException& e) {
|
|
||||||
// tell about the exception and continue
|
|
||||||
printf("Caught (not yet fatal) Kord exception: ");
|
|
||||||
e.print();
|
|
||||||
JournalRecord rec(journal);
|
|
||||||
rec << "Solution routine not finished (" << e.get_message()
|
|
||||||
<< "), see what happens" << endrec;
|
|
||||||
} catch (const TLException& e) {
|
|
||||||
mexErrMsgTxt("Caugth TL exception.");
|
|
||||||
} catch (SylvException& e) {
|
|
||||||
mexErrMsgTxt("Caught Sylv exception.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
// open mat file
|
||||||
|
std::string matfile(fName);//(params.basename);
|
||||||
|
matfile += ".mat";
|
||||||
|
FILE* matfd = NULL;
|
||||||
|
if (NULL == (matfd=fopen(matfile.c_str(), "wb"))) {
|
||||||
|
fprintf(stderr, "Couldn't open %s for writing.\n", matfile.c_str());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ss_matrix_name(fName);//params.prefix);
|
||||||
|
ss_matrix_name += "_steady_states";
|
||||||
|
ConstTwoDMatrix(app.getSS()).writeMat4(matfd, ss_matrix_name.c_str());
|
||||||
|
|
||||||
|
// write the folded decision rule to the Mat-4 file
|
||||||
|
app.getFoldDecisionRule().writeMat4(matfd, fName);//params.prefix);
|
||||||
|
|
||||||
|
fclose(matfd);
|
||||||
|
|
||||||
// get latest ysteady
|
// get latest ysteady
|
||||||
double * dYsteady = (dynare.getSteady().base());
|
double * dYsteady = (dynare.getSteady().base());
|
||||||
ySteady = (Vector*)(&dynare.getSteady());
|
ySteady = (Vector*)(&dynare.getSteady());
|
||||||
|
|
Loading…
Reference in New Issue