diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc index 26784fa7b9922e95ebd6288fb21af1bfa6aa2a0a..ac12dbf055850e2f8b8fb266c50f63305878c5e0 100644 --- a/mex/sources/bytecode/Interpreter.cc +++ b/mex/sources/bytecode/Interpreter.cc @@ -291,7 +291,7 @@ Interpreter::evaluate_a_block(bool initialization, bool single_block, const stri if (initialization) { fixe_u(); - Read_SparseMatrix(bin_base_name, size, 1, 0, 0, false, stack_solve_algo, solve_algo); + Read_SparseMatrix(bin_base_name, 1, 0, 0, false); } #ifdef DEBUG mexPrintf("in SOLVE FORWARD COMPLETE r = mxMalloc(%d*sizeof(double))\n", size); @@ -386,7 +386,7 @@ Interpreter::evaluate_a_block(bool initialization, bool single_block, const stri if (initialization) { fixe_u(); - Read_SparseMatrix(bin_base_name, size, 1, 0, 0, false, stack_solve_algo, solve_algo); + Read_SparseMatrix(bin_base_name, 1, 0, 0, false); } r = static_cast<double *>(mxMalloc(size*sizeof(double))); test_mxMalloc(r, __LINE__, __FILE__, __func__, size*sizeof(double)); @@ -421,7 +421,7 @@ Interpreter::evaluate_a_block(bool initialization, bool single_block, const stri if (initialization) { fixe_u(); - Read_SparseMatrix(bin_base_name, size, periods, y_kmin, y_kmax, true, stack_solve_algo, solve_algo); + Read_SparseMatrix(bin_base_name, periods, y_kmin, y_kmax, true); } u_count = u_count_int*(periods+y_kmax+y_kmin); r = static_cast<double *>(mxMalloc(size*sizeof(double))); @@ -496,7 +496,7 @@ Interpreter::simulate_a_block(const vector_table_conditional_local_type &vector_ else { fixe_u(); - Read_SparseMatrix(bin_base_name, size, 1, 0, 0, false, stack_solve_algo, solve_algo); + Read_SparseMatrix(bin_base_name, 1, 0, 0, false); } Per_u_ = 0; @@ -518,7 +518,7 @@ Interpreter::simulate_a_block(const vector_table_conditional_local_type &vector_ else { fixe_u(); - Read_SparseMatrix(bin_base_name, size, 1, 0, 0, false, stack_solve_algo, solve_algo); + Read_SparseMatrix(bin_base_name, 1, 0, 0, false); } Per_u_ = 0; @@ -547,7 +547,7 @@ Interpreter::simulate_a_block(const vector_table_conditional_local_type &vector_ else { fixe_u(); - Read_SparseMatrix(bin_base_name, size, periods, y_kmin, y_kmax, true, stack_solve_algo, solve_algo); + Read_SparseMatrix(bin_base_name, periods, y_kmin, y_kmax, true); } u_count = u_count_int*(periods+y_kmax+y_kmin); r = static_cast<double *>(mxMalloc(size*sizeof(double))); @@ -1118,7 +1118,7 @@ Interpreter::Close_SaveCode() } void -Interpreter::Read_SparseMatrix(const string &file_name, int Size, int periods, int y_kmin, int y_kmax, bool two_boundaries, int stack_solve_algo, int solve_algo) +Interpreter::Read_SparseMatrix(const string &file_name, int periods, int y_kmin, int y_kmax, bool two_boundaries) { unsigned int eq, var; int lag; @@ -1136,7 +1136,7 @@ Interpreter::Read_SparseMatrix(const string &file_name, int Size, int periods, i { if (stack_solve_algo == 5) { - for (int i = 0; i < u_count_init-Size; i++) + for (int i = 0; i < u_count_init-size; i++) { int val; SaveCode.read(reinterpret_cast<char *>(&eq), sizeof(eq)); @@ -1145,23 +1145,23 @@ Interpreter::Read_SparseMatrix(const string &file_name, int Size, int periods, i SaveCode.read(reinterpret_cast<char *>(&val), sizeof(val)); IM_i[{ eq, var, lag }] = val; } - for (int j = 0; j < Size; j++) - IM_i[{ j, Size*(periods+y_kmax), 0 }] = j; + for (int j = 0; j < size; j++) + IM_i[{ j, size*(periods+y_kmax), 0 }] = j; } else if ((stack_solve_algo >= 0 && stack_solve_algo <= 4) || stack_solve_algo == 6) { - for (int i = 0; i < u_count_init-Size; i++) + for (int i = 0; i < u_count_init-size; i++) { int val; SaveCode.read(reinterpret_cast<char *>(&eq), sizeof(eq)); SaveCode.read(reinterpret_cast<char *>(&var), sizeof(var)); SaveCode.read(reinterpret_cast<char *>(&lag), sizeof(lag)); SaveCode.read(reinterpret_cast<char *>(&val), sizeof(val)); - IM_i[{ var - lag*Size, -lag, eq }] = val; + IM_i[{ var - lag*size, -lag, eq }] = val; } - for (int j = 0; j < Size; j++) - IM_i[{ Size*(periods+y_kmax), 0, j }] = j; + for (int j = 0; j < size; j++) + IM_i[{ size*(periods+y_kmax), 0, j }] = j; } else throw FatalException{"Invalid value for solve_algo or stack_solve_algo"}; @@ -1191,23 +1191,23 @@ Interpreter::Read_SparseMatrix(const string &file_name, int Size, int periods, i SaveCode.read(reinterpret_cast<char *>(&var), sizeof(var)); SaveCode.read(reinterpret_cast<char *>(&lag), sizeof(lag)); SaveCode.read(reinterpret_cast<char *>(&val), sizeof(val)); - IM_i[{ var - lag*Size, -lag, eq }] = val; + IM_i[{ var - lag*size, -lag, eq }] = val; } } else throw FatalException{"Invalid value for solve_algo or stack_solve_algo"}; } - index_vara = static_cast<int *>(mxMalloc(Size*(periods+y_kmin+y_kmax)*sizeof(int))); - test_mxMalloc(index_vara, __LINE__, __FILE__, __func__, Size*(periods+y_kmin+y_kmax)*sizeof(int)); - for (int j = 0; j < Size; j++) + index_vara = static_cast<int *>(mxMalloc(size*(periods+y_kmin+y_kmax)*sizeof(int))); + test_mxMalloc(index_vara, __LINE__, __FILE__, __func__, size*(periods+y_kmin+y_kmax)*sizeof(int)); + for (int j = 0; j < size; j++) SaveCode.read(reinterpret_cast<char *>(&index_vara[j]), sizeof(*index_vara)); if (periods+y_kmin+y_kmax > 1) for (int i = 1; i < periods+y_kmin+y_kmax; i++) - for (int j = 0; j < Size; j++) - index_vara[j+Size*i] = index_vara[j+Size*(i-1)] + y_size; - index_equa = static_cast<int *>(mxMalloc(Size*sizeof(int))); - test_mxMalloc(index_equa, __LINE__, __FILE__, __func__, Size*sizeof(int)); - for (int j = 0; j < Size; j++) + for (int j = 0; j < size; j++) + index_vara[j+size*i] = index_vara[j+size*(i-1)] + y_size; + index_equa = static_cast<int *>(mxMalloc(size*sizeof(int))); + test_mxMalloc(index_equa, __LINE__, __FILE__, __func__, size*sizeof(int)); + for (int j = 0; j < size; j++) SaveCode.read(reinterpret_cast<char *>(&index_equa[j]), sizeof(*index_equa)); } diff --git a/mex/sources/bytecode/Interpreter.hh b/mex/sources/bytecode/Interpreter.hh index ee4b61baf6938c2b385b893a3203b79d371f367a..1fb03d1b07f1c85561c02f1f2566bf81df5cf942 100644 --- a/mex/sources/bytecode/Interpreter.hh +++ b/mex/sources/bytecode/Interpreter.hh @@ -170,7 +170,7 @@ private: void Simulate_Newton_Two_Boundaries(bool cvg, const vector_table_conditional_local_type &vector_table_conditional_local); void Simulate_Newton_One_Boundary(bool forward); void fixe_u(); - void Read_SparseMatrix(const string &file_name, int Size, int periods, int y_kmin, int y_kmax, bool two_boundaries, int stack_solve_algo, int solve_algo); + void Read_SparseMatrix(const string &file_name, int periods, int y_kmin, int y_kmax, bool two_boundaries); void Singular_display(int block, int Size); void End_Solver(); static int find_exo_num(const vector<s_plan> &sconstrained_extended_path, int value);