Commit 08eedcb4 authored by Sébastien Villemot's avatar Sébastien Villemot

Add const qualifier for tef_terms in writeOutput method and siblings

Consequently, change various function calls where tef_terms was empty, passing
an (empty) rvalue instead of an lvalue.
parent 33b280b3
......@@ -966,7 +966,6 @@ RamseyConstraintsStatement::writeOutput(ostream &output, const string &basename,
void
RamseyConstraintsStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"ramsey_constraints\""
<< ", \"ramsey_model_constraints\": [" << endl;
for (RamseyConstraintsStatement::constraints_t::const_iterator it = constraints.begin(); it != constraints.end(); ++it)
......@@ -993,7 +992,7 @@ RamseyConstraintsStatement::writeJsonOutput(ostream &output) const
exit(1);
}
output << " ";
it->expression->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->expression->writeJsonOutput(output, {}, {});
output << "\"}" << endl;
}
output << "]" << endl;
......@@ -1570,7 +1569,6 @@ EstimatedParamsStatement::writeOutput(ostream &output, const string &basename, b
void
EstimatedParamsStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"estimated_params\", "
<< "\"params\": [";
for (vector<EstimationParams>::const_iterator it = estim_params_list.begin(); it != estim_params_list.end(); it++)
......@@ -1593,23 +1591,23 @@ EstimatedParamsStatement::writeJsonOutput(ostream &output) const
}
output << ", \"init_val\": \"";
it->init_val->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->init_val->writeJsonOutput(output, {}, {});
output << "\", \"lower_bound\": \"";
it->low_bound->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->low_bound->writeJsonOutput(output, {}, {});
output << "\", \"upper_bound\": \"";
it->up_bound->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->up_bound->writeJsonOutput(output, {}, {});
output << "\", \"prior_distribution\": "
<< it->prior
<< ", \"mean\": \"";
it->mean->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->mean->writeJsonOutput(output, {}, {});
output << "\", \"std\": \"";
it->std->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->std->writeJsonOutput(output, {}, {});
output << "\", \"p3\": \"";
it->p3->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->p3->writeJsonOutput(output, {}, {});
output << "\", \"p4\": \"";
it->p4->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->p4->writeJsonOutput(output, {}, {});
output << "\", \"jscale\": \"";
it->jscale->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->jscale->writeJsonOutput(output, {}, {});
output << "\"}" << endl;
}
output << "]"
......@@ -1692,7 +1690,6 @@ EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basenam
void
EstimatedParamsInitStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"estimated_params_init\"";
if (use_calibration)
......@@ -1718,7 +1715,7 @@ EstimatedParamsInitStatement::writeJsonOutput(ostream &output) const
break;
}
output << ", \"init_val\": \"";
it->init_val->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->init_val->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......@@ -1814,7 +1811,6 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen
void
EstimatedParamsBoundsStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"estimated_params_bounds\", "
<< "\"params\": [";
......@@ -1836,9 +1832,9 @@ EstimatedParamsBoundsStatement::writeJsonOutput(ostream &output) const
break;
}
output << ", \"lower_bound\": ";
it->low_bound->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->low_bound->writeJsonOutput(output, {}, {});
output << ", \"upper_bound\": ";
it->up_bound->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->up_bound->writeJsonOutput(output, {}, {});
output << "}";
}
output << "]"
......@@ -1874,7 +1870,6 @@ ObservationTrendsStatement::writeOutput(ostream &output, const string &basename,
void
ObservationTrendsStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"observation_trends\", "
<< "\"trends\" : {";
bool printed = false;
......@@ -1886,7 +1881,7 @@ ObservationTrendsStatement::writeJsonOutput(ostream &output) const
if (printed)
output << ", ";
output << "\"" << it->first << "\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"" << endl;
printed = true;
}
......@@ -1977,7 +1972,6 @@ OsrParamsBoundsStatement::writeOutput(ostream &output, const string &basename, b
void
OsrParamsBoundsStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"osr_params_bounds\""
<< ", \"bounds\": [";
for (vector<OsrParams>::const_iterator it = osr_params_list.begin();
......@@ -1987,9 +1981,9 @@ OsrParamsBoundsStatement::writeJsonOutput(ostream &output) const
output << ", ";
output << "{\"parameter\": \"" << it->name << "\","
<< "\"bounds\": [\"";
it->low_bound->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->low_bound->writeJsonOutput(output, {}, {});
output << "\", \"";
it->up_bound->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->up_bound->writeJsonOutput(output, {}, {});
output << "\"]"
<< "}";
}
......@@ -2105,7 +2099,6 @@ OptimWeightsStatement::writeOutput(ostream &output, const string &basename, bool
void
OptimWeightsStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"optim_weights\", "
<< "\"weights\": [";
for (var_weights_t::const_iterator it = var_weights.begin();
......@@ -2115,7 +2108,7 @@ OptimWeightsStatement::writeJsonOutput(ostream &output) const
output << ", ";
output << "{\"name\": \"" << it->first << "\""
<< ", \"value\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
......@@ -2127,7 +2120,7 @@ OptimWeightsStatement::writeJsonOutput(ostream &output) const
output << "{\"name1\": \"" << it->first.first << "\""
<< ", \"name2\": \"" << it->first.second << "\""
<< ", \"value\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......@@ -3998,9 +3991,8 @@ BasicPriorStatement::writeJsonPriorOutput(ostream &output) const
writeJsonShape(output);
if (variance != NULL)
{
deriv_node_temp_terms_t tef_terms;
output << ", \"variance\": \"";
variance->writeJsonOutput(output, temporary_terms_t(), tef_terms);
variance->writeJsonOutput(output, {}, {});
output << "\"";
}
if (options_list.getNumberOfOptions())
......
......@@ -5895,9 +5895,6 @@ DynamicModel::writeResidualsC(const string &basename, bool cuda) const
mDynamicModelFile << "void Residuals(const double *y, double *x, int nb_row_x, double *params, double *steady_state, int it_, double *residual)" << endl
<< "{" << endl;
// this is always empty here, but needed by d1->writeOutput
deriv_node_temp_terms_t tef_terms;
ostringstream model_output; // Used for storing model equations
writeModelEquations(model_output, oCDynamic2Model);
......@@ -5950,9 +5947,6 @@ DynamicModel::writeFirstDerivativesC(const string &basename, bool cuda) const
mDynamicModelFile << "void FirstDerivatives(const 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;
// this is always empty here, but needed by d1->writeOutput
deriv_node_temp_terms_t tef_terms;
// Writing Jacobian
for (first_derivatives_t::const_iterator it = first_derivatives.begin();
it != first_derivatives.end(); it++)
......@@ -5965,7 +5959,7 @@ DynamicModel::writeFirstDerivativesC(const string &basename, bool cuda) const
mDynamicModelFile << "=";
// oCStaticModel makes reference to the static variables
// oCDynamicModel makes reference to the dynamic variables
d1->writeOutput(mDynamicModelFile, oCDynamicModel, temporary_terms, {}, tef_terms);
d1->writeOutput(mDynamicModelFile, oCDynamicModel, temporary_terms, {}, {});
mDynamicModelFile << ";" << endl;
}
......@@ -6014,8 +6008,6 @@ DynamicModel::writeFirstDerivativesC_csr(const string &basename, bool cuda) cons
<< "{" << endl;
int cols_nbr = 3*symbol_table.endo_nbr() + symbol_table.exo_nbr() + symbol_table.exo_det_nbr();
// this is always empty here, but needed by d1->writeOutput
deriv_node_temp_terms_t tef_terms;
// Indexing derivatives in column order
vector<derivative> D;
......@@ -6060,7 +6052,7 @@ DynamicModel::writeFirstDerivativesC_csr(const string &basename, bool cuda) cons
<< "=" << it->col_nbr << ";" << endl;
mDynamicModelFile << "value[" << k << "] = ";
// oCstaticModel makes reference to the static variables
it->value->writeOutput(mDynamicModelFile, oCDynamic2Model, temporary_terms, {}, tef_terms);
it->value->writeOutput(mDynamicModelFile, oCDynamic2Model, temporary_terms, {}, {});
mDynamicModelFile << ";" << endl;
k++;
}
......@@ -6119,9 +6111,6 @@ DynamicModel::writeSecondDerivativesC_csr(const string &basename, bool cuda) con
mDynamicModelFile << "void SecondDerivatives(const double *y, double *x, int nb_row_x, double *params, double *steady_state, int it_, double *residual, int *row_ptr, int *col_ptr, double *value)" << endl
<< "{" << endl;
// this is always empty here, but needed by d1->writeOutput
deriv_node_temp_terms_t tef_terms;
// Indexing derivatives in column order
vector<derivative> D;
int hessianColsNbr = dynJacobianColsNbr*dynJacobianColsNbr;
......@@ -6159,7 +6148,7 @@ DynamicModel::writeSecondDerivativesC_csr(const string &basename, bool cuda) con
<< "=" << it->col_nbr << ";" << endl;
mDynamicModelFile << "value[" << k << "] = ";
// oCstaticModel makes reference to the static variables
it->value->writeOutput(mDynamicModelFile, oCStaticModel, temporary_terms, {}, tef_terms);
it->value->writeOutput(mDynamicModelFile, oCStaticModel, temporary_terms, {}, {});
mDynamicModelFile << ";" << endl;
k++;
}
......@@ -6218,9 +6207,6 @@ DynamicModel::writeThirdDerivativesC_csr(const string &basename, bool cuda) cons
mDynamicModelFile << "void ThirdDerivatives(const 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;
// this is always empty here, but needed by d1->writeOutput
deriv_node_temp_terms_t tef_terms;
vector<derivative> D;
int hessianColsNbr = dynJacobianColsNbr*dynJacobianColsNbr;
int thirdDerivativesColsNbr = hessianColsNbr*dynJacobianColsNbr;
......@@ -6291,7 +6277,7 @@ DynamicModel::writeThirdDerivativesC_csr(const string &basename, bool cuda) cons
<< "=" << it->col_nbr << ";" << endl;
mDynamicModelFile << "value[" << k << "] = ";
// oCstaticModel makes reference to the static variables
it->value->writeOutput(mDynamicModelFile, oCStaticModel, temporary_terms, {}, tef_terms);
it->value->writeOutput(mDynamicModelFile, oCStaticModel, temporary_terms, {}, {});
mDynamicModelFile << ";" << endl;
k++;
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -2005,7 +2005,6 @@ ModelTree::isNonstationary(int symb_id) const
void
ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
{
deriv_node_temp_terms_t tef_terms;
vector<pair<string, string> > eqtags;
temporary_terms_t tt_empty;
if (residuals)
......@@ -2025,11 +2024,11 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
{
output << "{\"residual\": {"
<< "\"lhs\": \"";
lhs->writeJsonOutput(output, temporary_terms, tef_terms);
lhs->writeJsonOutput(output, temporary_terms, {});
output << "\"";
output << ", \"rhs\": \"";
rhs->writeJsonOutput(output, temporary_terms, tef_terms);
rhs->writeJsonOutput(output, temporary_terms, {});
output << "\"";
try
{
......@@ -2037,7 +2036,7 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
if (rhs->eval(eval_context_t()) != 0)
{
output << ", \"rhs\": \"";
rhs->writeJsonOutput(output, temporary_terms, tef_terms);
rhs->writeJsonOutput(output, temporary_terms, {});
output << "\"";
}
}
......@@ -2049,9 +2048,9 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
else
{
output << "{\"lhs\": \"";
lhs->writeJsonOutput(output, tt_empty, tef_terms);
lhs->writeJsonOutput(output, tt_empty, {});
output << "\", \"rhs\": \"";
rhs->writeJsonOutput(output, tt_empty, tef_terms);
rhs->writeJsonOutput(output, tt_empty, {});
output << "\""
<< ", \"line\": " << equations_lineno[eq];
......
......@@ -66,9 +66,8 @@ InitParamStatement::writeJuliaOutput(ostream &output, const string &basename)
void
InitParamStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"param_init\", \"name\": \"" << symbol_table.getName(symb_id) << "\", " << "\"value\": \"";
param_value->writeJsonOutput(output, temporary_terms_t(), tef_terms);
param_value->writeJsonOutput(output, {}, {});
output << "\"}";
}
......@@ -177,14 +176,13 @@ InitOrEndValStatement::writeInitValues(ostream &output) const
void
InitOrEndValStatement::writeJsonInitValues(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
for (init_values_t::const_iterator it = init_values.begin();
it != init_values.end(); it++)
{
if (it != init_values.begin())
output << ", ";
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\", " << "\"value\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
}
......@@ -419,7 +417,6 @@ HistValStatement::writeOutput(ostream &output, const string &basename, bool mini
void
HistValStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"hist_val\", \"vals\": [";
for (hist_values_t::const_iterator it = hist_values.begin();
it != hist_values.end(); it++)
......@@ -429,7 +426,7 @@ HistValStatement::writeJsonOutput(ostream &output) const
output << "{ \"name\": \"" << symbol_table.getName(it->first.first) << "\""
<< ", \"lag\": " << it->first.second
<< ", \"value\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]}";
......@@ -516,7 +513,6 @@ HomotopyStatement::writeOutput(ostream &output, const string &basename, bool min
void
HomotopyStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"homotopy\", "
<< "\"values\": [";
for (homotopy_values_t::const_iterator it = homotopy_values.begin();
......@@ -527,11 +523,11 @@ HomotopyStatement::writeJsonOutput(ostream &output) const
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\""
<< ", \"initial_value\": \"";
if (it->second.first != NULL)
it->second.first->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second.first->writeJsonOutput(output, {}, {});
else
output << "NaN";
output << "\", \"final_value\": \"";
it->second.second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second.second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......@@ -625,7 +621,6 @@ LoadParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &ba
void
LoadParamsAndSteadyStateStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"load_params_and_steady_state\""
<< "\"values\": [";
for (map<int, string>::const_iterator it = content.begin();
......
......@@ -70,7 +70,6 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const
void
AbstractShocksStatement::writeJsonDetShocks(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "\"deterministic_shocks\": [";
for (det_shocks_t::const_iterator it = det_shocks.begin();
it != det_shocks.end(); it++)
......@@ -87,7 +86,7 @@ AbstractShocksStatement::writeJsonDetShocks(ostream &output) const
output << "{\"period1\": " << it1->period1 << ", "
<< "\"period2\": " << it1->period2 << ", "
<< "\"value\": \"";
it1->value->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it1->value->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]}";
......@@ -154,7 +153,6 @@ ShocksStatement::writeOutput(ostream &output, const string &basename, bool minim
void
ShocksStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"shocks\""
<< ", \"overwrite\": ";
if (overwrite)
......@@ -173,7 +171,7 @@ ShocksStatement::writeJsonOutput(ostream &output) const
output << ", ";
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\", "
<< "\"variance\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......@@ -184,7 +182,7 @@ ShocksStatement::writeJsonOutput(ostream &output) const
output << ", ";
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\", "
<< "\"stderr\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......@@ -197,7 +195,7 @@ ShocksStatement::writeJsonOutput(ostream &output) const
<< "\"name\": \"" << symbol_table.getName(it->first.first) << "\", "
<< "\"name2\": \"" << symbol_table.getName(it->first.second) << "\", "
<< "\"covariance\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......@@ -210,7 +208,7 @@ ShocksStatement::writeJsonOutput(ostream &output) const
<< "\"name\": \"" << symbol_table.getName(it->first.first) << "\", "
<< "\"name2\": \"" << symbol_table.getName(it->first.second) << "\", "
<< "\"correlation\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......
......@@ -277,9 +277,7 @@ SteadyStateModel::writeJsonSteadyStateFile(ostream &output, bool transformComput
if (def_table.size() == 0)
return;
deriv_node_temp_terms_t tef_terms;
vector<pair<string, string> > eqtags;
temporary_terms_t tt_empty;
output << "{\"steady_state_model\": [";
......@@ -299,13 +297,13 @@ SteadyStateModel::writeJsonSteadyStateFile(ostream &output, bool transformComput
variable_node_map.find(make_pair(symb_ids[j], 0));
assert(it != variable_node_map.end());
output << "\"";
dynamic_cast<ExprNode *>(it->second)->writeJsonOutput(output, tt_empty, tef_terms, false);
dynamic_cast<ExprNode *>(it->second)->writeJsonOutput(output, {}, {}, false);
output << "\"";
}
if (symb_ids.size() > 1)
output << "]";
output << ", \"rhs\":\"";
def_table[i].second->writeJsonOutput(output, tt_empty, tef_terms, false);
def_table[i].second->writeJsonOutput(output, {}, {}, false);
output << "\"}" << endl;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment