Commit 4d4456b8 authored by MichelJuillard's avatar MichelJuillard

adding creation of <fname>_set_auxiliary_variables.m containing recursive...

adding creation of <fname>_set_auxiliary_variables.m containing recursive definition of auxiliary variables
parent 1e4c0852
......@@ -396,6 +396,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &static_basename) const
break;
}
output << "end" << endl;
writePowerDeriv(output, false);
output.close();
}
}
......@@ -1237,6 +1238,7 @@ StaticModel::writeStaticMFile(const string &func_name) const
output << "end" << endl; // Close the if nargout >= 3 statement
output << "end" << endl; // Close the *_static function
writePowerDeriv(output, false);
output.close();
}
......@@ -1270,6 +1272,7 @@ StaticModel::writeStaticFile(const string &basename, bool block, bool bytecode)
}
else
writeStaticMFile(basename);
writeAuxVarRecursiveDefinitions(basename);
}
void
......@@ -1320,6 +1323,7 @@ StaticModel::writeStaticBlockMFSFile(const string &basename) const
}
output << " end" << endl
<< "end" << endl;
writePowerDeriv(output, false);
output.close();
}
......@@ -1596,3 +1600,31 @@ StaticModel::writeAuxVarInitval(ostream &output, ExprNodeOutputType output_type)
output << ";" << endl;
}
}
void StaticModel::writeAuxVarRecursiveDefinitions(const string &basename) const
{
string func_name = basename + "_set_auxiliary_variables";
string filename = func_name + ".m";
ofstream output;
output.open(filename.c_str(), ios::out | ios::binary);
if (!output.is_open())
{
cerr << "ERROR: Can't open file " << filename << " for writing" << endl;
exit(EXIT_FAILURE);
}
output << "function y = " << func_name + "(y, x, params)" << endl
<< "%" << endl
<< "% Status : Computes static model for Dynare" << endl
<< "%" << endl
<< "% Warning : this file is generated automatically by Dynare" << endl
<< "% from model file (.mod)" << endl
<< endl;
for (int i = 0; i < (int) aux_equations.size(); i++)
{
dynamic_cast<ExprNode *>(aux_equations[i])->writeOutput(output, oMatlabStaticModel);
output << ";" << endl;
}
}
......@@ -190,6 +190,9 @@ public:
//! Writes initializations in oo_.steady_state or steady state file for the auxiliary variables
void writeAuxVarInitval(ostream &output, ExprNodeOutputType output_type) const;
//! Writes definition of the auxiliary variables in a M file
void writeAuxVarRecursiveDefinitions(const string &basename) const;
virtual int getDerivID(int symb_id, int lag) const throw (UnknownDerivIDException);
//! Return the number of blocks
......
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