From 4ff17d6191e8119e98d62a8bf3e8a9b0eb6d31c2 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Tue, 1 Dec 2015 11:41:55 +0100 Subject: [PATCH] Revert "preprocessor: write auxiliary variable definitions to matlab function" This reverts commit ad81129a9b90dab50799bd4589b635420918cf1f. --- preprocessor/DynamicModel.cc | 41 +----------------------------------- preprocessor/DynamicModel.hh | 3 +-- preprocessor/ModelTree.cc | 20 ------------------ preprocessor/ModelTree.hh | 3 +-- 4 files changed, 3 insertions(+), 64 deletions(-) diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc index a91bba7e8..cdc8f22d6 100644 --- a/preprocessor/DynamicModel.cc +++ b/preprocessor/DynamicModel.cc @@ -1515,42 +1515,6 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin code_file.close(); } -void -DynamicModel::writeDynamicAuxMFile(const string &dynamic_basename) const -{ - string filename = dynamic_basename + "_aux.m"; - ofstream mDynamicAuxFile; - mDynamicAuxFile.open(filename.c_str(), ios::out | ios::binary); - if (!mDynamicAuxFile.is_open()) - { - cerr << "Error: Can't open file " << filename << " for writing" << endl; - exit(EXIT_FAILURE); - } - mDynamicAuxFile << "function auxvars = " << dynamic_basename << "_aux(y, x, params, steady_state, it_)" - << endl - << "%" << endl - << "% Status : Computes auxiliary variables for Dynare" << endl - << "%" << endl - << "% Inputs :" << endl - << "% y [#dynamic variables by 1] double vector of endogenous variables in the order stored" << endl - << "% in M_.lead_lag_incidence; see the Manual" << endl - << "% x [nperiods by M_.exo_nbr] double matrix of exogenous variables (in declaration order)" << endl - << "% for all simulation periods" << endl - << "% params [M_.param_nbr by 1] double vector of parameter values in declaration order" << endl - << "% it_ scalar double time period for exogenous variables for which to evaluate the model" << endl - << "%" << endl - << "% Outputs:" << endl - << "% auxvars [length(M_.aux_vars) by 1] definitions of auxiliary variables" << endl - << "%" << endl - << "%" << endl - << "% Warning : this file is generated automatically by Dynare" << endl - << "% from the model file (.mod)" << endl << endl; - - writeModelAuxEquations(mDynamicAuxFile, oMatlabDynamicModel); - mDynamicAuxFile << "end" << endl; - mDynamicAuxFile.close(); -} - void DynamicModel::writeDynamicMFile(const string &dynamic_basename) const { @@ -3559,10 +3523,7 @@ DynamicModel::writeDynamicFile(const string &basename, bool block, bool bytecode else if (julia) writeDynamicJuliaFile(basename); else - { - writeDynamicMFile(t_basename); - writeDynamicAuxMFile(t_basename); - } + writeDynamicMFile(t_basename); } void diff --git a/preprocessor/DynamicModel.hh b/preprocessor/DynamicModel.hh index e2672800a..fbb18b222 100644 --- a/preprocessor/DynamicModel.hh +++ b/preprocessor/DynamicModel.hh @@ -73,8 +73,7 @@ private: //! Store the derivatives or the chainrule derivatives:map, expr_t> typedef map< pair< int, pair< int, int> >, expr_t> first_chain_rule_derivatives_t; first_chain_rule_derivatives_t first_chain_rule_derivatives; - //! Writes auxiliary equations file (Matlab version) - void writeDynamicAuxMFile(const string &dynamic_basename) const; + //! Writes dynamic model file (Matlab version) void writeDynamicMFile(const string &dynamic_basename) const; //! Writes dynamic model file (Julia version) diff --git a/preprocessor/ModelTree.cc b/preprocessor/ModelTree.cc index f3704e110..21c2d509e 100644 --- a/preprocessor/ModelTree.cc +++ b/preprocessor/ModelTree.cc @@ -1264,26 +1264,6 @@ ModelTree::writeModelEquations(ostream &output, ExprNodeOutputType output_type) } } -void -ModelTree::writeModelAuxEquations(ostream &output, ExprNodeOutputType output_type) const -{ - int eq_ind = 0, av_ind = 0; - for (vector::const_iterator it = equations_lineno.begin(); - it != equations_lineno.end(); it++, eq_ind++) - if (*it == -1) - { - expr_t rhs = equations[eq_ind]->get_arg2(); - if (IS_JULIA(output_type)) - output << " @inbounds "; - output << "auxvars" << LEFT_ARRAY_SUBSCRIPT(output_type) - << av_ind++ + ARRAY_SUBSCRIPT_OFFSET(output_type) - << RIGHT_ARRAY_SUBSCRIPT(output_type) - << " = "; - rhs->writeOutput(output, output_type, temporary_terms_t()); - output << ";" << endl; - } -} - void ModelTree::compileModelEquations(ostream &code_file, unsigned int &instruction_number, const temporary_terms_t &tt, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const { diff --git a/preprocessor/ModelTree.hh b/preprocessor/ModelTree.hh index a485bcd8a..ea799585c 100644 --- a/preprocessor/ModelTree.hh +++ b/preprocessor/ModelTree.hh @@ -173,11 +173,10 @@ protected: void compileTemporaryTerms(ostream &code_file, unsigned int &instruction_number, const temporary_terms_t &tt, map_idx_t map_idx, bool dynamic, bool steady_dynamic) const; //! Adds informations for simulation in a binary file void Write_Inf_To_Bin_File(const string &basename, int &u_count_int, bool &file_open, bool is_two_boundaries, int block_mfs) const; + //! Writes model local variables /*! No temporary term is used in the output, so that local parameters declarations can be safely put before temporary terms declaration in the output files */ void writeModelLocalVariables(ostream &output, ExprNodeOutputType output_type, deriv_node_temp_terms_t &tef_terms) const; - //! Writes model auxiliary equations - void writeModelAuxEquations(ostream &output, ExprNodeOutputType output_type) const; //! Writes model equations void writeModelEquations(ostream &output, ExprNodeOutputType output_type) const; //! Compiles model equations