Commit e19a1486 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Convert ExprNodeOutputType into a class enum

Incidentally, replace the IS_* macros by inline functions.
parent c6d4cb88
......@@ -225,7 +225,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
ExprNodeOutputType local_output_type;
Ufoss.str("");
local_output_type = oMatlabDynamicModelSparse;
local_output_type = ExprNodeOutputType::matlabDynamicModelSparse;
if (global_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_recursive = block_size - block_mfs;
deriv_node_temp_terms_t tef_terms;
local_output_type = oMatlabDynamicModelSparse;
local_output_type = ExprNodeOutputType::matlabDynamicModelSparse;
if (global_temporary_terms)
local_temporary_terms = temporary_terms;
......@@ -415,7 +415,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
{
output << " ";
// 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;
}
}
......@@ -1803,7 +1803,7 @@ DynamicModel::writeSparseDynamicMFile(const string &basename) const
else
tmp_output << " ";
// 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)
mDynamicModelFile << " global " << tmp_output.str() << ";\n";
......@@ -1814,7 +1814,7 @@ DynamicModel::writeSparseDynamicMFile(const string &basename) const
{
tmp_output << " ";
// 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";
}
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_output; // Used for storing third order derivatives equations
ExprNodeOutputType output_type = (use_dll ? oCDynamicModel :
julia ? oJuliaDynamicModel : oMatlabDynamicModel);
ExprNodeOutputType output_type = (use_dll ? ExprNodeOutputType::CDynamicModel :
julia ? ExprNodeOutputType::juliaDynamicModel : ExprNodeOutputType::matlabDynamicModel);
deriv_node_temp_terms_t tef_terms;
temporary_terms_t temp_term_union;
......@@ -2366,7 +2366,7 @@ DynamicModel::writeDynamicModel(const string &basename, ostream &DynamicOutput,
int col_nb_sym = id2 * dynJacobianColsNbr + id1;
ostringstream for_sym;
if (output_type == oJuliaDynamicModel)
if (output_type == ExprNodeOutputType::juliaDynamicModel)
{
for_sym << "g2[" << eq + 1 << "," << col_nb + 1 << "]";
hessian_output << " @inbounds " << for_sym.str() << " = ";
......@@ -2391,7 +2391,7 @@ DynamicModel::writeDynamicModel(const string &basename, ostream &DynamicOutput,
// Treating symetric elements
if (id1 != id2)
if (output_type == oJuliaDynamicModel)
if (output_type == ExprNodeOutputType::juliaDynamicModel)
hessian_output << " @inbounds g2[" << eq + 1 << "," << col_nb_sym + 1 << "] = "
<< for_sym.str() << endl;
else
......@@ -2436,7 +2436,7 @@ DynamicModel::writeDynamicModel(const string &basename, ostream &DynamicOutput,
int ref_col = id1 * hessianColsNbr + id2 * dynJacobianColsNbr + id3;
ostringstream for_sym;
if (output_type == oJuliaDynamicModel)
if (output_type == ExprNodeOutputType::juliaDynamicModel)
{
for_sym << "g3[" << eq + 1 << "," << ref_col + 1 << "]";
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
for (int col : cols)
if (col != ref_col)
if (output_type == oJuliaDynamicModel)
if (output_type == ExprNodeOutputType::juliaDynamicModel)
third_derivatives_output << " @inbounds g3[" << eq + 1 << "," << col + 1 << "] = "
<< for_sym.str() << endl;
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
map<string, string> tmp_paren_vars;
......@@ -2565,7 +2565,7 @@ DynamicModel::writeDynamicModel(const string &basename, ostream &DynamicOutput,
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
<< "{" << endl
......@@ -3428,7 +3428,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
// Write PacExpectationInfo
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>
......@@ -4652,7 +4652,7 @@ void
DynamicModel::writeSetAuxiliaryVariables(const string &basename, const bool julia) const
{
ostringstream output_func_body;
writeAuxVarRecursiveDefinitions(output_func_body, oMatlabDseries);
writeAuxVarRecursiveDefinitions(output_func_body, ExprNodeOutputType::matlabDseries);
if (output_func_body.str().empty())
return;
......@@ -5185,7 +5185,7 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
&& !hessian_params_derivatives.size())
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_output; // Used for storing model temp vars and equations
ostringstream jacobian_output; // Used for storing jacobian equations
......@@ -5422,13 +5422,13 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
void
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
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
......@@ -5908,7 +5908,7 @@ DynamicModel::isChecksumMatching(const string &basename) const
<< equation_tag.second.first
<< equation_tag.second.second;
ExprNodeOutputType buffer_type = oCDynamicModel;
ExprNodeOutputType buffer_type = ExprNodeOutputType::CDynamicModel;
for (int eq = 0; eq < (int) equations.size(); eq++)
{
......
......@@ -104,10 +104,10 @@ ExprNode::checkIfTemporaryTermThenWrite(ostream &output, ExprNodeOutputType outp
if (it == temporary_terms.end())
return false;
if (output_type == oMatlabDynamicModelSparse)
if (output_type == ExprNodeOutputType::matlabDynamicModelSparse)
output << "T" << idx << "(it_)";
else
if (output_type == oMatlabStaticModelSparse || IS_C(output_type))
if (output_type == ExprNodeOutputType::matlabStaticModelSparse || isCOutput(output_type))
output << "T" << idx;
else
{
......@@ -177,7 +177,7 @@ ExprNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr_t>>
void
ExprNode::writeOutput(ostream &output) const
{
writeOutput(output, oMatlabOutsideModel, {}, {});
writeOutput(output, ExprNodeOutputType::matlabOutsideModel, {}, {});
}
void
......@@ -827,12 +827,12 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
if (checkIfTemporaryTermThenWrite(output, output_type, temporary_terms, temporary_terms_idxs))
return;
if (IS_LATEX(output_type))
if (isLatexOutput(output_type))
{
if (output_type == oLatexDynamicSteadyStateOperator)
if (output_type == ExprNodeOutputType::latexDynamicSteadyStateOperator)
output << "\\bar";
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))
{
output << "_{t";
......@@ -854,16 +854,16 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
{
case SymbolType::parameter:
case SymbolType::parameterEpilogue:
if (output_type == oMatlabOutsideModel)
if (output_type == ExprNodeOutputType::matlabOutsideModel)
output << "M_.params" << "(" << tsid + 1 << ")";
else
output << "params" << LEFT_ARRAY_SUBSCRIPT(output_type) << tsid + ARRAY_SUBSCRIPT_OFFSET(output_type) << RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case SymbolType::modelLocalVariable:
if (output_type == oMatlabDynamicModelSparse || output_type == oMatlabStaticModelSparse
|| output_type == oMatlabDynamicSteadyStateOperator || output_type == oMatlabDynamicSparseSteadyStateOperator
|| output_type == oCDynamicSteadyStateOperator)
if (output_type == ExprNodeOutputType::matlabDynamicModelSparse || output_type == ExprNodeOutputType::matlabStaticModelSparse
|| output_type == ExprNodeOutputType::matlabDynamicSteadyStateOperator || output_type == ExprNodeOutputType::matlabDynamicSparseSteadyStateOperator
|| output_type == ExprNodeOutputType::CDynamicSteadyStateOperator)
{
output << "(";
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:
switch (output_type)
{
case oJuliaDynamicModel:
case oMatlabDynamicModel:
case oCDynamicModel:
case ExprNodeOutputType::juliaDynamicModel:
case ExprNodeOutputType::matlabDynamicModel:
case ExprNodeOutputType::CDynamicModel:
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);
break;
case oCStaticModel:
case oJuliaStaticModel:
case oMatlabStaticModel:
case oMatlabStaticModelSparse:
case ExprNodeOutputType::CStaticModel:
case ExprNodeOutputType::juliaStaticModel:
case ExprNodeOutputType::matlabStaticModel:
case ExprNodeOutputType::matlabStaticModelSparse:
i = tsid + ARRAY_SUBSCRIPT_OFFSET(output_type);
output << "y" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case oMatlabDynamicModelSparse:
case ExprNodeOutputType::matlabDynamicModelSparse:
i = tsid + ARRAY_SUBSCRIPT_OFFSET(output_type);
if (lag > 0)
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
output << "y" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_, " << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case oMatlabOutsideModel:
case ExprNodeOutputType::matlabOutsideModel:
output << "oo_.steady_state(" << tsid + 1 << ")";
break;
case oJuliaDynamicSteadyStateOperator:
case oMatlabDynamicSteadyStateOperator:
case oMatlabDynamicSparseSteadyStateOperator:
case ExprNodeOutputType::juliaDynamicSteadyStateOperator:
case ExprNodeOutputType::matlabDynamicSteadyStateOperator:
case ExprNodeOutputType::matlabDynamicSparseSteadyStateOperator:
output << "steady_state" << LEFT_ARRAY_SUBSCRIPT(output_type) << tsid + 1 << RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case oCDynamicSteadyStateOperator:
case ExprNodeOutputType::CDynamicSteadyStateOperator:
output << "steady_state[" << tsid << "]";
break;
case oJuliaSteadyStateFile:
case oSteadyStateFile:
case ExprNodeOutputType::juliaSteadyStateFile:
case ExprNodeOutputType::steadyStateFile:
output << "ys_" << LEFT_ARRAY_SUBSCRIPT(output_type) << tsid + 1 << RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case oMatlabDseries:
case ExprNodeOutputType::matlabDseries:
output << "ds." << datatree.symbol_table.getName(symb_id);
if (lag != 0)
output << LEFT_ARRAY_SUBSCRIPT(output_type) << lag << RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case oEpilogueFile:
case ExprNodeOutputType::epilogueFile:
output << datatree.symbol_table.getName(symb_id)
<< LEFT_ARRAY_SUBSCRIPT(output_type) << "epilogue_it__";
if (lag != 0)
......@@ -941,9 +941,9 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
i = tsid + ARRAY_SUBSCRIPT_OFFSET(output_type);
switch (output_type)
{
case oJuliaDynamicModel:
case oMatlabDynamicModel:
case oMatlabDynamicModelSparse:
case ExprNodeOutputType::juliaDynamicModel:
case ExprNodeOutputType::matlabDynamicModel:
case ExprNodeOutputType::matlabDynamicModelSparse:
if (lag > 0)
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_+" << lag << ", " << i
<< 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
<< RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case oCDynamicModel:
case ExprNodeOutputType::CDynamicModel:
if (lag == 0)
output << "x[it_+" << i << "*nb_row_x]";
else if (lag > 0)
......@@ -962,29 +962,29 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
else
output << "x[it_" << lag << "+" << i << "*nb_row_x]";
break;
case oCStaticModel:
case oJuliaStaticModel:
case oMatlabStaticModel:
case oMatlabStaticModelSparse:
case ExprNodeOutputType::CStaticModel:
case ExprNodeOutputType::juliaStaticModel:
case ExprNodeOutputType::matlabStaticModel:
case ExprNodeOutputType::matlabStaticModelSparse:
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case oMatlabOutsideModel:
case ExprNodeOutputType::matlabOutsideModel:
assert(lag == 0);
output << "oo_.exo_steady_state(" << i << ")";
break;
case oMatlabDynamicSteadyStateOperator:
case ExprNodeOutputType::matlabDynamicSteadyStateOperator:
output << "oo_.exo_steady_state(" << i << ")";
break;
case oJuliaSteadyStateFile:
case oSteadyStateFile:
case ExprNodeOutputType::juliaSteadyStateFile:
case ExprNodeOutputType::steadyStateFile:
output << "exo_" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case oMatlabDseries:
case ExprNodeOutputType::matlabDseries:
output << "ds." << datatree.symbol_table.getName(symb_id);
if (lag != 0)
output << LEFT_ARRAY_SUBSCRIPT(output_type) << lag << RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case oEpilogueFile:
case ExprNodeOutputType::epilogueFile:
output << datatree.symbol_table.getName(symb_id)
<< LEFT_ARRAY_SUBSCRIPT(output_type) << "epilogue_it__";
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);
switch (output_type)
{
case oJuliaDynamicModel:
case oMatlabDynamicModel:
case oMatlabDynamicModelSparse:
case ExprNodeOutputType::juliaDynamicModel:
case ExprNodeOutputType::matlabDynamicModel:
case ExprNodeOutputType::matlabDynamicModelSparse:
if (lag > 0)
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << "it_+" << lag << ", " << i
<< 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
<< RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case oCDynamicModel:
case ExprNodeOutputType::CDynamicModel:
if (lag == 0)
output << "x[it_+" << i << "*nb_row_x]";
else if (lag > 0)
......@@ -1022,29 +1022,29 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
else
output << "x[it_" << lag << "+" << i << "*nb_row_x]";
break;
case oCStaticModel:
case oJuliaStaticModel:
case oMatlabStaticModel:
case oMatlabStaticModelSparse:
case ExprNodeOutputType::CStaticModel:
case ExprNodeOutputType::juliaStaticModel:
case ExprNodeOutputType::matlabStaticModel:
case ExprNodeOutputType::matlabStaticModelSparse:
output << "x" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case oMatlabOutsideModel:
case ExprNodeOutputType::matlabOutsideModel:
assert(lag == 0);
output << "oo_.exo_det_steady_state(" << tsid + 1 << ")";
break;
case oMatlabDynamicSteadyStateOperator:
case ExprNodeOutputType::matlabDynamicSteadyStateOperator:
output << "oo_.exo_det_steady_state(" << tsid + 1 << ")";
break;
case oJuliaSteadyStateFile:
case oSteadyStateFile:
case ExprNodeOutputType::juliaSteadyStateFile:
case ExprNodeOutputType::steadyStateFile:
output << "exo_" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case oMatlabDseries:
case ExprNodeOutputType::matlabDseries:
output << "ds." << datatree.symbol_table.getName(symb_id);
if (lag != 0)
output << LEFT_ARRAY_SUBSCRIPT(output_type) << lag << RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case oEpilogueFile:
case ExprNodeOutputType::epilogueFile:
output << datatree.symbol_table.getName(symb_id)
<< LEFT_ARRAY_SUBSCRIPT(output_type) << "epilogue_it__";
if (lag != 0)
......@@ -2467,13 +2467,13 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
output << "exp";
break;
case UnaryOpcode::log:
if (IS_LATEX(output_type))
if (isLatexOutput(output_type))
output << "\\log";
else
output << "log";
break;
case UnaryOpcode::log10:
if (IS_LATEX(output_type))
if (isLatexOutput(output_type))
output << "\\log_{10}";
else
output << "log10";
......@@ -2521,7 +2521,7 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
output << "abs";
break;
case UnaryOpcode::sign:
if (output_type == oCDynamicModel || output_type == oCStaticModel)
if (output_type == ExprNodeOutputType::CDynamicModel || output_type == ExprNodeOutputType::CStaticModel)
output << "copysign";
else
output << "sign";
......@@ -2530,20 +2530,20 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
ExprNodeOutputType new_output_type;
switch (output_type)
{
case oMatlabDynamicModel:
new_output_type = oMatlabDynamicSteadyStateOperator;
case ExprNodeOutputType::matlabDynamicModel:
new_output_type = ExprNodeOutputType::matlabDynamicSteadyStateOperator;
break;
case oLatexDynamicModel:
new_output_type = oLatexDynamicSteadyStateOperator;
case ExprNodeOutputType::latexDynamicModel:
new_output_type = ExprNodeOutputType::latexDynamicSteadyStateOperator;
break;
case oCDynamicModel:
new_output_type = oCDynamicSteadyStateOperator;
case ExprNodeOutputType::CDynamicModel:
new_output_type = ExprNodeOutputType::CDynamicSteadyStateOperator;
break;
case oJuliaDynamicModel:
new_output_type = oJuliaDynamicSteadyStateOperator;
case ExprNodeOutputType::juliaDynamicModel:
new_output_type = ExprNodeOutputType::juliaDynamicSteadyStateOperator;
break;
case oMatlabDynamicModelSparse:
new_output_type = oMatlabDynamicSparseSteadyStateOperator;
case ExprNodeOutputType::matlabDynamicModelSparse:
new_output_type = ExprNodeOutputType::matlabDynamicSparseSteadyStateOperator;
break;
default:
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);
int tsid_endo = datatree.symbol_table.getTypeSpecificID(varg->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 << ")";
}
return;
......@@ -2575,13 +2575,13 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
int tsid_endo = datatree.symbol_table.getTypeSpecificID(varg->symb_id);
int tsid_param1 = datatree.symbol_table.getTypeSpecificID(param1_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
<< "," << tsid_param2+1 << ")";
}
return;
case UnaryOpcode::expectation:
if (!IS_LATEX(output_type))
if (!isLatexOutput(output_type))
{
cerr << "UnaryOpNode::writeOutput: not implemented on UnaryOpcode::expectation" << endl;
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)))
{
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,";
close_parenthesis = true;
}
......@@ -3761,7 +3761,7 @@ BinaryOpNode::precedence(ExprNodeOutputType output_type, const temporary_terms_t
return 4;
case BinaryOpcode::power:
case BinaryOpcode::powerDeriv:
if (IS_C(output_type))
if (isCOutput(output_type))
// In C, power operator is of the form pow(a, b)
return 100;
else
......@@ -4216,11 +4216,11 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
// Treat derivative of Power
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);
else
{
if (output_type == oJuliaStaticModel || output_type == oJuliaDynamicModel)
if (output_type == ExprNodeOutputType::juliaStaticModel || output_type == ExprNodeOutputType::juliaDynamicModel)
output << "get_power_deriv(";
else
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
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)
{
......@@ -4260,7 +4260,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
bool close_parenthesis = false;
if (IS_LATEX(output_type) && op_code == BinaryOpcode::divide)
if (isLatexOutput(output_type) && op_code == BinaryOpcode::divide)
output << "\\frac{";
else
{
......@@ -4280,7 +4280,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
if (close_parenthesis)
output << RIGHT_PAR(output_type);
if (IS_LATEX(output_type) && op_code == BinaryOpcode::divide)
if (isLatexOutput(output_type) && op_code == BinaryOpcode::divide)
output << "}";
// Write current operator symbol
......@@ -4293,13 +4293,13 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
output << "-";
break;
case BinaryOpcode::times:
if (IS_LATEX(output_type))
if (isLatexOutput(output_type))
output << "\\, ";
else
output << "*";
break;
case BinaryOpcode::divide:
if (!IS_LATEX(output_type))
if (!isLatexOutput(output_type))
output << "/";
break;
case BinaryOpcode::power:
......@@ -4312,13 +4312,13 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
output << ">";
break;
case BinaryOpcode::lessEqual:
if (IS_LATEX(output_type))
if (isLatexOutput(output_type))
output << "\\leq ";
else
output << "<=";
break;
case BinaryOpcode::greaterEqual:
if (IS_LATEX(output_type))
if (isLatexOutput(output_type))
output << "\\geq ";
else
output << ">=";
......@@ -4327,11 +4327,11 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
output << "==";
break;
case BinaryOpcode::different:
if (IS_MATLAB(output_type))
if (isMatlabOutput(output_type))
output << "~=";
else
{
if (IS_C(output_type) || IS_JULIA(output_type))
if (isCOutput(output_type) || isJuliaOutput(output_type))
output << "!=";
else
output << "\\neq ";
......@@ -4346,7 +4346,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
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 << "{";
else
{
......@@ -4358,9 +4358,9 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
auto *barg2 = dynamic_cast<BinaryOpNode *>(arg2);
int arg2_prec = arg2->precedence(output_type, temporary_terms);
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::divide && arg2_prec == prec && !IS_LATEX(output_type)))
|| (op_code == BinaryOpcode::divide && arg2_prec == prec && !isLatexOutput(output_type)))
{
output << LEFT_PAR(output_type);
close_parenthesis = true;
......@@ -4370,7 +4370,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
// Write right argument
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 << "}";
if (close_parenthesis)
......@@ -5830,7 +5830,7 @@ TrinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
switch (op_code)
{
case TrinaryOpcode::normcdf:
if (IS_C(output_type))
if (isCOutput(output_type))
{
// In C, there is no normcdf() primitive, so use erf()
output << "(0.5*(1+erf(((";
......@@ -5853,7 +5853,7 @@ TrinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
}
break;
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)))
output << "(1/(";
......@@ -7121,11 +7121,11 @@ ExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType output_typ
const temporary_terms_idxs_t &temporary_terms_idxs,
const deriv_node_temp_terms_t &tef_terms) const
{
if (output_type == oMatlabOutsideModel || output_type == oSteadyStateFile
|| output_type == oJuliaSteadyStateFile
|| IS_LATEX(output_type))
if (output_type == ExprNodeOutputType::matlabOutsideModel || output_type == ExprNodeOutputType::steadyStateFile
|| output_type == ExprNodeOutputType::juliaSteadyStateFile
|| 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);
output << name << "(";
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))
return;
if (IS_C(output_type))
if (isCOutput(output_type))
output << "*";
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);
assert(second_deriv_symb_id != eExtFunSetButNoNameProvided);
if (IS_C(output_type))
if (isCOutput(output_type))
{
stringstream ending;
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 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)