diff --git a/others/cpp/dynare_cpp_driver.cc b/others/cpp/dynare_cpp_driver.cc new file mode 100644 index 000000000..da0a58e4d --- /dev/null +++ b/others/cpp/dynare_cpp_driver.cc @@ -0,0 +1,419 @@ +/* + * Copyright (C) 2011-2012 Houtan Bastani, Daniel Waggoner, Tao Zha + * + * This 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. + * + * This code 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. + * + * More information is available at . + */ + +#include +#include +#include +#include +#include + +using namespace std; + +#include "dynare_cpp_driver.hh" + +DynareInfo::DynareInfo(map exo_names_arg, + map exo_det_names_arg, + map endo_names_arg, + map param_names_arg, + vector< double > params_arg, + vector aux_vars_arg, + vector predetermined_variables_arg, + vector varobs_arg, + vector > lead_lag_incidence_arg, + vector NNZDerivatives_arg) : + exo_names(exo_names_arg), + exo_det_names(exo_det_names_arg), + endo_names(endo_names_arg), + param_names(param_names_arg), + params(params_arg), + aux_vars(aux_vars_arg), + predetermined_variables(predetermined_variables_arg), + varobs(varobs_arg), + lead_lag_incidence(lead_lag_incidence_arg), + NNZDerivatives(NNZDerivatives_arg) +{ +} + +DynareInfo::~DynareInfo() +{ + for (vector::iterator it = markov_switching_vector.begin(); + it < markov_switching_vector.end(); it++ ) + delete *it; + + for (vector::iterator it = prior_vector.begin(); + it < prior_vector.end(); it++ ) + delete *it; + + for (vector::iterator it = structural_innovation_prior_vector.begin(); + it < structural_innovation_prior_vector.end(); it++ ) + delete *it; + + for (vector::iterator it = measurement_error_prior_vector.begin(); + it < measurement_error_prior_vector.end(); it++ ) + delete *it; + + for (vector::iterator it = structural_innovation_corr_prior_vector.begin(); + it < structural_innovation_corr_prior_vector.end(); it++ ) + delete *it; + + for (vector::iterator it = measurement_error_corr_prior_vector.begin(); + it < measurement_error_corr_prior_vector.end(); it++ ) + delete *it; + + markov_switching_vector.clear(); + prior_vector.clear(); + structural_innovation_prior_vector.clear(); + measurement_error_prior_vector.clear(); + structural_innovation_corr_prior_vector.clear(); + measurement_error_corr_prior_vector.clear(); + exo_names.clear(); + exo_det_names.clear(); + endo_names.clear(); + param_names.clear(); + params.clear(); + aux_vars.clear(); + predetermined_variables.clear(); + varobs.clear(); + lead_lag_incidence.clear(); + NNZDerivatives.clear(); +} + +string +DynareInfo::get_exo_name_by_index(int index) throw (ValueNotSetException) +{ + for (map::iterator it = exo_names.begin(); + it != exo_names.end(); it++) + if (it->second == index) + return it->first; + throw ValueNotSetException("get_exo_name_by_index" + index); +} + +int +DynareInfo::get_exo_index_by_name(string name) throw (ValueNotSetException) +{ + map::iterator it = exo_names.find(name); + if (it != exo_names.end()) + return it->second; + throw ValueNotSetException("get_exo_name_by_name" + name); +} + +string +DynareInfo::get_exo_det_name_by_index(int index) throw (ValueNotSetException) +{ + for (map::iterator it = exo_det_names.begin(); + it != exo_det_names.end(); it++) + if (it->second == index) + return it->first; + throw ValueNotSetException("get_exo_det_name_by_index" + index); +} + +int +DynareInfo::get_exo_det_index_by_name(string name) throw (ValueNotSetException) +{ + map::iterator it = exo_det_names.find(name); + if (it != exo_det_names.end()) + return it->second; + throw ValueNotSetException("get_exo_det_name_by_name" + name); +} + +string +DynareInfo::get_endo_name_by_index(int index) throw (ValueNotSetException) +{ + for (map::iterator it = endo_names.begin(); + it != endo_names.end(); it++) + if (it->second == index) + return it->first; + throw ValueNotSetException("get_endo_name_by_index" + index); +} + +int +DynareInfo::get_endo_index_by_name(string name) throw (ValueNotSetException) +{ + map::iterator it = endo_names.find(name); + if (it != endo_names.end()) + return it->second; + throw ValueNotSetException("get_endo_name_by_name" + name); +} + +string +DynareInfo::get_param_name_by_index(int index) throw (ValueNotSetException) +{ + for (map::iterator it = param_names.begin(); + it != param_names.end(); it++) + if (it->second == index) + return it->first; + throw ValueNotSetException("get_param_name_by_index" + index); +} + +int +DynareInfo::get_param_index_by_name(string name) throw (ValueNotSetException) +{ + map::iterator it = param_names.find(name); + if (it != param_names.end()) + return it->second; + throw ValueNotSetException("get_param_name_by_name" + name); +} + +double +DynareInfo::get_param_value_by_index(int index) throw (ValueNotSetException) +{ + return params[index]; + // map::iterator it = params.find(index); + // if (it != params.end()) + // return it->second; + // throw ValueNotSetException("get_param_value_by_index" + index); +} + +vector +DynareInfo::get_lead_lag_incidence_for_endo_var_by_index(int index) throw (ValueNotSetException) +{ + if (index < lead_lag_incidence.size()) + return lead_lag_incidence.at(index); + throw ValueNotSetException("get_lead_lag_incidence_for_endo_var_by_index" + index); +} + +MarkovSwitching::MarkovSwitching(const int chain_arg, + const int number_of_regimes_arg, + const int number_of_lags_arg, + const bool number_of_lags_was_passed_arg, + const vector parameters_arg, + const vector duration_arg, + const restriction_map_t restriction_map_arg) : + chain(chain_arg), + number_of_regimes(number_of_regimes_arg), + number_of_lags(number_of_lags_arg), + number_of_lags_was_passed(number_of_lags_was_passed_arg), + parameters(parameters_arg), + duration(duration_arg), + restriction_map(restriction_map_arg) +{ + assert(chain >= 1); + assert(number_of_regimes > 0); + if (number_of_lags_was_passed) + assert(number_of_lags > 0); + assert(!parameters.empty()); + assert(!duration.empty()); +} + +int +MarkovSwitching::get_number_of_lags() throw (ValueNotSetException) +{ + if (number_of_lags_has_val()) + return number_of_lags; + throw ValueNotSetException("number_of_lags"); +} + +restriction_map_t +MarkovSwitching::get_restriction_map() throw (ValueNotSetException) +{ + if (restriction_map_has_val()) + return restriction_map; + throw ValueNotSetException("restriction_map"); +} + +BasicModFilePrior::BasicModFilePrior(const int index_arg, + const string shape_arg, + const double mean_arg, + const double mode_arg, + const double stdev_arg, + const double variance_arg, + const vector domain_arg) : + index(index_arg), + shape(shape_arg), + mean(mean_arg), + mode(mode_arg), + stdev(stdev_arg), + variance(variance_arg), + domain(domain_arg) +{ + assert(index >= 0); + assert(!shape.empty()); + if (stdev_has_val()) + assert(stdev >= 0); + if (variance_has_val()) + assert(variance >= 0); + if (domain_has_val()) + assert(domain.size() == 2); +} + +double +BasicModFilePrior::get_mean() throw (ValueNotSetException) +{ + if (mean_has_val()) + return mean; + throw ValueNotSetException("mean"); +}; + +double +BasicModFilePrior::get_mode() throw (ValueNotSetException) +{ + if (mode_has_val()) + return mode; + throw ValueNotSetException("mode"); +}; + +double +BasicModFilePrior::get_stdev() throw (ValueNotSetException) +{ + if (stdev_has_val()) + return stdev; + throw ValueNotSetException("stdev"); +}; + +double +BasicModFilePrior::get_variance() throw (ValueNotSetException) +{ + if (variance_has_val()) + return variance; + throw ValueNotSetException("variance"); +}; + +vector +BasicModFilePrior::get_domain() throw (ValueNotSetException) +{ + if (domain_has_val()) + return domain; + throw ValueNotSetException("domain"); +}; + +ModFilePrior::ModFilePrior(const int index_arg, + const string shape_arg, + const double mean_arg, + const double mode_arg, + const double stdev_arg, + const double variance_arg, + const vector domain_arg) : + BasicModFilePrior(index_arg, + shape_arg, + mean_arg, + mode_arg, + stdev_arg, + variance_arg, + domain_arg) +{ +} + +ModFileStructuralInnovationPrior::ModFileStructuralInnovationPrior(const int index_arg, + const string shape_arg, + const double mean_arg, + const double stdev_arg, + const double variance_arg, + const double mode_arg, + const vector domain_arg) : + BasicModFilePrior(index_arg, + shape_arg, + mean_arg, + mode_arg, + stdev_arg, + variance_arg, + domain_arg) +{ +} + +ModFileMeasurementErrorPrior::ModFileMeasurementErrorPrior(const int index_arg, + const string shape_arg, + const double mean_arg, + const double stdev_arg, + const double variance_arg, + const double mode_arg, + const vector domain_arg) : + BasicModFilePrior(index_arg, + shape_arg, + mean_arg, + mode_arg, + stdev_arg, + variance_arg, + domain_arg) +{ +} + +ModFileStructuralInnovationCorrPrior::ModFileStructuralInnovationCorrPrior(const int index1_arg, + const int index2_arg, + const string shape_arg, + const double mean_arg, + const double stdev_arg, + const double variance_arg, + const double mode_arg, + const vector domain_arg) : + BasicModFilePrior(index1_arg, + shape_arg, + mean_arg, + mode_arg, + stdev_arg, + variance_arg, + domain_arg), + index2(index2_arg) +{ + assert(index2 >= 0); +} + +ModFileMeasurementErrorCorrPrior::ModFileMeasurementErrorCorrPrior(const int index1_arg, + const int index2_arg, + const string shape_arg, + const double mean_arg, + const double stdev_arg, + const double variance_arg, + const double mode_arg, + const vector domain_arg) : + BasicModFilePrior(index1_arg, + shape_arg, + mean_arg, + mode_arg, + stdev_arg, + variance_arg, + domain_arg), + index2(index2_arg) +{ + assert(index2 >= 0); +} + +BasicModFileOption::BasicModFileOption(const int index_arg, + const double init_arg) : + index(index_arg), + init(init_arg) +{ + assert(index >= 0); + assert(!isnan(init)); +} + +ModFileOption::ModFileOption(const int index_arg, const double init_arg) : + BasicModFileOption(index_arg, init_arg) +{ +} + +ModFileStructuralInnovationOption::ModFileStructuralInnovationOption(const int index_arg, const double init_arg) : + BasicModFileOption(index_arg, init_arg) +{ +} + +ModFileMeasurementErrorOption::ModFileMeasurementErrorOption(const int index_arg, const double init_arg) : + BasicModFileOption(index_arg, init_arg) +{ +} + +ModFileStructuralInnovationCorrOption::ModFileStructuralInnovationCorrOption(const int index1_arg, const int index2_arg, const double init_arg) : + BasicModFileOption(index1_arg, init_arg), + index2(index2_arg) +{ + assert(index2 >= 0); +} + +ModFileMeasurementErrorCorrOption::ModFileMeasurementErrorCorrOption(const int index1_arg, const int index2_arg, const double init_arg) : + BasicModFileOption(index1_arg, init_arg), + index2(index2_arg) +{ + assert(index2 >= 0); +} diff --git a/others/cpp/dynare_cpp_driver.hh b/others/cpp/dynare_cpp_driver.hh new file mode 100644 index 000000000..d031fd0f9 --- /dev/null +++ b/others/cpp/dynare_cpp_driver.hh @@ -0,0 +1,323 @@ +/* + * Copyright (C) 2011-2012 Houtan Bastani, Daniel Waggoner, Tao Zha + * + * This 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. + * + * This code 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. + * + * More information is available at . + */ + +#ifndef _DYNARE_CPP_DRIVER_HH +#define _DYNARE_CPP_DRIVER_HH + +#include +#include +#include +#include +#include + +using namespace std; + +struct aux_vars_t { + int endo_index, type, orig_index, orig_lead_lag; +} ; + +typedef map, double> restriction_map_t ; + +class ValueNotSetException +{ +public: + string name; + ValueNotSetException(const string &name_arg) : name(name_arg) + { + } +}; + +class MarkovSwitching +{ +private: + const int chain, number_of_regimes, number_of_lags; + const bool number_of_lags_was_passed; + const vector parameters; + const vector duration; + const restriction_map_t restriction_map; +public: + MarkovSwitching(const int chain_arg, + const int number_of_regimes_arg, + const int number_of_lags_arg, + const bool number_of_lags_was_passed_arg, + const vector parameters_arg, + const vector duration_arg, + const restriction_map_t restriction_map_arg); + + inline bool number_of_lags_has_val() const { return number_of_lags_was_passed; }; + inline bool restriction_map_has_val() const { return !restriction_map.empty(); }; + + inline int get_chain() const { return chain; }; + inline int get_number_of_regimes() const { return number_of_regimes; }; + int get_number_of_lags() throw (ValueNotSetException); + inline vector get_parameters() { return parameters; }; + inline vector get_duration() { return duration; }; + restriction_map_t get_restriction_map() throw (ValueNotSetException); +}; + +class BasicModFilePrior +{ +private: + inline bool isnan(double x) const { return (x!=x); }; +protected: + const int index; + const string shape; + const double mean, mode, stdev, variance; + const vector domain; + + BasicModFilePrior(const int index_arg, + const string shape_arg, + const double mean_arg, + const double mode_arg, + const double stdev_arg, + const double variance_arg, + const vector domain_arg); +public: + inline bool mean_has_val() const { return !isnan(mean); }; + inline bool mode_has_val() const { return !isnan(mode); }; + inline bool stdev_has_val() const { return !isnan(stdev); }; + inline bool variance_has_val() const { return !isnan(variance); }; + inline bool domain_has_val() const { return (domain.size() == 2); }; + + inline int get_index() const { return index; }; + inline string get_shape() const { return shape; }; + double get_mean() throw (ValueNotSetException); + double get_mode() throw (ValueNotSetException); + double get_stdev() throw (ValueNotSetException); + double get_variance() throw (ValueNotSetException); + vector get_domain() throw (ValueNotSetException); +}; + +class ModFilePrior : public BasicModFilePrior +{ +public: + ModFilePrior(const int index_arg, + const string shape_arg, + const double mean_arg, + const double mode_arg, + const double stdev_arg, + const double variance_arg, + const vector domain_arg); +}; + +class ModFileStructuralInnovationPrior: public BasicModFilePrior +{ +public: + ModFileStructuralInnovationPrior(const int index_arg, + const string shape_arg, + const double mean_arg, + const double mode_arg, + const double stdev_arg, + const double variance_arg, + const vector domain_arg); +}; + +class ModFileMeasurementErrorPrior : public BasicModFilePrior +{ +public: + ModFileMeasurementErrorPrior(const int index_arg, + const string shape_arg, + const double mean_arg, + const double stdev_arg, + const double variance_arg, + const double mode_arg, + const vector domain_arg); +}; + +class ModFileStructuralInnovationCorrPrior : public BasicModFilePrior +{ +private: + const int index2; +public: + ModFileStructuralInnovationCorrPrior(const int index1_arg, + const int index2_arg, + const string shape_arg, + const double mean_arg, + const double stdev_arg, + const double variance_arg, + const double mode_arg, + const vector domain_arg); +}; + +class ModFileMeasurementErrorCorrPrior : public BasicModFilePrior +{ +private: + const int index2; +public: + ModFileMeasurementErrorCorrPrior(const int index1_arg, + const int index2_arg, + const string shape_arg, + const double mean_arg, + const double stdev_arg, + const double variance_arg, + const double mode_arg, + const vector domain_arg); +}; + +class BasicModFileOption +{ +private: + inline bool isnan(double x) const { return (x!=x); }; +protected: + const int index; + const double init; + + BasicModFileOption(const int index_arg, + const double init_arg); +public: + inline int get_index() const { return index; }; + inline double get_init() const { return init; }; +}; + +class ModFileOption : public BasicModFileOption +{ +public: + ModFileOption(const int index_arg, + const double init_arg); +}; + +class ModFileStructuralInnovationOption: public BasicModFileOption +{ +public: + ModFileStructuralInnovationOption(const int index_arg, + const double init_arg); +}; + +class ModFileMeasurementErrorOption : public BasicModFileOption +{ +public: + ModFileMeasurementErrorOption(const int index_arg, + const double init_arg); +}; + +class ModFileStructuralInnovationCorrOption : public BasicModFileOption +{ +private: + const int index2; +public: + ModFileStructuralInnovationCorrOption(const int index1_arg, + const int index2_arg, + const double init_arg); +}; + +class ModFileMeasurementErrorCorrOption : public BasicModFileOption +{ +private: + const int index2; +public: + ModFileMeasurementErrorCorrOption(const int index1_arg, + const int index2_arg, + const double init_arg); +}; + +class DynareInfo +{ +private: + vector markov_switching_vector; + vector prior_vector; + vector structural_innovation_prior_vector; + vector measurement_error_prior_vector; + vector structural_innovation_corr_prior_vector; + vector measurement_error_corr_prior_vector; + vector option_vector; + vector structural_innovation_option_vector; + vector measurement_error_option_vector; + vector structural_innovation_corr_option_vector; + vector measurement_error_corr_option_vector; + map exo_names, exo_det_names, endo_names, param_names; + vector< double > params; + vector aux_vars; + vector predetermined_variables; + vector varobs; + vector >lead_lag_incidence; + vector NNZDerivatives; +public: + DynareInfo(map exo_names_arg, + map exo_det_names_arg, + map endo_names_arg, + map param_names_arg, + vector< double > params_arg, + vector aux_vars_arg, + vector predetermined_variables_arg, + vector varobs_arg, + vector< vector > lead_lag_incidence_arg, + vector NNZDerivatives_arg); + ~DynareInfo(); + + inline void addMarkovSwitching(MarkovSwitching *ms) { markov_switching_vector.push_back(ms); }; + + inline void addPrior(ModFilePrior *p) { prior_vector.push_back(p); }; + inline void addStructuralInnovationPrior(ModFileStructuralInnovationPrior *sip) { structural_innovation_prior_vector.push_back(sip); }; + inline void addMeasurementErrorPrior(ModFileMeasurementErrorPrior *mep) { measurement_error_prior_vector.push_back(mep); }; + inline void addStructuralInnovationCorrPrior(ModFileStructuralInnovationCorrPrior *sicp) { structural_innovation_corr_prior_vector.push_back(sicp); }; + inline void addMeasurementErrorCorrPrior(ModFileMeasurementErrorCorrPrior *mecp) { measurement_error_corr_prior_vector.push_back(mecp); }; + + inline void addOption(ModFileOption *o) { option_vector.push_back(o); }; + inline void addStructuralInnovationOption(ModFileStructuralInnovationOption *sio) { structural_innovation_option_vector.push_back(sio); }; + inline void addMeasurementErrorOption(ModFileMeasurementErrorOption *meo) { measurement_error_option_vector.push_back(meo); }; + inline void addStructuralInnovationCorrOption(ModFileStructuralInnovationCorrOption *sico) { structural_innovation_corr_option_vector.push_back(sico); }; + inline void addMeasurementErrorCorrOption(ModFileMeasurementErrorCorrOption *meco) { measurement_error_corr_option_vector.push_back(meco); }; + + inline bool markov_switching_has_val() { return !markov_switching_vector.empty(); }; + inline bool prior_has_val() { return !prior_vector.empty(); }; + inline bool structural_innovation_prior_has_val() { return !structural_innovation_prior_vector.empty(); }; + inline bool measurement_error_prior_has_val() { return !measurement_error_prior_vector.empty(); }; + inline bool structural_innovation_corr_prior_has_val() { return !structural_innovation_corr_prior_vector.empty(); }; + inline bool measurement_error_corr_prior_has_val() { return !measurement_error_corr_prior_vector.empty(); }; + + inline bool option_has_val() { return !option_vector.empty(); }; + inline bool structural_innovation_option_has_val() { return !structural_innovation_option_vector.empty(); }; + inline bool measurement_error_option_has_val() { return !measurement_error_option_vector.empty(); }; + inline bool structural_innovation_corr_option_has_val() { return !structural_innovation_corr_option_vector.empty(); }; + inline bool measurement_error_corr_option_has_val() { return !measurement_error_corr_option_vector.empty(); }; + + inline vectorget_markov_switching() { return markov_switching_vector; }; + inline vector get_prior() { return prior_vector; }; + inline vector get_structural_innovation_prior() { return structural_innovation_prior_vector; }; + inline vector get_measurement_error_prior() { return measurement_error_prior_vector; }; + inline vector get_structural_innovation_corr_prior() { return structural_innovation_corr_prior_vector; }; + inline vector get_measurement_error_corr_prior() { return measurement_error_corr_prior_vector; }; + + inline vector get_option() { return option_vector; }; + inline vector get_structural_innovation_option() { return structural_innovation_option_vector; }; + inline vector get_measurement_error_option() { return measurement_error_option_vector; }; + inline vector get_structural_innovation_corr_option() { return structural_innovation_corr_option_vector; }; + inline vector get_measurement_error_corr_option() { return measurement_error_corr_option_vector; }; + + inline map get_exo_names() { return exo_names; }; + inline map get_exo_det_names() { return exo_det_names; }; + inline map get_endo_names() { return endo_names; }; + inline map get_param_names() { return param_names; }; + inline vector get_params() { return params; }; + inline vector get_aux_vars() { return aux_vars; }; + inline vector get_predetermined_variables() { return predetermined_variables; }; + inline vector get_varobs() { return varobs; }; + inline vector > get_lead_lag_incidence() { return lead_lag_incidence; }; + inline vector get_NNZDerivatives() { return NNZDerivatives; }; + + string get_exo_name_by_index(int index) throw (ValueNotSetException); + int get_exo_index_by_name(string name) throw (ValueNotSetException); + string get_exo_det_name_by_index(int index) throw (ValueNotSetException); + int get_exo_det_index_by_name(string name) throw (ValueNotSetException); + string get_endo_name_by_index(int index) throw (ValueNotSetException); + int get_endo_index_by_name(string name) throw (ValueNotSetException); + string get_param_name_by_index(int index) throw (ValueNotSetException); + int get_param_index_by_name(string name) throw (ValueNotSetException); + double get_param_value_by_index(int index) throw (ValueNotSetException); + vectorget_lead_lag_incidence_for_endo_var_by_index(int index) throw (ValueNotSetException); +}; + +#endif // ! _DYNARE_CPP_DRIVER_HH diff --git a/others/cpp/ms_dsge_c_driver.hh b/others/cpp/ms_dsge_c_driver.hh index 27ceed078..9e968b4b6 100644 --- a/others/cpp/ms_dsge_c_driver.hh +++ b/others/cpp/ms_dsge_c_driver.hh @@ -14,8 +14,8 @@ * More information is available at . */ -#ifndef _MS_DSGE_C_DRIVER_HH -#define _MS_DSGE_C_DRIVER_HH +#ifndef _DYNARE_CPP_DRIVER_HH +#define _DYNARE_CPP_DRIVER_HH #include #include @@ -223,7 +223,7 @@ public: const double init_arg); }; -class MsDsgeInfo +class DynareInfo { private: vector markov_switching_vector; @@ -245,7 +245,7 @@ private: vector >lead_lag_incidence; vector NNZDerivatives; public: - MsDsgeInfo(map exo_names_arg, + DynareInfo(map exo_names_arg, map exo_det_names_arg, map endo_names_arg, map param_names_arg, @@ -255,7 +255,7 @@ public: vector varobs_arg, vector > lead_lag_incidence_arg, vector NNZDerivatives_arg); - ~MsDsgeInfo(); + ~DynareInfo(); inline void addMarkovSwitching(MarkovSwitching *ms) { markov_switching_vector.push_back(ms); }; @@ -320,4 +320,4 @@ public: vectorget_lead_lag_incidence_for_endo_var_by_index(int index) throw (ValueNotSetException); }; -#endif // ! _MS_DSGE_C_DRIVER_HH +#endif // ! _DYNARE_CPP_DRIVER_HH diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index 5725a6dcd..432778b58 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -824,9 +824,9 @@ ModFile::writeModelCC(const string &basename, bool cuda) const << " * from model file (.mod)" << endl << " */" << endl << endl - << "#include \"ms_dsge_c_driver.hh\"" << endl + << "#include \"dynare_cpp_driver.hh\"" << endl << endl - << "MsDsgeInfo *" << endl + << "DynareInfo *" << endl << "preprocessorOutput()" << endl << "{" << endl; @@ -837,7 +837,6 @@ ModFile::writeModelCC(const string &basename, bool cuda) const << " * Writing statements" << endl << " */" << endl << "/* prior args*/" << endl - << "MsDsgeInfo *msdsgeinfo = new MsDsgeInfo(exo_names, exo_det_names, endo_names, param_names, params, aux_vars, predetermined_variables, varobs, lead_lag_incidence, NNZDerivatives);" << endl << "int index, index1;" << endl << "string shape;" << endl << "double mean, mode, stdev, variance;" << endl @@ -848,15 +847,19 @@ ModFile::writeModelCC(const string &basename, bool cuda) const << "vector duration;" << endl << "restriction_map_t restriction_map;" << endl << "/* options args*/" << endl - << "double init;" << endl << endl; + << "double init;" << endl + << "vector< vector > lead_lag_incidence;" << endl + << "vector NNZDerivatives;" << endl + << "vector params(param_nbr);" << endl << endl; // Print statements for (vector::const_iterator it = statements.begin(); it != statements.end(); it++) (*it)->writeCOutput(mDriverCFile, basename); - mDriverCFile << "return msdsgeinfo;" << endl; - mDriverCFile << "}" << endl; + mDriverCFile << "DynareInfo *model_info = new DynareInfo(exo_names, exo_det_names, endo_names, param_names, params, aux_vars, predetermined_variables, varobs, lead_lag_incidence, NNZDerivatives);" << endl + << "return model_info;" << endl + << "}" << endl; mDriverCFile.close(); // Write informational m file