diff --git a/mex/sources/bytecode/ErrorHandling.hh b/mex/sources/bytecode/ErrorHandling.hh index a37a2813a..a45211e07 100644 --- a/mex/sources/bytecode/ErrorHandling.hh +++ b/mex/sources/bytecode/ErrorHandling.hh @@ -1767,7 +1767,7 @@ public: mexPrintf("------------------------------\n"); mexPrintf("CALL "); mexEvalString("drawnow;"); #endif - FCALL_ *fc = static_cast(it_code->second); + auto *fc = static_cast(it_code->second); string function_name = fc->get_function_name(); #ifdef DEBUG mexPrintf("function_name=%s ", function_name.c_str()); mexEvalString("drawnow;"); @@ -2054,14 +2054,14 @@ public: mexPrintf("FLDTEF\n"); mexPrintf("var=%d Stack.size()=%d\n", var, Stackf.size()); { - map::const_iterator it = TEF.find(var-1); + auto it = TEF.find(var-1); mexPrintf("FLD TEF[var-1]=%f done\n", it->second); } mexEvalString("drawnow;"); #endif if (compute) { - map::const_iterator it = TEF.find(var-1); + auto it = TEF.find(var-1); Stackf.push(it->second); } tmp_out.str(""); @@ -2106,13 +2106,13 @@ public: #ifdef DEBUG mexPrintf("FLDTEFD\n"); mexPrintf("indx=%d row=%d Stack.size()=%d\n", indx, row, Stack.size()); - map, double>::const_iterator it = TEFD.find(make_pair(indx, row-1)); + auto it = TEFD.find(make_pair(indx, row-1)); mexPrintf("FLD TEFD[make_pair(indx, row)]=%f done\n", it->second); mexEvalString("drawnow;"); #endif if (compute) { - map, double>::const_iterator it = TEFD.find(make_pair(indx, row-1)); + auto it = TEFD.find(make_pair(indx, row-1)); Stackf.push(it->second); } tmp_out.str(""); @@ -2135,7 +2135,7 @@ public: #ifdef DEBUG double rr = Stackf.top(); mexPrintf("rr=%f\n", rr); - map>, double>::const_iterator it = TEFDD.find(make_pair(indx, make_pair(row-1, col-1))); + auto it = TEFDD.find(make_pair(indx, make_pair(row-1, col-1))); mexPrintf("FSTP TEFDD[make_pair(indx, make_pair(row, col))]=%f done\n", it->second); mexEvalString("drawnow;"); #endif @@ -2158,13 +2158,13 @@ public: #ifdef DEBUG mexPrintf("FLDTEFD\n"); mexPrintf("indx=%d Stack.size()=%d\n", indx, Stack.size()); - map>, double>::const_iterator it = TEFDD.find(make_pair(indx, make_pair(row-1, col-1))); + auto it = TEFDD.find(make_pair(indx, make_pair(row-1, col-1))); mexPrintf("FLD TEFD[make_pair(indx, make_pair(row, col))]=%f done\n", it->second); mexEvalString("drawnow;"); #endif if (compute) { - map>, double>::const_iterator it = TEFDD.find(make_pair(indx, make_pair(row-1, col-1))); + auto it = TEFDD.find(make_pair(indx, make_pair(row-1, col-1))); Stackf.push(it->second); } tmp_out.str(""); diff --git a/mex/sources/bytecode/Evaluate.cc b/mex/sources/bytecode/Evaluate.cc index 31639b7bd..9ed6313bf 100644 --- a/mex/sources/bytecode/Evaluate.cc +++ b/mex/sources/bytecode/Evaluate.cc @@ -1137,7 +1137,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int mexPrintf("------------------------------\n"); mexPrintf("CALL "); mexEvalString("drawnow;"); #endif - FCALL_ *fc = static_cast(it_code->second); + auto *fc = static_cast(it_code->second); string function_name = fc->get_function_name(); #ifdef DEBUG mexPrintf("function_name=%s ", function_name.c_str()); mexEvalString("drawnow;"); @@ -1505,7 +1505,7 @@ Evaluate::evaluate_over_periods(const bool forward) compute_block_time(0, false, false); else { - it_code_type begining = it_code; + auto begining = it_code; if (forward) { for (it_ = y_kmin; it_ < periods+y_kmin; it_++) diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc index e87b65ab9..1335ef7a5 100644 --- a/mex/sources/bytecode/Interpreter.cc +++ b/mex/sources/bytecode/Interpreter.cc @@ -368,7 +368,7 @@ Interpreter::simulate_a_block(vector_table_conditional_local_type vector_table_c #endif if (vector_table_conditional_local.size()) { - it_code_type curr_it_code = it_code; + auto curr_it_code = it_code; evaluate_a_block(true); it_code = curr_it_code; } @@ -395,7 +395,7 @@ Interpreter::simulate_a_block(vector_table_conditional_local_type vector_table_c #endif if (vector_table_conditional_local.size()) { - it_code_type curr_it_code = it_code; + auto curr_it_code = it_code; evaluate_a_block(true); it_code = curr_it_code; } @@ -428,7 +428,7 @@ Interpreter::simulate_a_block(vector_table_conditional_local_type vector_table_c } if (vector_table_conditional_local.size()) { - it_code_type curr_it_code = it_code; + auto curr_it_code = it_code; evaluate_a_block(true); it_code = curr_it_code; } @@ -663,7 +663,7 @@ Interpreter::MainLoop(string bin_basename, CodeLoad code, bool evaluate, int blo #endif //it's a new block { - FBEGINBLOCK_ *fb = static_cast(it_code->second); + auto *fb = static_cast(it_code->second); Block_Contain = fb->get_Block_Contain(); it_code++; if (constrained) @@ -860,9 +860,9 @@ Interpreter::extended_path(string file_name, string bin_basename, bool evaluate, double *y_save = (double *) mxMalloc(size_of_direction); double *x_save = (double *) mxMalloc((periods + y_kmax + y_kmin) * col_x *sizeof(double));*/ size_t size_of_direction = y_size*col_y*sizeof(double); - double *y_save = static_cast(mxMalloc(size_of_direction)); + auto *y_save = static_cast(mxMalloc(size_of_direction)); test_mxMalloc(y_save, __LINE__, __FILE__, __func__, size_of_direction); - double *x_save = static_cast(mxMalloc(nb_row_x * col_x *sizeof(double))); + auto *x_save = static_cast(mxMalloc(nb_row_x * col_x *sizeof(double))); test_mxMalloc(x_save, __LINE__, __FILE__, __func__, nb_row_x * col_x *sizeof(double)); vector_table_conditional_local_type vector_table_conditional_local; @@ -976,7 +976,7 @@ Interpreter::compute_blocks(string file_name, string bin_basename, bool evaluate //The big loop on intructions it_code = code_liste.begin(); - it_code_type Init_Code = it_code; + auto Init_Code = it_code; vector s_plan_junk; vector_table_conditional_local_type vector_table_conditional_local_junk; diff --git a/mex/sources/bytecode/SparseMatrix.cc b/mex/sources/bytecode/SparseMatrix.cc index babb77579..a8a700665 100644 --- a/mex/sources/bytecode/SparseMatrix.cc +++ b/mex/sources/bytecode/SparseMatrix.cc @@ -661,9 +661,9 @@ dynSparseMatrix::Simple_Init(int Size, map, int>, int> &IM, test_mxMalloc(FNZE_R, __LINE__, __FILE__, __func__, i); FNZE_C = static_cast(mxMalloc(i)); test_mxMalloc(FNZE_C, __LINE__, __FILE__, __func__, i); - NonZeroElem **temp_NZE_R = static_cast(mxMalloc(i)); + auto **temp_NZE_R = static_cast(mxMalloc(i)); test_mxMalloc(temp_NZE_R, __LINE__, __FILE__, __func__, i); - NonZeroElem **temp_NZE_C = static_cast(mxMalloc(i)); + auto **temp_NZE_C = static_cast(mxMalloc(i)); test_mxMalloc(temp_NZE_C, __LINE__, __FILE__, __func__, i); i = Size*sizeof(int); NbNZRow = static_cast(mxMalloc(i)); @@ -970,7 +970,7 @@ dynSparseMatrix::find_exo_num(vector sconstrained_extended_path, int val { int res = -1; int i = 0; - for (vector::iterator it = sconstrained_extended_path.begin(); it != sconstrained_extended_path.end(); it++, i++) + for (auto it = sconstrained_extended_path.begin(); it != sconstrained_extended_path.end(); it++, i++) if (it->exo_num == value) { res = i; @@ -984,7 +984,7 @@ dynSparseMatrix::find_int_date(vector> per_value, int value) { int res = -1; int i = 0; - for (vector>::iterator it = per_value.begin(); it != per_value.end(); it++, i++) + for (auto it = per_value.begin(); it != per_value.end(); it++, i++) if (it->first == value) { res = i; @@ -1698,7 +1698,7 @@ void dynSparseMatrix::PrintM(int n, double *Ax, mwIndex *Ap, mwIndex *Ai) { int nnz = Ap[n]; - double *A = static_cast(mxMalloc(n * n * sizeof(double))); + auto *A = static_cast(mxMalloc(n * n * sizeof(double))); test_mxMalloc(A, __LINE__, __FILE__, __func__, n * n * sizeof(double)); memset(A, 0, n * n * sizeof(double)); int k = 0; @@ -1898,9 +1898,9 @@ dynSparseMatrix::Init_GE(int periods, int y_kmin, int y_kmax, int Size, map(mxMalloc(i)); test_mxMalloc(FNZE_C, __LINE__, __FILE__, __func__, i); - NonZeroElem **temp_NZE_R = static_cast(mxMalloc(i)); + auto **temp_NZE_R = static_cast(mxMalloc(i)); test_mxMalloc(temp_NZE_R, __LINE__, __FILE__, __func__, i); - NonZeroElem **temp_NZE_C = static_cast(mxMalloc(i)); + auto **temp_NZE_C = static_cast(mxMalloc(i)); test_mxMalloc(temp_NZE_C, __LINE__, __FILE__, __func__, i); i = (periods+y_kmax+1)*Size*sizeof(int); NbNZRow = static_cast(mxMalloc(i)); @@ -2133,7 +2133,7 @@ dynSparseMatrix::compare(int *save_op, int *save_opa, int *save_opaa, int beg_t, double *up; while (i < nop4) { - t_save_op_s *save_op_s = reinterpret_cast(&(save_op[i])); + auto *save_op_s = reinterpret_cast(&(save_op[i])); up = &u[save_op_s->first+t*diff1[j]]; switch (save_op_s->operat) { @@ -2165,7 +2165,7 @@ dynSparseMatrix::compare(int *save_op, int *save_opa, int *save_opaa, int beg_t, int gap = periods_beg_t-t; while (i < nop4) { - t_save_op_s *save_op_s = reinterpret_cast(&(save_op[i])); + auto *save_op_s = reinterpret_cast(&(save_op[i])); if (save_op_s->lag < gap) { double *up = &u[save_op_s->first+t*diff1[j]]; @@ -3540,9 +3540,9 @@ dynSparseMatrix::Solve_LU_UMFPack(mxArray *A_m, mxArray *b_m, int Size, double s { SuiteSparse_long n = mxGetM(A_m); - SuiteSparse_long *Ap = reinterpret_cast(mxGetJc(A_m)); + auto *Ap = reinterpret_cast(mxGetJc(A_m)); - SuiteSparse_long *Ai = reinterpret_cast(mxGetIr(A_m)); + auto *Ai = reinterpret_cast(mxGetIr(A_m)); double *Ax = mxGetPr(A_m); double *B = mxGetPr(b_m); SuiteSparse_long status, sys = 0; @@ -6177,7 +6177,7 @@ dynSparseMatrix::Check_and_Correct_Previous_Iteration(int block_num, int y_size, if (false) { - double *p = static_cast(mxMalloc(size * sizeof(double))); + auto *p = static_cast(mxMalloc(size * sizeof(double))); test_mxMalloc(p, __LINE__, __FILE__, __func__, size * sizeof(double)); Grad_f_product(size, b_m_save, p, A_m_save, Ap_save, Ai_save, Ax_save, b_save); double slope = 0.0; diff --git a/mex/sources/bytecode/bytecode.cc b/mex/sources/bytecode/bytecode.cc index e4d07b44d..14c1f15d2 100644 --- a/mex/sources/bytecode/bytecode.cc +++ b/mex/sources/bytecode/bytecode.cc @@ -42,7 +42,7 @@ string Get_Argument(const mxArray *prhs) { const mxArray *mxa = prhs; - mwSize buflen = mwSize(mxGetM(mxa) * mxGetN(mxa) + 1); + auto buflen = mwSize(mxGetM(mxa) * mxGetN(mxa) + 1); char *first_argument; first_argument = static_cast(mxCalloc(buflen, sizeof(char))); size_t status = mxGetString(mxa, first_argument, buflen); @@ -946,11 +946,11 @@ main(int nrhs, const char *prhs[]) field = mxGetFieldNumber(options_, "slowc"); if (field < 0) mexErrMsgTxt("slows is not a field of options_"); - double slowc = double (*(mxGetPr(mxGetFieldByNumber(options_, 0, field)))); + auto slowc = double (*(mxGetPr(mxGetFieldByNumber(options_, 0, field)))); field = mxGetFieldNumber(options_, "markowitz"); if (field < 0) mexErrMsgTxt("markowitz is not a field of options_"); - double markowitz_c = double (*(mxGetPr(mxGetFieldByNumber(options_, 0, field)))); + auto markowitz_c = double (*(mxGetPr(mxGetFieldByNumber(options_, 0, field)))); field = mxGetFieldNumber(options_, "minimal_solving_periods"); if (field < 0) mexErrMsgTxt("minimal_solving_periods is not a field of options_"); @@ -1020,15 +1020,15 @@ main(int nrhs, const char *prhs[]) mexErrMsgTxt("bytecode has not been compiled with CUDA option. Bytecode Can't use options_.stack_solve_algo=7\n"); #endif size_t size_of_direction = col_y*row_y*sizeof(double); - double *y = static_cast(mxMalloc(size_of_direction)); + auto *y = static_cast(mxMalloc(size_of_direction)); error_msg.test_mxMalloc(y, __LINE__, __FILE__, __func__, size_of_direction); - double *ya = static_cast(mxMalloc(size_of_direction)); + auto *ya = static_cast(mxMalloc(size_of_direction)); error_msg.test_mxMalloc(ya, __LINE__, __FILE__, __func__, size_of_direction); direction = static_cast(mxMalloc(size_of_direction)); error_msg.test_mxMalloc(direction, __LINE__, __FILE__, __func__, size_of_direction); memset(direction, 0, size_of_direction); /*mexPrintf("col_x : %d, row_x : %d\n",col_x, row_x);*/ - double *x = static_cast(mxMalloc(col_x*row_x*sizeof(double))); + auto *x = static_cast(mxMalloc(col_x*row_x*sizeof(double))); error_msg.test_mxMalloc(x, __LINE__, __FILE__, __func__, col_x*row_x*sizeof(double)); for (i = 0; i < row_x*col_x; i++) { diff --git a/mex/sources/bytecode/testing/mex_interface.cc b/mex/sources/bytecode/testing/mex_interface.cc index 713de54c9..da1136995 100644 --- a/mex/sources/bytecode/testing/mex_interface.cc +++ b/mex/sources/bytecode/testing/mex_interface.cc @@ -102,7 +102,7 @@ mxGetPr(const mxArray *b_m) mxArray * mxCreateDoubleMatrix(unsigned int rows, unsigned int cols, mxData_type mx_type) { - mxArray *Array = new mxArray; + auto *Array = new mxArray; Array->type = mxDOUBLE_CLASS; Array->size_1 = rows; Array->size_2 = cols; @@ -113,7 +113,7 @@ mxCreateDoubleMatrix(unsigned int rows, unsigned int cols, mxData_type mx_type) mxArray * mxCreateCharArray(unsigned int rows, unsigned int cols, mxData_type mx_type) { - mxArray *Array = new mxArray; + auto *Array = new mxArray; Array->type = mxCHAR_CLASS; Array->size_1 = rows; Array->size_2 = cols; @@ -124,7 +124,7 @@ mxCreateCharArray(unsigned int rows, unsigned int cols, mxData_type mx_type) mxArray * mxCreateSparse(unsigned int rows, unsigned int cols, unsigned int nz_max, mxData_type mx_type) { - mxArray *Array = new mxArray; + auto *Array = new mxArray; Array->type = mxSPARSE_CLASS; Array->size_1 = rows; Array->size_2 = cols; @@ -138,7 +138,7 @@ mxCreateSparse(unsigned int rows, unsigned int cols, unsigned int nz_max, mxData mxArray * mxCreateDoubleScalar(double value) { - mxArray *Array = new mxArray; + auto *Array = new mxArray; Array->type = mxSINGLE_CLASS; Array->size_1 = 1; Array->size_2 = 1; @@ -156,7 +156,7 @@ mxCreatNULLMatrix() mxArray * mxCreateStructMatrix(unsigned int rows, unsigned int cols, unsigned int nfields, const vector &fieldnames) { - mxArray *Array = new mxArray; + auto *Array = new mxArray; Array->type = mxSTRUCT_CLASS; Array->size_1 = rows; Array->size_2 = cols; @@ -223,7 +223,7 @@ mexGetVariable(const char *space_name, const char *matrix_name) int mxGetFieldNumber(const mxArray *Struct, const char *field_name) { - vector::const_iterator it = find(Struct->field_name.begin(), Struct->field_name.end(), field_name); + auto it = find(Struct->field_name.begin(), Struct->field_name.end(), field_name); if (it == Struct->field_name.end()) { stringstream tmp; @@ -293,7 +293,7 @@ mxDuplicateArray(const mxArray *array) unsigned int i; vector::const_iterator it_v_array; vector::const_iterator it_v_string; - mxArray *Array = (mxArray *) mxMalloc(sizeof(mxArray)); + auto *Array = (mxArray *) mxMalloc(sizeof(mxArray)); Array->type = array->type; Array->size_1 = array->size_1; Array->size_2 = Array->size_2;