Convert ExprNodeOutputType into a class enum
Incidentally, replace the IS_* macros by inline functions.issue#70
parent
c6d4cb88c3
commit
e19a14869e
|
@ -225,7 +225,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
|
||||||
ExprNodeOutputType local_output_type;
|
ExprNodeOutputType local_output_type;
|
||||||
Ufoss.str("");
|
Ufoss.str("");
|
||||||
|
|
||||||
local_output_type = oMatlabDynamicModelSparse;
|
local_output_type = ExprNodeOutputType::matlabDynamicModelSparse;
|
||||||
if (global_temporary_terms)
|
if (global_temporary_terms)
|
||||||
local_temporary_terms = temporary_terms;
|
local_temporary_terms = temporary_terms;
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
|
||||||
unsigned int block_mfs = getBlockMfs(block);
|
unsigned int block_mfs = getBlockMfs(block);
|
||||||
unsigned int block_recursive = block_size - block_mfs;
|
unsigned int block_recursive = block_size - block_mfs;
|
||||||
deriv_node_temp_terms_t tef_terms;
|
deriv_node_temp_terms_t tef_terms;
|
||||||
local_output_type = oMatlabDynamicModelSparse;
|
local_output_type = ExprNodeOutputType::matlabDynamicModelSparse;
|
||||||
if (global_temporary_terms)
|
if (global_temporary_terms)
|
||||||
local_temporary_terms = temporary_terms;
|
local_temporary_terms = temporary_terms;
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
|
||||||
{
|
{
|
||||||
output << " ";
|
output << " ";
|
||||||
// In the following, "Static" is used to avoid getting the "(it_)" subscripting
|
// In the following, "Static" is used to avoid getting the "(it_)" subscripting
|
||||||
it->writeOutput(output, oMatlabStaticModelSparse, local_temporary_terms, {});
|
it->writeOutput(output, ExprNodeOutputType::matlabStaticModelSparse, local_temporary_terms, {});
|
||||||
output << " = T_zeros;" << endl;
|
output << " = T_zeros;" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1803,7 +1803,7 @@ DynamicModel::writeSparseDynamicMFile(const string &basename) const
|
||||||
else
|
else
|
||||||
tmp_output << " ";
|
tmp_output << " ";
|
||||||
// In the following, "Static" is used to avoid getting the "(it_)" subscripting
|
// In the following, "Static" is used to avoid getting the "(it_)" subscripting
|
||||||
temporary_term->writeOutput(tmp_output, oMatlabStaticModelSparse, temporary_terms, {});
|
temporary_term->writeOutput(tmp_output, ExprNodeOutputType::matlabStaticModelSparse, temporary_terms, {});
|
||||||
}
|
}
|
||||||
if (tmp_output.str().length() > 0)
|
if (tmp_output.str().length() > 0)
|
||||||
mDynamicModelFile << " global " << tmp_output.str() << ";\n";
|
mDynamicModelFile << " global " << tmp_output.str() << ";\n";
|
||||||
|
@ -1814,7 +1814,7 @@ DynamicModel::writeSparseDynamicMFile(const string &basename) const
|
||||||
{
|
{
|
||||||
tmp_output << " ";
|
tmp_output << " ";
|
||||||
// In the following, "Static" is used to avoid getting the "(it_)" subscripting
|
// In the following, "Static" is used to avoid getting the "(it_)" subscripting
|
||||||
temporary_term->writeOutput(tmp_output, oMatlabStaticModelSparse, temporary_terms, {});
|
temporary_term->writeOutput(tmp_output, ExprNodeOutputType::matlabStaticModelSparse, temporary_terms, {});
|
||||||
tmp_output << "=T_init;\n";
|
tmp_output << "=T_init;\n";
|
||||||
}
|
}
|
||||||
if (tmp_output.str().length() > 0)
|
if (tmp_output.str().length() > 0)
|
||||||
|
@ -2298,8 +2298,8 @@ DynamicModel::writeDynamicModel(const string &basename, ostream &DynamicOutput,
|
||||||
ostringstream third_derivatives_tt_output; // Used for storing third order derivatives temp terms
|
ostringstream third_derivatives_tt_output; // Used for storing third order derivatives temp terms
|
||||||
ostringstream third_derivatives_output; // Used for storing third order derivatives equations
|
ostringstream third_derivatives_output; // Used for storing third order derivatives equations
|
||||||
|
|
||||||
ExprNodeOutputType output_type = (use_dll ? oCDynamicModel :
|
ExprNodeOutputType output_type = (use_dll ? ExprNodeOutputType::CDynamicModel :
|
||||||
julia ? oJuliaDynamicModel : oMatlabDynamicModel);
|
julia ? ExprNodeOutputType::juliaDynamicModel : ExprNodeOutputType::matlabDynamicModel);
|
||||||
|
|
||||||
deriv_node_temp_terms_t tef_terms;
|
deriv_node_temp_terms_t tef_terms;
|
||||||
temporary_terms_t temp_term_union;
|
temporary_terms_t temp_term_union;
|
||||||
|
@ -2366,7 +2366,7 @@ DynamicModel::writeDynamicModel(const string &basename, ostream &DynamicOutput,
|
||||||
int col_nb_sym = id2 * dynJacobianColsNbr + id1;
|
int col_nb_sym = id2 * dynJacobianColsNbr + id1;
|
||||||
|
|
||||||
ostringstream for_sym;
|
ostringstream for_sym;
|
||||||
if (output_type == oJuliaDynamicModel)
|
if (output_type == ExprNodeOutputType::juliaDynamicModel)
|
||||||
{
|
{
|
||||||
for_sym << "g2[" << eq + 1 << "," << col_nb + 1 << "]";
|
for_sym << "g2[" << eq + 1 << "," << col_nb + 1 << "]";
|
||||||
hessian_output << " @inbounds " << for_sym.str() << " = ";
|
hessian_output << " @inbounds " << for_sym.str() << " = ";
|
||||||
|
@ -2391,7 +2391,7 @@ DynamicModel::writeDynamicModel(const string &basename, ostream &DynamicOutput,
|
||||||
|
|
||||||
// Treating symetric elements
|
// Treating symetric elements
|
||||||
if (id1 != id2)
|
if (id1 != id2)
|
||||||
if (output_type == oJuliaDynamicModel)
|
if (output_type == ExprNodeOutputType::juliaDynamicModel)
|
||||||
hessian_output << " @inbounds g2[" << eq + 1 << "," << col_nb_sym + 1 << "] = "
|
hessian_output << " @inbounds g2[" << eq + 1 << "," << col_nb_sym + 1 << "] = "
|
||||||
<< for_sym.str() << endl;
|
<< for_sym.str() << endl;
|
||||||
else
|
else
|
||||||
|
@ -2436,7 +2436,7 @@ DynamicModel::writeDynamicModel(const string &basename, ostream &DynamicOutput,
|
||||||
int ref_col = id1 * hessianColsNbr + id2 * dynJacobianColsNbr + id3;
|
int ref_col = id1 * hessianColsNbr + id2 * dynJacobianColsNbr + id3;
|
||||||
|
|
||||||
ostringstream for_sym;
|
ostringstream for_sym;
|
||||||
if (output_type == oJuliaDynamicModel)
|
if (output_type == ExprNodeOutputType::juliaDynamicModel)
|
||||||
{
|
{
|
||||||
for_sym << "g3[" << eq + 1 << "," << ref_col + 1 << "]";
|
for_sym << "g3[" << eq + 1 << "," << ref_col + 1 << "]";
|
||||||
third_derivatives_output << " @inbounds " << for_sym.str() << " = ";
|
third_derivatives_output << " @inbounds " << for_sym.str() << " = ";
|
||||||
|
@ -2469,7 +2469,7 @@ DynamicModel::writeDynamicModel(const string &basename, ostream &DynamicOutput,
|
||||||
int k2 = 1; // Keeps the offset of the permutation relative to k
|
int k2 = 1; // Keeps the offset of the permutation relative to k
|
||||||
for (int col : cols)
|
for (int col : cols)
|
||||||
if (col != ref_col)
|
if (col != ref_col)
|
||||||
if (output_type == oJuliaDynamicModel)
|
if (output_type == ExprNodeOutputType::juliaDynamicModel)
|
||||||
third_derivatives_output << " @inbounds g3[" << eq + 1 << "," << col + 1 << "] = "
|
third_derivatives_output << " @inbounds g3[" << eq + 1 << "," << col + 1 << "] = "
|
||||||
<< for_sym.str() << endl;
|
<< for_sym.str() << endl;
|
||||||
else
|
else
|
||||||
|
@ -2491,7 +2491,7 @@ DynamicModel::writeDynamicModel(const string &basename, ostream &DynamicOutput,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output_type == oMatlabDynamicModel)
|
if (output_type == ExprNodeOutputType::matlabDynamicModel)
|
||||||
{
|
{
|
||||||
// Check that we don't have more than 32 nested parenthesis because Matlab does not suppor this. See Issue #1201
|
// Check that we don't have more than 32 nested parenthesis because Matlab does not suppor this. See Issue #1201
|
||||||
map<string, string> tmp_paren_vars;
|
map<string, string> tmp_paren_vars;
|
||||||
|
@ -2565,7 +2565,7 @@ DynamicModel::writeDynamicModel(const string &basename, ostream &DynamicOutput,
|
||||||
|
|
||||||
writeDynamicMatlabCompatLayer(basename);
|
writeDynamicMatlabCompatLayer(basename);
|
||||||
}
|
}
|
||||||
else if (output_type == oCDynamicModel)
|
else if (output_type == ExprNodeOutputType::CDynamicModel)
|
||||||
{
|
{
|
||||||
DynamicOutput << "void Dynamic(double *y, double *x, int nb_row_x, double *params, double *steady_state, int it_, double *residual, double *g1, double *v2, double *v3)" << endl
|
DynamicOutput << "void Dynamic(double *y, double *x, int nb_row_x, double *params, double *steady_state, int it_, double *residual, double *g1, double *v2, double *v3)" << endl
|
||||||
<< "{" << endl
|
<< "{" << endl
|
||||||
|
@ -3428,7 +3428,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
|
||||||
|
|
||||||
// Write PacExpectationInfo
|
// Write PacExpectationInfo
|
||||||
for (auto it : pac_expectation_info)
|
for (auto it : pac_expectation_info)
|
||||||
it->ExprNode::writeOutput(output, oMatlabDynamicModel);
|
it->ExprNode::writeOutput(output, ExprNodeOutputType::matlabDynamicModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
map<pair<int, pair<int, int >>, expr_t>
|
map<pair<int, pair<int, int >>, expr_t>
|
||||||
|
@ -4652,7 +4652,7 @@ void
|
||||||
DynamicModel::writeSetAuxiliaryVariables(const string &basename, const bool julia) const
|
DynamicModel::writeSetAuxiliaryVariables(const string &basename, const bool julia) const
|
||||||
{
|
{
|
||||||
ostringstream output_func_body;
|
ostringstream output_func_body;
|
||||||
writeAuxVarRecursiveDefinitions(output_func_body, oMatlabDseries);
|
writeAuxVarRecursiveDefinitions(output_func_body, ExprNodeOutputType::matlabDseries);
|
||||||
|
|
||||||
if (output_func_body.str().empty())
|
if (output_func_body.str().empty())
|
||||||
return;
|
return;
|
||||||
|
@ -5185,7 +5185,7 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
|
||||||
&& !hessian_params_derivatives.size())
|
&& !hessian_params_derivatives.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ExprNodeOutputType output_type = (julia ? oJuliaDynamicModel : oMatlabDynamicModel);
|
ExprNodeOutputType output_type = (julia ? ExprNodeOutputType::juliaDynamicModel : ExprNodeOutputType::matlabDynamicModel);
|
||||||
ostringstream model_local_vars_output; // Used for storing model local vars
|
ostringstream model_local_vars_output; // Used for storing model local vars
|
||||||
ostringstream model_output; // Used for storing model temp vars and equations
|
ostringstream model_output; // Used for storing model temp vars and equations
|
||||||
ostringstream jacobian_output; // Used for storing jacobian equations
|
ostringstream jacobian_output; // Used for storing jacobian equations
|
||||||
|
@ -5422,13 +5422,13 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
|
||||||
void
|
void
|
||||||
DynamicModel::writeLatexFile(const string &basename, const bool write_equation_tags) const
|
DynamicModel::writeLatexFile(const string &basename, const bool write_equation_tags) const
|
||||||
{
|
{
|
||||||
writeLatexModelFile(basename + "_dynamic", oLatexDynamicModel, write_equation_tags);
|
writeLatexModelFile(basename + "_dynamic", ExprNodeOutputType::latexDynamicModel, write_equation_tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicModel::writeLatexOriginalFile(const string &basename, const bool write_equation_tags) const
|
DynamicModel::writeLatexOriginalFile(const string &basename, const bool write_equation_tags) const
|
||||||
{
|
{
|
||||||
writeLatexModelFile(basename + "_original", oLatexDynamicModel, write_equation_tags);
|
writeLatexModelFile(basename + "_original", ExprNodeOutputType::latexDynamicModel, write_equation_tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -5908,7 +5908,7 @@ DynamicModel::isChecksumMatching(const string &basename) const
|
||||||
<< equation_tag.second.first
|
<< equation_tag.second.first
|
||||||
<< equation_tag.second.second;
|
<< equation_tag.second.second;
|
||||||
|
|
||||||
ExprNodeOutputType buffer_type = oCDynamicModel;
|
ExprNodeOutputType buffer_type = ExprNodeOutputType::CDynamicModel;
|
||||||
|
|
||||||
for (int eq = 0; eq < (int) equations.size(); eq++)
|
for (int eq = 0; eq < (int) equations.size(); eq++)
|
||||||
{
|
{
|
||||||
|
|
224
src/ExprNode.cc
224
src/ExprNode.cc
|
@ -104,10 +104,10 @@ ExprNode::checkIfTemporaryTermThenWrite(ostream &output, ExprNodeOutputType outp
|
||||||
if (it == temporary_terms.end())
|
if (it == temporary_terms.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (output_type == oMatlabDynamicModelSparse)
|
if (output_type == ExprNodeOutputType::matlabDynamicModelSparse)
|
||||||
output << "T" << idx << "(it_)";
|
output << "T" << idx << "(it_)";
|
||||||
else
|
else
|
||||||
if (output_type == oMatlabStaticModelSparse || IS_C(output_type))
|
if (output_type == ExprNodeOutputType::matlabStaticModelSparse || isCOutput(output_type))
|
||||||
output << "T" << idx;
|
output << "T" << idx;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -177,7 +177,7 @@ ExprNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr_t>>
|
||||||
void
|
void
|
||||||
ExprNode::writeOutput(ostream &output) const
|
ExprNode::writeOutput(ostream &output) const
|
||||||
{
|
{
|
||||||
writeOutput(output, oMatlabOutsideModel, {}, {});
|
writeOutput(output, ExprNodeOutputType::matlabOutsideModel, {}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -827,12 +827,12 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
if (checkIfTemporaryTermThenWrite(output, output_type, temporary_terms, temporary_terms_idxs))
|
if (checkIfTemporaryTermThenWrite(output, output_type, temporary_terms, temporary_terms_idxs))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (IS_LATEX(output_type))
|
if (isLatexOutput(output_type))
|
||||||
{
|
{
|
||||||
if (output_type == oLatexDynamicSteadyStateOperator)
|
if (output_type == ExprNodeOutputType::latexDynamicSteadyStateOperator)
|
||||||
output << "\\bar";
|
output << "\\bar";
|
||||||
output << "{" << datatree.symbol_table.getTeXName(symb_id);
|
output << "{" << datatree.symbol_table.getTeXName(symb_id);
|
||||||
if (output_type == oLatexDynamicModel
|
if (output_type == ExprNodeOutputType::latexDynamicModel
|
||||||
&& (type == SymbolType::endogenous || type == SymbolType::exogenous || type == SymbolType::exogenousDet || type == SymbolType::modelLocalVariable || type == SymbolType::trend || type == SymbolType::logTrend))
|
&& (type == SymbolType::endogenous || type == SymbolType::exogenous || type == SymbolType::exogenousDet || type == SymbolType::modelLocalVariable || type == SymbolType::trend || type == SymbolType::logTrend))
|
||||||
{
|
{
|
||||||
output << "_{t";
|
output << "_{t";
|
||||||
|
@ -854,16 +854,16 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
{
|
{
|
||||||
case SymbolType::parameter:
|
case SymbolType::parameter:
|
||||||
case SymbolType::parameterEpilogue:
|
case SymbolType::parameterEpilogue:
|
||||||
if (output_type == oMatlabOutsideModel)
|
if (output_type == ExprNodeOutputType::matlabOutsideModel)
|
||||||
output << "M_.params" << "(" << tsid + 1 << ")";
|
output << "M_.params" << "(" << tsid + 1 << ")";
|
||||||
else
|
else
|
||||||
output << "params" << LEFT_ARRAY_SUBSCRIPT(output_type) << tsid + ARRAY_SUBSCRIPT_OFFSET(output_type) << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << "params" << LEFT_ARRAY_SUBSCRIPT(output_type) << tsid + ARRAY_SUBSCRIPT_OFFSET(output_type) << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SymbolType::modelLocalVariable:
|
case SymbolType::modelLocalVariable:
|
||||||
if (output_type == oMatlabDynamicModelSparse || output_type == oMatlabStaticModelSparse
|
if (output_type == ExprNodeOutputType::matlabDynamicModelSparse || output_type == ExprNodeOutputType::matlabStaticModelSparse
|
||||||
|| output_type == oMatlabDynamicSteadyStateOperator || output_type == oMatlabDynamicSparseSteadyStateOperator
|
|| output_type == ExprNodeOutputType::matlabDynamicSteadyStateOperator || output_type == ExprNodeOutputType::matlabDynamicSparseSteadyStateOperator
|
||||||
|| output_type == oCDynamicSteadyStateOperator)
|
|| output_type == ExprNodeOutputType::CDynamicSteadyStateOperator)
|
||||||
{
|
{
|
||||||
output << "(";
|
output << "(";
|
||||||
datatree.getLocalVariable(symb_id)->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
|
datatree.getLocalVariable(symb_id)->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
|
||||||
|
@ -882,20 +882,20 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
case SymbolType::endogenous:
|
case SymbolType::endogenous:
|
||||||
switch (output_type)
|
switch (output_type)
|
||||||
{
|
{
|
||||||
case oJuliaDynamicModel:
|
case ExprNodeOutputType::juliaDynamicModel:
|
||||||
case oMatlabDynamicModel:
|
case ExprNodeOutputType::matlabDynamicModel:
|
||||||
case oCDynamicModel:
|
case ExprNodeOutputType::CDynamicModel:
|
||||||
i = datatree.getDynJacobianCol(datatree.getDerivID(symb_id, lag)) + ARRAY_SUBSCRIPT_OFFSET(output_type);
|
i = datatree.getDynJacobianCol(datatree.getDerivID(symb_id, lag)) + ARRAY_SUBSCRIPT_OFFSET(output_type);
|
||||||
output << "y" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << "y" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oCStaticModel:
|
case ExprNodeOutputType::CStaticModel:
|
||||||
case oJuliaStaticModel:
|
case ExprNodeOutputType::juliaStaticModel:
|
||||||
case oMatlabStaticModel:
|
case ExprNodeOutputType::matlabStaticModel:
|
||||||
case oMatlabStaticModelSparse:
|
case ExprNodeOutputType::matlabStaticModelSparse:
|
||||||
i = tsid + ARRAY_SUBSCRIPT_OFFSET(output_type);
|
i = tsid + ARRAY_SUBSCRIPT_OFFSET(output_type);
|
||||||
output << "y" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << "y" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oMatlabDynamicModelSparse:
|
case ExprNodeOutputType::matlabDynamicModelSparse:
|
||||||
i = tsid + ARRAY_SUBSCRIPT_OFFSET(output_type);
|
i = tsid + ARRAY_SUBSCRIPT_OFFSET(output_type);
|
||||||
if (lag > 0)
|
if (lag > 0)
|
||||||
output << "y" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_+" << lag << ", " << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << "y" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_+" << lag << ", " << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
|
@ -904,27 +904,27 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
else
|
else
|
||||||
output << "y" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_, " << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << "y" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_, " << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oMatlabOutsideModel:
|
case ExprNodeOutputType::matlabOutsideModel:
|
||||||
output << "oo_.steady_state(" << tsid + 1 << ")";
|
output << "oo_.steady_state(" << tsid + 1 << ")";
|
||||||
break;
|
break;
|
||||||
case oJuliaDynamicSteadyStateOperator:
|
case ExprNodeOutputType::juliaDynamicSteadyStateOperator:
|
||||||
case oMatlabDynamicSteadyStateOperator:
|
case ExprNodeOutputType::matlabDynamicSteadyStateOperator:
|
||||||
case oMatlabDynamicSparseSteadyStateOperator:
|
case ExprNodeOutputType::matlabDynamicSparseSteadyStateOperator:
|
||||||
output << "steady_state" << LEFT_ARRAY_SUBSCRIPT(output_type) << tsid + 1 << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << "steady_state" << LEFT_ARRAY_SUBSCRIPT(output_type) << tsid + 1 << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oCDynamicSteadyStateOperator:
|
case ExprNodeOutputType::CDynamicSteadyStateOperator:
|
||||||
output << "steady_state[" << tsid << "]";
|
output << "steady_state[" << tsid << "]";
|
||||||
break;
|
break;
|
||||||
case oJuliaSteadyStateFile:
|
case ExprNodeOutputType::juliaSteadyStateFile:
|
||||||
case oSteadyStateFile:
|
case ExprNodeOutputType::steadyStateFile:
|
||||||
output << "ys_" << LEFT_ARRAY_SUBSCRIPT(output_type) << tsid + 1 << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << "ys_" << LEFT_ARRAY_SUBSCRIPT(output_type) << tsid + 1 << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oMatlabDseries:
|
case ExprNodeOutputType::matlabDseries:
|
||||||
output << "ds." << datatree.symbol_table.getName(symb_id);
|
output << "ds." << datatree.symbol_table.getName(symb_id);
|
||||||
if (lag != 0)
|
if (lag != 0)
|
||||||
output << LEFT_ARRAY_SUBSCRIPT(output_type) << lag << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << LEFT_ARRAY_SUBSCRIPT(output_type) << lag << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oEpilogueFile:
|
case ExprNodeOutputType::epilogueFile:
|
||||||
output << datatree.symbol_table.getName(symb_id)
|
output << datatree.symbol_table.getName(symb_id)
|
||||||
<< LEFT_ARRAY_SUBSCRIPT(output_type) << "epilogue_it__";
|
<< LEFT_ARRAY_SUBSCRIPT(output_type) << "epilogue_it__";
|
||||||
if (lag != 0)
|
if (lag != 0)
|
||||||
|
@ -941,9 +941,9 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
i = tsid + ARRAY_SUBSCRIPT_OFFSET(output_type);
|
i = tsid + ARRAY_SUBSCRIPT_OFFSET(output_type);
|
||||||
switch (output_type)
|
switch (output_type)
|
||||||
{
|
{
|
||||||
case oJuliaDynamicModel:
|
case ExprNodeOutputType::juliaDynamicModel:
|
||||||
case oMatlabDynamicModel:
|
case ExprNodeOutputType::matlabDynamicModel:
|
||||||
case oMatlabDynamicModelSparse:
|
case ExprNodeOutputType::matlabDynamicModelSparse:
|
||||||
if (lag > 0)
|
if (lag > 0)
|
||||||
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_+" << lag << ", " << i
|
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_+" << lag << ", " << i
|
||||||
<< RIGHT_ARRAY_SUBSCRIPT(output_type);
|
<< RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
|
@ -954,7 +954,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_, " << i
|
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_, " << i
|
||||||
<< RIGHT_ARRAY_SUBSCRIPT(output_type);
|
<< RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oCDynamicModel:
|
case ExprNodeOutputType::CDynamicModel:
|
||||||
if (lag == 0)
|
if (lag == 0)
|
||||||
output << "x[it_+" << i << "*nb_row_x]";
|
output << "x[it_+" << i << "*nb_row_x]";
|
||||||
else if (lag > 0)
|
else if (lag > 0)
|
||||||
|
@ -962,29 +962,29 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
else
|
else
|
||||||
output << "x[it_" << lag << "+" << i << "*nb_row_x]";
|
output << "x[it_" << lag << "+" << i << "*nb_row_x]";
|
||||||
break;
|
break;
|
||||||
case oCStaticModel:
|
case ExprNodeOutputType::CStaticModel:
|
||||||
case oJuliaStaticModel:
|
case ExprNodeOutputType::juliaStaticModel:
|
||||||
case oMatlabStaticModel:
|
case ExprNodeOutputType::matlabStaticModel:
|
||||||
case oMatlabStaticModelSparse:
|
case ExprNodeOutputType::matlabStaticModelSparse:
|
||||||
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oMatlabOutsideModel:
|
case ExprNodeOutputType::matlabOutsideModel:
|
||||||
assert(lag == 0);
|
assert(lag == 0);
|
||||||
output << "oo_.exo_steady_state(" << i << ")";
|
output << "oo_.exo_steady_state(" << i << ")";
|
||||||
break;
|
break;
|
||||||
case oMatlabDynamicSteadyStateOperator:
|
case ExprNodeOutputType::matlabDynamicSteadyStateOperator:
|
||||||
output << "oo_.exo_steady_state(" << i << ")";
|
output << "oo_.exo_steady_state(" << i << ")";
|
||||||
break;
|
break;
|
||||||
case oJuliaSteadyStateFile:
|
case ExprNodeOutputType::juliaSteadyStateFile:
|
||||||
case oSteadyStateFile:
|
case ExprNodeOutputType::steadyStateFile:
|
||||||
output << "exo_" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << "exo_" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oMatlabDseries:
|
case ExprNodeOutputType::matlabDseries:
|
||||||
output << "ds." << datatree.symbol_table.getName(symb_id);
|
output << "ds." << datatree.symbol_table.getName(symb_id);
|
||||||
if (lag != 0)
|
if (lag != 0)
|
||||||
output << LEFT_ARRAY_SUBSCRIPT(output_type) << lag << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << LEFT_ARRAY_SUBSCRIPT(output_type) << lag << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oEpilogueFile:
|
case ExprNodeOutputType::epilogueFile:
|
||||||
output << datatree.symbol_table.getName(symb_id)
|
output << datatree.symbol_table.getName(symb_id)
|
||||||
<< LEFT_ARRAY_SUBSCRIPT(output_type) << "epilogue_it__";
|
<< LEFT_ARRAY_SUBSCRIPT(output_type) << "epilogue_it__";
|
||||||
if (lag != 0)
|
if (lag != 0)
|
||||||
|
@ -1001,9 +1001,9 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
i = tsid + datatree.symbol_table.exo_nbr() + ARRAY_SUBSCRIPT_OFFSET(output_type);
|
i = tsid + datatree.symbol_table.exo_nbr() + ARRAY_SUBSCRIPT_OFFSET(output_type);
|
||||||
switch (output_type)
|
switch (output_type)
|
||||||
{
|
{
|
||||||
case oJuliaDynamicModel:
|
case ExprNodeOutputType::juliaDynamicModel:
|
||||||
case oMatlabDynamicModel:
|
case ExprNodeOutputType::matlabDynamicModel:
|
||||||
case oMatlabDynamicModelSparse:
|
case ExprNodeOutputType::matlabDynamicModelSparse:
|
||||||
if (lag > 0)
|
if (lag > 0)
|
||||||
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_+" << lag << ", " << i
|
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_+" << lag << ", " << i
|
||||||
<< RIGHT_ARRAY_SUBSCRIPT(output_type);
|
<< RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
|
@ -1014,7 +1014,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_, " << i
|
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_, " << i
|
||||||
<< RIGHT_ARRAY_SUBSCRIPT(output_type);
|
<< RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oCDynamicModel:
|
case ExprNodeOutputType::CDynamicModel:
|
||||||
if (lag == 0)
|
if (lag == 0)
|
||||||
output << "x[it_+" << i << "*nb_row_x]";
|
output << "x[it_+" << i << "*nb_row_x]";
|
||||||
else if (lag > 0)
|
else if (lag > 0)
|
||||||
|
@ -1022,29 +1022,29 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
else
|
else
|
||||||
output << "x[it_" << lag << "+" << i << "*nb_row_x]";
|
output << "x[it_" << lag << "+" << i << "*nb_row_x]";
|
||||||
break;
|
break;
|
||||||
case oCStaticModel:
|
case ExprNodeOutputType::CStaticModel:
|
||||||
case oJuliaStaticModel:
|
case ExprNodeOutputType::juliaStaticModel:
|
||||||
case oMatlabStaticModel:
|
case ExprNodeOutputType::matlabStaticModel:
|
||||||
case oMatlabStaticModelSparse:
|
case ExprNodeOutputType::matlabStaticModelSparse:
|
||||||
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oMatlabOutsideModel:
|
case ExprNodeOutputType::matlabOutsideModel:
|
||||||
assert(lag == 0);
|
assert(lag == 0);
|
||||||
output << "oo_.exo_det_steady_state(" << tsid + 1 << ")";
|
output << "oo_.exo_det_steady_state(" << tsid + 1 << ")";
|
||||||
break;
|
break;
|
||||||
case oMatlabDynamicSteadyStateOperator:
|
case ExprNodeOutputType::matlabDynamicSteadyStateOperator:
|
||||||
output << "oo_.exo_det_steady_state(" << tsid + 1 << ")";
|
output << "oo_.exo_det_steady_state(" << tsid + 1 << ")";
|
||||||
break;
|
break;
|
||||||
case oJuliaSteadyStateFile:
|
case ExprNodeOutputType::juliaSteadyStateFile:
|
||||||
case oSteadyStateFile:
|
case ExprNodeOutputType::steadyStateFile:
|
||||||
output << "exo_" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << "exo_" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oMatlabDseries:
|
case ExprNodeOutputType::matlabDseries:
|
||||||
output << "ds." << datatree.symbol_table.getName(symb_id);
|
output << "ds." << datatree.symbol_table.getName(symb_id);
|
||||||
if (lag != 0)
|
if (lag != 0)
|
||||||
output << LEFT_ARRAY_SUBSCRIPT(output_type) << lag << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << LEFT_ARRAY_SUBSCRIPT(output_type) << lag << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
break;
|
break;
|
||||||
case oEpilogueFile:
|
case ExprNodeOutputType::epilogueFile:
|
||||||
output << datatree.symbol_table.getName(symb_id)
|
output << datatree.symbol_table.getName(symb_id)
|
||||||
<< LEFT_ARRAY_SUBSCRIPT(output_type) << "epilogue_it__";
|
<< LEFT_ARRAY_SUBSCRIPT(output_type) << "epilogue_it__";
|
||||||
if (lag != 0)
|
if (lag != 0)
|
||||||
|
@ -2467,13 +2467,13 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
output << "exp";
|
output << "exp";
|
||||||
break;
|
break;
|
||||||
case UnaryOpcode::log:
|
case UnaryOpcode::log:
|
||||||
if (IS_LATEX(output_type))
|
if (isLatexOutput(output_type))
|
||||||
output << "\\log";
|
output << "\\log";
|
||||||
else
|
else
|
||||||
output << "log";
|
output << "log";
|
||||||
break;
|
break;
|
||||||
case UnaryOpcode::log10:
|
case UnaryOpcode::log10:
|
||||||
if (IS_LATEX(output_type))
|
if (isLatexOutput(output_type))
|
||||||
output << "\\log_{10}";
|
output << "\\log_{10}";
|
||||||
else
|
else
|
||||||
output << "log10";
|
output << "log10";
|
||||||
|
@ -2521,7 +2521,7 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
output << "abs";
|
output << "abs";
|
||||||
break;
|
break;
|
||||||
case UnaryOpcode::sign:
|
case UnaryOpcode::sign:
|
||||||
if (output_type == oCDynamicModel || output_type == oCStaticModel)
|
if (output_type == ExprNodeOutputType::CDynamicModel || output_type == ExprNodeOutputType::CStaticModel)
|
||||||
output << "copysign";
|
output << "copysign";
|
||||||
else
|
else
|
||||||
output << "sign";
|
output << "sign";
|
||||||
|
@ -2530,20 +2530,20 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
ExprNodeOutputType new_output_type;
|
ExprNodeOutputType new_output_type;
|
||||||
switch (output_type)
|
switch (output_type)
|
||||||
{
|
{
|
||||||
case oMatlabDynamicModel:
|
case ExprNodeOutputType::matlabDynamicModel:
|
||||||
new_output_type = oMatlabDynamicSteadyStateOperator;
|
new_output_type = ExprNodeOutputType::matlabDynamicSteadyStateOperator;
|
||||||
break;
|
break;
|
||||||
case oLatexDynamicModel:
|
case ExprNodeOutputType::latexDynamicModel:
|
||||||
new_output_type = oLatexDynamicSteadyStateOperator;
|
new_output_type = ExprNodeOutputType::latexDynamicSteadyStateOperator;
|
||||||
break;
|
break;
|
||||||
case oCDynamicModel:
|
case ExprNodeOutputType::CDynamicModel:
|
||||||
new_output_type = oCDynamicSteadyStateOperator;
|
new_output_type = ExprNodeOutputType::CDynamicSteadyStateOperator;
|
||||||
break;
|
break;
|
||||||
case oJuliaDynamicModel:
|
case ExprNodeOutputType::juliaDynamicModel:
|
||||||
new_output_type = oJuliaDynamicSteadyStateOperator;
|
new_output_type = ExprNodeOutputType::juliaDynamicSteadyStateOperator;
|
||||||
break;
|
break;
|
||||||
case oMatlabDynamicModelSparse:
|
case ExprNodeOutputType::matlabDynamicModelSparse:
|
||||||
new_output_type = oMatlabDynamicSparseSteadyStateOperator;
|
new_output_type = ExprNodeOutputType::matlabDynamicSparseSteadyStateOperator;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
new_output_type = output_type;
|
new_output_type = output_type;
|
||||||
|
@ -2561,7 +2561,7 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
assert(datatree.symbol_table.getType(param1_symb_id) == SymbolType::parameter);
|
assert(datatree.symbol_table.getType(param1_symb_id) == SymbolType::parameter);
|
||||||
int tsid_endo = datatree.symbol_table.getTypeSpecificID(varg->symb_id);
|
int tsid_endo = datatree.symbol_table.getTypeSpecificID(varg->symb_id);
|
||||||
int tsid_param = datatree.symbol_table.getTypeSpecificID(param1_symb_id);
|
int tsid_param = datatree.symbol_table.getTypeSpecificID(param1_symb_id);
|
||||||
assert(IS_MATLAB(output_type));
|
assert(isMatlabOutput(output_type));
|
||||||
output << "ss_param_deriv(" << tsid_endo+1 << "," << tsid_param+1 << ")";
|
output << "ss_param_deriv(" << tsid_endo+1 << "," << tsid_param+1 << ")";
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -2575,13 +2575,13 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
int tsid_endo = datatree.symbol_table.getTypeSpecificID(varg->symb_id);
|
int tsid_endo = datatree.symbol_table.getTypeSpecificID(varg->symb_id);
|
||||||
int tsid_param1 = datatree.symbol_table.getTypeSpecificID(param1_symb_id);
|
int tsid_param1 = datatree.symbol_table.getTypeSpecificID(param1_symb_id);
|
||||||
int tsid_param2 = datatree.symbol_table.getTypeSpecificID(param2_symb_id);
|
int tsid_param2 = datatree.symbol_table.getTypeSpecificID(param2_symb_id);
|
||||||
assert(IS_MATLAB(output_type));
|
assert(isMatlabOutput(output_type));
|
||||||
output << "ss_param_2nd_deriv(" << tsid_endo+1 << "," << tsid_param1+1
|
output << "ss_param_2nd_deriv(" << tsid_endo+1 << "," << tsid_param1+1
|
||||||
<< "," << tsid_param2+1 << ")";
|
<< "," << tsid_param2+1 << ")";
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case UnaryOpcode::expectation:
|
case UnaryOpcode::expectation:
|
||||||
if (!IS_LATEX(output_type))
|
if (!isLatexOutput(output_type))
|
||||||
{
|
{
|
||||||
cerr << "UnaryOpNode::writeOutput: not implemented on UnaryOpcode::expectation" << endl;
|
cerr << "UnaryOpNode::writeOutput: not implemented on UnaryOpcode::expectation" << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -2617,7 +2617,7 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
&& arg->precedence(output_type, temporary_terms) < precedence(output_type, temporary_terms)))
|
&& arg->precedence(output_type, temporary_terms) < precedence(output_type, temporary_terms)))
|
||||||
{
|
{
|
||||||
output << LEFT_PAR(output_type);
|
output << LEFT_PAR(output_type);
|
||||||
if (op_code == UnaryOpcode::sign && (output_type == oCDynamicModel || output_type == oCStaticModel))
|
if (op_code == UnaryOpcode::sign && (output_type == ExprNodeOutputType::CDynamicModel || output_type == ExprNodeOutputType::CStaticModel))
|
||||||
output << "1.0,";
|
output << "1.0,";
|
||||||
close_parenthesis = true;
|
close_parenthesis = true;
|
||||||
}
|
}
|
||||||
|
@ -3761,7 +3761,7 @@ BinaryOpNode::precedence(ExprNodeOutputType output_type, const temporary_terms_t
|
||||||
return 4;
|
return 4;
|
||||||
case BinaryOpcode::power:
|
case BinaryOpcode::power:
|
||||||
case BinaryOpcode::powerDeriv:
|
case BinaryOpcode::powerDeriv:
|
||||||
if (IS_C(output_type))
|
if (isCOutput(output_type))
|
||||||
// In C, power operator is of the form pow(a, b)
|
// In C, power operator is of the form pow(a, b)
|
||||||
return 100;
|
return 100;
|
||||||
else
|
else
|
||||||
|
@ -4216,11 +4216,11 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
// Treat derivative of Power
|
// Treat derivative of Power
|
||||||
if (op_code == BinaryOpcode::powerDeriv)
|
if (op_code == BinaryOpcode::powerDeriv)
|
||||||
{
|
{
|
||||||
if (IS_LATEX(output_type))
|
if (isLatexOutput(output_type))
|
||||||
unpackPowerDeriv()->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
|
unpackPowerDeriv()->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (output_type == oJuliaStaticModel || output_type == oJuliaDynamicModel)
|
if (output_type == ExprNodeOutputType::juliaStaticModel || output_type == ExprNodeOutputType::juliaDynamicModel)
|
||||||
output << "get_power_deriv(";
|
output << "get_power_deriv(";
|
||||||
else
|
else
|
||||||
output << "getPowerDeriv(";
|
output << "getPowerDeriv(";
|
||||||
|
@ -4233,7 +4233,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Treat special case of power operator in C, and case of max and min operators
|
// Treat special case of power operator in C, and case of max and min operators
|
||||||
if ((op_code == BinaryOpcode::power && IS_C(output_type)) || op_code == BinaryOpcode::max || op_code == BinaryOpcode::min)
|
if ((op_code == BinaryOpcode::power && isCOutput(output_type)) || op_code == BinaryOpcode::max || op_code == BinaryOpcode::min)
|
||||||
{
|
{
|
||||||
switch (op_code)
|
switch (op_code)
|
||||||
{
|
{
|
||||||
|
@ -4260,7 +4260,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
|
|
||||||
bool close_parenthesis = false;
|
bool close_parenthesis = false;
|
||||||
|
|
||||||
if (IS_LATEX(output_type) && op_code == BinaryOpcode::divide)
|
if (isLatexOutput(output_type) && op_code == BinaryOpcode::divide)
|
||||||
output << "\\frac{";
|
output << "\\frac{";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4280,7 +4280,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
if (close_parenthesis)
|
if (close_parenthesis)
|
||||||
output << RIGHT_PAR(output_type);
|
output << RIGHT_PAR(output_type);
|
||||||
|
|
||||||
if (IS_LATEX(output_type) && op_code == BinaryOpcode::divide)
|
if (isLatexOutput(output_type) && op_code == BinaryOpcode::divide)
|
||||||
output << "}";
|
output << "}";
|
||||||
|
|
||||||
// Write current operator symbol
|
// Write current operator symbol
|
||||||
|
@ -4293,13 +4293,13 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
output << "-";
|
output << "-";
|
||||||
break;
|
break;
|
||||||
case BinaryOpcode::times:
|
case BinaryOpcode::times:
|
||||||
if (IS_LATEX(output_type))
|
if (isLatexOutput(output_type))
|
||||||
output << "\\, ";
|
output << "\\, ";
|
||||||
else
|
else
|
||||||
output << "*";
|
output << "*";
|
||||||
break;
|
break;
|
||||||
case BinaryOpcode::divide:
|
case BinaryOpcode::divide:
|
||||||
if (!IS_LATEX(output_type))
|
if (!isLatexOutput(output_type))
|
||||||
output << "/";
|
output << "/";
|
||||||
break;
|
break;
|
||||||
case BinaryOpcode::power:
|
case BinaryOpcode::power:
|
||||||
|
@ -4312,13 +4312,13 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
output << ">";
|
output << ">";
|
||||||
break;
|
break;
|
||||||
case BinaryOpcode::lessEqual:
|
case BinaryOpcode::lessEqual:
|
||||||
if (IS_LATEX(output_type))
|
if (isLatexOutput(output_type))
|
||||||
output << "\\leq ";
|
output << "\\leq ";
|
||||||
else
|
else
|
||||||
output << "<=";
|
output << "<=";
|
||||||
break;
|
break;
|
||||||
case BinaryOpcode::greaterEqual:
|
case BinaryOpcode::greaterEqual:
|
||||||
if (IS_LATEX(output_type))
|
if (isLatexOutput(output_type))
|
||||||
output << "\\geq ";
|
output << "\\geq ";
|
||||||
else
|
else
|
||||||
output << ">=";
|
output << ">=";
|
||||||
|
@ -4327,11 +4327,11 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
output << "==";
|
output << "==";
|
||||||
break;
|
break;
|
||||||
case BinaryOpcode::different:
|
case BinaryOpcode::different:
|
||||||
if (IS_MATLAB(output_type))
|
if (isMatlabOutput(output_type))
|
||||||
output << "~=";
|
output << "~=";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (IS_C(output_type) || IS_JULIA(output_type))
|
if (isCOutput(output_type) || isJuliaOutput(output_type))
|
||||||
output << "!=";
|
output << "!=";
|
||||||
else
|
else
|
||||||
output << "\\neq ";
|
output << "\\neq ";
|
||||||
|
@ -4346,7 +4346,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
|
|
||||||
close_parenthesis = false;
|
close_parenthesis = false;
|
||||||
|
|
||||||
if (IS_LATEX(output_type) && (op_code == BinaryOpcode::power || op_code == BinaryOpcode::divide))
|
if (isLatexOutput(output_type) && (op_code == BinaryOpcode::power || op_code == BinaryOpcode::divide))
|
||||||
output << "{";
|
output << "{";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4358,9 +4358,9 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
auto *barg2 = dynamic_cast<BinaryOpNode *>(arg2);
|
auto *barg2 = dynamic_cast<BinaryOpNode *>(arg2);
|
||||||
int arg2_prec = arg2->precedence(output_type, temporary_terms);
|
int arg2_prec = arg2->precedence(output_type, temporary_terms);
|
||||||
if (arg2_prec < prec
|
if (arg2_prec < prec
|
||||||
|| (op_code == BinaryOpcode::power && barg2 != nullptr && barg2->op_code == BinaryOpcode::power && !IS_LATEX(output_type))
|
|| (op_code == BinaryOpcode::power && barg2 != nullptr && barg2->op_code == BinaryOpcode::power && !isLatexOutput(output_type))
|
||||||
|| (op_code == BinaryOpcode::minus && arg2_prec == prec)
|
|| (op_code == BinaryOpcode::minus && arg2_prec == prec)
|
||||||
|| (op_code == BinaryOpcode::divide && arg2_prec == prec && !IS_LATEX(output_type)))
|
|| (op_code == BinaryOpcode::divide && arg2_prec == prec && !isLatexOutput(output_type)))
|
||||||
{
|
{
|
||||||
output << LEFT_PAR(output_type);
|
output << LEFT_PAR(output_type);
|
||||||
close_parenthesis = true;
|
close_parenthesis = true;
|
||||||
|
@ -4370,7 +4370,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
// Write right argument
|
// Write right argument
|
||||||
arg2->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
|
arg2->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
|
||||||
|
|
||||||
if (IS_LATEX(output_type) && (op_code == BinaryOpcode::power || op_code == BinaryOpcode::divide))
|
if (isLatexOutput(output_type) && (op_code == BinaryOpcode::power || op_code == BinaryOpcode::divide))
|
||||||
output << "}";
|
output << "}";
|
||||||
|
|
||||||
if (close_parenthesis)
|
if (close_parenthesis)
|
||||||
|
@ -5830,7 +5830,7 @@ TrinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
switch (op_code)
|
switch (op_code)
|
||||||
{
|
{
|
||||||
case TrinaryOpcode::normcdf:
|
case TrinaryOpcode::normcdf:
|
||||||
if (IS_C(output_type))
|
if (isCOutput(output_type))
|
||||||
{
|
{
|
||||||
// In C, there is no normcdf() primitive, so use erf()
|
// In C, there is no normcdf() primitive, so use erf()
|
||||||
output << "(0.5*(1+erf(((";
|
output << "(0.5*(1+erf(((";
|
||||||
|
@ -5853,7 +5853,7 @@ TrinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TrinaryOpcode::normpdf:
|
case TrinaryOpcode::normpdf:
|
||||||
if (IS_C(output_type))
|
if (isCOutput(output_type))
|
||||||
{
|
{
|
||||||
//(1/(v3*sqrt(2*M_PI)*exp(pow((v1-v2)/v3,2)/2)))
|
//(1/(v3*sqrt(2*M_PI)*exp(pow((v1-v2)/v3,2)/2)))
|
||||||
output << "(1/(";
|
output << "(1/(";
|
||||||
|
@ -7121,11 +7121,11 @@ ExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType output_typ
|
||||||
const temporary_terms_idxs_t &temporary_terms_idxs,
|
const temporary_terms_idxs_t &temporary_terms_idxs,
|
||||||
const deriv_node_temp_terms_t &tef_terms) const
|
const deriv_node_temp_terms_t &tef_terms) const
|
||||||
{
|
{
|
||||||
if (output_type == oMatlabOutsideModel || output_type == oSteadyStateFile
|
if (output_type == ExprNodeOutputType::matlabOutsideModel || output_type == ExprNodeOutputType::steadyStateFile
|
||||||
|| output_type == oJuliaSteadyStateFile
|
|| output_type == ExprNodeOutputType::juliaSteadyStateFile
|
||||||
|| IS_LATEX(output_type))
|
|| isLatexOutput(output_type))
|
||||||
{
|
{
|
||||||
string name = IS_LATEX(output_type) ? datatree.symbol_table.getTeXName(symb_id)
|
string name = isLatexOutput(output_type) ? datatree.symbol_table.getTeXName(symb_id)
|
||||||
: datatree.symbol_table.getName(symb_id);
|
: datatree.symbol_table.getName(symb_id);
|
||||||
output << name << "(";
|
output << name << "(";
|
||||||
writeExternalFunctionArguments(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
|
writeExternalFunctionArguments(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
|
||||||
|
@ -7136,7 +7136,7 @@ ExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType output_typ
|
||||||
if (checkIfTemporaryTermThenWrite(output, output_type, temporary_terms, temporary_terms_idxs))
|
if (checkIfTemporaryTermThenWrite(output, output_type, temporary_terms, temporary_terms_idxs))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (IS_C(output_type))
|
if (isCOutput(output_type))
|
||||||
output << "*";
|
output << "*";
|
||||||
output << "TEF_" << getIndxInTefTerms(symb_id, tef_terms);
|
output << "TEF_" << getIndxInTefTerms(symb_id, tef_terms);
|
||||||
}
|
}
|
||||||
|
@ -7160,7 +7160,7 @@ ExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutpu
|
||||||
int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
|
int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
|
||||||
assert(second_deriv_symb_id != eExtFunSetButNoNameProvided);
|
assert(second_deriv_symb_id != eExtFunSetButNoNameProvided);
|
||||||
|
|
||||||
if (IS_C(output_type))
|
if (isCOutput(output_type))
|
||||||
{
|
{
|
||||||
stringstream ending;
|
stringstream ending;
|
||||||
ending << "_tef_" << getIndxInTefTerms(symb_id, tef_terms);
|
ending << "_tef_" << getIndxInTefTerms(symb_id, tef_terms);
|
||||||
|
@ -7367,9 +7367,9 @@ FirstDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType
|
||||||
const temporary_terms_idxs_t &temporary_terms_idxs,
|
const temporary_terms_idxs_t &temporary_terms_idxs,
|
||||||
const deriv_node_temp_terms_t &tef_terms) const
|
const deriv_node_temp_terms_t &tef_terms) const
|
||||||
{
|
{
|
||||||
assert(output_type != oMatlabOutsideModel);
|
assert(output_type != ExprNodeOutputType::matlabOutsideModel);
|
||||||
|
|
||||||
if (IS_LATEX(output_type))
|
if (isLatexOutput(output_type))
|
||||||
{
|
{
|
||||||
output << "\\frac{\\partial " << datatree.symbol_table.getTeXName(symb_id)
|
output << "\\frac{\\partial " << datatree.symbol_table.getTeXName(symb_id)
|
||||||
<< "}{\\partial " << inputIndex << "}(";
|
<< "}{\\partial " << inputIndex << "}(";
|
||||||
|
@ -7391,7 +7391,7 @@ FirstDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType
|
||||||
<< LEFT_ARRAY_SUBSCRIPT(output_type) << tmpIndx << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
<< LEFT_ARRAY_SUBSCRIPT(output_type) << tmpIndx << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
else if (first_deriv_symb_id == eExtFunNotSet)
|
else if (first_deriv_symb_id == eExtFunNotSet)
|
||||||
{
|
{
|
||||||
if (IS_C(output_type))
|
if (isCOutput(output_type))
|
||||||
output << "*";
|
output << "*";
|
||||||
output << "TEFD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex;
|
output << "TEFD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex;
|
||||||
}
|
}
|
||||||
|
@ -7444,7 +7444,7 @@ FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Exp
|
||||||
const temporary_terms_idxs_t &temporary_terms_idxs,
|
const temporary_terms_idxs_t &temporary_terms_idxs,
|
||||||
deriv_node_temp_terms_t &tef_terms) const
|
deriv_node_temp_terms_t &tef_terms) const
|
||||||
{
|
{
|
||||||
assert(output_type != oMatlabOutsideModel);
|
assert(output_type != ExprNodeOutputType::matlabOutsideModel);
|
||||||
int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id);
|
int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id);
|
||||||
assert(first_deriv_symb_id != eExtFunSetButNoNameProvided);
|
assert(first_deriv_symb_id != eExtFunSetButNoNameProvided);
|
||||||
|
|
||||||
|
@ -7461,7 +7461,7 @@ FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Exp
|
||||||
if (alreadyWrittenAsTefTerm(first_deriv_symb_id, tef_terms))
|
if (alreadyWrittenAsTefTerm(first_deriv_symb_id, tef_terms))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (IS_C(output_type))
|
if (isCOutput(output_type))
|
||||||
if (first_deriv_symb_id == eExtFunNotSet)
|
if (first_deriv_symb_id == eExtFunNotSet)
|
||||||
{
|
{
|
||||||
stringstream ending;
|
stringstream ending;
|
||||||
|
@ -7748,9 +7748,9 @@ SecondDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType
|
||||||
const temporary_terms_idxs_t &temporary_terms_idxs,
|
const temporary_terms_idxs_t &temporary_terms_idxs,
|
||||||
const deriv_node_temp_terms_t &tef_terms) const
|
const deriv_node_temp_terms_t &tef_terms) const
|
||||||
{
|
{
|
||||||
assert(output_type != oMatlabOutsideModel);
|
assert(output_type != ExprNodeOutputType::matlabOutsideModel);
|
||||||
|
|
||||||
if (IS_LATEX(output_type))
|
if (isLatexOutput(output_type))
|
||||||
{
|
{
|
||||||
output << "\\frac{\\partial^2 " << datatree.symbol_table.getTeXName(symb_id)
|
output << "\\frac{\\partial^2 " << datatree.symbol_table.getTeXName(symb_id)
|
||||||
<< "}{\\partial " << inputIndex1 << "\\partial " << inputIndex2 << "}(";
|
<< "}{\\partial " << inputIndex1 << "\\partial " << inputIndex2 << "}(";
|
||||||
|
@ -7770,7 +7770,7 @@ SecondDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType
|
||||||
|
|
||||||
int indx = getIndxInTefTerms(symb_id, tef_terms);
|
int indx = getIndxInTefTerms(symb_id, tef_terms);
|
||||||
if (second_deriv_symb_id == symb_id)
|
if (second_deriv_symb_id == symb_id)
|
||||||
if (IS_C(output_type))
|
if (isCOutput(output_type))
|
||||||
output << "TEFDD_" << indx
|
output << "TEFDD_" << indx
|
||||||
<< LEFT_ARRAY_SUBSCRIPT(output_type) << tmpIndex1 << " * TEFDD_" << indx << "_nrows + "
|
<< LEFT_ARRAY_SUBSCRIPT(output_type) << tmpIndex1 << " * TEFDD_" << indx << "_nrows + "
|
||||||
<< tmpIndex2 << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
<< tmpIndex2 << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
|
@ -7779,12 +7779,12 @@ SecondDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType
|
||||||
<< LEFT_ARRAY_SUBSCRIPT(output_type) << tmpIndex1 << "," << tmpIndex2 << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
<< LEFT_ARRAY_SUBSCRIPT(output_type) << tmpIndex1 << "," << tmpIndex2 << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
else if (second_deriv_symb_id == eExtFunNotSet)
|
else if (second_deriv_symb_id == eExtFunNotSet)
|
||||||
{
|
{
|
||||||
if (IS_C(output_type))
|
if (isCOutput(output_type))
|
||||||
output << "*";
|
output << "*";
|
||||||
output << "TEFDD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex1 << "_" << inputIndex2;
|
output << "TEFDD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex1 << "_" << inputIndex2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (IS_C(output_type))
|
if (isCOutput(output_type))
|
||||||
output << "TEFDD_def_" << getIndxInTefTerms(second_deriv_symb_id, tef_terms)
|
output << "TEFDD_def_" << getIndxInTefTerms(second_deriv_symb_id, tef_terms)
|
||||||
<< LEFT_ARRAY_SUBSCRIPT(output_type) << tmpIndex1 << " * PROBLEM_" << indx << "_nrows"
|
<< LEFT_ARRAY_SUBSCRIPT(output_type) << tmpIndex1 << " * PROBLEM_" << indx << "_nrows"
|
||||||
<< tmpIndex2 << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
<< tmpIndex2 << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
|
@ -7799,7 +7799,7 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex
|
||||||
const temporary_terms_idxs_t &temporary_terms_idxs,
|
const temporary_terms_idxs_t &temporary_terms_idxs,
|
||||||
deriv_node_temp_terms_t &tef_terms) const
|
deriv_node_temp_terms_t &tef_terms) const
|
||||||
{
|
{
|
||||||
assert(output_type != oMatlabOutsideModel);
|
assert(output_type != ExprNodeOutputType::matlabOutsideModel);
|
||||||
int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
|
int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
|
||||||
assert(second_deriv_symb_id != eExtFunSetButNoNameProvided);
|
assert(second_deriv_symb_id != eExtFunSetButNoNameProvided);
|
||||||
|
|
||||||
|
@ -7816,7 +7816,7 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex
|
||||||
if (alreadyWrittenAsTefTerm(second_deriv_symb_id, tef_terms))
|
if (alreadyWrittenAsTefTerm(second_deriv_symb_id, tef_terms))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (IS_C(output_type))
|
if (isCOutput(output_type))
|
||||||
if (second_deriv_symb_id == eExtFunNotSet)
|
if (second_deriv_symb_id == eExtFunNotSet)
|
||||||
{
|
{
|
||||||
stringstream ending;
|
stringstream ending;
|
||||||
|
@ -8060,9 +8060,9 @@ VarExpectationNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
const temporary_terms_idxs_t &temporary_terms_idxs,
|
const temporary_terms_idxs_t &temporary_terms_idxs,
|
||||||
const deriv_node_temp_terms_t &tef_terms) const
|
const deriv_node_temp_terms_t &tef_terms) const
|
||||||
{
|
{
|
||||||
assert(output_type != oMatlabOutsideModel);
|
assert(output_type != ExprNodeOutputType::matlabOutsideModel);
|
||||||
|
|
||||||
if (IS_LATEX(output_type))
|
if (isLatexOutput(output_type))
|
||||||
{
|
{
|
||||||
output << "VAR_EXPECTATION(" << model_name << ')';
|
output << "VAR_EXPECTATION(" << model_name << ')';
|
||||||
return;
|
return;
|
||||||
|
@ -8505,9 +8505,9 @@ PacExpectationNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
const temporary_terms_idxs_t &temporary_terms_idxs,
|
const temporary_terms_idxs_t &temporary_terms_idxs,
|
||||||
const deriv_node_temp_terms_t &tef_terms) const
|
const deriv_node_temp_terms_t &tef_terms) const
|
||||||
{
|
{
|
||||||
assert(output_type != oMatlabOutsideModel);
|
assert(output_type != ExprNodeOutputType::matlabOutsideModel);
|
||||||
|
|
||||||
if (IS_LATEX(output_type))
|
if (isLatexOutput(output_type))
|
||||||
{
|
{
|
||||||
output << "PAC_EXPECTATION" << LEFT_PAR(output_type) << model_name << RIGHT_PAR(output_type);
|
output << "PAC_EXPECTATION" << LEFT_PAR(output_type) << model_name << RIGHT_PAR(output_type);
|
||||||
return;
|
return;
|
||||||
|
|
108
src/ExprNode.hh
108
src/ExprNode.hh
|
@ -67,65 +67,81 @@ using deriv_node_temp_terms_t = map<pair<int, vector<expr_t>>, int>;
|
||||||
using diff_table_t = map<expr_t, map<int, expr_t>>;
|
using diff_table_t = map<expr_t, map<int, expr_t>>;
|
||||||
|
|
||||||
//! Possible types of output when writing ExprNode(s)
|
//! Possible types of output when writing ExprNode(s)
|
||||||
enum ExprNodeOutputType
|
enum class ExprNodeOutputType
|
||||||
{
|
{
|
||||||
oMatlabStaticModel, //!< Matlab code, static model
|
matlabStaticModel, //!< Matlab code, static model
|
||||||
oMatlabDynamicModel, //!< Matlab code, dynamic model
|
matlabDynamicModel, //!< Matlab code, dynamic model
|
||||||
oMatlabStaticModelSparse, //!< Matlab code, static block decomposed model
|
matlabStaticModelSparse, //!< Matlab code, static block decomposed model
|
||||||
oMatlabDynamicModelSparse, //!< Matlab code, dynamic block decomposed model
|
matlabDynamicModelSparse, //!< Matlab code, dynamic block decomposed model
|
||||||
oCDynamicModel, //!< C code, dynamic model
|
CDynamicModel, //!< C code, dynamic model
|
||||||
oCStaticModel, //!< C code, static model
|
CStaticModel, //!< C code, static model
|
||||||
oJuliaStaticModel, //!< Julia code, static model
|
juliaStaticModel, //!< Julia code, static model
|
||||||
oJuliaDynamicModel, //!< Julia code, dynamic model
|
juliaDynamicModel, //!< Julia code, dynamic model
|
||||||
oMatlabOutsideModel, //!< Matlab code, outside model block (for example in initval)
|
matlabOutsideModel, //!< Matlab code, outside model block (for example in initval)
|
||||||
oLatexStaticModel, //!< LaTeX code, static model
|
latexStaticModel, //!< LaTeX code, static model
|
||||||
oLatexDynamicModel, //!< LaTeX code, dynamic model
|
latexDynamicModel, //!< LaTeX code, dynamic model
|
||||||
oLatexDynamicSteadyStateOperator, //!< LaTeX code, dynamic model, inside a steady state operator
|
latexDynamicSteadyStateOperator, //!< LaTeX code, dynamic model, inside a steady state operator
|
||||||
oMatlabDynamicSteadyStateOperator, //!< Matlab code, dynamic model, inside a steady state operator
|
matlabDynamicSteadyStateOperator, //!< Matlab code, dynamic model, inside a steady state operator
|
||||||
oMatlabDynamicSparseSteadyStateOperator, //!< Matlab code, dynamic block decomposed model, inside a steady state operator
|
matlabDynamicSparseSteadyStateOperator, //!< Matlab code, dynamic block decomposed model, inside a steady state operator
|
||||||
oCDynamicSteadyStateOperator, //!< C code, dynamic model, inside a steady state operator
|
CDynamicSteadyStateOperator, //!< C code, dynamic model, inside a steady state operator
|
||||||
oJuliaDynamicSteadyStateOperator, //!< Julia code, dynamic model, inside a steady state operator
|
juliaDynamicSteadyStateOperator, //!< Julia code, dynamic model, inside a steady state operator
|
||||||
oSteadyStateFile, //!< Matlab code, in the generated steady state file
|
steadyStateFile, //!< Matlab code, in the generated steady state file
|
||||||
oJuliaSteadyStateFile, //!< Julia code, in the generated steady state file
|
juliaSteadyStateFile, //!< Julia code, in the generated steady state file
|
||||||
oMatlabDseries, //!< Matlab code for dseries
|
matlabDseries, //!< Matlab code for dseries
|
||||||
oEpilogueFile //!< Matlab code, in the generated epilogue file
|
epilogueFile //!< Matlab code, in the generated epilogue file
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IS_MATLAB(output_type) ((output_type) == oMatlabStaticModel \
|
inline bool
|
||||||
|| (output_type) == oMatlabDynamicModel \
|
isMatlabOutput(ExprNodeOutputType output_type)
|
||||||
|| (output_type) == oMatlabOutsideModel \
|
{
|
||||||
|| (output_type) == oMatlabStaticModelSparse \
|
return output_type == ExprNodeOutputType::matlabStaticModel
|
||||||
|| (output_type) == oMatlabDynamicModelSparse \
|
|| output_type == ExprNodeOutputType::matlabDynamicModel
|
||||||
|| (output_type) == oMatlabDynamicSteadyStateOperator \
|
|| output_type == ExprNodeOutputType::matlabOutsideModel
|
||||||
|| (output_type) == oMatlabDynamicSparseSteadyStateOperator \
|
|| output_type == ExprNodeOutputType::matlabStaticModelSparse
|
||||||
|| (output_type) == oSteadyStateFile \
|
|| output_type == ExprNodeOutputType::matlabDynamicModelSparse
|
||||||
|| (output_type) == oMatlabDseries \
|
|| output_type == ExprNodeOutputType::matlabDynamicSteadyStateOperator
|
||||||
|| (output_type) == oEpilogueFile)
|
|| output_type == ExprNodeOutputType::matlabDynamicSparseSteadyStateOperator
|
||||||
|
|| output_type == ExprNodeOutputType::steadyStateFile
|
||||||
|
|| output_type == ExprNodeOutputType::matlabDseries
|
||||||
|
|| output_type == ExprNodeOutputType::epilogueFile;
|
||||||
|
}
|
||||||
|
|
||||||
#define IS_JULIA(output_type) ((output_type) == oJuliaStaticModel \
|
inline bool
|
||||||
|| (output_type) == oJuliaDynamicModel \
|
isJuliaOutput(ExprNodeOutputType output_type)
|
||||||
|| (output_type) == oJuliaDynamicSteadyStateOperator \
|
{
|
||||||
|| (output_type) == oJuliaSteadyStateFile)
|
return output_type == ExprNodeOutputType::juliaStaticModel
|
||||||
|
|| output_type == ExprNodeOutputType::juliaDynamicModel
|
||||||
|
|| output_type == ExprNodeOutputType::juliaDynamicSteadyStateOperator
|
||||||
|
|| output_type == ExprNodeOutputType::juliaSteadyStateFile;
|
||||||
|
}
|
||||||
|
|
||||||
#define IS_C(output_type) ((output_type) == oCDynamicModel \
|
inline bool
|
||||||
|| (output_type) == oCStaticModel \
|
isCOutput(ExprNodeOutputType output_type)
|
||||||
|| (output_type) == oCDynamicSteadyStateOperator)
|
{
|
||||||
|
return output_type == ExprNodeOutputType::CDynamicModel
|
||||||
|
|| output_type == ExprNodeOutputType::CStaticModel
|
||||||
|
|| output_type == ExprNodeOutputType::CDynamicSteadyStateOperator;
|
||||||
|
}
|
||||||
|
|
||||||
#define IS_LATEX(output_type) ((output_type) == oLatexStaticModel \
|
inline bool
|
||||||
|| (output_type) == oLatexDynamicModel \
|
isLatexOutput(ExprNodeOutputType output_type)
|
||||||
|| (output_type) == oLatexDynamicSteadyStateOperator)
|
{
|
||||||
|
return output_type == ExprNodeOutputType::latexStaticModel
|
||||||
|
|| output_type == ExprNodeOutputType::latexDynamicModel
|
||||||
|
|| output_type == ExprNodeOutputType::latexDynamicSteadyStateOperator;
|
||||||
|
}
|
||||||
|
|
||||||
/* Equal to 1 for Matlab langage or Julia, or to 0 for C language. Not defined for LaTeX.
|
/* Equal to 1 for Matlab langage or Julia, or to 0 for C language. Not defined for LaTeX.
|
||||||
In Matlab and Julia, array indexes begin at 1, while they begin at 0 in C */
|
In Matlab and Julia, array indexes begin at 1, while they begin at 0 in C */
|
||||||
#define ARRAY_SUBSCRIPT_OFFSET(output_type) ((int) (IS_MATLAB(output_type) || IS_JULIA(output_type)))
|
#define ARRAY_SUBSCRIPT_OFFSET(output_type) ((int) (isMatlabOutput(output_type) || isJuliaOutput(output_type)))
|
||||||
|
|
||||||
// Left and right array subscript delimiters: '(' and ')' for Matlab, '[' and ']' for C
|
// Left and right array subscript delimiters: '(' and ')' for Matlab, '[' and ']' for C
|
||||||
#define LEFT_ARRAY_SUBSCRIPT(output_type) (IS_MATLAB(output_type) ? '(' : '[')
|
#define LEFT_ARRAY_SUBSCRIPT(output_type) (isMatlabOutput(output_type) ? '(' : '[')
|
||||||
#define RIGHT_ARRAY_SUBSCRIPT(output_type) (IS_MATLAB(output_type) ? ')' : ']')
|
#define RIGHT_ARRAY_SUBSCRIPT(output_type) (isMatlabOutput(output_type) ? ')' : ']')
|
||||||
|
|
||||||
// Left and right parentheses
|
// Left and right parentheses
|
||||||
#define LEFT_PAR(output_type) (IS_LATEX(output_type) ? "\\left(" : "(")
|
#define LEFT_PAR(output_type) (isLatexOutput(output_type) ? "\\left(" : "(")
|
||||||
#define RIGHT_PAR(output_type) (IS_LATEX(output_type) ? "\\right)" : ")")
|
#define RIGHT_PAR(output_type) (isLatexOutput(output_type) ? "\\right)" : ")")
|
||||||
|
|
||||||
//! Base class for expression nodes
|
//! Base class for expression nodes
|
||||||
class ExprNode
|
class ExprNode
|
||||||
|
|
|
@ -1009,19 +1009,19 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
|
||||||
auto ivs = dynamic_cast<InitValStatement *>(statement.get());
|
auto ivs = dynamic_cast<InitValStatement *>(statement.get());
|
||||||
if (ivs != nullptr)
|
if (ivs != nullptr)
|
||||||
{
|
{
|
||||||
static_model.writeAuxVarInitval(mOutputFile, oMatlabOutsideModel);
|
static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
|
||||||
ivs->writeOutputPostInit(mOutputFile);
|
ivs->writeOutputPostInit(mOutputFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special treatment for endval block: insert initial values for the auxiliary variables
|
// Special treatment for endval block: insert initial values for the auxiliary variables
|
||||||
auto evs = dynamic_cast<EndValStatement *>(statement.get());
|
auto evs = dynamic_cast<EndValStatement *>(statement.get());
|
||||||
if (evs != nullptr)
|
if (evs != nullptr)
|
||||||
static_model.writeAuxVarInitval(mOutputFile, oMatlabOutsideModel);
|
static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
|
||||||
|
|
||||||
// Special treatment for load params and steady state statement: insert initial values for the auxiliary variables
|
// Special treatment for load params and steady state statement: insert initial values for the auxiliary variables
|
||||||
auto lpass = dynamic_cast<LoadParamsAndSteadyStateStatement *>(statement.get());
|
auto lpass = dynamic_cast<LoadParamsAndSteadyStateStatement *>(statement.get());
|
||||||
if (lpass && !no_static)
|
if (lpass && !no_static)
|
||||||
static_model.writeAuxVarInitval(mOutputFile, oMatlabOutsideModel);
|
static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
mOutputFile << "save('" << basename << "_results.mat', 'oo_', 'M_', 'options_');" << endl
|
mOutputFile << "save('" << basename << "_results.mat', 'oo_', 'M_', 'options_');" << endl
|
||||||
|
|
|
@ -147,7 +147,7 @@ SteadyStateModel::writeLatexSteadyStateFile(const string &basename) const
|
||||||
expr_t value = it.second;
|
expr_t value = it.second;
|
||||||
content_output << "\\begin{dmath}" << endl
|
content_output << "\\begin{dmath}" << endl
|
||||||
<< symbol_table.getTeXName(id) << " = ";
|
<< symbol_table.getTeXName(id) << " = ";
|
||||||
value->writeOutput(content_output, oLatexStaticModel);
|
value->writeOutput(content_output, ExprNodeOutputType::latexStaticModel);
|
||||||
content_output << endl << "\\end{dmath}" << endl;
|
content_output << endl << "\\end{dmath}" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool ramsey_model
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprNodeOutputType output_type = (julia ? oJuliaSteadyStateFile : oSteadyStateFile);
|
ExprNodeOutputType output_type = (julia ? ExprNodeOutputType::juliaSteadyStateFile : ExprNodeOutputType::steadyStateFile);
|
||||||
|
|
||||||
if (!julia)
|
if (!julia)
|
||||||
output << "function [ys_, params, info] = steadystate("
|
output << "function [ys_, params, info] = steadystate("
|
||||||
|
@ -328,7 +328,7 @@ Epilogue::writeEpilogueFile(const string &basename) const
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprNodeOutputType output_type = oEpilogueFile;
|
ExprNodeOutputType output_type = ExprNodeOutputType::epilogueFile;
|
||||||
output << "function ds = epilogue(params, ds)" << endl
|
output << "function ds = epilogue(params, ds)" << endl
|
||||||
<< "% function ds = epilogue(params, ds)" << endl
|
<< "% function ds = epilogue(params, ds)" << endl
|
||||||
<< "% Epilogue file generated by Dynare preprocessor" << endl << endl
|
<< "% Epilogue file generated by Dynare preprocessor" << endl << endl
|
||||||
|
|
|
@ -279,7 +279,7 @@ ModelTree::evaluateAndReduceJacobian(const eval_context_t &eval_context, jacob_m
|
||||||
catch (ExprNode::EvalException &e)
|
catch (ExprNode::EvalException &e)
|
||||||
{
|
{
|
||||||
cerr << "ERROR: evaluation of Jacobian failed for equation " << eq+1 << " (line " << equations_lineno[eq] << ") and variable " << symbol_table.getName(symb) << "(" << lag << ") [" << symb << "] !" << endl;
|
cerr << "ERROR: evaluation of Jacobian failed for equation " << eq+1 << " (line " << equations_lineno[eq] << ") and variable " << symbol_table.getName(symb) << "(" << lag << ") [" << symb << "] !" << endl;
|
||||||
Id->writeOutput(cerr, oMatlabDynamicModelSparse, temporary_terms, {});
|
Id->writeOutput(cerr, ExprNodeOutputType::matlabDynamicModelSparse, temporary_terms, {});
|
||||||
cerr << endl;
|
cerr << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -1193,16 +1193,16 @@ ModelTree::writeModelLocalVariableTemporaryTerms(const temporary_terms_t &tto, c
|
||||||
temporary_terms_t tt2;
|
temporary_terms_t tt2;
|
||||||
for (auto it : tt)
|
for (auto it : tt)
|
||||||
{
|
{
|
||||||
if (IS_C(output_type))
|
if (isCOutput(output_type))
|
||||||
output << "double ";
|
output << "double ";
|
||||||
else if (IS_JULIA(output_type))
|
else if (isJuliaOutput(output_type))
|
||||||
output << " @inbounds const ";
|
output << " @inbounds const ";
|
||||||
|
|
||||||
it.first->writeOutput(output, output_type, tto, temporary_terms_idxs, tef_terms);
|
it.first->writeOutput(output, output_type, tto, temporary_terms_idxs, tef_terms);
|
||||||
output << " = ";
|
output << " = ";
|
||||||
it.second->writeOutput(output, output_type, tt2, temporary_terms_idxs, tef_terms);
|
it.second->writeOutput(output, output_type, tt2, temporary_terms_idxs, tef_terms);
|
||||||
|
|
||||||
if (IS_C(output_type) || IS_MATLAB(output_type))
|
if (isCOutput(output_type) || isMatlabOutput(output_type))
|
||||||
output << ";";
|
output << ";";
|
||||||
output << endl;
|
output << endl;
|
||||||
|
|
||||||
|
@ -1225,16 +1225,16 @@ ModelTree::writeTemporaryTerms(const temporary_terms_t &tt,
|
||||||
if (dynamic_cast<AbstractExternalFunctionNode *>(*it) != nullptr)
|
if (dynamic_cast<AbstractExternalFunctionNode *>(*it) != nullptr)
|
||||||
(*it)->writeExternalFunctionOutput(output, output_type, tt2, tt_idxs, tef_terms);
|
(*it)->writeExternalFunctionOutput(output, output_type, tt2, tt_idxs, tef_terms);
|
||||||
|
|
||||||
if (IS_C(output_type))
|
if (isCOutput(output_type))
|
||||||
output << "double ";
|
output << "double ";
|
||||||
else if (IS_JULIA(output_type))
|
else if (isJuliaOutput(output_type))
|
||||||
output << " @inbounds ";
|
output << " @inbounds ";
|
||||||
|
|
||||||
(*it)->writeOutput(output, output_type, tt, tt_idxs, tef_terms);
|
(*it)->writeOutput(output, output_type, tt, tt_idxs, tef_terms);
|
||||||
output << " = ";
|
output << " = ";
|
||||||
(*it)->writeOutput(output, output_type, tt2, tt_idxs, tef_terms);
|
(*it)->writeOutput(output, output_type, tt2, tt_idxs, tef_terms);
|
||||||
|
|
||||||
if (IS_C(output_type) || IS_MATLAB(output_type))
|
if (isCOutput(output_type) || isMatlabOutput(output_type))
|
||||||
output << ";";
|
output << ";";
|
||||||
output << endl;
|
output << endl;
|
||||||
|
|
||||||
|
@ -1527,7 +1527,7 @@ ModelTree::writeModelEquations(ostream &output, ExprNodeOutputType output_type,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vrhs != 0) // The right hand side of the equation is not empty ==> residual=lhs-rhs;
|
if (vrhs != 0) // The right hand side of the equation is not empty ==> residual=lhs-rhs;
|
||||||
if (IS_JULIA(output_type))
|
if (isJuliaOutput(output_type))
|
||||||
{
|
{
|
||||||
output << " @inbounds residual" << LEFT_ARRAY_SUBSCRIPT(output_type)
|
output << " @inbounds residual" << LEFT_ARRAY_SUBSCRIPT(output_type)
|
||||||
<< eq + ARRAY_SUBSCRIPT_OFFSET(output_type)
|
<< eq + ARRAY_SUBSCRIPT_OFFSET(output_type)
|
||||||
|
@ -1553,7 +1553,7 @@ ModelTree::writeModelEquations(ostream &output, ExprNodeOutputType output_type,
|
||||||
}
|
}
|
||||||
else // The right hand side of the equation is empty ==> residual=lhs;
|
else // The right hand side of the equation is empty ==> residual=lhs;
|
||||||
{
|
{
|
||||||
if (IS_JULIA(output_type))
|
if (isJuliaOutput(output_type))
|
||||||
output << " @inbounds ";
|
output << " @inbounds ";
|
||||||
output << "residual" << LEFT_ARRAY_SUBSCRIPT(output_type)
|
output << "residual" << LEFT_ARRAY_SUBSCRIPT(output_type)
|
||||||
<< eq + ARRAY_SUBSCRIPT_OFFSET(output_type)
|
<< eq + ARRAY_SUBSCRIPT_OFFSET(output_type)
|
||||||
|
@ -1801,10 +1801,10 @@ ModelTree::set_cutoff_to_zero()
|
||||||
void
|
void
|
||||||
ModelTree::jacobianHelper(ostream &output, int eq_nb, int col_nb, ExprNodeOutputType output_type) const
|
ModelTree::jacobianHelper(ostream &output, int eq_nb, int col_nb, ExprNodeOutputType output_type) const
|
||||||
{
|
{
|
||||||
if (IS_JULIA(output_type))
|
if (isJuliaOutput(output_type))
|
||||||
output << " @inbounds ";
|
output << " @inbounds ";
|
||||||
output << "g1" << LEFT_ARRAY_SUBSCRIPT(output_type);
|
output << "g1" << LEFT_ARRAY_SUBSCRIPT(output_type);
|
||||||
if (IS_MATLAB(output_type) || IS_JULIA(output_type))
|
if (isMatlabOutput(output_type) || isJuliaOutput(output_type))
|
||||||
output << eq_nb + 1 << "," << col_nb + 1;
|
output << eq_nb + 1 << "," << col_nb + 1;
|
||||||
else
|
else
|
||||||
output << eq_nb + col_nb *equations.size();
|
output << eq_nb + col_nb *equations.size();
|
||||||
|
@ -1815,7 +1815,7 @@ void
|
||||||
ModelTree::sparseHelper(int order, ostream &output, int row_nb, int col_nb, ExprNodeOutputType output_type) const
|
ModelTree::sparseHelper(int order, ostream &output, int row_nb, int col_nb, ExprNodeOutputType output_type) const
|
||||||
{
|
{
|
||||||
output << "v" << order << LEFT_ARRAY_SUBSCRIPT(output_type);
|
output << "v" << order << LEFT_ARRAY_SUBSCRIPT(output_type);
|
||||||
if (IS_MATLAB(output_type) || IS_JULIA(output_type))
|
if (isMatlabOutput(output_type) || isJuliaOutput(output_type))
|
||||||
output << row_nb + 1 << "," << col_nb + 1;
|
output << row_nb + 1 << "," << col_nb + 1;
|
||||||
else
|
else
|
||||||
output << row_nb + col_nb * NNZDerivatives[order-1];
|
output << row_nb + col_nb * NNZDerivatives[order-1];
|
||||||
|
|
|
@ -203,7 +203,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &basename) const
|
||||||
deriv_node_temp_terms_t tef_terms;
|
deriv_node_temp_terms_t tef_terms;
|
||||||
ExprNodeOutputType local_output_type;
|
ExprNodeOutputType local_output_type;
|
||||||
|
|
||||||
local_output_type = oMatlabStaticModelSparse;
|
local_output_type = ExprNodeOutputType::matlabStaticModelSparse;
|
||||||
if (global_temporary_terms)
|
if (global_temporary_terms)
|
||||||
local_temporary_terms = temporary_terms;
|
local_temporary_terms = temporary_terms;
|
||||||
|
|
||||||
|
@ -1343,8 +1343,8 @@ StaticModel::writeStaticModel(const string &basename,
|
||||||
ostringstream third_derivatives_output; // Used for storing third order derivatives equations
|
ostringstream third_derivatives_output; // Used for storing third order derivatives equations
|
||||||
ostringstream for_sym;
|
ostringstream for_sym;
|
||||||
|
|
||||||
ExprNodeOutputType output_type = (use_dll ? oCStaticModel :
|
ExprNodeOutputType output_type = (use_dll ? ExprNodeOutputType::CStaticModel :
|
||||||
julia ? oJuliaStaticModel : oMatlabStaticModel);
|
julia ? ExprNodeOutputType::juliaStaticModel : ExprNodeOutputType::matlabStaticModel);
|
||||||
|
|
||||||
deriv_node_temp_terms_t tef_terms;
|
deriv_node_temp_terms_t tef_terms;
|
||||||
temporary_terms_t temp_term_union;
|
temporary_terms_t temp_term_union;
|
||||||
|
@ -1415,7 +1415,7 @@ StaticModel::writeStaticModel(const string &basename,
|
||||||
int col_nb = tsid1*symbol_table.endo_nbr()+tsid2;
|
int col_nb = tsid1*symbol_table.endo_nbr()+tsid2;
|
||||||
int col_nb_sym = tsid2*symbol_table.endo_nbr()+tsid1;
|
int col_nb_sym = tsid2*symbol_table.endo_nbr()+tsid1;
|
||||||
|
|
||||||
if (output_type == oJuliaStaticModel)
|
if (output_type == ExprNodeOutputType::juliaStaticModel)
|
||||||
{
|
{
|
||||||
for_sym << "g2[" << eq + 1 << "," << col_nb + 1 << "]";
|
for_sym << "g2[" << eq + 1 << "," << col_nb + 1 << "]";
|
||||||
hessian_output << " @inbounds " << for_sym.str() << " = ";
|
hessian_output << " @inbounds " << for_sym.str() << " = ";
|
||||||
|
@ -1440,7 +1440,7 @@ StaticModel::writeStaticModel(const string &basename,
|
||||||
|
|
||||||
// Treating symetric elements
|
// Treating symetric elements
|
||||||
if (symb_id1 != symb_id2)
|
if (symb_id1 != symb_id2)
|
||||||
if (output_type == oJuliaStaticModel)
|
if (output_type == ExprNodeOutputType::juliaStaticModel)
|
||||||
hessian_output << " @inbounds g2[" << eq + 1 << "," << col_nb_sym + 1 << "] = "
|
hessian_output << " @inbounds g2[" << eq + 1 << "," << col_nb_sym + 1 << "] = "
|
||||||
<< for_sym.str() << endl;
|
<< for_sym.str() << endl;
|
||||||
else
|
else
|
||||||
|
@ -1484,7 +1484,7 @@ StaticModel::writeStaticModel(const string &basename,
|
||||||
// Reference column number for the g3 matrix
|
// Reference column number for the g3 matrix
|
||||||
int ref_col = id1 * hessianColsNbr + id2 * JacobianColsNbr + id3;
|
int ref_col = id1 * hessianColsNbr + id2 * JacobianColsNbr + id3;
|
||||||
|
|
||||||
if (output_type == oJuliaStaticModel)
|
if (output_type == ExprNodeOutputType::juliaStaticModel)
|
||||||
{
|
{
|
||||||
for_sym << "g3[" << eq + 1 << "," << ref_col + 1 << "]";
|
for_sym << "g3[" << eq + 1 << "," << ref_col + 1 << "]";
|
||||||
third_derivatives_output << " @inbounds " << for_sym.str() << " = ";
|
third_derivatives_output << " @inbounds " << for_sym.str() << " = ";
|
||||||
|
@ -1517,7 +1517,7 @@ StaticModel::writeStaticModel(const string &basename,
|
||||||
int k2 = 1; // Keeps the offset of the permutation relative to k
|
int k2 = 1; // Keeps the offset of the permutation relative to k
|
||||||
for (int col : cols)
|
for (int col : cols)
|
||||||
if (col != ref_col)
|
if (col != ref_col)
|
||||||
if (output_type == oJuliaStaticModel)
|
if (output_type == ExprNodeOutputType::juliaStaticModel)
|
||||||
third_derivatives_output << " @inbounds g3[" << eq + 1 << "," << col + 1 << "] = "
|
third_derivatives_output << " @inbounds g3[" << eq + 1 << "," << col + 1 << "] = "
|
||||||
<< for_sym.str() << endl;
|
<< for_sym.str() << endl;
|
||||||
else
|
else
|
||||||
|
@ -1539,7 +1539,7 @@ StaticModel::writeStaticModel(const string &basename,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output_type == oMatlabStaticModel)
|
if (output_type == ExprNodeOutputType::matlabStaticModel)
|
||||||
{
|
{
|
||||||
// Check that we don't have more than 32 nested parenthesis because Matlab does not suppor this. See Issue #1201
|
// Check that we don't have more than 32 nested parenthesis because Matlab does not suppor this. See Issue #1201
|
||||||
map<string, string> tmp_paren_vars;
|
map<string, string> tmp_paren_vars;
|
||||||
|
@ -1619,7 +1619,7 @@ StaticModel::writeStaticModel(const string &basename,
|
||||||
|
|
||||||
writeStaticMatlabCompatLayer(basename);
|
writeStaticMatlabCompatLayer(basename);
|
||||||
}
|
}
|
||||||
else if (output_type == oCStaticModel)
|
else if (output_type == ExprNodeOutputType::CStaticModel)
|
||||||
{
|
{
|
||||||
StaticOutput << "void Static(double *y, double *x, int nb_row_x, double *params, double *residual, double *g1, double *v2)" << endl
|
StaticOutput << "void Static(double *y, double *x, int nb_row_x, double *params, double *residual, double *g1, double *v2)" << endl
|
||||||
<< "{" << endl
|
<< "{" << endl
|
||||||
|
@ -2351,7 +2351,7 @@ StaticModel::collect_block_first_order_derivatives()
|
||||||
void
|
void
|
||||||
StaticModel::writeLatexFile(const string &basename, bool write_equation_tags) const
|
StaticModel::writeLatexFile(const string &basename, bool write_equation_tags) const
|
||||||
{
|
{
|
||||||
writeLatexModelFile(basename + "_static", oLatexStaticModel, write_equation_tags);
|
writeLatexModelFile(basename + "_static", ExprNodeOutputType::latexStaticModel, write_equation_tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2368,7 +2368,7 @@ void
|
||||||
StaticModel::writeSetAuxiliaryVariables(const string &basename, const bool julia) const
|
StaticModel::writeSetAuxiliaryVariables(const string &basename, const bool julia) const
|
||||||
{
|
{
|
||||||
ostringstream output_func_body;
|
ostringstream output_func_body;
|
||||||
writeAuxVarRecursiveDefinitions(output_func_body, oMatlabStaticModel);
|
writeAuxVarRecursiveDefinitions(output_func_body, ExprNodeOutputType::matlabStaticModel);
|
||||||
|
|
||||||
if (output_func_body.str().empty())
|
if (output_func_body.str().empty())
|
||||||
return;
|
return;
|
||||||
|
@ -2402,7 +2402,7 @@ StaticModel::writeAuxVarRecursiveDefinitions(ostream &output, ExprNodeOutputType
|
||||||
deriv_node_temp_terms_t tef_terms;
|
deriv_node_temp_terms_t tef_terms;
|
||||||
for (auto aux_equation : aux_equations)
|
for (auto aux_equation : aux_equations)
|
||||||
if (dynamic_cast<ExprNode *>(aux_equation)->containsExternalFunction())
|
if (dynamic_cast<ExprNode *>(aux_equation)->containsExternalFunction())
|
||||||
dynamic_cast<ExprNode *>(aux_equation)->writeExternalFunctionOutput(output, oMatlabStaticModel, {}, {}, tef_terms);
|
dynamic_cast<ExprNode *>(aux_equation)->writeExternalFunctionOutput(output, ExprNodeOutputType::matlabStaticModel, {}, {}, tef_terms);
|
||||||
for (auto aux_equation : aux_equations)
|
for (auto aux_equation : aux_equations)
|
||||||
{
|
{
|
||||||
dynamic_cast<ExprNode *>(aux_equation->substituteStaticAuxiliaryDefinition())->writeOutput(output, output_type);
|
dynamic_cast<ExprNode *>(aux_equation->substituteStaticAuxiliaryDefinition())->writeOutput(output, output_type);
|
||||||
|
@ -2418,12 +2418,12 @@ StaticModel::writeLatexAuxVarRecursiveDefinitions(ostream &output) const
|
||||||
temporary_terms_idxs_t temporary_terms_idxs;
|
temporary_terms_idxs_t temporary_terms_idxs;
|
||||||
for (auto aux_equation : aux_equations)
|
for (auto aux_equation : aux_equations)
|
||||||
if (dynamic_cast<ExprNode *>(aux_equation)->containsExternalFunction())
|
if (dynamic_cast<ExprNode *>(aux_equation)->containsExternalFunction())
|
||||||
dynamic_cast<ExprNode *>(aux_equation)->writeExternalFunctionOutput(output, oLatexStaticModel,
|
dynamic_cast<ExprNode *>(aux_equation)->writeExternalFunctionOutput(output, ExprNodeOutputType::latexStaticModel,
|
||||||
temporary_terms, temporary_terms_idxs, tef_terms);
|
temporary_terms, temporary_terms_idxs, tef_terms);
|
||||||
for (auto aux_equation : aux_equations)
|
for (auto aux_equation : aux_equations)
|
||||||
{
|
{
|
||||||
output << "\\begin{dmath}" << endl;
|
output << "\\begin{dmath}" << endl;
|
||||||
dynamic_cast<ExprNode *>(aux_equation->substituteStaticAuxiliaryDefinition())->writeOutput(output, oLatexStaticModel);
|
dynamic_cast<ExprNode *>(aux_equation->substituteStaticAuxiliaryDefinition())->writeOutput(output, ExprNodeOutputType::latexStaticModel);
|
||||||
output << endl << "\\end{dmath}" << endl;
|
output << endl << "\\end{dmath}" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2470,7 +2470,7 @@ StaticModel::writeParamsDerivativesFile(const string &basename, bool julia) cons
|
||||||
&& !hessian_params_derivatives.size())
|
&& !hessian_params_derivatives.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ExprNodeOutputType output_type = (julia ? oJuliaStaticModel : oMatlabStaticModel);
|
ExprNodeOutputType output_type = (julia ? ExprNodeOutputType::juliaStaticModel : ExprNodeOutputType::matlabStaticModel);
|
||||||
|
|
||||||
ostringstream model_local_vars_output; // Used for storing model local vars
|
ostringstream model_local_vars_output; // Used for storing model local vars
|
||||||
ostringstream model_output; // Used for storing model
|
ostringstream model_output; // Used for storing model
|
||||||
|
|
|
@ -371,7 +371,7 @@ SymbolTable::writeOutput(ostream &output) const noexcept(false)
|
||||||
output << "M_.aux_vars(" << i+1 << ").orig_expr = '\\mathbb{E}_{t"
|
output << "M_.aux_vars(" << i+1 << ").orig_expr = '\\mathbb{E}_{t"
|
||||||
<< (aux_vars[i].get_information_set() < 0 ? "" : "+")
|
<< (aux_vars[i].get_information_set() < 0 ? "" : "+")
|
||||||
<< aux_vars[i].get_information_set() << "}(";
|
<< aux_vars[i].get_information_set() << "}(";
|
||||||
aux_vars[i].get_expr_node()->writeOutput(output, oLatexDynamicModel);
|
aux_vars[i].get_expr_node()->writeOutput(output, ExprNodeOutputType::latexDynamicModel);
|
||||||
output << ")';" << endl;
|
output << ")';" << endl;
|
||||||
break;
|
break;
|
||||||
case AuxVarType::diff:
|
case AuxVarType::diff:
|
||||||
|
@ -1139,7 +1139,7 @@ SymbolTable::writeJuliaOutput(ostream &output) const noexcept(false)
|
||||||
output << "typemin(Int), typemin(Int), typemin(Int), \"\\mathbb{E}_{t"
|
output << "typemin(Int), typemin(Int), typemin(Int), \"\\mathbb{E}_{t"
|
||||||
<< (aux_var.get_information_set() < 0 ? "" : "+")
|
<< (aux_var.get_information_set() < 0 ? "" : "+")
|
||||||
<< aux_var.get_information_set() << "}(";
|
<< aux_var.get_information_set() << "}(";
|
||||||
aux_var.get_expr_node()->writeOutput(output, oLatexDynamicModel);
|
aux_var.get_expr_node()->writeOutput(output, ExprNodeOutputType::latexDynamicModel);
|
||||||
output << ")\"";
|
output << ")\"";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue