diff --git a/mex/sources/bytecode/Evaluate.cc b/mex/sources/bytecode/Evaluate.cc index 2fb0e8cdcdaf5055092550f9bab89ac87800a5e5..b1b3ec3fdd9f703ecbc0e1e7c7ee4bac9ecc7c46 100644 --- a/mex/sources/bytecode/Evaluate.cc +++ b/mex/sources/bytecode/Evaluate.cc @@ -29,7 +29,7 @@ #include "CommonEnums.hh" #include "ErrorHandling.hh" -Evaluate::Evaluate(bool steady_state_arg, BasicSymbolTable &symbol_table_arg) : +Evaluate::Evaluate(bool steady_state_arg, const BasicSymbolTable &symbol_table_arg) : symbol_table {symbol_table_arg}, steady_state {steady_state_arg} { diff --git a/mex/sources/bytecode/Evaluate.hh b/mex/sources/bytecode/Evaluate.hh index 09d5accbae9bf64e68988e872a8d27d6f712fc0a..2d6a0f86971cb638539268618d7c69c4de0f52e4 100644 --- a/mex/sources/bytecode/Evaluate.hh +++ b/mex/sources/bytecode/Evaluate.hh @@ -36,6 +36,9 @@ private: using instructions_list_t = vector<BytecodeInstruction *>; using it_code_type = instructions_list_t::const_iterator; + const BasicSymbolTable &symbol_table; + const bool steady_state; // Whether this is a static or dynamic .cod file + // Memory copy of the contents of the .cod file unique_ptr<char[]> raw_bytecode; @@ -76,11 +79,8 @@ private: } protected: - BasicSymbolTable &symbol_table; void evaluateBlock(int it_, double *__restrict__ y, const double *__restrict__ ya, int y_size, double *__restrict__ x, int nb_row_x, double *__restrict__ params, const double *__restrict__ steady_y, double *__restrict__ u, int Per_u_, double *__restrict__ T, int T_nrows, map<int, double> &TEF, map<pair<int, int>, double> &TEFD, map<tuple<int, int, int>, double> &TEFDD, double *__restrict__ r, double *__restrict__ g1, double *__restrict__ jacob, double *__restrict__ jacob_exo, double *__restrict__ jacob_exo_det, bool evaluate, bool no_derivatives); - bool steady_state; - /* Prints a bytecode expression in human readable form. If faulty_op is not default constructed, it should point to a tag within the expression that created a floating point exception, in which case the @@ -147,7 +147,7 @@ protected: } public: - Evaluate(bool steady_state_arg, BasicSymbolTable &symbol_table_arg); + Evaluate(bool steady_state_arg, const BasicSymbolTable &symbol_table_arg); // TODO: integrate into the constructor void loadCodeFile(const filesystem::path &codfile); diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc index eeae7b364ca8219f3b50928a157625661c5b4400..60476d7250093b573d3415b7295a893778a76951 100644 --- a/mex/sources/bytecode/Interpreter.cc +++ b/mex/sources/bytecode/Interpreter.cc @@ -34,7 +34,7 @@ Interpreter::Interpreter(double *params_arg, double *y_arg, double *ya_arg, doub int maxit_arg_, double solve_tolf_arg, size_t size_of_direction_arg, int y_decal_arg, double markowitz_c_arg, string &filename_arg, int minimal_solving_periods_arg, int stack_solve_algo_arg, int solve_algo_arg, bool global_temporary_terms_arg, bool print_arg, bool print_error_arg, mxArray *GlobalTemporaryTerms_arg, - bool steady_state_arg, bool block_decomposed_arg, bool print_it_arg, int col_x_arg, int col_y_arg, BasicSymbolTable &symbol_table_arg) + bool steady_state_arg, bool block_decomposed_arg, bool print_it_arg, int col_x_arg, int col_y_arg, const BasicSymbolTable &symbol_table_arg) : dynSparseMatrix {y_size_arg, y_kmin_arg, y_kmax_arg, print_it_arg, steady_state_arg, block_decomposed_arg, periods_arg, minimal_solving_periods_arg, symbol_table_arg, print_error_arg} { params = params_arg; diff --git a/mex/sources/bytecode/Interpreter.hh b/mex/sources/bytecode/Interpreter.hh index c77291a275c158ee453684b10c66580e46c2efee..efe90d34262ebf4115476fc88e5c74bd6422483d 100644 --- a/mex/sources/bytecode/Interpreter.hh +++ b/mex/sources/bytecode/Interpreter.hh @@ -57,7 +57,7 @@ public: int maxit_arg_, double solve_tolf_arg, size_t size_of_direction_arg, int y_decal_arg, double markowitz_c_arg, string &filename_arg, int minimal_solving_periods_arg, int stack_solve_algo_arg, int solve_algo_arg, bool global_temporary_terms_arg, bool print_arg, bool print_error_arg, mxArray *GlobalTemporaryTerms_arg, - bool steady_state_arg, bool block_decomposed_arg, bool print_it_arg, int col_x_arg, int col_y_arg, BasicSymbolTable &symbol_table_arg); + bool steady_state_arg, bool block_decomposed_arg, bool print_it_arg, int col_x_arg, int col_y_arg, const BasicSymbolTable &symbol_table_arg); pair<bool, vector<int>> extended_path(const string &file_name, bool evaluate, int block, int nb_periods, const vector<s_plan> &sextended_path, const vector<s_plan> &sconstrained_extended_path, const vector<string> &dates, const table_conditional_global_type &table_conditional_global); pair<bool, vector<int>> compute_blocks(const string &file_name, bool evaluate, int block); void check_for_controlled_exo_validity(int current_block, const vector<s_plan> &sconstrained_extended_path); diff --git a/mex/sources/bytecode/SparseMatrix.cc b/mex/sources/bytecode/SparseMatrix.cc index 574dacde792de9847fa2679f8f75a95e1b71a918..f9f2ccfa3388eed7a86353f90147af22c32c9ca1 100644 --- a/mex/sources/bytecode/SparseMatrix.cc +++ b/mex/sources/bytecode/SparseMatrix.cc @@ -25,9 +25,11 @@ #include "SparseMatrix.hh" dynSparseMatrix::dynSparseMatrix(int y_size_arg, int y_kmin_arg, int y_kmax_arg, bool print_it_arg, bool steady_state_arg, bool block_decomposed_arg, int periods_arg, - int minimal_solving_periods_arg, BasicSymbolTable &symbol_table_arg, + int minimal_solving_periods_arg, const BasicSymbolTable &symbol_table_arg, bool print_error_arg) : Evaluate {steady_state_arg, symbol_table_arg}, + symbol_table {symbol_table_arg}, + steady_state {steady_state_arg}, block_decomposed {block_decomposed_arg}, minimal_solving_periods {minimal_solving_periods_arg}, print_it {print_it_arg}, diff --git a/mex/sources/bytecode/SparseMatrix.hh b/mex/sources/bytecode/SparseMatrix.hh index 2f69253f4705d5679369528ffc634b561573b02f..6d26f6d7e6ee9e5372aed1406b45367cac3d41d1 100644 --- a/mex/sources/bytecode/SparseMatrix.hh +++ b/mex/sources/bytecode/SparseMatrix.hh @@ -68,7 +68,7 @@ constexpr double mem_increasing_factor = 1.1; class dynSparseMatrix : public Evaluate { public: - dynSparseMatrix(int y_size_arg, int y_kmin_arg, int y_kmax_arg, bool print_it_arg, bool steady_state_arg, bool block_decomposed_arg, int periods_arg, int minimal_solving_periods_arg, BasicSymbolTable &symbol_table_arg, bool print_error_arg); + dynSparseMatrix(int y_size_arg, int y_kmin_arg, int y_kmax_arg, bool print_it_arg, bool steady_state_arg, bool block_decomposed_arg, int periods_arg, int minimal_solving_periods_arg, const BasicSymbolTable &symbol_table_arg, bool print_error_arg); void Simulate_Newton_Two_Boundaries(int blck, int y_size, int y_kmin, int y_kmax, int Size, int periods, bool cvg, int minimal_solving_periods, int stack_solve_algo, const vector_table_conditional_local_type &vector_table_conditional_local); void Simulate_Newton_One_Boundary(bool forward); void fixe_u(double **u, int u_count_int, int max_lag_plus_max_lead_plus_1); @@ -141,6 +141,9 @@ private: // Computes A−B where A and B are dense. The result is dense. static mxArray *subtract_A_B(const mxArray *A_m, const mxArray *B_m); protected: + const BasicSymbolTable &symbol_table; + const bool steady_state; // Whether this is a static or dynamic model + // Whether to use the block-decomposed version of the bytecode file bool block_decomposed;