-
Sébastien Villemot authored
This is necessary to enforce the documented behavior which says that, if a variable is not given a value in the endval block, a zero value is assumed.
Sébastien Villemot authoredThis is necessary to enforce the documented behavior which says that, if a variable is not given a value in the endval block, a zero value is assumed.
NumericalInitialization.cc 13.83 KiB
/*
* Copyright (C) 2003-2013 Dynare Team
*
* This file is part of Dynare.
*
* Dynare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dynare is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include "NumericalInitialization.hh"
InitParamStatement::InitParamStatement(int symb_id_arg,
const expr_t param_value_arg,
const SymbolTable &symbol_table_arg) :
symb_id(symb_id_arg),
param_value(param_value_arg),
symbol_table(symbol_table_arg)
{
}
void
InitParamStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
{
if (symbol_table.getName(symb_id) == "dsge_prior_weight")
mod_file_struct.dsge_prior_weight_initialized = true;
}
void
InitParamStatement::writeOutput(ostream &output, const string &basename) const
{
int id = symbol_table.getTypeSpecificID(symb_id) + 1;
output << "M_.params( " << id << " ) = ";
param_value->writeOutput(output);
output << ";" << endl;
output << symbol_table.getName(symb_id) << " = M_.params( " << id << " );\n";
}
void
InitParamStatement::fillEvalContext(eval_context_t &eval_context) const
{
try
{
eval_context[symb_id] = param_value->eval(eval_context);
}
catch (ExprNode::EvalException &e)
{
// Do nothing
}
}
InitOrEndValStatement::InitOrEndValStatement(const init_values_t &init_values_arg,
const SymbolTable &symbol_table_arg,
const bool &all_values_required_arg) :
init_values(init_values_arg),
symbol_table(symbol_table_arg),