diff --git a/CodeInterpreter.hh b/CodeInterpreter.hh index 76f4ae1054fbe744f26c2841cfa2cf0f7d31907e..532e2e41be9ffc77d8bf373584cbe79264701e1a 100644 --- a/CodeInterpreter.hh +++ b/CodeInterpreter.hh @@ -77,7 +77,6 @@ enum Tags FSTPG3, //!< Loads a derivative matrix for a dynamic model from the stack - 15 (21) FSTPG4, //!< Loads a second order derivative matrix for a dynamic model from the stack - 16 (22) - FUNARY, //!< A Unary operator - 17 (23) FBINARY, //!< A binary operator - 18 (24) FTRINARY, //!< A trinary operator - 19 (25) @@ -243,7 +242,8 @@ class TagWithoutArgument protected: uint8_t op_code; public: - inline TagWithoutArgument(uint8_t op_code_arg) : op_code(op_code_arg) + inline + TagWithoutArgument(uint8_t op_code_arg) : op_code(op_code_arg) { }; inline void @@ -261,10 +261,12 @@ protected: uint8_t op_code; T1 arg1; public: - inline TagWithOneArgument(uint8_t op_code_arg) : op_code(op_code_arg) + inline + TagWithOneArgument(uint8_t op_code_arg) : op_code(op_code_arg) { }; - inline TagWithOneArgument(uint8_t op_code_arg, T1 arg_arg1) : op_code(op_code_arg), arg1(arg_arg1) + inline + TagWithOneArgument(uint8_t op_code_arg, T1 arg_arg1) : op_code(op_code_arg), arg1(arg_arg1) { }; inline void @@ -283,10 +285,12 @@ protected: T1 arg1; T2 arg2; public: - inline TagWithTwoArguments(uint8_t op_code_arg) : op_code(op_code_arg) + inline + TagWithTwoArguments(uint8_t op_code_arg) : op_code(op_code_arg) { }; - inline TagWithTwoArguments(uint8_t op_code_arg, T1 arg_arg1, T2 arg_arg2) : op_code(op_code_arg), arg1(arg_arg1), arg2(arg_arg2) + inline + TagWithTwoArguments(uint8_t op_code_arg, T1 arg_arg1, T2 arg_arg2) : op_code(op_code_arg), arg1(arg_arg1), arg2(arg_arg2) { }; inline void @@ -306,10 +310,12 @@ protected: T2 arg2; T3 arg3; public: - inline TagWithThreeArguments(uint8_t op_code_arg) : op_code(op_code_arg) + inline + TagWithThreeArguments(uint8_t op_code_arg) : op_code(op_code_arg) { }; - inline TagWithThreeArguments(uint8_t op_code_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3) : op_code(op_code_arg), arg1(arg_arg1), arg2(arg_arg2), arg3(arg_arg3) + inline + TagWithThreeArguments(uint8_t op_code_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3) : op_code(op_code_arg), arg1(arg_arg1), arg2(arg_arg2), arg3(arg_arg3) { }; inline void @@ -320,7 +326,6 @@ public: }; }; - template < class T1, class T2, class T3, class T4 > class TagWithFourArguments { @@ -331,10 +336,12 @@ protected: T3 arg3; T4 arg4; public: - inline TagWithFourArguments(uint8_t op_code_arg) : op_code(op_code_arg) + inline + TagWithFourArguments(uint8_t op_code_arg) : op_code(op_code_arg) { }; - inline TagWithFourArguments(uint8_t op_code_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3, T4 arg_arg4) : op_code(op_code_arg), arg1(arg_arg1), arg2(arg_arg2), arg3(arg_arg3), arg4(arg_arg4) + inline + TagWithFourArguments(uint8_t op_code_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3, T4 arg_arg4) : op_code(op_code_arg), arg1(arg_arg1), arg2(arg_arg2), arg3(arg_arg3), arg4(arg_arg4) { }; inline void @@ -345,12 +352,11 @@ public: }; }; - - class FLDZ_ : public TagWithoutArgument { public: - inline FLDZ_() : TagWithoutArgument(FLDZ) + inline + FLDZ_() : TagWithoutArgument(FLDZ) { }; }; @@ -358,7 +364,8 @@ public: class FEND_ : public TagWithoutArgument { public: - inline FEND_() : TagWithoutArgument(FEND) + inline + FEND_() : TagWithoutArgument(FEND) { }; }; @@ -366,7 +373,8 @@ public: class FENDBLOCK_ : public TagWithoutArgument { public: - inline FENDBLOCK_() : TagWithoutArgument(FENDBLOCK) + inline + FENDBLOCK_() : TagWithoutArgument(FENDBLOCK) { }; }; @@ -374,7 +382,8 @@ public: class FENDEQU_ : public TagWithoutArgument { public: - inline FENDEQU_() : TagWithoutArgument(FENDEQU) + inline + FENDEQU_() : TagWithoutArgument(FENDEQU) { }; }; @@ -382,25 +391,26 @@ public: class FCUML_ : public TagWithoutArgument { public: - inline FCUML_() : TagWithoutArgument(FCUML) + inline + FCUML_() : TagWithoutArgument(FCUML) { }; }; - class FPUSH_ : public TagWithoutArgument { public: - inline FPUSH_() : TagWithoutArgument(FPUSH) + inline + FPUSH_() : TagWithoutArgument(FPUSH) { }; }; - class FPOP_ : public TagWithoutArgument { public: - inline FPOP_() : TagWithoutArgument(FPOP) + inline + FPOP_() : TagWithoutArgument(FPOP) { }; }; @@ -408,10 +418,12 @@ public: class FDIMT_ : public TagWithOneArgument<unsigned int> { public: - inline FDIMT_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FDIMT) + inline + FDIMT_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FDIMT) { }; - inline FDIMT_(unsigned int size_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FDIMT, size_arg) + inline + FDIMT_(unsigned int size_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FDIMT, size_arg) { }; inline unsigned int @@ -424,10 +436,12 @@ public: class FDIMST_ : public TagWithOneArgument<unsigned int> { public: - inline FDIMST_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FDIMST) + inline + FDIMST_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FDIMST) { }; - inline FDIMST_(const unsigned int size_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FDIMST, size_arg) + inline + FDIMST_(const unsigned int size_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FDIMST, size_arg) { }; inline unsigned int @@ -440,10 +454,12 @@ public: class FLDC_ : public TagWithOneArgument<double> { public: - inline FLDC_() : TagWithOneArgument<double>::TagWithOneArgument(FLDC) + inline + FLDC_() : TagWithOneArgument<double>::TagWithOneArgument(FLDC) { }; - inline FLDC_(const double value_arg) : TagWithOneArgument<double>::TagWithOneArgument(FLDC, value_arg) + inline + FLDC_(const double value_arg) : TagWithOneArgument<double>::TagWithOneArgument(FLDC, value_arg) { }; inline double @@ -456,10 +472,12 @@ public: class FLDU_ : public TagWithOneArgument<unsigned int> { public: - inline FLDU_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDU) + inline + FLDU_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDU) { }; - inline FLDU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDU, pos_arg) + inline + FLDU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDU, pos_arg) { }; inline unsigned int @@ -472,10 +490,12 @@ public: class FLDSU_ : public TagWithOneArgument<unsigned int> { public: - inline FLDSU_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDSU) + inline + FLDSU_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDSU) { }; - inline FLDSU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDSU, pos_arg) + inline + FLDSU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDSU, pos_arg) { }; inline unsigned int @@ -488,10 +508,12 @@ public: class FLDR_ : public TagWithOneArgument<unsigned int> { public: - inline FLDR_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDR) + inline + FLDR_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDR) { }; - inline FLDR_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDR, pos_arg) + inline + FLDR_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDR, pos_arg) { }; inline unsigned int @@ -504,10 +526,12 @@ public: class FLDT_ : public TagWithOneArgument<unsigned int> { public: - inline FLDT_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDT) + inline + FLDT_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDT) { }; - inline FLDT_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDT, pos_arg) + inline + FLDT_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDT, pos_arg) { }; inline unsigned int @@ -520,10 +544,12 @@ public: class FLDST_ : public TagWithOneArgument<unsigned int> { public: - inline FLDST_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDST) + inline + FLDST_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDST) { }; - inline FLDST_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDST, pos_arg) + inline + FLDST_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDST, pos_arg) { }; inline unsigned int @@ -536,10 +562,12 @@ public: class FSTPT_ : public TagWithOneArgument<unsigned int> { public: - inline FSTPT_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPT) + inline + FSTPT_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPT) { }; - inline FSTPT_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPT, pos_arg) + inline + FSTPT_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPT, pos_arg) { }; inline unsigned int @@ -552,10 +580,12 @@ public: class FSTPST_ : public TagWithOneArgument<unsigned int> { public: - inline FSTPST_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPST) + inline + FSTPST_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPST) { }; - inline FSTPST_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPST, pos_arg) + inline + FSTPST_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPST, pos_arg) { }; inline unsigned int @@ -568,10 +598,12 @@ public: class FSTPR_ : public TagWithOneArgument<unsigned int> { public: - inline FSTPR_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPR) + inline + FSTPR_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPR) { }; - inline FSTPR_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPR, pos_arg) + inline + FSTPR_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPR, pos_arg) { }; inline unsigned int @@ -584,10 +616,12 @@ public: class FSTPU_ : public TagWithOneArgument<unsigned int> { public: - inline FSTPU_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPU) + inline + FSTPU_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPU) { }; - inline FSTPU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPU, pos_arg) + inline + FSTPU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPU, pos_arg) { }; inline unsigned int @@ -600,10 +634,12 @@ public: class FSTPSU_ : public TagWithOneArgument<unsigned int> { public: - inline FSTPSU_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPSU) + inline + FSTPSU_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPSU) { }; - inline FSTPSU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPSU, pos_arg) + inline + FSTPSU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPSU, pos_arg) { }; inline unsigned int @@ -616,10 +652,12 @@ public: class FSTPG_ : public TagWithOneArgument<unsigned int> { public: - inline FSTPG_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPG, 0) + inline + FSTPG_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPG, 0) { }; - inline FSTPG_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPG, pos_arg) + inline + FSTPG_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPG, pos_arg) { }; inline unsigned int @@ -632,10 +670,12 @@ public: class FSTPG2_ : public TagWithTwoArguments<unsigned int, unsigned int> { public: - inline FSTPG2_() : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FSTPG2, 0, 0) + inline + FSTPG2_() : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FSTPG2, 0, 0) { }; - inline FSTPG2_(const unsigned int pos_arg1, const unsigned int pos_arg2) : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FSTPG2, pos_arg1, pos_arg2) + inline + FSTPG2_(const unsigned int pos_arg1, const unsigned int pos_arg2) : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FSTPG2, pos_arg1, pos_arg2) { }; inline unsigned int @@ -653,10 +693,12 @@ public: class FSTPG3_ : public TagWithFourArguments<unsigned int, unsigned int, int, unsigned int> { public: - inline FSTPG3_() : TagWithFourArguments<unsigned int, unsigned int, int, unsigned int>::TagWithFourArguments(FSTPG3, 0, 0, 0, 0) + inline + FSTPG3_() : TagWithFourArguments<unsigned int, unsigned int, int, unsigned int>::TagWithFourArguments(FSTPG3, 0, 0, 0, 0) { }; - inline FSTPG3_(const unsigned int pos_arg1, const unsigned int pos_arg2, const int pos_arg3, const unsigned int pos_arg4) : TagWithFourArguments<unsigned int, unsigned int, int, unsigned int>::TagWithFourArguments(FSTPG3, pos_arg1, pos_arg2, pos_arg3, pos_arg4) + inline + FSTPG3_(const unsigned int pos_arg1, const unsigned int pos_arg2, const int pos_arg3, const unsigned int pos_arg4) : TagWithFourArguments<unsigned int, unsigned int, int, unsigned int>::TagWithFourArguments(FSTPG3, pos_arg1, pos_arg2, pos_arg3, pos_arg4) { }; inline unsigned int @@ -684,10 +726,12 @@ public: class FUNARY_ : public TagWithOneArgument<uint8_t> { public: - inline FUNARY_() : TagWithOneArgument<uint8_t>::TagWithOneArgument(FUNARY) + inline + FUNARY_() : TagWithOneArgument<uint8_t>::TagWithOneArgument(FUNARY) { }; - inline FUNARY_(uint8_t op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument(FUNARY, op_type_arg) + inline + FUNARY_(uint8_t op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument(FUNARY, op_type_arg) { }; inline uint8_t @@ -700,10 +744,12 @@ public: class FBINARY_ : public TagWithOneArgument<uint8_t> { public: - inline FBINARY_() : TagWithOneArgument<uint8_t>::TagWithOneArgument(FBINARY) + inline + FBINARY_() : TagWithOneArgument<uint8_t>::TagWithOneArgument(FBINARY) { }; - inline FBINARY_(const int op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument(FBINARY, op_type_arg) + inline + FBINARY_(const int op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument(FBINARY, op_type_arg) { }; inline uint8_t @@ -716,10 +762,12 @@ public: class FTRINARY_ : public TagWithOneArgument<uint8_t> { public: - inline FTRINARY_() : TagWithOneArgument<uint8_t>::TagWithOneArgument(FTRINARY) + inline + FTRINARY_() : TagWithOneArgument<uint8_t>::TagWithOneArgument(FTRINARY) { }; - inline FTRINARY_(const int op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument(FTRINARY, op_type_arg) + inline + FTRINARY_(const int op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument(FTRINARY, op_type_arg) { }; inline uint8_t @@ -732,10 +780,12 @@ public: class FOK_ : public TagWithOneArgument<int> { public: - inline FOK_() : TagWithOneArgument<int>::TagWithOneArgument(FOK) + inline + FOK_() : TagWithOneArgument<int>::TagWithOneArgument(FOK) { }; - inline FOK_(const int arg_arg) : TagWithOneArgument<int>::TagWithOneArgument(FOK, arg_arg) + inline + FOK_(const int arg_arg) : TagWithOneArgument<int>::TagWithOneArgument(FOK, arg_arg) { }; inline int @@ -748,10 +798,12 @@ public: class FJMPIFEVAL_ : public TagWithOneArgument<unsigned int> { public: - inline FJMPIFEVAL_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FJMPIFEVAL) + inline + FJMPIFEVAL_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FJMPIFEVAL) { }; - inline FJMPIFEVAL_(unsigned int arg_pos) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FJMPIFEVAL, arg_pos) + inline + FJMPIFEVAL_(unsigned int arg_pos) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FJMPIFEVAL, arg_pos) { }; inline unsigned int @@ -764,10 +816,12 @@ public: class FJMP_ : public TagWithOneArgument<unsigned int> { public: - inline FJMP_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FJMP) + inline + FJMP_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FJMP) { }; - inline FJMP_(unsigned int arg_pos) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FJMP, arg_pos) + inline + FJMP_(unsigned int arg_pos) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FJMP, arg_pos) { }; inline unsigned int @@ -777,14 +831,15 @@ public: } }; - class FLDTEF_ : public TagWithOneArgument<unsigned int> { public: - inline FLDTEF_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDTEF) + inline + FLDTEF_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDTEF) { }; - inline FLDTEF_(unsigned int number) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDTEF, number) + inline + FLDTEF_(unsigned int number) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDTEF, number) { }; inline unsigned int @@ -794,14 +849,15 @@ public: } }; - class FSTPTEF_ : public TagWithOneArgument<unsigned int> { public: - inline FSTPTEF_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPTEF) + inline + FSTPTEF_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPTEF) { }; - inline FSTPTEF_(unsigned int number) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPTEF, number) + inline + FSTPTEF_(unsigned int number) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPTEF, number) { }; inline unsigned int @@ -814,10 +870,12 @@ public: class FLDTEFD_ : public TagWithTwoArguments<unsigned int, unsigned int> { public: - inline FLDTEFD_() : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FLDTEFD) + inline + FLDTEFD_() : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FLDTEFD) { }; - inline FLDTEFD_(unsigned int indx, unsigned int row) : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FLDTEFD, indx, row) + inline + FLDTEFD_(unsigned int indx, unsigned int row) : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FLDTEFD, indx, row) { }; inline unsigned int @@ -832,14 +890,15 @@ public: }; }; - class FSTPTEFD_ : public TagWithTwoArguments<unsigned int, unsigned int> { public: - inline FSTPTEFD_() : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FSTPTEFD) + inline + FSTPTEFD_() : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FSTPTEFD) { }; - inline FSTPTEFD_(unsigned int indx, unsigned int row) : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FSTPTEFD, indx, row) + inline + FSTPTEFD_(unsigned int indx, unsigned int row) : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FSTPTEFD, indx, row) { }; inline unsigned int @@ -857,10 +916,12 @@ public: class FLDTEFDD_ : public TagWithThreeArguments<unsigned int, unsigned int, unsigned int> { public: - inline FLDTEFDD_() : TagWithThreeArguments<unsigned int, unsigned int, unsigned int>::TagWithThreeArguments(FLDTEFDD) + inline + FLDTEFDD_() : TagWithThreeArguments<unsigned int, unsigned int, unsigned int>::TagWithThreeArguments(FLDTEFDD) { }; - inline FLDTEFDD_(unsigned int indx, unsigned int row, unsigned int col) : TagWithThreeArguments<unsigned int, unsigned int, unsigned int>::TagWithThreeArguments(FLDTEFDD, indx, row, col) + inline + FLDTEFDD_(unsigned int indx, unsigned int row, unsigned int col) : TagWithThreeArguments<unsigned int, unsigned int, unsigned int>::TagWithThreeArguments(FLDTEFDD, indx, row, col) { }; inline unsigned int @@ -880,14 +941,15 @@ public: }; }; - class FSTPTEFDD_ : public TagWithThreeArguments<unsigned int, unsigned int, unsigned int> { public: - inline FSTPTEFDD_() : TagWithThreeArguments<unsigned int, unsigned int, unsigned int>::TagWithThreeArguments(FSTPTEFDD) + inline + FSTPTEFDD_() : TagWithThreeArguments<unsigned int, unsigned int, unsigned int>::TagWithThreeArguments(FSTPTEFDD) { }; - inline FSTPTEFDD_(unsigned int indx, unsigned int row, unsigned int col) : TagWithThreeArguments<unsigned int, unsigned int, unsigned int>::TagWithThreeArguments(FSTPTEF, indx, row, col) + inline + FSTPTEFDD_(unsigned int indx, unsigned int row, unsigned int col) : TagWithThreeArguments<unsigned int, unsigned int, unsigned int>::TagWithThreeArguments(FSTPTEF, indx, row, col) { }; inline unsigned int @@ -910,10 +972,12 @@ public: class FLDVS_ : public TagWithTwoArguments<uint8_t, unsigned int> { public: - inline FLDVS_() : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FLDVS) + inline + FLDVS_() : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FLDVS) { }; - inline FLDVS_(uint8_t type_arg, const unsigned int pos_arg) : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FLDVS, type_arg, pos_arg) + inline + FLDVS_(uint8_t type_arg, const unsigned int pos_arg) : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FLDVS, type_arg, pos_arg) { }; inline uint8_t @@ -931,10 +995,12 @@ public: class FLDSV_ : public TagWithTwoArguments<uint8_t, unsigned int> { public: - inline FLDSV_() : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FLDSV) + inline + FLDSV_() : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FLDSV) { }; - inline FLDSV_(const uint8_t type_arg, const unsigned int pos_arg) : + inline + FLDSV_(const uint8_t type_arg, const unsigned int pos_arg) : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FLDSV, type_arg, pos_arg) { }; @@ -953,10 +1019,12 @@ public: class FSTPSV_ : public TagWithTwoArguments<uint8_t, unsigned int> { public: - inline FSTPSV_() : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FSTPSV) + inline + FSTPSV_() : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FSTPSV) { }; - inline FSTPSV_(const uint8_t type_arg, const unsigned int pos_arg) : + inline + FSTPSV_(const uint8_t type_arg, const unsigned int pos_arg) : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FSTPSV, type_arg, pos_arg) { }; @@ -975,14 +1043,17 @@ public: class FLDV_ : public TagWithThreeArguments<uint8_t, unsigned int, int> { public: - inline FLDV_() : TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FLDV) + inline + FLDV_() : TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FLDV) { }; - inline FLDV_(const int type_arg, const unsigned int pos_arg) : + inline + FLDV_(const int type_arg, const unsigned int pos_arg) : TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FLDV, type_arg, pos_arg, 0) { }; - inline FLDV_(const int type_arg, const unsigned int pos_arg, const int lead_lag_arg) : + inline + FLDV_(const int type_arg, const unsigned int pos_arg, const int lead_lag_arg) : TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FLDV, type_arg, pos_arg, lead_lag_arg) { }; @@ -1006,14 +1077,17 @@ public: class FSTPV_ : public TagWithThreeArguments<uint8_t, unsigned int, int> { public: - inline FSTPV_() : TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FSTPV) + inline + FSTPV_() : TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FSTPV) { }; - inline FSTPV_(const int type_arg, const unsigned int pos_arg) : + inline + FSTPV_(const int type_arg, const unsigned int pos_arg) : TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FSTPV, type_arg, pos_arg, 0) { }; - inline FSTPV_(const int type_arg, const unsigned int pos_arg, const int lead_lag_arg) : + inline + FSTPV_(const int type_arg, const unsigned int pos_arg, const int lead_lag_arg) : TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FSTPV, type_arg, pos_arg, lead_lag_arg) { }; @@ -1034,7 +1108,6 @@ public: }; }; - class FCALL_ : public TagWithFourArguments<unsigned int, unsigned int, string, unsigned int> { string func_name; @@ -1042,7 +1115,8 @@ class FCALL_ : public TagWithFourArguments<unsigned int, unsigned int, string, u unsigned int add_input_arguments, row, col; external_function_type function_type; public: - inline FCALL_() : TagWithFourArguments<unsigned int, unsigned int, string, unsigned int>::TagWithFourArguments(FCALL) + inline + FCALL_() : TagWithFourArguments<unsigned int, unsigned int, string, unsigned int>::TagWithFourArguments(FCALL) { arg_func_name = ""; add_input_arguments = 0; @@ -1050,7 +1124,8 @@ public: col = 0; function_type = ExternalFunctionWithoutDerivative; }; - inline FCALL_(unsigned int nb_output_arguments, unsigned int nb_input_arguments, string f_name, unsigned int indx) : + inline + FCALL_(unsigned int nb_output_arguments, unsigned int nb_input_arguments, string f_name, unsigned int indx) : TagWithFourArguments<unsigned int, unsigned int, string, unsigned int>::TagWithFourArguments(FCALL, nb_output_arguments, nb_input_arguments, f_name, indx) { arg_func_name = ""; @@ -1123,14 +1198,14 @@ public: }; inline void set_function_type(external_function_type arg_function_type) - { - function_type = arg_function_type; - }; + { + function_type = arg_function_type; + }; inline external_function_type get_function_type() - { - return(function_type); - } + { + return (function_type); + } inline void write(ostream &CompileCode, unsigned int &instruction_number) { @@ -1167,13 +1242,13 @@ public: memcpy(&function_type, code, sizeof(function_type)); code += sizeof(function_type); int size; memcpy(&size, code, sizeof(size)); code += sizeof(size); - char* name = (char*)mxMalloc((size+1)*sizeof(char)); + char *name = (char *) mxMalloc((size+1)*sizeof(char)); memcpy(name, code, size); code += size; name[size] = NULL; func_name = name; mxFree(name); memcpy(&size, code, sizeof(size)); code += sizeof(size); - name = (char*)mxMalloc((size+1)*sizeof(char)); + name = (char *) mxMalloc((size+1)*sizeof(char)); memcpy(name, code, size); code += size; name[size] = NULL; arg_func_name = name; @@ -1183,7 +1258,6 @@ public: #endif }; - class FNUMEXPR_ : public TagWithOneArgument<ExpressionType> { private: @@ -1191,36 +1265,42 @@ private: uint16_t dvariable1, dvariable2, dvariable3; int8_t lag1, lag2, lag3; public: - inline FNUMEXPR_() : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR) + inline + FNUMEXPR_() : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR) { }; - inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type), - dvariable1(0), dvariable2(0), dvariable3(0), lag1(0), lag2(0), lag3(0) + inline + FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type), + dvariable1(0), dvariable2(0), dvariable3(0), lag1(0), lag2(0), lag3(0) { equation = equation_arg; }; - inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type), - dvariable2(0), dvariable3(0), lag1(0), lag2(0), lag3(0) + inline + FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type), + dvariable2(0), dvariable3(0), lag1(0), lag2(0), lag3(0) { equation = equation_arg; dvariable1 = dvariable1_arg; }; - inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type), - dvariable2(0), dvariable3(0), lag2(0), lag3(0) + inline + FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type), + dvariable2(0), dvariable3(0), lag2(0), lag3(0) { equation = equation_arg; dvariable1 = dvariable1_arg; lag1 = lag1_arg; }; - inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, unsigned int dvariable2_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type), - dvariable3(0), lag1(0), lag2(0), lag3(0) + inline + FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, unsigned int dvariable2_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type), + dvariable3(0), lag1(0), lag2(0), lag3(0) { equation = equation_arg; dvariable1 = dvariable1_arg; dvariable2 = dvariable2_arg; }; - inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg, unsigned int dvariable2_arg, int lag2_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type), - dvariable3(0), lag3(0) + inline + FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg, unsigned int dvariable2_arg, int lag2_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type), + dvariable3(0), lag3(0) { equation = equation_arg; dvariable1 = dvariable1_arg; @@ -1228,15 +1308,17 @@ public: dvariable2 = dvariable2_arg; lag2 = lag2_arg; }; - inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, unsigned int dvariable2_arg, unsigned int dvariable3_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type), - lag1(0), lag2(0), lag3(0) + inline + FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, unsigned int dvariable2_arg, unsigned int dvariable3_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type), + lag1(0), lag2(0), lag3(0) { equation = equation_arg; dvariable1 = dvariable1_arg; dvariable2 = dvariable2_arg; dvariable3 = dvariable3_arg; }; - inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg, unsigned int dvariable2_arg, int lag2_arg, unsigned int dvariable3_arg, int lag3_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type) + inline + FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg, unsigned int dvariable2_arg, int lag2_arg, unsigned int dvariable3_arg, int lag3_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type) { equation = equation_arg; dvariable1 = dvariable1_arg; @@ -1315,16 +1397,18 @@ private: unsigned int det_exo_size, exo_size, other_endo_size; unsigned int nb_col_other_endo_jacob; public: - inline FBEGINBLOCK_() + inline + FBEGINBLOCK_() { op_code = FBEGINBLOCK; size = 0; type = UNKNOWN; /*variable = NULL; equation = NULL;*/ is_linear = false; endo_nbr = 0; Max_Lag = 0; Max_Lead = 0; u_count_int = 0; nb_col_jacob = 0; }; - inline FBEGINBLOCK_(unsigned int size_arg, BlockSimulationType type_arg, int unsigned first_element, int unsigned block_size, - const vector<int> &variable_arg, const vector<int> &equation_arg, - bool is_linear_arg, int endo_nbr_arg, int Max_Lag_arg, int Max_Lead_arg, int &u_count_int_arg, int nb_col_jacob_arg, - unsigned int det_exo_size_arg, unsigned int exo_size_arg, unsigned int other_endo_size_arg, unsigned int nb_col_other_endo_jacob_arg, - const vector<unsigned int> &det_exogenous_arg, const vector<unsigned int> &exogenous_arg, const vector<unsigned int> &other_endogenous_arg) + inline + FBEGINBLOCK_(unsigned int size_arg, BlockSimulationType type_arg, int unsigned first_element, int unsigned block_size, + const vector<int> &variable_arg, const vector<int> &equation_arg, + bool is_linear_arg, int endo_nbr_arg, int Max_Lag_arg, int Max_Lead_arg, int &u_count_int_arg, int nb_col_jacob_arg, + unsigned int det_exo_size_arg, unsigned int exo_size_arg, unsigned int other_endo_size_arg, unsigned int nb_col_other_endo_jacob_arg, + const vector<unsigned int> &det_exogenous_arg, const vector<unsigned int> &exogenous_arg, const vector<unsigned int> &other_endogenous_arg) { op_code = FBEGINBLOCK; size = size_arg; type = type_arg; variable = vector<int>(variable_arg.begin()+first_element, variable_arg.begin()+(first_element+block_size)); @@ -1336,9 +1420,10 @@ public: nb_col_jacob = nb_col_jacob_arg; det_exo_size = det_exo_size_arg; exo_size = exo_size_arg; other_endo_size = other_endo_size_arg; nb_col_other_endo_jacob = nb_col_other_endo_jacob_arg; }; - inline FBEGINBLOCK_(unsigned int size_arg, BlockSimulationType type_arg, int unsigned first_element, int unsigned block_size, - const vector<int> &variable_arg, const vector<int> &equation_arg, - bool is_linear_arg, int endo_nbr_arg, int Max_Lag_arg, int Max_Lead_arg, int &u_count_int_arg, int nb_col_jacob_arg) + inline + FBEGINBLOCK_(unsigned int size_arg, BlockSimulationType type_arg, int unsigned first_element, int unsigned block_size, + const vector<int> &variable_arg, const vector<int> &equation_arg, + bool is_linear_arg, int endo_nbr_arg, int Max_Lag_arg, int Max_Lead_arg, int &u_count_int_arg, int nb_col_jacob_arg) { op_code = FBEGINBLOCK; size = size_arg; type = type_arg; variable = vector<int>(variable_arg.begin()+first_element, variable_arg.begin()+(first_element+block_size)); @@ -1807,8 +1892,8 @@ public: tags_liste.push_back(make_pair(FCALL, fcall)); # ifdef DEBUGL - mexPrintf("FCALL finish\n");mexEvalString("drawnow;"); - mexPrintf("-- *code=%d\n",*code);mexEvalString("drawnow;"); + mexPrintf("FCALL finish\n"); mexEvalString("drawnow;"); + mexPrintf("-- *code=%d\n", *code); mexEvalString("drawnow;"); # endif } break; diff --git a/ComputingTasks.cc b/ComputingTasks.cc index 241062d74684e36c6b2b281695490b121cd06fd4..0cb37338a9d127de5b898f33f6452e5c88cc4d64 100644 --- a/ComputingTasks.cc +++ b/ComputingTasks.cc @@ -257,16 +257,16 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct) it = options_list.num_options.find("dsge_varlag"); if (it != options_list.num_options.end()) - if (mod_file_struct.dsge_var_calibrated.empty() && - !mod_file_struct.dsge_var_estimated) + if (mod_file_struct.dsge_var_calibrated.empty() + && !mod_file_struct.dsge_var_estimated) { cerr << "ERROR: The estimation statement requires a dsge_var option to be passed " << "if the dsge_varlag option is passed." << endl; exit(EXIT_FAILURE); } - if (!mod_file_struct.dsge_var_calibrated.empty() && - mod_file_struct.dsge_var_estimated) + if (!mod_file_struct.dsge_var_calibrated.empty() + && mod_file_struct.dsge_var_estimated) { cerr << "ERROR: An estimation statement cannot take more than one dsge_var option." << endl; exit(EXIT_FAILURE); @@ -375,8 +375,8 @@ EstimatedParamsStatement::checkPass(ModFileStructure &mod_file_struct) if (it->prior == "1") //BETA_PDF is associated with "1" in DynareBison.yy try { - if (it->mean->eval(eval_context_t()) == 0.5 && - it->std->eval(eval_context_t()) == 0.5) + if (it->mean->eval(eval_context_t()) == 0.5 + && it->std->eval(eval_context_t()) == 0.5) { cerr << "ERROR: The prior density is not defined for the beta distribution when the mean = standard deviation = 0.5." << endl; exit(EXIT_FAILURE); @@ -1012,20 +1012,20 @@ SvarIdentificationStatement::writeOutput(ostream &output, const string &basename if (!upper_cholesky_present && !lower_cholesky_present) { int n = symbol_table.endo_nbr(); -// int m = symbol_table.exo_nbr(); + // int m = symbol_table.exo_nbr(); int m = 1; // this is the constant, not the shocks int r = getMaxLag(); int k = r*n+m; if (k < 1) - { - cerr << "ERROR: lag = " << r - << ", number of endogenous variables = " << n - << ", number of exogenous variables = " << m - << ". If this is not a logical error in the specification" - << " of the .mod file, please report it to the Dynare Team." << endl; - exit(EXIT_FAILURE); - } + { + cerr << "ERROR: lag = " << r + << ", number of endogenous variables = " << n + << ", number of exogenous variables = " << m + << ". If this is not a logical error in the specification" + << " of the .mod file, please report it to the Dynare Team." << endl; + exit(EXIT_FAILURE); + } if (n < 1) { cerr << "ERROR: Number of endogenous variables = " << n << "< 1. If this is not a logical " diff --git a/ConfigFile.cc b/ConfigFile.cc index 15e1b2adbefa1650a1099c49f8921cc87f1f859a..ed2bcb835281b8a4c0950d411c2efbe3c5c2f553 100644 --- a/ConfigFile.cc +++ b/ConfigFile.cc @@ -73,20 +73,20 @@ ConfigFile::getConfigFileInfo(const string ¶llel_config_file) { // Test OS and try to open default file #if defined(_WIN32) || defined(__CYGWIN32__) - if (getenv("APPDATA")==NULL) + if (getenv("APPDATA") == NULL) { cerr << "ERROR: APPDATA environment variable not found." << endl; exit(EXIT_FAILURE); } - string defaultConfigFile (getenv("APPDATA")); + string defaultConfigFile(getenv("APPDATA")); defaultConfigFile += "\\dynare.ini"; #else - if (getenv("HOME")==NULL) + if (getenv("HOME") == NULL) { cerr << "ERROR: HOME environment variable not found." << endl; exit(EXIT_FAILURE); } - string defaultConfigFile (getenv("HOME")); + string defaultConfigFile(getenv("HOME")); defaultConfigFile += "/.dynare"; #endif configFile = new ifstream(defaultConfigFile.c_str(), fstream::in); @@ -125,9 +125,9 @@ ConfigFile::getConfigFileInfo(const string ¶llel_config_file) if (!line.compare("[node]") || !line.compare("[cluster]")) { addConfFileElement(inNode, inCluster, member_nodes, name, - computerName, minCpuNbr, maxCpuNbr, userName, - password, remoteDrive, remoteDirectory, - dynarePath, matlabOctavePath, singleCompThread); + computerName, minCpuNbr, maxCpuNbr, userName, + password, remoteDrive, remoteDirectory, + dynarePath, matlabOctavePath, singleCompThread); //! Reset communication vars / option defaults if (!line.compare("[node]")) @@ -141,8 +141,8 @@ ConfigFile::getConfigFileInfo(const string ¶llel_config_file) inCluster = true; } - name = userName = computerName = password = remoteDrive = - remoteDirectory = dynarePath = matlabOctavePath = ""; + name = userName = computerName = password = remoteDrive + = remoteDirectory = dynarePath = matlabOctavePath = ""; minCpuNbr = maxCpuNbr = 0; singleCompThread = true; member_nodes.clear(); @@ -172,17 +172,17 @@ ConfigFile::getConfigFileInfo(const string ¶llel_config_file) minCpuNbr = 1; maxCpuNbr = boost::lexical_cast< int >(tokenizedCpuNbr.front()); } - else if (tokenizedCpuNbr.size() == 2 && - tokenizedCpuNbr[0].at(0) == '[' && - tokenizedCpuNbr[1].at(tokenizedCpuNbr[1].size()-1) == ']') + else if (tokenizedCpuNbr.size() == 2 + && tokenizedCpuNbr[0].at(0) == '[' + && tokenizedCpuNbr[1].at(tokenizedCpuNbr[1].size()-1) == ']') { - tokenizedCpuNbr[0].erase(0,1); - tokenizedCpuNbr[1].erase(tokenizedCpuNbr[1].size()-1,1); + tokenizedCpuNbr[0].erase(0, 1); + tokenizedCpuNbr[1].erase(tokenizedCpuNbr[1].size()-1, 1); minCpuNbr = boost::lexical_cast< int >(tokenizedCpuNbr[0]); maxCpuNbr = boost::lexical_cast< int >(tokenizedCpuNbr[1]); } } - catch( const boost::bad_lexical_cast & ) + catch (const boost::bad_lexical_cast &) { cerr << "ERROR: Could not convert value to integer for CPUnbr." << endl; exit(EXIT_FAILURE); @@ -234,8 +234,8 @@ ConfigFile::getConfigFileInfo(const string ¶llel_config_file) { vector<string> tmp_member_nodes; boost::split(tmp_member_nodes, tokenizedLine.back(), boost::is_any_of(";, ")); - for ( vector<string>::iterator it = tmp_member_nodes.begin(); - it < tmp_member_nodes.end(); it++ ) + for (vector<string>::iterator it = tmp_member_nodes.begin(); + it < tmp_member_nodes.end(); it++) { boost::trim(*it); if (!it->empty()) @@ -283,9 +283,9 @@ ConfigFile::addConfFileElement(bool inNode, bool inCluster, vector<string> membe matlabOctavePath, singleCompThread); //! ADD CLUSTER else if (inCluster) - if ( minCpuNbr > 0 || maxCpuNbr > 0 || !userName.empty() || - !password.empty() || !remoteDrive.empty() || !remoteDirectory.empty() || - !dynarePath.empty() || !matlabOctavePath.empty()) + if (minCpuNbr > 0 || maxCpuNbr > 0 || !userName.empty() + || !password.empty() || !remoteDrive.empty() || !remoteDirectory.empty() + || !dynarePath.empty() || !matlabOctavePath.empty()) { cerr << "Invalid option passed to [cluster]." << endl; exit(EXIT_FAILURE); @@ -415,7 +415,7 @@ ConfigFile::writeCluster(ostream &output) const if (!parallel && !parallel_test) return; - map<string, Cluster *>::const_iterator cluster_it ; + map<string, Cluster *>::const_iterator cluster_it; if (cluster_name.empty()) cluster_it = clusters.find(firstClusterName); else @@ -464,10 +464,10 @@ ConfigFile::writeCluster(ostream &output) const output << "InitializeComputationalEnvironment();" << endl; if (parallel_test) - output << "ErrorCode = AnalyseComputationalEnvironment(options_.parallel, options_.parallel_info);" << endl - << "disp(['AnalyseComputationalEnvironment returned with Error Code: ' num2str(ErrorCode)]);" << endl - << "diary off;" << endl - << "return;" << endl; + output << "ErrorCode = AnalyseComputationalEnvironment(options_.parallel, options_.parallel_info);" << endl + << "disp(['AnalyseComputationalEnvironment returned with Error Code: ' num2str(ErrorCode)]);" << endl + << "diary off;" << endl + << "return;" << endl; } void diff --git a/DataTree.cc b/DataTree.cc index 21f322b989cb74019c044d5123561a4572e86a9b..4f3ad4a36e9411d75eb8a45714fb29d4b93951a3 100644 --- a/DataTree.cc +++ b/DataTree.cc @@ -500,9 +500,9 @@ DataTree::AddFirstDerivExternalFunctionNode(int top_level_symb_id, const vector< { assert(symbol_table.getType(top_level_symb_id) == eExternalFunction); - first_deriv_external_function_node_map_t::iterator it = - first_deriv_external_function_node_map.find(make_pair(make_pair(arguments, input_index), - top_level_symb_id)); + first_deriv_external_function_node_map_t::iterator it + = first_deriv_external_function_node_map.find(make_pair(make_pair(arguments, input_index), + top_level_symb_id)); if (it != first_deriv_external_function_node_map.end()) return it->second; @@ -514,10 +514,10 @@ DataTree::AddSecondDerivExternalFunctionNode(int top_level_symb_id, const vector { assert(symbol_table.getType(top_level_symb_id) == eExternalFunction); - second_deriv_external_function_node_map_t::iterator it = - second_deriv_external_function_node_map.find(make_pair(make_pair(arguments, - make_pair(input_index1, input_index2)), - top_level_symb_id)); + second_deriv_external_function_node_map_t::iterator it + = second_deriv_external_function_node_map.find(make_pair(make_pair(arguments, + make_pair(input_index1, input_index2)), + top_level_symb_id)); if (it != second_deriv_external_function_node_map.end()) return it->second; diff --git a/DataTree.hh b/DataTree.hh index 596ce0671581d8712d6aa5aabf2559baa9bb0f72..1a8b9f6de5e4271e197fffb3d331c98fd4e9378b 100644 --- a/DataTree.hh +++ b/DataTree.hh @@ -88,7 +88,7 @@ private: int node_counter; inline expr_t AddPossiblyNegativeConstant(double val); - inline expr_t AddUnaryOp(UnaryOpcode op_code, expr_t arg, int arg_exp_info_set = 0, const string &arg_exp_info_set_name="", int param1_symb_id = 0, int param2_symb_id = 0); + inline expr_t AddUnaryOp(UnaryOpcode op_code, expr_t arg, int arg_exp_info_set = 0, const string &arg_exp_info_set_name = "", int param1_symb_id = 0, int param2_symb_id = 0); inline expr_t AddBinaryOp(expr_t arg1, BinaryOpcode op_code, expr_t arg2, int powerDerivOrder = 0); inline expr_t AddTrinaryOp(expr_t arg1, TrinaryOpcode op_code, expr_t arg2, expr_t arg3); diff --git a/DynamicModel.cc b/DynamicModel.cc index 4a49e18bc23c86a890a4ec8dbf91e4368a142dda..e8a35f07f462ee52b18dae1f421b7f87f572e1fd 100644 --- a/DynamicModel.cc +++ b/DynamicModel.cc @@ -85,15 +85,13 @@ DynamicModel::compileChainRuleDerivative(ofstream &code_file, unsigned int &inst void DynamicModel::initializeVariablesAndEquations() { - for(int j=0; j<equation_number(); j++) + for (int j = 0; j < equation_number(); j++) { equation_reordered.push_back(j); variable_reordered.push_back(j); } } - - void DynamicModel::computeTemporaryTermsOrdered() { @@ -212,11 +210,10 @@ DynamicModel::computeTemporaryTermsMapping() // Add a mapping form node ID to temporary terms order int j = 0; for (temporary_terms_t::const_iterator it = temporary_terms.begin(); - it != temporary_terms.end(); it++) + it != temporary_terms.end(); it++) map_idx[(*it)->idx] = j++; } - void DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const { @@ -261,7 +258,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const unsigned int prev_var, count_col, count_col_endo, count_col_exo, count_col_exo_det, count_col_other_endo; map<pair<int, pair<int, int> >, expr_t> tmp_block_endo_derivative; for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) - tmp_block_endo_derivative[make_pair(it->second.first, make_pair(it->first.second, it->first.first) )] = it->second.second ; + tmp_block_endo_derivative[make_pair(it->second.first, make_pair(it->first.second, it->first.first))] = it->second.second; prev_var = 999999999; prev_lag = -9999999; count_col_endo = 0; @@ -280,7 +277,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const } map<pair<int, pair<int, int> >, expr_t> tmp_block_exo_derivative; for (derivative_t::const_iterator it = derivative_exo[block].begin(); it != (derivative_exo[block]).end(); it++) - tmp_block_exo_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first) )] = it->second ; + tmp_block_exo_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first))] = it->second; prev_var = 999999999; prev_lag = -9999999; count_col_exo = 0; @@ -299,7 +296,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const } map<pair<int, pair<int, int> >, expr_t> tmp_block_exo_det_derivative; for (derivative_t::const_iterator it = derivative_exo_det[block].begin(); it != (derivative_exo_det[block]).end(); it++) - tmp_block_exo_det_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first) )] = it->second; + tmp_block_exo_det_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first))] = it->second; prev_var = 999999999; prev_lag = -9999999; count_col_exo_det = 0; @@ -318,7 +315,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const } map<pair<int, pair<int, int> >, expr_t> tmp_block_other_endo_derivative; for (derivative_t::const_iterator it = derivative_other_endo[block].begin(); it != (derivative_other_endo[block]).end(); it++) - tmp_block_other_endo_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first) )] = it->second; + tmp_block_other_endo_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first))] = it->second; prev_var = 999999999; prev_lag = -9999999; count_col_other_endo = 0; @@ -661,7 +658,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const } expr_t id = it->second; - output << " g1_o(" << eqr+1 << ", " << /*var+1+(lag+block_max_lag)*block_size*/count_col << ") = "; + output << " g1_o(" << eqr+1 << ", " << /*var+1+(lag+block_max_lag)*block_size*/ count_col << ") = "; id->writeOutput(output, local_output_type, local_temporary_terms); output << "; % variable=" << symbol_table.getName(symbol_table.getID(eEndogenous, var)) << "(" << lag @@ -825,7 +822,7 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen else simulation_type = SOLVE_BACKWARD_COMPLETE; - Write_Inf_To_Bin_File(file_name, u_count_int, file_open, simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE, symbol_table.endo_nbr() ); + Write_Inf_To_Bin_File(file_name, u_count_int, file_open, simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE, symbol_table.endo_nbr()); file_open = true; //Temporary variables declaration @@ -835,9 +832,9 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen vector<unsigned int> exo, exo_det, other_endo; - for(int i = 0; i < symbol_table.exo_det_nbr(); i++) + for (int i = 0; i < symbol_table.exo_det_nbr(); i++) exo_det.push_back(i); - for(int i = 0; i < symbol_table.exo_nbr(); i++) + for (int i = 0; i < symbol_table.exo_nbr(); i++) exo.push_back(i); map<pair< int, pair<int, int> >, expr_t> first_derivatives_reordered_endo, first_derivatives_reordered_exo; @@ -851,7 +848,7 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen int lag = getLagByDerivID(deriv_id); if (getTypeByDerivID(deriv_id) == eEndogenous) first_derivatives_reordered_endo[make_pair(lag, make_pair(var, eq))] = it->second; - else if(getTypeByDerivID(deriv_id) == eExogenous || getTypeByDerivID(deriv_id) == eExogenousDet) + else if (getTypeByDerivID(deriv_id) == eExogenous || getTypeByDerivID(deriv_id) == eExogenousDet) first_derivatives_reordered_exo[make_pair(lag, make_pair(var, eq))] = it->second; } int prev_var = -1; @@ -862,7 +859,7 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen { int var = it->first.second.first; int lag = it->first.first; - if(prev_var != var || prev_lag != lag) + if (prev_var != var || prev_lag != lag) { prev_var = var; prev_lag = lag; @@ -878,7 +875,7 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen { int var = it->first.second.first; int lag = it->first.first; - if(prev_var != var || prev_lag != lag) + if (prev_var != var || prev_lag != lag) { prev_var = var; prev_lag = lag; @@ -953,8 +950,8 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen fldr.write(code_file, instruction_number); if (derivatives[i].size()) { - for(vector<pair<pair<int, int>, int> >::const_iterator it = derivatives[i].begin(); - it != derivatives[i].end(); it++) + for (vector<pair<pair<int, int>, int> >::const_iterator it = derivatives[i].begin(); + it != derivatives[i].end(); it++) { FLDU_ fldu(it->second); fldu.write(code_file, instruction_number); @@ -985,7 +982,7 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen FJMPIFEVAL_ fjmp_if_eval1(instruction_number - prev_instruction_number); fjmp_if_eval1.write(code_file, instruction_number); code_file.seekp(pos3); - prev_instruction_number = instruction_number ; + prev_instruction_number = instruction_number; // The Jacobian prev_var = -1; @@ -1000,7 +997,7 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen expr_t d1 = it->second; FNUMEXPR_ fnumexpr(FirstEndoDerivative, eq, var, lag); fnumexpr.write(code_file, instruction_number); - if(prev_var != var || prev_lag != lag) + if (prev_var != var || prev_lag != lag) { prev_var = var; prev_lag = lag; @@ -1022,7 +1019,7 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen expr_t d1 = it->second; FNUMEXPR_ fnumexpr(FirstExoDerivative, eq, var, lag); fnumexpr.write(code_file, instruction_number); - if(prev_var != var || prev_lag != lag) + if (prev_var != var || prev_lag != lag) { prev_var = var; prev_lag = lag; @@ -1039,7 +1036,6 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen fjmp1.write(code_file, instruction_number); code_file.seekp(pos1); - FENDBLOCK_ fendblock; fendblock.write(code_file, instruction_number); FEND_ fend; @@ -1048,8 +1044,6 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen code_file.close(); } - - void DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin_basename, const map_idx_t &map_idx) const { @@ -1112,21 +1106,21 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin || simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_FORWARD_COMPLETE) { Write_Inf_To_Bin_File_Block(file_name, bin_basename, block, u_count_int, file_open, - simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE); + simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE); file_open = true; } map<pair<int, pair<int, int> >, expr_t> tmp_block_endo_derivative; for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) - tmp_block_endo_derivative[make_pair(it->second.first, make_pair(it->first.second, it->first.first) )] = it->second.second ; + tmp_block_endo_derivative[make_pair(it->second.first, make_pair(it->first.second, it->first.first))] = it->second.second; map<pair<int, pair<int, int> >, expr_t> tmp_exo_derivative; for (derivative_t::const_iterator it = derivative_exo[block].begin(); it != (derivative_exo[block]).end(); it++) - tmp_exo_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first) )] = it->second ; + tmp_exo_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first))] = it->second; map<pair<int, pair<int, int> >, expr_t> tmp_exo_det_derivative; for (derivative_t::const_iterator it = derivative_exo_det[block].begin(); it != (derivative_exo_det[block]).end(); it++) - tmp_exo_det_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first) )] = it->second; + tmp_exo_det_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first))] = it->second; map<pair<int, pair<int, int> >, expr_t> tmp_other_endo_derivative; for (derivative_t::const_iterator it = derivative_other_endo[block].begin(); it != (derivative_other_endo[block]).end(); it++) - tmp_other_endo_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first) )] = it->second; + tmp_other_endo_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first))] = it->second; int prev_var = -1; int prev_lag = -999999999; int count_col_endo = 0; @@ -1134,7 +1128,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin { int lag = it->first.first; int var = it->first.second.first; - if(prev_var != var || prev_lag != lag) + if (prev_var != var || prev_lag != lag) { prev_var = var; prev_lag = lag; @@ -1190,10 +1184,10 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin if (dynamic_cast<ExternalFunctionNode *>(*it) != NULL) (*it)->compileExternalFunctionOutput(code_file, instruction_number, false, tt2, map_idx, true, false, tef_terms); - FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find((*it)->idx)->second)); + FNUMEXPR_ fnumexpr(TemporaryTerm, (int) (map_idx.find((*it)->idx)->second)); fnumexpr.write(code_file, instruction_number); (*it)->compile(code_file, instruction_number, false, tt2, map_idx, true, false, tef_terms); - FSTPT_ fstpt((int)(map_idx.find((*it)->idx)->second)); + FSTPT_ fstpt((int) (map_idx.find((*it)->idx)->second)); fstpt.write(code_file, instruction_number); // Insert current node into tt2 tt2.insert(*it); @@ -1391,7 +1385,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin FJMPIFEVAL_ fjmp_if_eval1(instruction_number - prev_instruction_number); fjmp_if_eval1.write(code_file, instruction_number); code_file.seekp(pos3); - prev_instruction_number = instruction_number ; + prev_instruction_number = instruction_number; // The Jacobian if we have to solve the block determinsitic block prev_var = -1; @@ -1404,7 +1398,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin int var = it->first.second.first; unsigned int eqr = getBlockEquationID(block, eq); unsigned int varr = getBlockVariableID(block, var); - if(prev_var != var || prev_lag != lag) + if (prev_var != var || prev_lag != lag) { prev_var = var; prev_lag = lag; @@ -1426,7 +1420,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin int var = it->first.second.first; int eqr = getBlockInitialEquationID(block, eq); int varr = getBlockInitialExogenousID(block, var); - if(prev_var != var || prev_lag != lag) + if (prev_var != var || prev_lag != lag) { prev_var = var; prev_lag = lag; @@ -1437,7 +1431,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin FNUMEXPR_ fnumexpr(FirstExoDerivative, eqr, varr, lag); fnumexpr.write(code_file, instruction_number); id->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false); - FSTPG3_ fstpg3(eq, var, lag, /*var*/count_col_exo-1); + FSTPG3_ fstpg3(eq, var, lag, /*var*/ count_col_exo-1); fstpg3.write(code_file, instruction_number); } prev_var = -1; @@ -1450,7 +1444,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin int var = it->first.second.first; int eqr = getBlockInitialEquationID(block, eq); int varr = getBlockInitialDetExogenousID(block, var); - if(prev_var != var || prev_lag != lag) + if (prev_var != var || prev_lag != lag) { prev_var = var; prev_lag = lag; @@ -1474,7 +1468,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin int var = it->first.second.first; int eqr = getBlockInitialEquationID(block, eq); int varr = getBlockInitialOtherEndogenousID(block, var);; - if(prev_var != var || prev_lag != lag) + if (prev_var != var || prev_lag != lag) { prev_var = var; prev_lag = lag; @@ -1652,7 +1646,7 @@ DynamicModel::reform(const string name1) const void DynamicModel::Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const string &bin_basename, const int &num, - int &u_count_int, bool &file_open, bool is_two_boundaries) const + int &u_count_int, bool &file_open, bool is_two_boundaries) const { int j; std::ofstream SaveCode; @@ -2340,17 +2334,17 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de set<int> exogenous; exogenous.clear(); for (lag_var_t::const_iterator it = exo_block[block].begin(); it != exo_block[block].end(); it++) - for(var_t::const_iterator it1 = it->second.begin(); it1 != it->second.end(); it1++) + for (var_t::const_iterator it1 = it->second.begin(); it1 != it->second.end(); it1++) exogenous.insert(*it1); set<int> exogenous_det; exogenous_det.clear(); for (lag_var_t::const_iterator it = exo_det_block[block].begin(); it != exo_det_block[block].end(); it++) - for(var_t::const_iterator it1 = it->second.begin(); it1 != it->second.end(); it1++) + for (var_t::const_iterator it1 = it->second.begin(); it1 != it->second.end(); it1++) exogenous_det.insert(*it1); set<int> other_endogenous; other_endogenous.clear(); for (lag_var_t::const_iterator it = other_endo_block[block].begin(); it != other_endo_block[block].end(); it++) - for(var_t::const_iterator it1 = it->second.begin(); it1 != it->second.end(); it1++) + for (var_t::const_iterator it1 = it->second.begin(); it1 != it->second.end(); it1++) other_endogenous.insert(*it1); output << "block_structure.block(" << block+1 << ").Simulation_Type = " << simulation_type << ";\n"; output << "block_structure.block(" << block+1 << ").maximum_lag = " << max_lag << ";\n"; @@ -2529,13 +2523,13 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de { output << "M_.NNZDerivatives(2) = " << NNZDerivatives[1] << ";" << endl; if (order > 2) - output << "M_.NNZDerivatives(3) = " << NNZDerivatives[2] << ";" << endl; + output << "M_.NNZDerivatives(3) = " << NNZDerivatives[2] << ";" << endl; else - output << "M_.NNZDerivatives(3) = -1;" << endl; + output << "M_.NNZDerivatives(3) = -1;" << endl; } else output << "M_.NNZDerivatives(2) = -1;" << endl - << "M_.NNZDerivatives(3) = -1;" << endl; + << "M_.NNZDerivatives(3) = -1;" << endl; } @@ -2656,7 +2650,7 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative variable_block_lead_lag = vector< pair< int, pair< int, int> > >(equation_number()); for (unsigned int i = 0; i < getNbBlocks(); i++) { - for(unsigned int j = 0; j< getBlockSize(i); j++) + for (unsigned int j = 0; j < getBlockSize(i); j++) { equation_block[equation_reordered[k]] = i; int l = variable_reordered[k]; @@ -2837,20 +2831,20 @@ DynamicModel::collect_block_first_order_derivatives() if (lag > 0 && lag > other_endo_max_leadlag_block[block_eq].second) other_endo_max_leadlag_block[block_eq] = make_pair(other_endo_max_leadlag_block[block_eq].first, lag); tmp_derivative = derivative_other_endo[block_eq]; - { - map< int, map<int, int> >::const_iterator it = block_other_endo_index.find(block_eq); - if (it == block_other_endo_index.end()) - block_other_endo_index[block_eq][var] = 0; - else - { - map<int, int>::const_iterator it1 = it->second.find(var); - if (it1 == it->second.end()) - { - int size = block_other_endo_index[block_eq].size(); - block_other_endo_index[block_eq][var] = size; - } - } - } + { + map< int, map<int, int> >::const_iterator it = block_other_endo_index.find(block_eq); + if (it == block_other_endo_index.end()) + block_other_endo_index[block_eq][var] = 0; + else + { + map<int, int>::const_iterator it1 = it->second.find(var); + if (it1 == it->second.end()) + { + int size = block_other_endo_index[block_eq].size(); + block_other_endo_index[block_eq][var] = size; + } + } + } tmp_derivative[make_pair(lag, make_pair(eq, var))] = first_derivatives[make_pair(eq, getDerivID(symbol_table.getID(eEndogenous, var), lag))]; derivative_other_endo[block_eq] = tmp_derivative; lag_var = other_endo_block[block_eq]; @@ -2866,20 +2860,20 @@ DynamicModel::collect_block_first_order_derivatives() if (lag > 0 && lag > exo_max_leadlag_block[block_eq].second) exo_max_leadlag_block[block_eq] = make_pair(exo_max_leadlag_block[block_eq].first, lag); tmp_derivative = derivative_exo[block_eq]; - { - map< int, map<int, int> >::const_iterator it = block_exo_index.find(block_eq); - if (it == block_exo_index.end()) - block_exo_index[block_eq][var] = 0; - else - { - map<int, int>::const_iterator it1 = it->second.find(var); - if (it1 == it->second.end()) - { - int size = block_exo_index[block_eq].size(); - block_exo_index[block_eq][var] = size; - } - } - } + { + map< int, map<int, int> >::const_iterator it = block_exo_index.find(block_eq); + if (it == block_exo_index.end()) + block_exo_index[block_eq][var] = 0; + else + { + map<int, int>::const_iterator it1 = it->second.find(var); + if (it1 == it->second.end()) + { + int size = block_exo_index[block_eq].size(); + block_exo_index[block_eq][var] = size; + } + } + } tmp_derivative[make_pair(lag, make_pair(eq, var))] = first_derivatives[make_pair(eq, getDerivID(symbol_table.getID(eExogenous, var), lag))]; derivative_exo[block_eq] = tmp_derivative; lag_var = exo_block[block_eq]; @@ -2894,20 +2888,20 @@ DynamicModel::collect_block_first_order_derivatives() if (lag > 0 && lag > exo_det_max_leadlag_block[block_eq].second) exo_det_max_leadlag_block[block_eq] = make_pair(exo_det_max_leadlag_block[block_eq].first, lag); tmp_derivative = derivative_exo_det[block_eq]; - { - map< int, map<int, int> >::const_iterator it = block_det_exo_index.find(block_eq); - if (it == block_det_exo_index.end()) - block_det_exo_index[block_eq][var] = 0; - else - { - map<int, int>::const_iterator it1 = it->second.find(var); - if (it1 == it->second.end()) - { - int size = block_det_exo_index[block_eq].size(); - block_det_exo_index[block_eq][var] = size; - } - } - } + { + map< int, map<int, int> >::const_iterator it = block_det_exo_index.find(block_eq); + if (it == block_det_exo_index.end()) + block_det_exo_index[block_eq][var] = 0; + else + { + map<int, int>::const_iterator it1 = it->second.find(var); + if (it1 == it->second.end()) + { + int size = block_det_exo_index[block_eq].size(); + block_det_exo_index[block_eq][var] = size; + } + } + } tmp_derivative[make_pair(lag, make_pair(eq, var))] = first_derivatives[make_pair(eq, getDerivID(symbol_table.getID(eExogenous, var), lag))]; derivative_exo_det[block_eq] = tmp_derivative; lag_var = exo_det_block[block_eq]; @@ -2927,8 +2921,8 @@ DynamicModel::collect_block_first_order_derivatives() } - -void DynamicModel::collectBlockVariables() +void +DynamicModel::collectBlockVariables() { for (unsigned int block = 0; block < getNbBlocks(); block++) { @@ -2939,11 +2933,11 @@ void DynamicModel::collectBlockVariables() for (lag_var_t::const_iterator it = exo_block[block].begin(); it != exo_block[block].end(); it++) { int lag = it->first; - for(var_t::const_iterator it2 = it->second.begin(); it2 != it->second.end(); it2++) + for (var_t::const_iterator it2 = it->second.begin(); it2 != it->second.end(); it2++) { int var = *it2; tmp_var_exo.insert(var); - if(prev_var != var || prev_lag != lag) + if (prev_var != var || prev_lag != lag) { prev_var = var; prev_lag = lag; @@ -2955,7 +2949,6 @@ void DynamicModel::collectBlockVariables() } } - void DynamicModel::writeDynamicFile(const string &basename, bool block, bool bytecode, bool use_dll, int order) const { @@ -2963,7 +2956,7 @@ DynamicModel::writeDynamicFile(const string &basename, bool block, bool bytecode string t_basename = basename + "_dynamic"; if (block && bytecode) writeModelEquationsCode_Block(t_basename, basename, map_idx); - else if (!block && bytecode) + else if (!block && bytecode) writeModelEquationsCode(t_basename, basename, map_idx); else if (block && !bytecode) { @@ -3759,5 +3752,5 @@ DynamicModel::fillEvalContext(eval_context_t &eval_context) const vector <int> trendVars = symbol_table.getTrendVarIds(); for (vector <int>::const_iterator it = trendVars.begin(); it != trendVars.end(); it++) - eval_context[*it] = 2; //not <= 0 bc of log, not 1 bc of powers + eval_context[*it] = 2; //not <= 0 bc of log, not 1 bc of powers } diff --git a/DynamicModel.hh b/DynamicModel.hh index 82be0a345ffe6554bb1b14df399532e5a1b43f7a..5f4346a146f2d47128417847baf2e4f1f3fb1524 100644 --- a/DynamicModel.hh +++ b/DynamicModel.hh @@ -225,18 +225,17 @@ private: //!List for each block the exogenous variables vector<pair<var_t, int> > block_var_exo; - map< int, map<int , int> > block_exo_index, block_det_exo_index, block_other_endo_index; + map< int, map<int, int> > block_exo_index, block_det_exo_index, block_other_endo_index; //! for each block described the number of static, forward, backward and mixed variables in the block /*! pair< pair<static, forward>, pair<backward,mixed> > */ - vector<pair< pair<int, int>, pair<int,int> > > block_col_type; + vector<pair< pair<int, int>, pair<int, int> > > block_col_type; //! List for each variable its block number and its maximum lag and lead inside the block vector<pair<int, pair<int, int> > > variable_block_lead_lag; //! List for each equation its block number vector<int> equation_block; - //!Maximum lead and lag for each block on endogenous of the block, endogenous of the previous blocks, exogenous and deterministic exogenous vector<pair<int, int> > endo_max_leadlag_block, other_endo_max_leadlag_block, exo_max_leadlag_block, exo_det_max_leadlag_block, max_leadlag_block; @@ -272,7 +271,7 @@ public: //! Adds informations for simulation in a binary file void Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const string &bin_basename, - const int &num, int &u_count_int, bool &file_open, bool is_two_boundaries) const; + const int &num, int &u_count_int, bool &file_open, bool is_two_boundaries) const; //! Writes dynamic model file void writeDynamicFile(const string &basename, bool block, bool bytecode, bool use_dll, int order) const; //! Writes file containing parameters derivatives @@ -447,7 +446,7 @@ public: int getBlockVariableID(int variable_number) const { - return(variable_block_lead_lag[variable_number].first); + return (variable_block_lead_lag[variable_number].first); }; //! Return the position of the exogenous variable_number in the block number belonging to the block block_number virtual int @@ -457,7 +456,7 @@ public: if (it != block_exo_index.end()) { map<int, int>::const_iterator it1 = it->second.find(variable_number); - if( it1 != it->second.end()) + if (it1 != it->second.end()) return it1->second; else return -1; @@ -473,7 +472,7 @@ public: if (it != block_det_exo_index.end()) { map<int, int>::const_iterator it1 = it->second.find(variable_number); - if( it1 != it->second.end()) + if (it1 != it->second.end()) return it1->second; else return -1; @@ -489,7 +488,7 @@ public: if (it != block_other_endo_index.end()) { map<int, int>::const_iterator it1 = it->second.find(variable_number); - if( it1 != it->second.end()) + if (it1 != it->second.end()) return it1->second; else return -1; diff --git a/DynareMain2.cc b/DynareMain2.cc index 3813a6e272a4fcad3ce30c10f046efb2b71139c6..13a5f974aca484400afd31a528b32b71e499838c 100644 --- a/DynareMain2.cc +++ b/DynareMain2.cc @@ -38,7 +38,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tm // Do parsing and construct internal representation of mod file ModFile *mod_file = p.parse(in, debug); - ConfigFile config_file (parallel, parallel_test, parallel_slave_open_mode, cluster_name); + ConfigFile config_file(parallel, parallel_test, parallel_slave_open_mode, cluster_name); config_file.getConfigFileInfo(parallel_config_file); // Run checking pass diff --git a/ExprNode.cc b/ExprNode.cc index 21d75bcdf571a914eaf473f7b1c9e62ad4894718..b72f4e0e512e7f694334cd6c26fcbd61bba53405 100644 --- a/ExprNode.cc +++ b/ExprNode.cc @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2007-2011 Dynare Team * * This file is part of Dynare. @@ -159,14 +159,13 @@ ExprNode::writeOutput(ostream &output, ExprNodeOutputType output_type, const tem void ExprNode::compile(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const { deriv_node_temp_terms_t tef_terms; compile(CompileCode, instruction_number, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic, tef_terms); } - void ExprNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, @@ -175,12 +174,11 @@ ExprNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output // Nothing to do } - void ExprNode::compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, - deriv_node_temp_terms_t &tef_terms) const + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, + deriv_node_temp_terms_t &tef_terms) const { // Nothing to do } @@ -1200,14 +1198,14 @@ VariableNode::removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const if (get_lag() > 0) { expr_t growthFactorSequence = it->second->decreaseLeadsLags(-1); - for (int i=1; i<get_lag(); i++) + for (int i = 1; i < get_lag(); i++) growthFactorSequence = datatree.AddTimes(growthFactorSequence, it->second->decreaseLeadsLags(-1*(i+1))); return datatree.AddTimes(noTrendLeadLagNode, growthFactorSequence); } else //get_lag < 0 { expr_t growthFactorSequence = it->second; - for (int i=1; i<abs(get_lag()); i++) + for (int i = 1; i < abs(get_lag()); i++) growthFactorSequence = datatree.AddTimes(growthFactorSequence, it->second->decreaseLeadsLags(i)); return datatree.AddDivide(noTrendLeadLagNode, growthFactorSequence); } @@ -1698,15 +1696,14 @@ UnaryOpNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType out void UnaryOpNode::compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, - deriv_node_temp_terms_t &tef_terms) const + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, + deriv_node_temp_terms_t &tef_terms) const { arg->compileExternalFunctionOutput(CompileCode, instruction_number, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic, tef_terms); } - double UnaryOpNode::eval_opcode(UnaryOpcode op_code, double v) throw (EvalException, EvalExternalFunctionException) { @@ -1769,9 +1766,9 @@ UnaryOpNode::eval(const eval_context_t &eval_context) const throw (EvalException void UnaryOpNode::compile(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, - deriv_node_temp_terms_t &tef_terms) const + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, + deriv_node_temp_terms_t &tef_terms) const { temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this)); if (it != temporary_terms.end()) @@ -2136,7 +2133,7 @@ UnaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNo cerr << "ERROR: UnaryOpNode::substituteExpectation() should not arrive here. Please inform Dynare Team." << endl; exit(EXIT_FAILURE); } - else if (dynamic_cast<VariableNode *>(arg)->get_lag()!=0) + else if (dynamic_cast<VariableNode *>(arg)->get_lag() != 0) { cerr << "ERROR: EXPECTATION(" << expectation_information_set_name << ")(X) requres that X be from the current period." << endl; exit(EXIT_FAILURE); @@ -2274,7 +2271,7 @@ BinaryOpNode::composeDerivatives(expr_t darg1, expr_t darg2) return datatree.Zero; case oPower: if (darg2 == datatree.Zero) - if(darg1 == datatree.Zero) + if (darg1 == datatree.Zero) return datatree.Zero; else if (dynamic_cast<NumConstNode *>(arg2) != NULL) @@ -2308,14 +2305,14 @@ BinaryOpNode::composeDerivatives(expr_t darg1, expr_t darg2) expr_t f = datatree.AddPower(arg1, t12); expr_t first_part = datatree.AddTimes(f, t15); - for (int i=0; i<powerDerivOrder; i++) + for (int i = 0; i < powerDerivOrder; i++) first_part = datatree.AddTimes(first_part, datatree.AddMinus(arg2, datatree.AddPossiblyNegativeConstant(i))); t13 = datatree.Zero; - for (int i=0; i<powerDerivOrder; i++) + for (int i = 0; i < powerDerivOrder; i++) { t11 = datatree.One; - for (int j=0; j<powerDerivOrder; j++) + for (int j = 0; j < powerDerivOrder; j++) if (i != j) { t12 = datatree.AddMinus(arg2, datatree.AddPossiblyNegativeConstant(j)); @@ -2353,7 +2350,7 @@ BinaryOpNode::unpackPowerDeriv() const return const_cast<BinaryOpNode *>(this); expr_t front = datatree.One; - for (int i=0; i<powerDerivOrder; i++) + for (int i = 0; i < powerDerivOrder; i++) front = datatree.AddTimes(front, datatree.AddMinus(arg2, datatree.AddPossiblyNegativeConstant(i))); @@ -2551,14 +2548,14 @@ BinaryOpNode::eval_opcode(double v1, BinaryOpcode op_code, double v2, int derivO case oPower: return (pow(v1, v2)); case oPowerDeriv: - if (fabs(v1) < NEAR_ZERO && v2 > 0 && - derivOrder >= v2 && - fabs(v2-nearbyint(v2)) < NEAR_ZERO) + if (fabs(v1) < NEAR_ZERO && v2 > 0 + && derivOrder >= v2 + && fabs(v2-nearbyint(v2)) < NEAR_ZERO) return 0.0; else { double dxp = pow(v1, v2-derivOrder); - for (int i=0; i<derivOrder; i++) + for (int i = 0; i < derivOrder; i++) dxp *= v2--; return dxp; } @@ -2836,14 +2833,14 @@ BinaryOpNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType ou void BinaryOpNode::compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, - deriv_node_temp_terms_t &tef_terms) const + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, + deriv_node_temp_terms_t &tef_terms) const { arg1->compileExternalFunctionOutput(CompileCode, instruction_number, lhs_rhs, temporary_terms, map_idx, - dynamic, steady_dynamic, tef_terms); + dynamic, steady_dynamic, tef_terms); arg2->compileExternalFunctionOutput(CompileCode, instruction_number, lhs_rhs, temporary_terms, map_idx, - dynamic, steady_dynamic, tef_terms); + dynamic, steady_dynamic, tef_terms); } void @@ -2934,7 +2931,7 @@ BinaryOpNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr expr_t_2 = Compute_RHS(it.second.second, expr_t_2, it.first, 1); else if (it.second.second && it.second.first) /*Binary operator*/ expr_t_2 = Compute_RHS(it.second.first, it.second.second, it.first, 1); - else /*Unary operator*/ + else /*Unary operator*/ expr_t_2 = Compute_RHS((UnaryOpNode *) expr_t_2, (UnaryOpNode *) it.second.first, it.first, 0); } } @@ -3606,7 +3603,7 @@ TrinaryOpNode::eval_opcode(double v1, TrinaryOpcode op_code, double v2, double v case oNormcdf: return (0.5*(1+erf((v1-v2)/v3/M_SQRT2))); case oNormpdf: - return (1/(v3*sqrt(2*M_PI)*exp(pow((v1-v2)/v3,2)/2))); + return (1/(v3*sqrt(2*M_PI)*exp(pow((v1-v2)/v3, 2)/2))); } // Suppress GCC warning exit(EXIT_FAILURE); @@ -3624,9 +3621,9 @@ TrinaryOpNode::eval(const eval_context_t &eval_context) const throw (EvalExcepti void TrinaryOpNode::compile(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, - deriv_node_temp_terms_t &tef_terms) const + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, + deriv_node_temp_terms_t &tef_terms) const { // If current node is a temporary term temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this)); @@ -3745,16 +3742,16 @@ TrinaryOpNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType o void TrinaryOpNode::compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, - deriv_node_temp_terms_t &tef_terms) const + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, + deriv_node_temp_terms_t &tef_terms) const { arg1->compileExternalFunctionOutput(CompileCode, instruction_number, lhs_rhs, temporary_terms, map_idx, - dynamic, steady_dynamic, tef_terms); + dynamic, steady_dynamic, tef_terms); arg2->compileExternalFunctionOutput(CompileCode, instruction_number, lhs_rhs, temporary_terms, map_idx, - dynamic, steady_dynamic, tef_terms); + dynamic, steady_dynamic, tef_terms); arg3->compileExternalFunctionOutput(CompileCode, instruction_number, lhs_rhs, temporary_terms, map_idx, - dynamic, steady_dynamic, tef_terms); + dynamic, steady_dynamic, tef_terms); } void @@ -3965,14 +3962,14 @@ TrinaryOpNode::removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const } ExternalFunctionNode::ExternalFunctionNode(DataTree &datatree_arg, - int symb_id_arg, - const vector<expr_t> &arguments_arg) : + int symb_id_arg, + const vector<expr_t> &arguments_arg) : ExprNode(datatree_arg), symb_id(symb_id_arg), arguments(arguments_arg) { // Add myself to the external function map - datatree.external_function_node_map[make_pair(arguments,symb_id)] = this; + datatree.external_function_node_map[make_pair(arguments, symb_id)] = this; } void @@ -3985,7 +3982,7 @@ ExternalFunctionNode::prepareForDerivation() (*it)->prepareForDerivation(); non_null_derivatives = arguments.at(0)->non_null_derivatives; - for (int i = 1; i < (int)arguments.size(); i++) + for (int i = 1; i < (int) arguments.size(); i++) set_union(non_null_derivatives.begin(), non_null_derivatives.end(), arguments.at(i)->non_null_derivatives.begin(), @@ -4009,7 +4006,7 @@ expr_t ExternalFunctionNode::composeDerivatives(const vector<expr_t> &dargs) { vector<expr_t> dNodes; - for (int i = 0; i < (int)dargs.size(); i++) + for (int i = 0; i < (int) dargs.size(); i++) if (dargs.at(i) != 0) dNodes.push_back(datatree.AddTimes(dargs.at(i), datatree.AddFirstDerivExternalFunctionNode(symb_id, arguments, i+1))); @@ -4026,15 +4023,15 @@ ExternalFunctionNode::getChainRuleDerivative(int deriv_id, const map<int, expr_t assert(datatree.external_functions_table.getNargs(symb_id) > 0); vector<expr_t> dargs; for (vector<expr_t>::const_iterator it = arguments.begin(); - it != arguments.end(); it++) + it != arguments.end(); it++) dargs.push_back((*it)->getChainRuleDerivative(deriv_id, recursive_variables)); return composeDerivatives(dargs); } void ExternalFunctionNode::computeTemporaryTerms(map<expr_t, int> &reference_count, - temporary_terms_t &temporary_terms, - bool is_matlab) const + temporary_terms_t &temporary_terms, + bool is_matlab) const { temporary_terms.insert(const_cast<ExternalFunctionNode *>(this)); } @@ -4106,12 +4103,11 @@ ExternalFunctionNode::compileExternalFunctionArguments(ostream &CompileCode, uns { for (vector<expr_t>::const_iterator it = arguments.begin(); it != arguments.end(); it++) - (*it)->compile(CompileCode, instruction_number, lhs_rhs, temporary_terms, map_idx, - dynamic, steady_dynamic, tef_terms); - return(arguments.size()); + (*it)->compile(CompileCode, instruction_number, lhs_rhs, temporary_terms, map_idx, + dynamic, steady_dynamic, tef_terms); + return (arguments.size()); } - void ExternalFunctionNode::compile(ostream &CompileCode, unsigned int &instruction_number, bool lhs_rhs, const temporary_terms_t &temporary_terms, @@ -4171,8 +4167,8 @@ ExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutpu { stringstream ending; ending << "_tef_" << getIndxInTefTerms(symb_id, tef_terms); - if (symb_id == first_deriv_symb_id && - symb_id == second_deriv_symb_id) + if (symb_id == first_deriv_symb_id + && symb_id == second_deriv_symb_id) output << "int nlhs" << ending.str() << " = 3;" << endl << "double *TEF_" << indx << ", " << "*TEFD_" << indx << ", " @@ -4196,8 +4192,8 @@ ExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutpu << "prhs" << ending.str() << ", \"" << datatree.symbol_table.getName(symb_id) << "\");" << endl; - if (symb_id == first_deriv_symb_id && - symb_id == second_deriv_symb_id) + if (symb_id == first_deriv_symb_id + && symb_id == second_deriv_symb_id) output << "TEF_" << indx << " = mxGetPr(plhs" << ending.str() << "[0]);" << endl << "TEFD_" << indx << " = mxGetPr(plhs" << ending.str() << "[1]);" << endl << "TEFDD_" << indx << " = mxGetPr(plhs" << ending.str() << "[2]);" << endl @@ -4210,8 +4206,8 @@ ExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutpu } else { - if (symb_id == first_deriv_symb_id && - symb_id == second_deriv_symb_id) + if (symb_id == first_deriv_symb_id + && symb_id == second_deriv_symb_id) output << "[TEF_" << indx << " TEFD_"<< indx << " TEFDD_"<< indx << "] = "; else if (symb_id == first_deriv_symb_id) output << "[TEF_" << indx << " TEFD_"<< indx << "] = "; @@ -4234,7 +4230,7 @@ ExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCode, unsign int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id); assert(first_deriv_symb_id != eExtFunSetButNoNameProvided); - for (vector<expr_t>::const_iterator it = arguments.begin(); + for (vector<expr_t>::const_iterator it = arguments.begin(); it != arguments.end(); it++) (*it)->compileExternalFunctionOutput(CompileCode, instruction_number, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic, tef_terms); @@ -4247,28 +4243,28 @@ ExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCode, unsign assert(second_deriv_symb_id != eExtFunSetButNoNameProvided); unsigned int nb_output_arguments = 0; - if (symb_id == first_deriv_symb_id && - symb_id == second_deriv_symb_id) + if (symb_id == first_deriv_symb_id + && symb_id == second_deriv_symb_id) nb_output_arguments = 3; else if (symb_id == first_deriv_symb_id) nb_output_arguments = 2; else nb_output_arguments = 1; unsigned int nb_input_arguments = compileExternalFunctionArguments(CompileCode, instruction_number, lhs_rhs, temporary_terms, - map_idx, dynamic, steady_dynamic, tef_terms); + map_idx, dynamic, steady_dynamic, tef_terms); FCALL_ fcall(nb_output_arguments, nb_input_arguments, datatree.symbol_table.getName(symb_id), indx); - switch(nb_output_arguments) + switch (nb_output_arguments) { - case 1: - fcall.set_function_type(ExternalFunctionWithoutDerivative); - break; - case 2: - fcall.set_function_type(ExternalFunctionWithFirstDerivative); - break; - case 3: - fcall.set_function_type(ExternalFunctionWithFirstandSecondDerivative); - break; + case 1: + fcall.set_function_type(ExternalFunctionWithoutDerivative); + break; + case 2: + fcall.set_function_type(ExternalFunctionWithFirstDerivative); + break; + case 3: + fcall.set_function_type(ExternalFunctionWithFirstandSecondDerivative); + break; } fcall.write(CompileCode, instruction_number); FSTPTEF_ fstptef(indx); @@ -4278,11 +4274,11 @@ ExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCode, unsign void ExternalFunctionNode::computeTemporaryTerms(map<expr_t, int> &reference_count, - temporary_terms_t &temporary_terms, - map<expr_t, pair<int, int> > &first_occurence, - int Curr_block, - vector< vector<temporary_terms_t> > &v_temporary_terms, - int equation) const + temporary_terms_t &temporary_terms, + map<expr_t, pair<int, int> > &first_occurence, + int Curr_block, + vector< vector<temporary_terms_t> > &v_temporary_terms, + int equation) const { expr_t this2 = const_cast<ExternalFunctionNode *>(this); temporary_terms.insert(this2); @@ -4307,8 +4303,8 @@ ExternalFunctionNode::collectTemporary_terms(const temporary_terms_t &temporary_ else { for (vector<expr_t>::const_iterator it = arguments.begin(); - it != arguments.end(); it++) - (*it)->collectTemporary_terms(temporary_terms, temporary_terms_inuse, Curr_Block); + it != arguments.end(); it++) + (*it)->collectTemporary_terms(temporary_terms, temporary_terms_inuse, Curr_Block); } } @@ -4318,7 +4314,6 @@ ExternalFunctionNode::eval(const eval_context_t &eval_context) const throw (Eval throw EvalExternalFunctionException(); } - pair<int, expr_t> ExternalFunctionNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr_t> > > &List_of_Op_RHS) const { @@ -4532,7 +4527,7 @@ FirstDerivExternalFunctionNode::FirstDerivExternalFunctionNode(DataTree &datatre inputIndex(inputIndex_arg) { // Add myself to the first derivative external function map - datatree.first_deriv_external_function_node_map[make_pair(make_pair(arguments,inputIndex),symb_id)] = this; + datatree.first_deriv_external_function_node_map[make_pair(make_pair(arguments, inputIndex), symb_id)] = this; } void @@ -4561,7 +4556,7 @@ expr_t FirstDerivExternalFunctionNode::composeDerivatives(const vector<expr_t> &dargs) { vector<expr_t> dNodes; - for (int i = 0; i < (int)dargs.size(); i++) + for (int i = 0; i < (int) dargs.size(); i++) if (dargs.at(i) != 0) dNodes.push_back(datatree.AddTimes(dargs.at(i), datatree.AddSecondDerivExternalFunctionNode(symb_id, arguments, inputIndex, i+1))); @@ -4612,9 +4607,9 @@ FirstDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType void FirstDerivExternalFunctionNode::compile(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, - deriv_node_temp_terms_t &tef_terms) const + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, + deriv_node_temp_terms_t &tef_terms) const { temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<FirstDerivExternalFunctionNode *>(this)); if (it != temporary_terms.end()) @@ -4744,9 +4739,9 @@ FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Exp void FirstDerivExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, - deriv_node_temp_terms_t &tef_terms) const + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, + deriv_node_temp_terms_t &tef_terms) const { int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id); assert(first_deriv_symb_id != eExtFunSetButNoNameProvided); @@ -4755,7 +4750,7 @@ FirstDerivExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCo return; unsigned int nb_add_input_arguments = compileExternalFunctionArguments(CompileCode, instruction_number, lhs_rhs, temporary_terms, - map_idx, dynamic, steady_dynamic, tef_terms); + map_idx, dynamic, steady_dynamic, tef_terms); if (first_deriv_symb_id == eExtFunNotSet) { unsigned int nb_input_arguments = 0; @@ -4779,7 +4774,6 @@ FirstDerivExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCo unsigned int nb_output_arguments = 1; - FCALL_ fcall(nb_output_arguments, nb_add_input_arguments, datatree.symbol_table.getName(first_deriv_symb_id), indx); fcall.set_function_type(ExternalFunctionFirstDerivative); fcall.write(CompileCode, instruction_number); @@ -4788,7 +4782,6 @@ FirstDerivExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCo } } - SecondDerivExternalFunctionNode::SecondDerivExternalFunctionNode(DataTree &datatree_arg, int top_level_symb_id_arg, const vector<expr_t> &arguments_arg, @@ -4799,7 +4792,7 @@ SecondDerivExternalFunctionNode::SecondDerivExternalFunctionNode(DataTree &datat inputIndex2(inputIndex2_arg) { // Add myself to the second derivative external function map - datatree.second_deriv_external_function_node_map[make_pair(make_pair(arguments,make_pair(inputIndex1,inputIndex2)),symb_id)] = this; + datatree.second_deriv_external_function_node_map[make_pair(make_pair(arguments, make_pair(inputIndex1, inputIndex2)), symb_id)] = this; } void @@ -4812,11 +4805,11 @@ SecondDerivExternalFunctionNode::computeTemporaryTerms(map<expr_t, int> &referen void SecondDerivExternalFunctionNode::computeTemporaryTerms(map<expr_t, int> &reference_count, - temporary_terms_t &temporary_terms, - map<expr_t, pair<int, int> > &first_occurence, - int Curr_block, - vector< vector<temporary_terms_t> > &v_temporary_terms, - int equation) const + temporary_terms_t &temporary_terms, + map<expr_t, pair<int, int> > &first_occurence, + int Curr_block, + vector< vector<temporary_terms_t> > &v_temporary_terms, + int equation) const { expr_t this2 = const_cast<SecondDerivExternalFunctionNode *>(this); temporary_terms.insert(this2); @@ -4894,8 +4887,8 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id); assert(second_deriv_symb_id != eExtFunSetButNoNameProvided); - if (alreadyWrittenAsTefTerm(second_deriv_symb_id, tef_terms) || - second_deriv_symb_id == symb_id) + if (alreadyWrittenAsTefTerm(second_deriv_symb_id, tef_terms) + || second_deriv_symb_id == symb_id) return; if (IS_C(output_type)) diff --git a/ExprNode.hh b/ExprNode.hh index 15bab4f0ac492a5d91cae4472a8ef496a734cfe0..c4bce3db3e42cadabeb00806976489cce0288e85 100644 --- a/ExprNode.hh +++ b/ExprNode.hh @@ -107,7 +107,6 @@ enum ExprNodeOutputType #define MIN_COST_C (40*4) #define MIN_COST(is_matlab) ((is_matlab) ? MIN_COST_MATLAB : MIN_COST_C) - //! Base class for expression nodes class ExprNode { @@ -198,9 +197,9 @@ public: deriv_node_temp_terms_t &tef_terms) const; virtual void compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, - deriv_node_temp_terms_t &tef_terms) const; + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, + deriv_node_temp_terms_t &tef_terms) const; //! Computes the set of all variables of a given symbol type in the expression /*! @@ -252,7 +251,7 @@ public: { }; - virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException ) = 0; + virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException) = 0; virtual void compile(ostream &CompileCode, unsigned int &instruction_number, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, deriv_node_temp_terms_t &tef_terms) const = 0; void compile(ostream &CompileCode, unsigned int &instruction_number, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const; //! Creates a static version of this node @@ -358,14 +357,14 @@ public: /*! \param[in] value of the numerical constante \param[out] the boolean equal to true if NodeId is a constant equal to value - */ + */ virtual bool isNumConstNodeEqualTo(double value) const = 0; //! Return true if the nodeID is a variable withe a type equal to type_arg, a specific variable id aqual to varfiable_id and a lag equal to lag_arg and false otherwise /*! \param[in] the type (type_arg), specifique variable id (variable_id and the lag (lag_arg) \param[out] the boolean equal to true if NodeId is the variable - */ + */ virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const = 0; //! Replaces the Trend var with datatree.One @@ -415,7 +414,7 @@ public: virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const; virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const; virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const; - virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException ); + virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException); virtual void compile(ostream &CompileCode, unsigned int &instruction_number, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, deriv_node_temp_terms_t &tef_terms) const; virtual expr_t toStatic(DataTree &static_datatree) const; virtual pair<int, expr_t> normalizeEquation(int symb_id_endo, vector<pair<int, pair<expr_t, expr_t> > > &List_of_Op_RHS) const; @@ -462,7 +461,7 @@ public: vector< vector<temporary_terms_t> > &v_temporary_terms, int equation) const; virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const; - virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException ); + virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException); virtual void compile(ostream &CompileCode, unsigned int &instruction_number, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, deriv_node_temp_terms_t &tef_terms) const; virtual expr_t toStatic(DataTree &static_datatree) const; SymbolType @@ -533,8 +532,8 @@ public: int equation) const; virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const; virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const; - static double eval_opcode(UnaryOpcode op_code, double v) throw (EvalException, EvalExternalFunctionException ); - virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException ); + static double eval_opcode(UnaryOpcode op_code, double v) throw (EvalException, EvalExternalFunctionException); + virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException); virtual void compile(ostream &CompileCode, unsigned int &instruction_number, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, deriv_node_temp_terms_t &tef_terms) const; //! Returns operand expr_t @@ -607,8 +606,8 @@ public: int equation) const; virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const; virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const; - static double eval_opcode(double v1, BinaryOpcode op_code, double v2, int derivOrder) throw (EvalException, EvalExternalFunctionException ); - virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException ); + static double eval_opcode(double v1, BinaryOpcode op_code, double v2, int derivOrder) throw (EvalException, EvalExternalFunctionException); + virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException); virtual void compile(ostream &CompileCode, unsigned int &instruction_number, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, deriv_node_temp_terms_t &tef_terms) const; virtual expr_t Compute_RHS(expr_t arg1, expr_t arg2, int op, int op_type) const; //! Returns first operand @@ -693,8 +692,8 @@ public: int equation) const; virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const; virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const; - static double eval_opcode(double v1, TrinaryOpcode op_code, double v2, double v3) throw (EvalException, EvalExternalFunctionException ); - virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException ); + static double eval_opcode(double v1, TrinaryOpcode op_code, double v2, double v3) throw (EvalException, EvalExternalFunctionException); + virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException); virtual void compile(ostream &CompileCode, unsigned int &instruction_number, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, deriv_node_temp_terms_t &tef_terms) const; virtual expr_t toStatic(DataTree &static_datatree) const; virtual pair<int, expr_t> normalizeEquation(int symb_id_endo, vector<pair<int, pair<expr_t, expr_t> > > &List_of_Op_RHS) const; @@ -741,7 +740,7 @@ protected: void writeExternalFunctionArguments(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const; public: ExternalFunctionNode(DataTree &datatree_arg, int symb_id_arg, - const vector<expr_t> &arguments_arg); + const vector<expr_t> &arguments_arg); virtual void prepareForDerivation(); virtual void computeTemporaryTerms(map<expr_t, int> &reference_count, temporary_terms_t &temporary_terms, bool is_matlab) const; virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const; @@ -749,9 +748,9 @@ public: const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const; virtual void compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, - deriv_node_temp_terms_t &tef_terms) const; + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, + deriv_node_temp_terms_t &tef_terms) const; virtual void computeTemporaryTerms(map<expr_t, int> &reference_count, temporary_terms_t &temporary_terms, map<expr_t, pair<int, int> > &first_occurence, @@ -760,11 +759,11 @@ public: int equation) const; virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const; virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const; - virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException ); + virtual double eval(const eval_context_t &eval_context) const throw (EvalException, EvalExternalFunctionException); unsigned int compileExternalFunctionArguments(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, - deriv_node_temp_terms_t &tef_terms) const; + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, + deriv_node_temp_terms_t &tef_terms) const; virtual void compile(ostream &CompileCode, unsigned int &instruction_number, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, deriv_node_temp_terms_t &tef_terms) const; virtual expr_t toStatic(DataTree &static_datatree) const; @@ -810,16 +809,16 @@ public: int equation) const; virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const; virtual void compile(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, - deriv_node_temp_terms_t &tef_terms) const; + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, + deriv_node_temp_terms_t &tef_terms) const; virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const; virtual void compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number, - bool lhs_rhs, const temporary_terms_t &temporary_terms, - const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, - deriv_node_temp_terms_t &tef_terms) const; + bool lhs_rhs, const temporary_terms_t &temporary_terms, + const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, + deriv_node_temp_terms_t &tef_terms) const; }; class SecondDerivExternalFunctionNode : public ExternalFunctionNode diff --git a/ExternalFunctionsTable.cc b/ExternalFunctionsTable.cc index 2650a977d2220fb3933dc7abebe275859ece1e99..5491d5057905ef277f690705371e350b60270b66 100644 --- a/ExternalFunctionsTable.cc +++ b/ExternalFunctionsTable.cc @@ -48,33 +48,33 @@ ExternalFunctionsTable::addExternalFunction(int symb_id, const external_function external_function_options_chng.nargs = eExtFunNotSet; // Ensure 1st & 2nd deriv option consistency - if (external_function_options_chng.secondDerivSymbID == symb_id && - external_function_options_chng.firstDerivSymbID != symb_id) + if (external_function_options_chng.secondDerivSymbID == symb_id + && external_function_options_chng.firstDerivSymbID != symb_id) { cerr << "ERROR: If the second derivative is provided by the top-level function " << "the first derivative must also be provided by the same function." << endl; exit(EXIT_FAILURE); } - if ((external_function_options_chng.secondDerivSymbID != symb_id && - external_function_options_chng.firstDerivSymbID == symb_id) && - external_function_options_chng.secondDerivSymbID != eExtFunNotSet) + if ((external_function_options_chng.secondDerivSymbID != symb_id + && external_function_options_chng.firstDerivSymbID == symb_id) + && external_function_options_chng.secondDerivSymbID != eExtFunNotSet) { cerr << "ERROR: If the first derivative is provided by the top-level function, the " << "second derivative cannot be provided by any other external function." << endl; exit(EXIT_FAILURE); } - if (external_function_options_chng.secondDerivSymbID != eExtFunNotSet&& - external_function_options_chng.firstDerivSymbID == eExtFunNotSet) + if (external_function_options_chng.secondDerivSymbID != eExtFunNotSet + && external_function_options_chng.firstDerivSymbID == eExtFunNotSet) { cerr << "ERROR: If the second derivative is provided, the first derivative must also be provided." << endl; exit(EXIT_FAILURE); } - if (external_function_options_chng.secondDerivSymbID == external_function_options_chng.firstDerivSymbID && - external_function_options_chng.firstDerivSymbID != symb_id && - external_function_options_chng.firstDerivSymbID != eExtFunNotSet) + if (external_function_options_chng.secondDerivSymbID == external_function_options_chng.firstDerivSymbID + && external_function_options_chng.firstDerivSymbID != symb_id + && external_function_options_chng.firstDerivSymbID != eExtFunNotSet) { cerr << "ERROR: If the Jacobian and Hessian are provided by the same function, that " << "function must be the top-level function." << endl; @@ -90,7 +90,7 @@ ExternalFunctionsTable::addExternalFunction(int symb_id, const external_function if (!ok_to_overwrite) // prevents multiple non-compatible calls to external_function(name=funcname) { // e.g. e_f(name=a,nargs=1,fd,sd) and e_f(name=a,nargs=2,fd=b,sd=c) should cause an error - if (external_function_options_chng.nargs != getNargs(symb_id)) + if (external_function_options_chng.nargs != getNargs(symb_id)) { cerr << "ERROR: The number of arguments passed to the external_function() statement do not " << "match the number of arguments passed to a previous call or declaration of the top-level function."<< endl; diff --git a/ExternalFunctionsTable.hh b/ExternalFunctionsTable.hh index 85e97e40fab8633180cfc598037b3792fc437bed..8775a90d14860cfeb5b80a2c71fbe2755c9c1d22 100644 --- a/ExternalFunctionsTable.hh +++ b/ExternalFunctionsTable.hh @@ -69,7 +69,7 @@ public: //! See if the function exists in the External Functions Table inline bool exists(int symb_id) const; //! Get the number of arguments for a given external function - inline int getNargs( int symb_id) const throw (UnknownExternalFunctionSymbolIDException); + inline int getNargs(int symb_id) const throw (UnknownExternalFunctionSymbolIDException); //! Get the symbol_id of the first derivative function inline int getFirstDerivSymbID(int symb_id) const throw (UnknownExternalFunctionSymbolIDException); //! Get the symbol_id of the second derivative function diff --git a/MinimumFeedbackSet.cc b/MinimumFeedbackSet.cc index 19b1537b210623401c0eaea459352ae2cbd4c5e4..e24507f9d1e4caf90ee4ae860fed12c06df39c0a 100644 --- a/MinimumFeedbackSet.cc +++ b/MinimumFeedbackSet.cc @@ -175,7 +175,7 @@ namespace MFS if (in_degree(vertex, G) > 0 && out_degree(vertex, G) > 0) for (tie(it_in, in_end) = in_edges(vertex, G); it_in != in_end; ++it_in) for (tie(it_out, out_end) = out_edges(vertex, G); it_out != out_end; ++it_out) - if (source(*it_in, G) == target(*it_out, G) && source(*it_in, G) != target(*it_in, G)) // not a loop + if (source(*it_in, G) == target(*it_out, G) && source(*it_in, G) != target(*it_in, G)) // not a loop Doublet.push_back(source(*it_in, G)); return Doublet; } diff --git a/ModFile.cc b/ModFile.cc index 503a45bfb8ee151334687f3651884dad8e6bdd39..0d8a134145425b8c8d2a3902435a3d25970a451a 100644 --- a/ModFile.cc +++ b/ModFile.cc @@ -141,7 +141,7 @@ ModFile::checkPass() exit(EXIT_FAILURE); } - if ( (stochastic_statement_present || mod_file_struct.check_present || mod_file_struct.steady_present) && no_static) + if ((stochastic_statement_present || mod_file_struct.check_present || mod_file_struct.steady_present) && no_static) { cerr << "no_static option is incompatible with stochastic simulation, estimation, optimal policy, steady or check command" << endl; exit(EXIT_FAILURE); @@ -303,7 +303,7 @@ ModFile::computingPass(bool no_tmp_terms) // Compute static model and its derivatives dynamic_model.toStatic(static_model); - if(!no_static) + if (!no_static) { static_model.initializeVariablesAndEquations(); static_model.computingPass(global_eval_context, no_tmp_terms, false, block, byte_code); @@ -407,7 +407,6 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool console, else mOutputFile << "M_.H = 0;" << endl; - if (linear == 1) mOutputFile << "options_.linear = 1;" << endl; @@ -470,9 +469,9 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool console, // Some mex commands are enclosed in an eval(), because otherwise it will make Octave fail #if defined(_WIN32) || defined(__CYGWIN32__) if (msvc) - mOutputFile << " eval('mex -O LINKFLAGS=\"$LINKFLAGS /export:Dynamic\" " << basename << "_dynamic.c')" << endl; // MATLAB/Windows + Microsoft Visual C++ + mOutputFile << " eval('mex -O LINKFLAGS=\"$LINKFLAGS /export:Dynamic\" " << basename << "_dynamic.c')" << endl; // MATLAB/Windows + Microsoft Visual C++ else if (cygwin) - mOutputFile << " eval('mex -O PRELINK_CMDS1=\"echo EXPORTS > mex.def & echo mexFunction >> mex.def & echo Dynamic >> mex.def\" " << basename << "_dynamic.c')" << endl; // MATLAB/Windows + Cygwin g++ + mOutputFile << " eval('mex -O PRELINK_CMDS1=\"echo EXPORTS > mex.def & echo mexFunction >> mex.def & echo Dynamic >> mex.def\" " << basename << "_dynamic.c')" << endl; // MATLAB/Windows + Cygwin g++ else mOutputFile << " error('When using the USE_DLL option, you must give either ''cygwin'' or ''msvc'' option to the ''dynare'' command')" << endl; #else diff --git a/ModelTree.cc b/ModelTree.cc index daa9ecf20a96a14e2b260c8871155dbd26a689c1..495860453bc9ff0ae1cc837d20acc704a3979164 100644 --- a/ModelTree.cc +++ b/ModelTree.cc @@ -537,7 +537,7 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob G2); vector<int> endo2block(num_vertices(G2)), discover_time(num_vertices(G2)); - iterator_property_map<int*, property_map<AdjacencyList_t, vertex_index_t>::type, int, int&> endo2block_map(&endo2block[0], get(vertex_index, G2)); + iterator_property_map<int *, property_map<AdjacencyList_t, vertex_index_t>::type, int, int &> endo2block_map(&endo2block[0], get(vertex_index, G2)); // Compute strongly connected components int num = strong_components(G2, endo2block_map); @@ -759,7 +759,7 @@ ModelTree::printBlockDecomposition(const vector<pair<int, int> > &blocks) const } block_type_firstequation_size_mfs_t -ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_jacobian, vector<pair<int, int> > &blocks, const equation_type_and_normalized_equation_t &Equation_Type, const vector<int> &variable_reordered, const vector<int> &equation_reordered, vector<unsigned int> &n_static, vector<unsigned int> &n_forward, vector<unsigned int> &n_backward, vector<unsigned int> &n_mixed, vector<pair< pair<int, int>, pair<int,int> > > &block_col_type) +ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_jacobian, vector<pair<int, int> > &blocks, const equation_type_and_normalized_equation_t &Equation_Type, const vector<int> &variable_reordered, const vector<int> &equation_reordered, vector<unsigned int> &n_static, vector<unsigned int> &n_forward, vector<unsigned int> &n_backward, vector<unsigned int> &n_mixed, vector<pair< pair<int, int>, pair<int, int> > > &block_col_type) { int i = 0; int count_equ = 0, blck_count_simult = 0; @@ -864,27 +864,27 @@ ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_j Lead = block_lag_lead[block_type_size_mfs.size()-1].second; block_lag_lead[block_type_size_mfs.size()-1] = make_pair(Lag, Lead); pair< pair< unsigned int, unsigned int>, pair<unsigned int, unsigned int> > tmp = block_col_type[block_col_type.size()-1]; - block_col_type[block_col_type.size()-1] = make_pair( make_pair(tmp.first.first+l_n_static, tmp.first.second+l_n_forward), make_pair(tmp.second.first+l_n_backward, tmp.second.second+l_n_mixed) ); + block_col_type[block_col_type.size()-1] = make_pair(make_pair(tmp.first.first+l_n_static, tmp.first.second+l_n_forward), make_pair(tmp.second.first+l_n_backward, tmp.second.second+l_n_mixed)); } else { block_type_size_mfs.push_back(make_pair(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size))); block_lag_lead.push_back(make_pair(Lag, Lead)); - block_col_type.push_back(make_pair( make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed) )); + block_col_type.push_back(make_pair(make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed))); } } else { block_type_size_mfs.push_back(make_pair(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size))); block_lag_lead.push_back(make_pair(Lag, Lead)); - block_col_type.push_back(make_pair( make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed) )); + block_col_type.push_back(make_pair(make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed))); } } else { block_type_size_mfs.push_back(make_pair(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size))); block_lag_lead.push_back(make_pair(Lag, Lead)); - block_col_type.push_back(make_pair( make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed) )); + block_col_type.push_back(make_pair(make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed))); } prev_Type = Simulation_Type; eq += Blck_Size; @@ -1095,7 +1095,6 @@ ModelTree::writeTemporaryTerms(const temporary_terms_t &tt, ostream &output, // To store the functions that have already been written in the form TEF* = ext_fun(); deriv_node_temp_terms_t tef_terms; - for (temporary_terms_t::const_iterator it = tt.begin(); it != tt.end(); it++) { @@ -1135,17 +1134,17 @@ ModelTree::compileTemporaryTerms(ostream &code_file, unsigned int &instruction_n (*it)->compileExternalFunctionOutput(code_file, instruction_number, false, tt2, map_idx, dynamic, steady_dynamic, tef_terms); } - FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find((*it)->idx)->second)); + FNUMEXPR_ fnumexpr(TemporaryTerm, (int) (map_idx.find((*it)->idx)->second)); fnumexpr.write(code_file, instruction_number); (*it)->compile(code_file, instruction_number, false, tt2, map_idx, dynamic, steady_dynamic, tef_terms); if (dynamic) { - FSTPT_ fstpt((int)(map_idx.find((*it)->idx)->second)); + FSTPT_ fstpt((int) (map_idx.find((*it)->idx)->second)); fstpt.write(code_file, instruction_number); } else { - FSTPST_ fstpst((int)(map_idx.find((*it)->idx)->second)); + FSTPST_ fstpst((int) (map_idx.find((*it)->idx)->second)); fstpst.write(code_file, instruction_number); } // Insert current node into tt2 @@ -1153,8 +1152,6 @@ ModelTree::compileTemporaryTerms(ostream &code_file, unsigned int &instruction_n } } - - void ModelTree::writeModelLocalVariables(ostream &output, ExprNodeOutputType output_type) const { @@ -1269,7 +1266,7 @@ ModelTree::compileModelEquations(ostream &code_file, unsigned int &instruction_n void ModelTree::Write_Inf_To_Bin_File(const string &basename, - int &u_count_int, bool &file_open, bool is_two_boundaries, int block_mfs) const + int &u_count_int, bool &file_open, bool is_two_boundaries, int block_mfs) const { int j; std::ofstream SaveCode; @@ -1284,7 +1281,7 @@ ModelTree::Write_Inf_To_Bin_File(const string &basename, exit(EXIT_FAILURE); } u_count_int = 0; - for (first_derivatives_t::const_iterator it = first_derivatives.begin();it != first_derivatives.end(); it++) + for (first_derivatives_t::const_iterator it = first_derivatives.begin(); it != first_derivatives.end(); it++) { int deriv_id = it->first.second; if (getTypeByDerivID(deriv_id) == eEndogenous) diff --git a/ModelTree.hh b/ModelTree.hh index e05da933242a5d7b7b89e8dbca641bf61430d564..7bc091fc9e0d0d2cedff08ae26a6c8f3e34c3493 100644 --- a/ModelTree.hh +++ b/ModelTree.hh @@ -175,7 +175,7 @@ protected: //! Compute the block decomposition and for a non-recusive block find the minimum feedback set void computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob_map_t &static_jacobian, const dynamic_jacob_map_t &dynamic_jacobian, vector<int> &equation_reordered, vector<int> &variable_reordered, vector<pair<int, int> > &blocks, const equation_type_and_normalized_equation_t &Equation_Type, bool verbose_, bool select_feedback_variable, int mfs, vector<int> &inv_equation_reordered, vector<int> &inv_variable_reordered, lag_lead_vector_t &equation_lag_lead, lag_lead_vector_t &variable_lag_lead_t, vector<unsigned int> &n_static, vector<unsigned int> &n_forward, vector<unsigned int> &n_backward, vector<unsigned int> &n_mixed) const; //! Reduce the number of block merging the same type equation in the prologue and the epilogue and determine the type of each block - block_type_firstequation_size_mfs_t reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_jacobian, vector<pair<int, int> > &blocks, const equation_type_and_normalized_equation_t &Equation_Type, const vector<int> &variable_reordered, const vector<int> &equation_reordered, vector<unsigned int> &n_static, vector<unsigned int> &n_forward, vector<unsigned int> &n_backward, vector<unsigned int> &n_mixed, vector<pair< pair<int, int>, pair<int,int> > > &block_col_type); + block_type_firstequation_size_mfs_t reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_jacobian, vector<pair<int, int> > &blocks, const equation_type_and_normalized_equation_t &Equation_Type, const vector<int> &variable_reordered, const vector<int> &equation_reordered, vector<unsigned int> &n_static, vector<unsigned int> &n_forward, vector<unsigned int> &n_backward, vector<unsigned int> &n_mixed, vector<pair< pair<int, int>, pair<int, int> > > &block_col_type); //! Determine the maximum number of lead and lag for the endogenous variable in a bloc void getVariableLeadLagByBlock(const dynamic_jacob_map_t &dynamic_jacobian, const vector<int> &components_set, int nb_blck_sim, lag_lead_vector_t &equation_lead_lag, lag_lead_vector_t &variable_lead_lag, const vector<int> &equation_reordered, const vector<int> &variable_reordered) const; //! Print an abstract of the block structure of the model diff --git a/ParsingDriver.cc b/ParsingDriver.cc index 51e9db10b281c1fcfd4ff3948cff5e351b587614..8f122655ded106430033b7d8e98de24428658014 100644 --- a/ParsingDriver.cc +++ b/ParsingDriver.cc @@ -452,7 +452,6 @@ ParsingDriver::block() mod_file->block = true; } - void ParsingDriver::no_static() { @@ -1523,7 +1522,7 @@ expr_t ParsingDriver::add_expectation(string *arg1, expr_t arg2) { expr_t expectationNode; - if ("varobs"==*arg1 || "full"==*arg1) + if ("varobs" == *arg1 || "full" == *arg1) if (dynamic_cast<VariableNode *>(arg2) == NULL) error("EXPECTATION(" + *arg1 + ")(X) can only be used when X is a single variable."); else @@ -1731,12 +1730,12 @@ ParsingDriver::external_function() if (current_external_function_id == eExtFunNotSet) error("The 'name' option must be passed to external_function()."); - if (current_external_function_options.secondDerivSymbID >= 0 && - current_external_function_options.firstDerivSymbID == eExtFunNotSet) + if (current_external_function_options.secondDerivSymbID >= 0 + && current_external_function_options.firstDerivSymbID == eExtFunNotSet) error("If the second derivative is provided to the external_function command, the first derivative must also be provided."); - if (current_external_function_options.secondDerivSymbID == eExtFunSetButNoNameProvided && - current_external_function_options.firstDerivSymbID != eExtFunSetButNoNameProvided) + if (current_external_function_options.secondDerivSymbID == eExtFunSetButNoNameProvided + && current_external_function_options.firstDerivSymbID != eExtFunSetButNoNameProvided) error("If the second derivative is provided in the top-level function, the first derivative must also be provided in that function."); mod_file->external_functions_table.addExternalFunction(current_external_function_id, current_external_function_options, true); @@ -1827,11 +1826,11 @@ ParsingDriver::add_model_var_or_external_function(string *function_name, bool in if (in_model_block) if (mod_file->external_functions_table.getNargs(symb_id) == eExtFunNotSet) - error("Before using " + *function_name + - "() in the model block, you must first declare it via the external_function() statement"); - else if ((int)(stack_external_function_args.top().size()) != mod_file->external_functions_table.getNargs(symb_id)) - error("The number of arguments passed to " + *function_name + - "() does not match those of a previous call or declaration of this function."); + error("Before using " + *function_name + +"() in the model block, you must first declare it via the external_function() statement"); + else if ((int) (stack_external_function_args.top().size()) != mod_file->external_functions_table.getNargs(symb_id)) + error("The number of arguments passed to " + *function_name + +"() does not match those of a previous call or declaration of this function."); } } else diff --git a/StaticModel.cc b/StaticModel.cc index 02743832f4220cc65deebcf7d17ec43d5fff33ee..ac497a9396c7160824879d6c03186d76c0748d94 100644 --- a/StaticModel.cc +++ b/StaticModel.cc @@ -74,7 +74,7 @@ StaticModel::compileChainRuleDerivative(ofstream &code_file, unsigned int &instr void StaticModel::initializeVariablesAndEquations() { - for(int j = 0; j < equation_number(); j++) + for (int j = 0; j < equation_number(); j++) { equation_reordered.push_back(j); variable_reordered.push_back(j); @@ -201,7 +201,7 @@ StaticModel::computeTemporaryTermsMapping(temporary_terms_t &temporary_terms, ma // Add a mapping form node ID to temporary terms order int j = 0; for (temporary_terms_t::const_iterator it = temporary_terms.begin(); - it != temporary_terms.end(); it++) + it != temporary_terms.end(); it++) map_idx[(*it)->idx] = j++; } @@ -504,8 +504,8 @@ StaticModel::writeModelEquationsCode(const string file_name, const string bin_ba fldr.write(code_file, instruction_number); if (derivatives[i].size()) { - for(vector<pair<int, int> >::const_iterator it = derivatives[i].begin(); - it != derivatives[i].end(); it++) + for (vector<pair<int, int> >::const_iterator it = derivatives[i].begin(); + it != derivatives[i].end(); it++) { FLDSU_ fldsu(it->second); fldsu.write(code_file, instruction_number); @@ -535,7 +535,7 @@ StaticModel::writeModelEquationsCode(const string file_name, const string bin_ba FJMPIFEVAL_ fjmp_if_eval1(instruction_number - prev_instruction_number); fjmp_if_eval1.write(code_file, instruction_number); code_file.seekp(pos3); - prev_instruction_number = instruction_number ; + prev_instruction_number = instruction_number; temporary_terms_t tt2; tt2.clear(); @@ -560,7 +560,7 @@ StaticModel::writeModelEquationsCode(const string file_name, const string bin_ba derivatives[eq].push_back(make_pair(var, count_u)); d1->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false); - FSTPG2_ fstpg2(eq,var); + FSTPG2_ fstpg2(eq, var); fstpg2.write(code_file, instruction_number); } } @@ -653,7 +653,7 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string 0, 0, u_count_int, - /*symbol_table.endo_nbr()*/block_size + /*symbol_table.endo_nbr()*/ block_size ); fbeginblock.write(code_file, instruction_number); @@ -677,10 +677,10 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string if (dynamic_cast<ExternalFunctionNode *>(*it) != NULL) (*it)->compileExternalFunctionOutput(code_file, instruction_number, false, tt2, map_idx, false, false, tef_terms); - FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find((*it)->idx)->second)); + FNUMEXPR_ fnumexpr(TemporaryTerm, (int) (map_idx.find((*it)->idx)->second)); fnumexpr.write(code_file, instruction_number); (*it)->compile(code_file, instruction_number, false, tt2, map_idx, false, false, tef_terms); - FSTPST_ fstpst((int)(map_idx.find((*it)->idx)->second)); + FSTPST_ fstpst((int) (map_idx.find((*it)->idx)->second)); fstpst.write(code_file, instruction_number); // Insert current node into tt2 tt2.insert(*it); @@ -746,8 +746,6 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string FENDEQU_ fendequ; fendequ.write(code_file, instruction_number); - - // The Jacobian if we have to solve the block if (simulation_type != EVALUATE_BACKWARD && simulation_type != EVALUATE_FORWARD) @@ -854,7 +852,7 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string FJMPIFEVAL_ fjmp_if_eval1(instruction_number - prev_instruction_number); fjmp_if_eval1.write(code_file, instruction_number); code_file.seekp(pos3); - prev_instruction_number = instruction_number ; + prev_instruction_number = instruction_number; temporary_terms_t tt2; tt2.clear(); @@ -872,12 +870,12 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string if (dynamic_cast<ExternalFunctionNode *>(*it) != NULL) (*it)->compileExternalFunctionOutput(code_file, instruction_number, false, tt3, map_idx2[block], false, false, tef_terms2); - FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx2[block].find((*it)->idx)->second)); + FNUMEXPR_ fnumexpr(TemporaryTerm, (int) (map_idx2[block].find((*it)->idx)->second)); fnumexpr.write(code_file, instruction_number); (*it)->compile(code_file, instruction_number, false, tt3, map_idx2[block], false, false, tef_terms); - FSTPST_ fstpst((int)(map_idx2[block].find((*it)->idx)->second)); + FSTPST_ fstpst((int) (map_idx2[block].find((*it)->idx)->second)); fstpst.write(code_file, instruction_number); // Insert current node into tt2 tt3.insert(*it); @@ -953,9 +951,9 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string FNUMEXPR_ fnumexpr(FirstEndoDerivative, 0, 0); fnumexpr.write(code_file, instruction_number); } - compileDerivative(code_file, instruction_number, getBlockEquationID(block, 0), getBlockVariableID(block, 0), map_idx2[block], tt2/*temporary_terms*/); + compileDerivative(code_file, instruction_number, getBlockEquationID(block, 0), getBlockVariableID(block, 0), map_idx2[block], tt2 /*temporary_terms*/); { - FSTPG2_ fstpg2(0,0); + FSTPG2_ fstpg2(0, 0); fstpg2.write(code_file, instruction_number); } break; @@ -973,9 +971,9 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string FNUMEXPR_ fnumexpr(FirstEndoDerivative, eqr, varr, 0); fnumexpr.write(code_file, instruction_number); - compileChainRuleDerivative(code_file, instruction_number, eqr, varr, 0, map_idx2[block], tt2/*temporary_terms*/); + compileChainRuleDerivative(code_file, instruction_number, eqr, varr, 0, map_idx2[block], tt2 /*temporary_terms*/); - FSTPG2_ fstpg2(eq,var); + FSTPG2_ fstpg2(eq, var); fstpg2.write(code_file, instruction_number); } break; @@ -998,7 +996,7 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string void StaticModel::Write_Inf_To_Bin_File_Block(const string &static_basename, const string &bin_basename, const int &num, - int &u_count_int, bool &file_open) const + int &u_count_int, bool &file_open) const { int j; std::ofstream SaveCode; @@ -1321,7 +1319,7 @@ StaticModel::writeStaticBlockMFSFile(const string &basename) const { output << " y_tmp = " << func_name << "_" << b+1 << "(y, x, params);\n"; ostringstream tmp; - for (int i = 0; i < (int)getBlockSize(b); i++) + for (int i = 0; i < (int) getBlockSize(b); i++) tmp << " " << getBlockVariableID(b, i)+1; output << " var_index = [" << tmp.str() << "];\n"; output << " residual = y(var_index) - y_tmp(var_index);\n"; @@ -1586,7 +1584,7 @@ StaticModel::jacobianHelper(ostream &output, int eq_nb, int col_nb, ExprNodeOutp if (IS_MATLAB(output_type)) output << eq_nb + 1 << ", " << col_nb + 1; else - output << eq_nb + col_nb * equations.size(); + output << eq_nb + col_nb *equations.size(); output << RIGHT_ARRAY_SUBSCRIPT(output_type); } diff --git a/StaticModel.hh b/StaticModel.hh index 5a2f1a2ff09c3db9be9a36101146b4fbd44bea10..7f42b11bf99b6c03d9f46be1313c3b68f1dbcb83 100644 --- a/StaticModel.hh +++ b/StaticModel.hh @@ -69,7 +69,6 @@ private: //! Writes the code of the model in virtual machine bytecode void writeModelEquationsCode(const string file_name, const string bin_basename, map_idx_t map_idx) const; - //! Computes jacobian and prepares for equation normalization /*! Using values from initval/endval blocks and parameter initializations: - computes the jacobian for the model w.r. to contemporaneous variables @@ -154,14 +153,13 @@ protected: //! for each block described the number of static, forward, backward and mixed variables in the block /*! pair< pair<static, forward>, pair<backward,mixed> > */ - vector<pair< pair<int, int>, pair<int,int> > > block_col_type; + vector<pair< pair<int, int>, pair<int, int> > > block_col_type; //! List for each variable its block number and its maximum lag and lead inside the block vector<pair<int, pair<int, int> > > variable_block_lead_lag; //! List for each equation its block number vector<int> equation_block; - //!Maximum lead and lag for each block on endogenous of the block, endogenous of the previous blocks, exogenous and deterministic exogenous vector<pair<int, int> > endo_max_leadlag_block, other_endo_max_leadlag_block, exo_max_leadlag_block, exo_det_max_leadlag_block, max_leadlag_block; @@ -194,7 +192,7 @@ public: //! Adds informations for simulation in a binary file for a block decomposed model void Write_Inf_To_Bin_File_Block(const string &static_basename, const string &bin_basename, const int &num, - int &u_count_int, bool &file_open) const; + int &u_count_int, bool &file_open) const; //! Writes static model file void writeStaticFile(const string &basename, bool block, bool bytecode) const; diff --git a/SteadyStateModel.cc b/SteadyStateModel.cc index 6caa166ed42e39459623e5010b83090924980556..a222aa32764717ddb4ba47f0f9e0d6c2c42ee8b0 100644 --- a/SteadyStateModel.cc +++ b/SteadyStateModel.cc @@ -82,8 +82,8 @@ SteadyStateModel::checkPass(bool ramsey_policy) const expr_t expr = def_table.find(symb_ids)->second; expr->collectVariables(eEndogenous, used_symbols); expr->collectVariables(eModFileLocalVariable, used_symbols); - for(set<pair<int, int> >::const_iterator it = used_symbols.begin(); - it != used_symbols.end(); ++it) + for (set<pair<int, int> >::const_iterator it = used_symbols.begin(); + it != used_symbols.end(); ++it) if (find(so_far_defined.begin(), so_far_defined.end(), it->first) == so_far_defined.end()) { diff --git a/SymbolTable.cc b/SymbolTable.cc index aba5c399c02b3e2adf9083a29a6645a6c3f59715..f1777ef6cb6dea8afa4213c40b4b9d595d970834 100644 --- a/SymbolTable.cc +++ b/SymbolTable.cc @@ -367,7 +367,7 @@ SymbolTable::addExpectationAuxiliaryVar(int information_set, int index, const st return symb_id; } -int +int SymbolTable::searchAuxiliaryVars(int orig_symb_id, int orig_lead_lag) const throw (SearchFailedException) { for (size_t i = 0; i < aux_vars.size(); i++) diff --git a/SymbolTable.hh b/SymbolTable.hh index 0925c5eab4a61885e387e9e3f819d85153a621be..7b95d742f8ad8b8a032e7da34e1223e597fcdaf0 100644 --- a/SymbolTable.hh +++ b/SymbolTable.hh @@ -222,7 +222,7 @@ public: */ int searchAuxiliaryVars(int orig_symb_id, int orig_lead_lag) const throw (SearchFailedException); //! Returns the number of auxiliary variables - int AuxVarsSize() const {return aux_vars.size();}; + int AuxVarsSize() const { return aux_vars.size(); }; //! Tests if symbol already exists inline bool exists(const string &name) const; //! Get symbol name (by ID) diff --git a/macro/MacroValue.cc b/macro/MacroValue.cc index 98833caba4bc8f3d0455e103ad6a944fda5d4fe6..0c9578fc0958ffa9f6be99198b0474833526de88 100644 --- a/macro/MacroValue.cc +++ b/macro/MacroValue.cc @@ -330,8 +330,8 @@ IntMV::new_range(MacroDriver &driver, const MacroValue *mv1, const MacroValue *m return new ArrayMV<int>(driver, result); } -StringMV::StringMV(MacroDriver &driver, const string &value_arg) - : MacroValue(driver), value(value_arg) +StringMV::StringMV(MacroDriver &driver, const string &value_arg) : + MacroValue(driver), value(value_arg) { }