diff --git a/dynare++/extern/matlab/dynare_simul.cc b/dynare++/extern/matlab/dynare_simul.cc index 192c81145..843c38816 100644 --- a/dynare++/extern/matlab/dynare_simul.cc +++ b/dynare++/extern/matlab/dynare_simul.cc @@ -34,20 +34,20 @@ extern "C" { if (nhrs < 12 || nlhs != 2) DYN_MEX_FUNC_ERR_MSG_TXT("dynare_simul_ must have at least 12 input parameters and exactly 2 output arguments.\n"); - int order = (int) mxGetScalar(prhs[0]); + auto order = (int) mxGetScalar(prhs[0]); if (nhrs != 12 + order) DYN_MEX_FUNC_ERR_MSG_TXT("dynare_simul_ must have exactly 11+order input parameters.\n"); - int nstat = (int) mxGetScalar(prhs[1]); - int npred = (int) mxGetScalar(prhs[2]); - int nboth = (int) mxGetScalar(prhs[3]); - int nforw = (int) mxGetScalar(prhs[4]); - int nexog = (int) mxGetScalar(prhs[5]); + auto nstat = (int) mxGetScalar(prhs[1]); + auto npred = (int) mxGetScalar(prhs[2]); + auto nboth = (int) mxGetScalar(prhs[3]); + auto nforw = (int) mxGetScalar(prhs[4]); + auto nexog = (int) mxGetScalar(prhs[5]); const mxArray *const ystart = prhs[6]; const mxArray *const shocks = prhs[7]; const mxArray *const vcov = prhs[8]; - int seed = (int) mxGetScalar(prhs[9]); + auto seed = (int) mxGetScalar(prhs[9]); const mxArray *const ysteady = prhs[10]; const mwSize *const ystart_dim = mxGetDimensions(ystart); const mwSize *const shocks_dim = mxGetDimensions(shocks); @@ -102,7 +102,7 @@ extern "C" { ft.zeros(); ConstTwoDMatrix gk_mat(ft.nrows(), ft.ncols(), mxGetPr(gk)); ft.add(1.0, gk_mat); - UFSTensor *ut = new UFSTensor(ft); + auto *ut = new UFSTensor(ft); pol.insert(ut); } // form the decision rule diff --git a/dynare++/integ/cc/quadrature.cc b/dynare++/integ/cc/quadrature.cc index 8a13cec55..b9377a982 100644 --- a/dynare++/integ/cc/quadrature.cc +++ b/dynare++/integ/cc/quadrature.cc @@ -33,7 +33,7 @@ double NormalICDF::get(double x) { double xx = (2*normal_icdf_end-1)*std::abs(x-0.5); - int i = (int) floor(xx/normal_icdf_step); + auto i = (int) floor(xx/normal_icdf_step); double xx1 = normal_icdf_step*i; double yy1 = normal_icdf_data[i]; double y; diff --git a/dynare++/integ/src/quadrature-points.cc b/dynare++/integ/src/quadrature-points.cc index 21604ae13..2e2c6e08f 100644 --- a/dynare++/integ/src/quadrature-points.cc +++ b/dynare++/integ/src/quadrature-points.cc @@ -150,8 +150,8 @@ main(int argc, char **argv) // sort and uniq OrderVec ordvec; std::sort(points.begin(), points.end(), ordvec); - std::vector::iterator new_end = std::unique(points.begin(), points.end()); - for (std::vector::iterator it = new_end; it != points.end(); ++it) + auto new_end = std::unique(points.begin(), points.end()); + for (auto it = new_end; it != points.end(); ++it) delete *it; points.erase(new_end, points.end()); diff --git a/dynare++/kord/approximation.cc b/dynare++/kord/approximation.cc index c6b66e5a6..eb0a3fdf4 100644 --- a/dynare++/kord/approximation.cc +++ b/dynare++/kord/approximation.cc @@ -261,7 +261,7 @@ Approximation::saveRuleDerivs(const FGSContainer &g) rule_ders_ss = new FGSContainer(4); for (auto & run : (*rule_ders)) { - FGSTensor *ten = new FGSTensor(ypart.nstat+ypart.npred, ypart.nyss(), *(run.second)); + auto *ten = new FGSTensor(ypart.nstat+ypart.npred, ypart.nyss(), *(run.second)); rule_ders_ss->insert(ten); } } diff --git a/dynare++/kord/decision_rule.cc b/dynare++/kord/decision_rule.cc index e3bf10ec9..b86b0ef76 100644 --- a/dynare++/kord/decision_rule.cc +++ b/dynare++/kord/decision_rule.cc @@ -489,7 +489,7 @@ IRFResults::writeMat(mat_t *fd, const char *prefix) const void SimulationWorker::operator()() { - ExplicitShockRealization *esr = new ExplicitShockRealization(sr, np); + auto *esr = new ExplicitShockRealization(sr, np); TwoDMatrix *m = dr.simulate(em, np, st, *esr); { SYNCHRO syn(&res, "simulation"); @@ -503,7 +503,7 @@ SimulationWorker::operator()() void SimulationIRFWorker::operator()() { - ExplicitShockRealization *esr + auto *esr = new ExplicitShockRealization(res.control.getShocks(idata)); esr->addToShock(ishock, 0, imp); const TwoDMatrix &data = res.control.getData(idata); diff --git a/dynare++/kord/decision_rule.hh b/dynare++/kord/decision_rule.hh index 03d681643..6f7757eb4 100644 --- a/dynare++/kord/decision_rule.hh +++ b/dynare++/kord/decision_rule.hh @@ -200,7 +200,7 @@ DecisionRuleImpl::fillTensors(const _Tg &g, double sigma) int dfact = 1; for (int d = 0; d <= g.getMaxDim(); d++, dfact *= d) { - _Ttensym *g_yud = new _Ttensym(ypart.ny(), ypart.nys()+nu, d); + auto *g_yud = new _Ttensym(ypart.ny(), ypart.nys()+nu, d); g_yud->zeros(); // fill tensor of |g_yud| of dimension |d| @@ -287,7 +287,7 @@ DecisionRuleImpl::simulate(emethod em, int np, const Vector &ystart, { KORD_RAISE_IF(ysteady.length() != ystart.length(), "Start and steady lengths differ in DecisionRuleImpl::simulate"); - TwoDMatrix *res = new TwoDMatrix(ypart.ny(), np); + auto *res = new TwoDMatrix(ypart.ny(), np); // initialize vectors and subvectors for simulation /* Here allocate the stack vector $(\Delta y^*, u)$, define the @@ -569,7 +569,7 @@ DRFixPoint::fillTensors(const _Tg &g, double sigma) int dfact = 1; for (int d = 0; d <= g.getMaxDim(); d++, dfact *= d) { - _Ttensym *g_yd = new _Ttensym(ypart.ny(), ypart.nys(), d); + auto *g_yd = new _Ttensym(ypart.ny(), ypart.nys(), d); g_yd->zeros(); int kfact = 1; for (int k = 0; d+k <= g.getMaxDim(); k++, kfact *= k) diff --git a/dynare++/kord/dynamic_model.cc b/dynare++/kord/dynamic_model.cc index f487bb6dc..df39c778a 100644 --- a/dynare++/kord/dynamic_model.cc +++ b/dynare++/kord/dynamic_model.cc @@ -20,7 +20,7 @@ NameList::writeMat(mat_t *fd, const char *vname) const if (maxlen == 0) return; - char *m = new char[getNum()*maxlen]; + auto *m = new char[getNum()*maxlen]; for (int i = 0; i < getNum(); i++) for (int j = 0; j < maxlen; j++) diff --git a/dynare++/kord/faa_di_bruno.cc b/dynare++/kord/faa_di_bruno.cc index 4c6054171..45fd5f613 100644 --- a/dynare++/kord/faa_di_bruno.cc +++ b/dynare++/kord/faa_di_bruno.cc @@ -122,7 +122,7 @@ FaaDiBruno::estimRefinment(const TensorDimens &tdims, int nr, int l, { int nthreads = THREAD_GROUP::max_parallel_threads; long int per_size1 = tdims.calcUnfoldMaxOffset(); - long int per_size2 = (long int) pow((double) tdims.getNVS().getMax(), l); + auto per_size2 = (long int) pow((double) tdims.getNVS().getMax(), l); double lambda = 0.0; long int per_size = sizeof(double)*nr *(long int) (lambda*per_size1+(1-lambda)*per_size2); diff --git a/dynare++/kord/first_order.cc b/dynare++/kord/first_order.cc index 2253a57d0..443484f58 100644 --- a/dynare++/kord/first_order.cc +++ b/dynare++/kord/first_order.cc @@ -161,7 +161,7 @@ FirstOrder::solve(const TwoDMatrix &fd) TwoDMatrix vsr(n, n); lapack_int lwork = 100*n+16; Vector work(lwork); - lapack_int *bwork = new lapack_int[n]; + auto *bwork = new lapack_int[n]; lapack_int info; lapack_int sdim2 = sdim; dgges("N", "V", "S", order_eigs, &n, matE.getData().base(), &n, diff --git a/dynare++/kord/global_check.cc b/dynare++/kord/global_check.cc index f7e885e5f..415765f12 100644 --- a/dynare++/kord/global_check.cc +++ b/dynare++/kord/global_check.cc @@ -101,7 +101,7 @@ ResidFunction::setYU(const Vector &ys, const Vector &xx) } else { - FFSTensor *ten = new FFSTensor(hss->nrows(), hss->nvars(), 0); + auto *ten = new FFSTensor(hss->nrows(), hss->nvars(), 0); ten->getData() = ysteady_ss; hss->insert(ten); } diff --git a/dynare++/kord/korder.cc b/dynare++/kord/korder.cc index 260593414..54ab42795 100644 --- a/dynare++/kord/korder.cc +++ b/dynare++/kord/korder.cc @@ -346,7 +346,7 @@ KOrder::switchToFolded() { if ((*si)[2] == 0 && g().check(*si)) { - FGSTensor *ft = new FGSTensor(*(g().get(*si))); + auto *ft = new FGSTensor(*(g().get(*si))); insertDerivative(ft); if (dim > 1) { @@ -357,7 +357,7 @@ KOrder::switchToFolded() } if (G().check(*si)) { - FGSTensor *ft = new FGSTensor(*(G().get(*si))); + auto *ft = new FGSTensor(*(G().get(*si))); G().insert(ft); if (dim > 1) { diff --git a/dynare++/kord/korder.hh b/dynare++/kord/korder.hh index 5b0b3741b..73d0fa8e3 100644 --- a/dynare++/kord/korder.hh +++ b/dynare++/kord/korder.hh @@ -450,7 +450,7 @@ KOrder::faaDiBrunoG(const Symmetry &sym) const JournalRecordPair pa(journal); pa << "Faa Di Bruno G container for " << sym << endrec; TensorDimens tdims(sym, nvs); - _Ttensor *res = new _Ttensor(ypart.nyss(), tdims); + auto *res = new _Ttensor(ypart.nyss(), tdims); FaaDiBruno bruno(journal); bruno.calculate(Gstack(), gss(), *res); return res; @@ -926,7 +926,7 @@ template Vector * KOrder::calcStochShift(int order, double sigma) const { - Vector *res = new Vector(ny); + auto *res = new Vector(ny); res->zeros(); int jfac = 1; for (int j = 1; j <= order; j++, jfac *= j) diff --git a/dynare++/kord/korder_stoch.hh b/dynare++/kord/korder_stoch.hh index 8315038ce..c6a6b1b44 100644 --- a/dynare++/kord/korder_stoch.hh +++ b/dynare++/kord/korder_stoch.hh @@ -182,7 +182,7 @@ StochForwardDerivs::StochForwardDerivs(const PartitionY &ypart, int nu, _Tpol g_int_sym(r, ypart.nys()+1); for (int d = 1; d <= maxd; d++) { - _Ttensym *ten = new _Ttensym(r, ypart.nys()+1, d); + auto *ten = new _Ttensym(r, ypart.nys()+1, d); ten->zeros(); for (int i = 0; i <= d; i++) { @@ -492,7 +492,7 @@ KOrderStoch::faaDiBrunoG(const Symmetry &sym) const JournalRecordPair pa(journal); pa << "Faa Di Bruno GX container for " << sym << endrec; TensorDimens tdims(sym, nvs); - _Ttensor *res = new _Ttensor(ypart.nyss(), tdims); + auto *res = new _Ttensor(ypart.nyss(), tdims); FaaDiBruno bruno(journal); bruno.calculate(Gstack(), h(), *res); return res; diff --git a/dynare++/kord/tests.cc b/dynare++/kord/tests.cc index fa60c6040..86827ae68 100644 --- a/dynare++/kord/tests.cc +++ b/dynare++/kord/tests.cc @@ -54,7 +54,7 @@ FSSparseTensor * SparseGenerator::makeTensor(int dim, int nv, int r, double fill, double m) { - FSSparseTensor *res = new FSSparseTensor(dim, nv, r); + auto *res = new FSSparseTensor(dim, nv, r); FFSTensor dummy(0, nv, dim); for (Tensor::index fi = dummy.begin(); fi != dummy.end(); ++fi) { diff --git a/dynare++/parser/cc/atom_assignings.cc b/dynare++/parser/cc/atom_assignings.cc index be1b919eb..8077bd230 100644 --- a/dynare++/parser/cc/atom_assignings.cc +++ b/dynare++/parser/cc/atom_assignings.cc @@ -36,7 +36,7 @@ extern location_type asgn_lloc; void AtomAssignings::parse(int length, const char *stream) { - char *buffer = new char[length+2]; + auto *buffer = new char[length+2]; strncpy(buffer, stream, length); buffer[length] = '\0'; buffer[length+1] = '\0'; @@ -104,7 +104,7 @@ AtomAssignings::add_assignment(int asgn_off, const char *str, int name_len, // find the name in the atoms, make copy of name to be able to put // '\0' at the end - char *buf = new char[name_len+1]; + auto *buf = new char[name_len+1]; strncpy(buf, str, name_len); buf[name_len] = '\0'; // if left hand side is a registered atom, insert it to tree @@ -203,7 +203,7 @@ AtomAsgnEvaluator::setValues(EvalTree &et) const int t = aa.atoms.index(ss); if (t >= 0) { - Tusrvalmap::const_iterator it = user_values.find(t); + auto it = user_values.find(t); if (it == user_values.end()) et.set_nulary(t, nan); else @@ -218,7 +218,7 @@ AtomAsgnEvaluator::set_user_value(const char *name, double val) int t = aa.atoms.index(name); if (t >= 0) { - Tusrvalmap::iterator it = user_values.find(t); + auto it = user_values.find(t); if (it == user_values.end()) user_values.insert(Tusrvalmap::value_type(t, val)); else @@ -240,7 +240,7 @@ AtomAsgnEvaluator::load(int i, double res) double AtomAsgnEvaluator::get_value(const char *name) const { - AtomAssignings::Tvarintmap::const_iterator it = aa.lname2expr.find(name); + auto it = aa.lname2expr.find(name); if (it == aa.lname2expr.end()) return std::numeric_limits::quiet_NaN(); else diff --git a/dynare++/parser/cc/atom_substitutions.cc b/dynare++/parser/cc/atom_substitutions.cc index c01bae638..64436bf2c 100644 --- a/dynare++/parser/cc/atom_substitutions.cc +++ b/dynare++/parser/cc/atom_substitutions.cc @@ -22,7 +22,7 @@ AtomSubstitutions::AtomSubstitutions(const AtomSubstitutions &as, const FineAtom for (const auto & it : as.old2new) { Tshiftnameset sset; - for (Tshiftnameset::const_iterator itt = it.second.begin(); + for (auto itt = it.second.begin(); itt != it.second.end(); ++itt) sset.insert(Tshiftname(ns.query((*itt).first), (*itt).second)); old2new.insert(Toldnamemap::value_type(ns.query(it.first), sset)); @@ -42,7 +42,7 @@ AtomSubstitutions::add_substitution(const char *newname, const char *oldname, in // insert to new2old map new2old.insert(Tshiftmap::value_type(newname, Tshiftname(oldname, tshift))); // insert to old2new map - Toldnamemap::iterator it = old2new.find(oldname); + auto it = old2new.find(oldname); if (it != old2new.end()) (*it).second.insert(Tshiftname(newname, -tshift)); else @@ -80,7 +80,7 @@ AtomSubstitutions::substitutions_finished(VarOrdering::ord_type ot) const char * AtomSubstitutions::get_new4old(const char *oldname, int tshift) const { - Toldnamemap::const_iterator it = old2new.find(oldname); + auto it = old2new.find(oldname); if (it != old2new.end()) { const Tshiftnameset &sset = (*it).second; @@ -96,7 +96,7 @@ AtomSubstitutions::print() const { printf("Atom Substitutions:\nOld ==> New:\n"); for (const auto & it : old2new) - for (Tshiftnameset::const_iterator itt = it.second.begin(); + for (auto itt = it.second.begin(); itt != it.second.end(); ++itt) printf(" %s ==> [%s, %d]\n", it.first, (*itt).first, (*itt).second); @@ -164,7 +164,7 @@ SAtoms::findNameWithLeadInInterval(const vector &names, { for (auto name : names) { - DynamicAtoms::Tvarmap::const_iterator it = vars.find(name); + auto it = vars.find(name); if (it != vars.end()) { const DynamicAtoms::Tlagmap &lmap = (*it).second; diff --git a/dynare++/parser/cc/csv_parser.cc b/dynare++/parser/cc/csv_parser.cc index 96f6eaf5d..1f0a8737f 100644 --- a/dynare++/parser/cc/csv_parser.cc +++ b/dynare++/parser/cc/csv_parser.cc @@ -28,7 +28,7 @@ void CSVParser::csv_parse(int length, const char *str) { // allocate temporary buffer and parse - char *buffer = new char[length+2]; + auto *buffer = new char[length+2]; strncpy(buffer, str, length); buffer[length] = '\0'; buffer[length+1] = '\0'; diff --git a/dynare++/parser/cc/dynamic_atoms.cc b/dynare++/parser/cc/dynamic_atoms.cc index 77f78e200..6634973ab 100644 --- a/dynare++/parser/cc/dynamic_atoms.cc +++ b/dynare++/parser/cc/dynamic_atoms.cc @@ -14,7 +14,7 @@ NameStorage::NameStorage(const NameStorage &stor) { for (auto i : stor.name_store) { - char *str = new char[strlen(i)+1]; + auto *str = new char[strlen(i)+1]; strcpy(str, i); name_store.push_back(str); name_set.insert(str); @@ -33,7 +33,7 @@ NameStorage::~NameStorage() const char * NameStorage::query(const char *name) const { - set::const_iterator it = name_set.find(name); + auto it = name_set.find(name); if (it == name_set.end()) return NULL; else @@ -43,10 +43,10 @@ NameStorage::query(const char *name) const const char * NameStorage::insert(const char *name) { - set::const_iterator it = name_set.find(name); + auto it = name_set.find(name); if (it == name_set.end()) { - char *str = new char[strlen(name)+1]; + auto *str = new char[strlen(name)+1]; strcpy(str, name); name_store.push_back(str); name_set.insert(str); @@ -97,14 +97,14 @@ Constants::is_constant(int t) const { if (t < OperationTree::num_constants) return true; - Tconstantmap::const_iterator it = cmap.find(t); + auto it = cmap.find(t); return (it != cmap.end()); } double Constants::get_constant_value(int t) const { - Tconstantmap::const_iterator it = cmap.find(t); + auto it = cmap.find(t); if (it != cmap.end()) return (*it).second; else @@ -120,7 +120,7 @@ Constants::check(const char *str) const { double d; sscanf(str, "%lf", &d); - Tconstantinvmap::const_iterator it = cinvmap.find(d); + auto it = cinvmap.find(d); if (it != cinvmap.end()) return (*it).second; else @@ -170,12 +170,12 @@ DynamicAtoms::check_variable(const char *name) const string str; int ll; parse_variable(name, str, ll); - Tvarmap::const_iterator it = vars.find(str.c_str()); + auto it = vars.find(str.c_str()); if (it != vars.end()) { const Tlagmap &lmap = (*it).second; - Tlagmap::const_iterator itt = lmap.find(ll); + auto itt = lmap.find(ll); if (itt != lmap.end()) return (*itt).second; } @@ -220,7 +220,7 @@ DynamicAtoms::assign_variable(const char *varname, int ll, int t) throw ogu::Exception(__FILE__, __LINE__, "Attempt to assign already allocated tree index"); - Tvarmap::iterator it = vars.find(varname); + auto it = vars.find(varname); if (it != vars.end()) { Tlagmap &lmap = (*it).second; @@ -247,11 +247,11 @@ DynamicAtoms::assign_variable(const char *varname, int ll, int t) void DynamicAtoms::unassign_variable(const char *varname, int ll, int t) { - Tvarmap::iterator it = vars.find(varname); + auto it = vars.find(varname); if (it != vars.end()) { Tlagmap &lmap = (*it).second; - Tlagmap::iterator itt = lmap.find(ll); + auto itt = lmap.find(ll); if (itt != lmap.end()) { if ((*itt).second == t) @@ -262,7 +262,7 @@ DynamicAtoms::unassign_variable(const char *varname, int ll, int t) if (lmap.size() == 0) vars.erase(it); // erase it from the indices - Tindexmap::iterator ittt = indices.find(t); + auto ittt = indices.find(t); if (ittt != indices.end()) indices.erase(ittt); @@ -318,7 +318,7 @@ DynamicAtoms::variables() const void DynamicAtoms::varspan(int t, int &mlead, int &mlag) const { - Tindexmap::const_iterator it = indices.find(t); + auto it = indices.find(t); if (indices.end() == it) { mlead = INT_MIN; @@ -331,7 +331,7 @@ DynamicAtoms::varspan(int t, int &mlead, int &mlag) const void DynamicAtoms::varspan(const char *name, int &mlead, int &mlag) const { - Tvarmap::const_iterator it = vars.find(name); + auto it = vars.find(name); if (vars.end() == it) { mlead = INT_MIN; @@ -339,8 +339,8 @@ DynamicAtoms::varspan(const char *name, int &mlead, int &mlag) const return; } const Tlagmap &lmap = (*it).second; - Tlagmap::const_iterator beg = lmap.begin(); - Tlagmap::const_reverse_iterator end = lmap.rbegin(); + auto beg = lmap.begin(); + auto end = lmap.rbegin(); mlag = (*beg).first; mlead = (*end).first; } @@ -370,11 +370,11 @@ DynamicAtoms::is_named_atom(int t) const int DynamicAtoms::index(const char *name, int ll) const { - Tvarmap::const_iterator it = vars.find(name); + auto it = vars.find(name); if (vars.end() != it) { const Tlagmap &lmap = (*it).second; - Tlagmap::const_iterator itt = lmap.find(ll); + auto itt = lmap.find(ll); if (lmap.end() != itt) return (*itt).second; } @@ -384,14 +384,14 @@ DynamicAtoms::index(const char *name, int ll) const bool DynamicAtoms::is_referenced(const char *name) const { - Tvarmap::const_iterator it = vars.find(name); + auto it = vars.find(name); return it != vars.end(); } const DynamicAtoms::Tlagmap & DynamicAtoms::lagmap(const char *name) const { - Tvarmap::const_iterator it = vars.find(name); + auto it = vars.find(name); if (vars.end() == it) throw ogu::Exception(__FILE__, __LINE__, std::string("Couldn't find the name ") @@ -402,7 +402,7 @@ DynamicAtoms::lagmap(const char *name) const const char * DynamicAtoms::name(int t) const { - Tindexmap::const_iterator it = indices.find(t); + auto it = indices.find(t); if (indices.end() == it) throw ogu::Exception(__FILE__, __LINE__, "Couldn't find tree index in DynamicAtoms::name"); @@ -414,7 +414,7 @@ DynamicAtoms::lead(int t) const { const char *nam = name(t); const Tlagmap &lmap = lagmap(nam); - Tlagmap::const_iterator it = lmap.begin(); + auto it = lmap.begin(); while (it != lmap.end() && (*it).second != t) ++it; if (lmap.end() == it) @@ -462,14 +462,14 @@ VarOrdering::VarOrdering(const VarOrdering &vo, const vector &vnam bool VarOrdering::check(int t) const { - map::const_iterator it = positions.find(t); + auto it = positions.find(t); return it != positions.end(); } int VarOrdering::get_pos_of(int t) const { - map::const_iterator it = positions.find(t); + auto it = positions.find(t); if (it != positions.end()) { return (*it).second; diff --git a/dynare++/parser/cc/fine_atoms.cc b/dynare++/parser/cc/fine_atoms.cc index 3b747653d..e77160557 100644 --- a/dynare++/parser/cc/fine_atoms.cc +++ b/dynare++/parser/cc/fine_atoms.cc @@ -29,7 +29,7 @@ AllvarOuterOrdering::AllvarOuterOrdering(const vector &allvar_oute // fill in endo2all and exo2all for (unsigned int i = 0; i < allvar.size(); i++) { - Tvarintmap::const_iterator it = atoms.endo_outer_map.find(allvar[i]); + auto it = atoms.endo_outer_map.find(allvar[i]); if (it != atoms.endo_outer_map.end()) endo2all[(*it).second] = i; else @@ -387,7 +387,7 @@ FineAtoms::get_exo_atoms_map() const int FineAtoms::name2outer_param(const char *name) const { - Tvarintmap::const_iterator it = param_outer_map.find(name); + auto it = param_outer_map.find(name); if (it == param_outer_map.end()) throw ogu::Exception(__FILE__, __LINE__, "Name is not a parameter in FineAtoms::name2outer_param"); @@ -397,7 +397,7 @@ FineAtoms::name2outer_param(const char *name) const int FineAtoms::name2outer_endo(const char *name) const { - Tvarintmap::const_iterator it = endo_outer_map.find(name); + auto it = endo_outer_map.find(name); if (it == endo_outer_map.end()) throw ogu::Exception(__FILE__, __LINE__, "Name is not an endogenous variable in FineAtoms::name2outer_endo"); @@ -407,7 +407,7 @@ FineAtoms::name2outer_endo(const char *name) const int FineAtoms::name2outer_exo(const char *name) const { - Tvarintmap::const_iterator it = exo_outer_map.find(name); + auto it = exo_outer_map.find(name); if (it == exo_outer_map.end()) throw ogu::Exception(__FILE__, __LINE__, "Name is not an exogenous variable in FineAtoms::name2outer_exo"); @@ -421,7 +421,7 @@ FineAtoms::name2outer_allvar(const char *name) const throw ogu::Exception(__FILE__, __LINE__, "FineAtoms::name2outer_allvar called beore parsing_finished"); - Tvarintmap::const_iterator it = endo_outer_map.find(name); + auto it = endo_outer_map.find(name); if (it != endo_outer_map.end()) return allvar_order->get_endo2all()[(*it).second]; else diff --git a/dynare++/parser/cc/formula_parser.cc b/dynare++/parser/cc/formula_parser.cc index fefd1e424..87e6293dd 100644 --- a/dynare++/parser/cc/formula_parser.cc +++ b/dynare++/parser/cc/formula_parser.cc @@ -133,7 +133,7 @@ extern location_type fmla_lloc; void FormulaParser::parse(int length, const char *stream) { - char *buffer = new char[length+2]; + auto *buffer = new char[length+2]; strncpy(buffer, stream, length); buffer[length] = '\0'; buffer[length+1] = '\0'; @@ -273,7 +273,7 @@ FormulaDerivatives::derivative(const FoldMultiIndex &mi) const throw ogu::Exception(__FILE__, __LINE__, "Wrong multi-index variables in FormulaDerivatives::derivative"); - Tfmiintmap::const_iterator it = ind2der.find(mi); + auto it = ind2der.find(mi); if (it == ind2der.end()) return OperationTree::zero; else @@ -428,7 +428,7 @@ int FoldMultiIndex::offset() const { // make copy for the recursions - int *tmp = new int[ord]; + auto *tmp = new int[ord]; for (int i = 0; i < ord; i++) tmp[i] = data[i]; // call the recursive algorithm @@ -499,11 +499,11 @@ FormulaDerEvaluator::eval(const AtomValues &av, FormulaDerEvalLoader &loader, in etree.reset_all(); av.setValues(etree); - int *vars = new int[order]; + auto *vars = new int[order]; for (unsigned int i = 0; i < ders.size(); i++) { - for (FormulaDerivatives::Tfmiintmap::const_iterator it = ders[i]->ind2der.begin(); + for (auto it = ders[i]->ind2der.begin(); it != ders[i]->ind2der.end(); ++it) { const FoldMultiIndex &mi = (*it).first; @@ -532,7 +532,7 @@ FormulaDerEvaluator::eval(const vector &mp, const AtomValues &av, int nvar_glob = der_atoms.size(); int nvar = mp.size(); - int *vars = new int[order]; + auto *vars = new int[order]; for (unsigned int i = 0; i < ders.size(); i++) { diff --git a/dynare++/parser/cc/matrix_parser.cc b/dynare++/parser/cc/matrix_parser.cc index 68b664f66..f71f8248e 100644 --- a/dynare++/parser/cc/matrix_parser.cc +++ b/dynare++/parser/cc/matrix_parser.cc @@ -29,7 +29,7 @@ MatrixParser::parse(int length, const char *stream) row_lengths.clear(); nc = 0; // allocate temporary buffer and parse - char *buffer = new char[length+2]; + auto *buffer = new char[length+2]; strncpy(buffer, stream, length); buffer[length] = '\0'; buffer[length+1] = '\0'; diff --git a/dynare++/parser/cc/namelist.cc b/dynare++/parser/cc/namelist.cc index c9c148e2a..d4cf02ff1 100644 --- a/dynare++/parser/cc/namelist.cc +++ b/dynare++/parser/cc/namelist.cc @@ -19,7 +19,7 @@ void namelist_parse(); void NameListParser::namelist_parse(int length, const char *stream) { - char *buffer = new char[length+2]; + auto *buffer = new char[length+2]; strncpy(buffer, stream, length); buffer[length] = '\0'; buffer[length+1] = '\0'; diff --git a/dynare++/parser/cc/static_atoms.cc b/dynare++/parser/cc/static_atoms.cc index 2a045ccd2..f742e6af2 100644 --- a/dynare++/parser/cc/static_atoms.cc +++ b/dynare++/parser/cc/static_atoms.cc @@ -72,7 +72,7 @@ StaticAtoms::check(const char *name) const int StaticAtoms::index(const char *name) const { - Tvarmap::const_iterator it = vars.find(name); + auto it = vars.find(name); if (it == vars.end()) return -1; else @@ -82,7 +82,7 @@ StaticAtoms::index(const char *name) const const char * StaticAtoms::inv_index(int t) const { - Tinvmap::const_iterator it = indices.find(t); + auto it = indices.find(t); if (it == indices.end()) return NULL; else diff --git a/dynare++/parser/cc/static_fine_atoms.cc b/dynare++/parser/cc/static_fine_atoms.cc index 8b37e3215..e2c8ee938 100644 --- a/dynare++/parser/cc/static_fine_atoms.cc +++ b/dynare++/parser/cc/static_fine_atoms.cc @@ -135,7 +135,7 @@ StaticFineAtoms::parsing_finished() int StaticFineAtoms::name2outer_param(const char *name) const { - Tvarintmap::const_iterator it = param_outer_map.find(name); + auto it = param_outer_map.find(name); if (it == param_outer_map.end()) throw ogu::Exception(__FILE__, __LINE__, "Name is not a parameter in StaticFineAtoms::name2outer_param"); @@ -145,7 +145,7 @@ StaticFineAtoms::name2outer_param(const char *name) const int StaticFineAtoms::name2outer_endo(const char *name) const { - Tvarintmap::const_iterator it = endo_outer_map.find(name); + auto it = endo_outer_map.find(name); if (it == endo_outer_map.end()) throw ogu::Exception(__FILE__, __LINE__, "Name is not an endogenous variable in StaticFineAtoms::name2outer_endo"); @@ -155,7 +155,7 @@ StaticFineAtoms::name2outer_endo(const char *name) const int StaticFineAtoms::name2outer_exo(const char *name) const { - Tvarintmap::const_iterator it = exo_outer_map.find(name); + auto it = exo_outer_map.find(name); if (it == exo_outer_map.end()) throw ogu::Exception(__FILE__, __LINE__, "Name is not an exogenous variable in StaticFineAtoms::name2outer_exo"); diff --git a/dynare++/parser/cc/tree.cc b/dynare++/parser/cc/tree.cc index a6bc9dbd9..21c4cafdf 100644 --- a/dynare++/parser/cc/tree.cc +++ b/dynare++/parser/cc/tree.cc @@ -54,7 +54,7 @@ OperationTree::add_unary(code_t code, int op) return one; Operation unary(code, op); - _Topmap::const_iterator i = ((const _Topmap &) opmap).find(unary); + auto i = ((const _Topmap &) opmap).find(unary); if (i == opmap.end()) { int newop = terms.size(); @@ -144,7 +144,7 @@ OperationTree::add_binary(code_t code, int op1, int op2) // construct operation and check/add it Operation binary(code, op1, op2); - _Topmap::const_iterator i = ((const _Topmap &) opmap).find(binary); + auto i = ((const _Topmap &) opmap).find(binary); if (i == opmap.end()) { int newop = terms.size(); @@ -334,7 +334,7 @@ OperationTree::add_substitution(int t, const map &subst, const OperationTree &otree) { // return substitution of t if it is in the map - map::const_iterator it = subst.find(t); + auto it = subst.find(t); if (subst.end() != it) return (*it).second; @@ -374,7 +374,7 @@ void OperationTree::nularify(int t) { // remove the original operation from opmap - _Topmap::iterator it = opmap.find(terms[t]); + auto it = opmap.find(terms[t]); if (it != opmap.end()) opmap.erase(it); // turn the operation to nulary diff --git a/dynare++/src/dynare3.cc b/dynare++/src/dynare3.cc index 08603cab2..b0239709e 100644 --- a/dynare++/src/dynare3.cc +++ b/dynare++/src/dynare3.cc @@ -333,7 +333,7 @@ DynareDerEvalLoader::DynareDerEvalLoader(const ogp::FineAtoms &a, md.clear(); for (int iord = 1; iord <= order; iord++) { - FSSparseTensor *t = new FSSparseTensor(iord, atoms.ny()+atoms.nys()+atoms.nyss()+atoms.nexo(), atoms.ny()); + auto *t = new FSSparseTensor(iord, atoms.ny()+atoms.nys()+atoms.nyss()+atoms.nexo(), atoms.ny()); md.insert(t); } } diff --git a/dynare++/src/dynare_atoms.cc b/dynare++/src/dynare_atoms.cc index 68b952eda..a7e8f9d61 100644 --- a/dynare++/src/dynare_atoms.cc +++ b/dynare++/src/dynare_atoms.cc @@ -26,7 +26,7 @@ DynareStaticAtoms::check_variable(const char *name) const { if (0 == varnames.query(name)) throw ogp::ParserException(std::string("Unknown name <")+name+">", 0); - Tvarmap::const_iterator it = vars.find(name); + auto it = vars.find(name); if (it == vars.end()) return -1; else @@ -88,7 +88,7 @@ DynareDynamicAtoms::register_uniq_param(const char *name) bool DynareDynamicAtoms::is_type(const char *name, atype tp) const { - Tatypemap::const_iterator it = atom_type.find(name); + auto it = atom_type.find(name); if (it != atom_type.end() && (*it).second == tp) return true; else diff --git a/dynare++/src/dynare_model.cc b/dynare++/src/dynare_model.cc index 89ba8b4d5..0d95c91cf 100644 --- a/dynare++/src/dynare_model.cc +++ b/dynare++/src/dynare_model.cc @@ -593,7 +593,7 @@ extern ogp::location_type dynglob_lloc; void DynareParser::parse_glob(int length, const char *stream) { - char *buffer = new char[length+2]; + auto *buffer = new char[length+2]; strncpy(buffer, stream, length); buffer[length] = '\0'; buffer[length+1] = '\0'; @@ -607,7 +607,7 @@ DynareParser::parse_glob(int length, const char *stream) int DynareParser::parse_order(int len, const char *str) { - char *buf = new char[len+1]; + auto *buf = new char[len+1]; strncpy(buf, str, len); buf[len] = '\0'; int res; @@ -619,7 +619,7 @@ DynareParser::parse_order(int len, const char *str) int DynareParser::parse_pldiscount(int len, const char *str) { - char *buf = new char[len+1]; + auto *buf = new char[len+1]; strncpy(buf, str, len); buf[len] = '\0'; if (!atoms.is_type(buf, DynareDynamicAtoms::param)) diff --git a/dynare++/sylv/cc/GeneralMatrix.cc b/dynare++/sylv/cc/GeneralMatrix.cc index c035248b9..9fb2b09fc 100644 --- a/dynare++/sylv/cc/GeneralMatrix.cc +++ b/dynare++/sylv/cc/GeneralMatrix.cc @@ -453,7 +453,7 @@ ConstGeneralMatrix::multInvLeft(const char *trans, int mrows, int mcols, int mld if (rows > 0) { GeneralMatrix inv(*this); - lapack_int *ipiv = new lapack_int[rows]; + auto *ipiv = new lapack_int[rows]; lapack_int info; lapack_int rows2 = rows, mcols2 = mcols, mld2 = mld; dgetrf(&rows2, &rows2, inv.getData().base(), &rows2, ipiv, &info); @@ -564,7 +564,7 @@ SVDDecomp::construct(const GeneralMatrix &A) lapack_int lwork = -1; lapack_int info; - lapack_int *iwork = new lapack_int[8*minmn]; + auto *iwork = new lapack_int[8*minmn]; // query for optimal lwork dgesdd("A", &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, &tmpwork, &lwork, iwork, &info); diff --git a/dynare++/sylv/cc/QuasiTriangular.cc b/dynare++/sylv/cc/QuasiTriangular.cc index e9f910f5f..5496de63f 100644 --- a/dynare++/sylv/cc/QuasiTriangular.cc +++ b/dynare++/sylv/cc/QuasiTriangular.cc @@ -478,7 +478,7 @@ QuasiTriangular::QuasiTriangular(const SchurDecompZero &decomp) } } // construct diagonal - Diagonal *const d = new Diagonal(getData().base(), decomp.getDim()); + auto *const d = new Diagonal(getData().base(), decomp.getDim()); diagonal = *d; delete d; } diff --git a/dynare++/sylv/cc/SchurDecomp.cc b/dynare++/sylv/cc/SchurDecomp.cc index 265a53a37..6fe16e1ee 100644 --- a/dynare++/sylv/cc/SchurDecomp.cc +++ b/dynare++/sylv/cc/SchurDecomp.cc @@ -13,10 +13,10 @@ SchurDecomp::SchurDecomp(const SqSylvMatrix &m) q = new SqSylvMatrix(rows); SqSylvMatrix auxt(m); lapack_int sdim; - double *const wr = new double[rows]; - double *const wi = new double[rows]; + auto *const wr = new double[rows]; + auto *const wi = new double[rows]; lapack_int lwork = 6*rows; - double *const work = new double[lwork]; + auto *const work = new double[lwork]; lapack_int info; dgees("V", "N", 0, &rows, auxt.base(), &rows, &sdim, wr, wi, q->base(), &rows, diff --git a/dynare++/sylv/cc/SchurDecompEig.cc b/dynare++/sylv/cc/SchurDecompEig.cc index 751b52818..394be8f37 100644 --- a/dynare++/sylv/cc/SchurDecompEig.cc +++ b/dynare++/sylv/cc/SchurDecompEig.cc @@ -55,7 +55,7 @@ SchurDecompEig::tryToSwap(diag_iter &it, diag_iter &itadd) lapack_int n = getDim(); lapack_int ifst = (*it).getIndex() + 1; lapack_int ilst = (*itadd).getIndex() + 1; - double *work = new double[n]; + auto *work = new double[n]; lapack_int info; dtrexc("V", &n, getT().base(), &n, getQ().base(), &n, &ifst, &ilst, work, &info); diff --git a/dynare++/sylv/cc/SylvMatrix.cc b/dynare++/sylv/cc/SylvMatrix.cc index 5a4059ec6..36fdd076f 100644 --- a/dynare++/sylv/cc/SylvMatrix.cc +++ b/dynare++/sylv/cc/SylvMatrix.cc @@ -242,7 +242,7 @@ SqSylvMatrix::multInvLeft2(GeneralMatrix &a, GeneralMatrix &b, } // PLU factorization Vector inv(data); - lapack_int *const ipiv = new lapack_int[rows]; + auto *const ipiv = new lapack_int[rows]; lapack_int info; lapack_int rows2 = rows; dgetrf(&rows2, &rows2, inv.base(), &rows2, ipiv, &info); @@ -259,8 +259,8 @@ SqSylvMatrix::multInvLeft2(GeneralMatrix &a, GeneralMatrix &b, delete [] ipiv; // condition numbers - double *const work = new double[4*rows]; - lapack_int *const iwork = new lapack_int[rows]; + auto *const work = new double[4*rows]; + auto *const iwork = new lapack_int[rows]; double norm1 = getNorm1(); dgecon("1", &rows2, inv.base(), &rows2, &norm1, &rcond1, work, iwork, &info); diff --git a/dynare++/sylv/cc/SymSchurDecomp.cc b/dynare++/sylv/cc/SymSchurDecomp.cc index d5df7efb8..746c43465 100644 --- a/dynare++/sylv/cc/SymSchurDecomp.cc +++ b/dynare++/sylv/cc/SymSchurDecomp.cc @@ -49,8 +49,8 @@ SymSchurDecomp::SymSchurDecomp(const GeneralMatrix &mata) lwork = (int) tmpwork; liwork = tmpiwork; // allocate work arrays - double *work = new double[lwork]; - lapack_int *iwork = new lapack_int[liwork]; + auto *work = new double[lwork]; + auto *iwork = new lapack_int[liwork]; // do the calculation dsyevr(jobz, range, uplo, &n, a, &lda, vl, vu, il, iu, &abstol, diff --git a/dynare++/sylv/matlab/gensylv.cc b/dynare++/sylv/matlab/gensylv.cc index 14bebce58..113a776dc 100644 --- a/dynare++/sylv/matlab/gensylv.cc +++ b/dynare++/sylv/matlab/gensylv.cc @@ -35,7 +35,7 @@ extern "C" { if (nhrs != 5 || nlhs > 3 || nlhs < 2) DYN_MEX_FUNC_ERR_MSG_TXT("Gensylv: Must have exactly 5 input args and either 2 or 3 output args."); - int order = (int) mxGetScalar(prhs[0]); + auto order = (int) mxGetScalar(prhs[0]); const mxArray *const A = prhs[1]; const mxArray *const B = prhs[2]; const mxArray *const C = prhs[3]; diff --git a/dynare++/tl/cc/equivalence.cc b/dynare++/tl/cc/equivalence.cc index 5d9e21a2c..e79d9b20d 100644 --- a/dynare++/tl/cc/equivalence.cc +++ b/dynare++/tl/cc/equivalence.cc @@ -46,7 +46,7 @@ OrdSequence::operator==(const OrdSequence &s) const void OrdSequence::add(int i) { - vector::iterator vit = data.begin(); + auto vit = data.begin(); while (vit != data.end() && *vit < i) ++vit; if (vit != data.end() && *vit == i) @@ -57,7 +57,7 @@ OrdSequence::add(int i) void OrdSequence::add(const OrdSequence &s) { - vector::const_iterator vit = s.data.begin(); + auto vit = s.data.begin(); while (vit != s.data.end()) { add(*vit); @@ -69,7 +69,7 @@ OrdSequence::add(const OrdSequence &s) bool OrdSequence::has(int i) const { - vector::const_iterator vit = data.begin(); + auto vit = data.begin(); while (vit != data.end()) { if (*vit == i) @@ -133,8 +133,8 @@ Equivalence::Equivalence(const Equivalence &e, int i1, int i2) : n(e.n), classes(e.classes) { - seqit s1 = find(i1); - seqit s2 = find(i2); + auto s1 = find(i1); + auto s2 = find(i2); if (s1 != s2) { OrdSequence ns(*s1); @@ -171,7 +171,7 @@ Equivalence::operator==(const Equivalence &e) const Equivalence::const_seqit Equivalence::findHaving(int i) const { - const_seqit si = classes.begin(); + auto si = classes.begin(); while (si != classes.end()) { if ((*si).has(i)) @@ -186,7 +186,7 @@ Equivalence::findHaving(int i) const Equivalence::seqit Equivalence::findHaving(int i) { - seqit si = classes.begin(); + auto si = classes.begin(); while (si != classes.end()) { if ((*si).has(i)) @@ -203,7 +203,7 @@ Equivalence::findHaving(int i) Equivalence::const_seqit Equivalence::find(int j) const { - const_seqit si = classes.begin(); + auto si = classes.begin(); int i = 0; while (si != classes.end() && i < j) { @@ -218,7 +218,7 @@ Equivalence::find(int j) const Equivalence::seqit Equivalence::find(int j) { - seqit si = classes.begin(); + auto si = classes.begin(); int i = 0; while (si != classes.end() && i < j) { @@ -234,7 +234,7 @@ Equivalence::find(int j) void Equivalence::insert(const OrdSequence &s) { - seqit si = classes.begin(); + auto si = classes.begin(); while (si != classes.end() && *si < s) ++si; classes.insert(si, s); @@ -251,7 +251,7 @@ Equivalence::trace(IntSequence &out, int num) const { int i = 0; int nc = 0; - for (const_seqit it = begin(); it != end() && nc < num; ++it, ++nc) + for (auto it = begin(); it != end() && nc < num; ++it, ++nc) for (int j = 0; j < (*it).length(); j++, i++) { TL_RAISE_IF(i >= out.size(), @@ -270,7 +270,7 @@ Equivalence::trace(IntSequence &out, const Permutation &per) const int i = 0; for (int iclass = 0; iclass < numClasses(); iclass++) { - const_seqit itper = find(per.getMap()[iclass]); + auto itper = find(per.getMap()[iclass]); for (int j = 0; j < (*itper).length(); j++, i++) out[i] = (*itper)[j]; } @@ -281,7 +281,7 @@ void Equivalence::print(const char *prefix) const { int i = 0; - for (const_seqit it = classes.begin(); + for (auto it = classes.begin(); it != classes.end(); ++it, i++) { @@ -343,7 +343,7 @@ EquivalenceSet::EquivalenceSet(int num) bool EquivalenceSet::has(const Equivalence &e) const { - list::const_reverse_iterator rit = equis.rbegin(); + auto rit = equis.rbegin(); while (rit != equis.rend() && *rit != e) ++rit; if (rit != equis.rend()) @@ -385,7 +385,7 @@ EquivalenceSet::print(const char *prefix) const strcpy(tmp, prefix); strcat(tmp, " "); int i = 0; - for (list::const_iterator it = equis.begin(); + for (auto it = equis.begin(); it != equis.end(); ++it, i++) { diff --git a/dynare++/tl/cc/gs_tensor.cc b/dynare++/tl/cc/gs_tensor.cc index 13d1ad79c..5e53c93ce 100644 --- a/dynare++/tl/cc/gs_tensor.cc +++ b/dynare++/tl/cc/gs_tensor.cc @@ -184,9 +184,9 @@ FGSTensor::FGSTensor(const FSSparseTensor &t, const IntSequence &ss, } zeros(); - FSSparseTensor::const_iterator lbi = t.getMap().lower_bound(lb); - FSSparseTensor::const_iterator ubi = t.getMap().upper_bound(ub); - for (FSSparseTensor::const_iterator run = lbi; run != ubi; ++run) + auto lbi = t.getMap().lower_bound(lb); + auto ubi = t.getMap().upper_bound(ub); + for (auto run = lbi; run != ubi; ++run) { if (lb.lessEq((*run).first) && (*run).first.lessEq(ub)) { diff --git a/dynare++/tl/cc/kron_prod.cc b/dynare++/tl/cc/kron_prod.cc index c286b50ca..a60f8fb5d 100644 --- a/dynare++/tl/cc/kron_prod.cc +++ b/dynare++/tl/cc/kron_prod.cc @@ -306,7 +306,7 @@ KronProdAll::mult(const ConstTwoDMatrix &in, TwoDMatrix &out) const { KronProdIAI interkron(*this, i); c = interkron.kpd.ncols(); - TwoDMatrix *newlast = new TwoDMatrix(in.nrows(), c); + auto *newlast = new TwoDMatrix(in.nrows(), c); interkron.mult(*last, *newlast); delete last; last = newlast; @@ -355,7 +355,7 @@ KronProdAll::multRows(const IntSequence &irows) const row = new ConstVector(irows[j], *(matlist[j])); else { - Vector *aux = new Vector(ncols(j)); + auto *aux = new Vector(ncols(j)); aux->zeros(); (*aux)[irows[j]] = 1.0; to_delete.push_back(aux); diff --git a/dynare++/tl/cc/normal_moments.cc b/dynare++/tl/cc/normal_moments.cc index 013d363ae..c4de8d498 100644 --- a/dynare++/tl/cc/normal_moments.cc +++ b/dynare++/tl/cc/normal_moments.cc @@ -27,20 +27,20 @@ UNormalMoments::generateMoments(int maxdim, const TwoDMatrix &v) "Variance-covariance matrix is not square in UNormalMoments constructor"); int nv = v.nrows(); - URSingleTensor *mom2 = new URSingleTensor(nv, 2); + auto *mom2 = new URSingleTensor(nv, 2); mom2->getData() = v.getData(); insert(mom2); - URSingleTensor *kronv = new URSingleTensor(nv, 2); + auto *kronv = new URSingleTensor(nv, 2); kronv->getData() = v.getData(); for (int d = 4; d <= maxdim; d += 2) { - URSingleTensor *newkronv = new URSingleTensor(nv, d); + auto *newkronv = new URSingleTensor(nv, d); KronProd::kronMult(ConstVector(v.getData()), ConstVector(kronv->getData()), newkronv->getData()); delete kronv; kronv = newkronv; - URSingleTensor *mom = new URSingleTensor(nv, d); + auto *mom = new URSingleTensor(nv, d); // apply $F_n$ to |kronv| /* Here we go through all equivalences, select only those having 2 elements in each class, then go through all elements in |kronv| and @@ -94,7 +94,7 @@ FNormalMoments::FNormalMoments(const UNormalMoments &moms) { for (const auto & mom : moms) { - FRSingleTensor *fm = new FRSingleTensor(*(mom.second)); + auto *fm = new FRSingleTensor(*(mom.second)); insert(fm); } } diff --git a/dynare++/tl/cc/ps_tensor.cc b/dynare++/tl/cc/ps_tensor.cc index c9a57b8a0..a97dd9681 100644 --- a/dynare++/tl/cc/ps_tensor.cc +++ b/dynare++/tl/cc/ps_tensor.cc @@ -62,7 +62,7 @@ FTensor & UPSTensor::fold() const { TL_RAISE("Never should come to this place in UPSTensor::fold"); - FFSTensor *nothing = new FFSTensor(0, 0, 0); + auto *nothing = new FFSTensor(0, 0, 0); return *nothing; } @@ -171,11 +171,11 @@ UPSTensor::fillFromSparseOne(const FSSparseTensor &t, const IntSequence &ss, IntSequence c(run.getCoor()); c.add(1, cum); c.sort(); - FSSparseTensor::const_iterator sl = t.getMap().lower_bound(c); + auto sl = t.getMap().lower_bound(c); if (sl != t.getMap().end()) { - FSSparseTensor::const_iterator su = t.getMap().upper_bound(c); - for (FSSparseTensor::const_iterator srun = sl; srun != su; ++srun) + auto su = t.getMap().upper_bound(c); + for (auto srun = sl; srun != su; ++srun) get((*srun).second.first, *run) = (*srun).second.second; } } @@ -219,9 +219,9 @@ UPSTensor::fillFromSparseTwo(const FSSparseTensor &t, const IntSequence &ss, Permutation unsort(coor); zeros(); - FSSparseTensor::const_iterator lbi = t.getMap().lower_bound(lb_srt); - FSSparseTensor::const_iterator ubi = t.getMap().upper_bound(ub_srt); - for (FSSparseTensor::const_iterator run = lbi; run != ubi; ++run) + auto lbi = t.getMap().lower_bound(lb_srt); + auto ubi = t.getMap().upper_bound(ub_srt); + for (auto run = lbi; run != ubi; ++run) { if (lb_srt.lessEq((*run).first) && (*run).first.lessEq(ub_srt)) { @@ -320,7 +320,7 @@ UTensor & FPSTensor::unfold() const { TL_RAISE("Unfolding of FPSTensor not implemented"); - UFSTensor *nothing = new UFSTensor(0, 0, 0); + auto *nothing = new UFSTensor(0, 0, 0); return *nothing; } @@ -383,12 +383,12 @@ FPSTensor::FPSTensor(const TensorDimens &td, const Equivalence &e, const Permuta { Tensor::index fold_ind = dummy.getFirstIndexOf(run); const IntSequence &c = fold_ind.getCoor(); - GSSparseTensor::const_iterator sl = a.getMap().lower_bound(c); + auto sl = a.getMap().lower_bound(c); if (sl != a.getMap().end()) { Vector *row_prod = kp.multRows(run.getCoor()); - GSSparseTensor::const_iterator su = a.getMap().upper_bound(c); - for (GSSparseTensor::const_iterator srun = sl; srun != su; ++srun) + auto su = a.getMap().upper_bound(c); + for (auto srun = sl; srun != su; ++srun) { Vector out_row((*srun).second.first, *this); out_row.add((*srun).second.second, *row_prod); diff --git a/dynare++/tl/cc/pyramid_prod2.cc b/dynare++/tl/cc/pyramid_prod2.cc index d40cf27ea..9252a1666 100644 --- a/dynare++/tl/cc/pyramid_prod2.cc +++ b/dynare++/tl/cc/pyramid_prod2.cc @@ -89,10 +89,10 @@ IrregTensor::IrregTensor(const IrregTensorHeader &h) return; } - Vector *last = new Vector(*(header.cols[header.dimen()-1])); + auto *last = new Vector(*(header.cols[header.dimen()-1])); for (int i = header.dimen()-2; i > 0; i--) { - Vector *newlast = new Vector(last->length()*header.cols[i]->length()); + auto *newlast = new Vector(last->length()*header.cols[i]->length()); KronProd::kronMult(ConstVector(*(header.cols[i])), ConstVector(*last), *newlast); delete last; diff --git a/dynare++/tl/cc/rfs_tensor.cc b/dynare++/tl/cc/rfs_tensor.cc index 2e1fdb701..d4193e655 100644 --- a/dynare++/tl/cc/rfs_tensor.cc +++ b/dynare++/tl/cc/rfs_tensor.cc @@ -124,10 +124,10 @@ URSingleTensor::URSingleTensor(const vector &cols) return; } - Vector *last = new Vector(cols[cols.size()-1]); + auto *last = new Vector(cols[cols.size()-1]); for (int i = cols.size()-2; i > 0; i--) { - Vector *newlast = new Vector(Tensor::power(nvar(), cols.size()-i)); + auto *newlast = new Vector(Tensor::power(nvar(), cols.size()-i)); KronProd::kronMult(cols[i], ConstVector(*last), *newlast); delete last; last = newlast; @@ -148,10 +148,10 @@ URSingleTensor::URSingleTensor(const ConstVector &v, int d) return; } - Vector *last = new Vector(v); + auto *last = new Vector(v); for (int i = d-2; i > 0; i--) { - Vector *newlast = new Vector(last->length()*v.length()); + auto *newlast = new Vector(last->length()*v.length()); KronProd::kronMult(v, ConstVector(*last), *newlast); delete last; last = newlast; diff --git a/dynare++/tl/cc/sparse_tensor.cc b/dynare++/tl/cc/sparse_tensor.cc index bd3ed02d0..6e3a1d129 100644 --- a/dynare++/tl/cc/sparse_tensor.cc +++ b/dynare++/tl/cc/sparse_tensor.cc @@ -19,11 +19,11 @@ SparseTensor::insert(const IntSequence &key, int r, double c) TL_RAISE_IF(!std::isfinite(c), "Insertion of non-finite value in SparseTensor::insert"); - iterator first_pos = m.lower_bound(key); + auto first_pos = m.lower_bound(key); // check that pair |key| and |r| is unique - iterator last_pos = m.upper_bound(key); - for (iterator it = first_pos; it != last_pos; ++it) + auto last_pos = m.upper_bound(key); + for (auto it = first_pos; it != last_pos; ++it) if ((*it).second.first == r) { TL_RAISE("Duplicate insertion in SparseTensor::insert"); @@ -43,7 +43,7 @@ bool SparseTensor::isFinite() const { bool res = true; - const_iterator run = m.begin(); + auto run = m.begin(); while (res && run != m.end()) { if (!std::isfinite((*run).second.second)) @@ -60,7 +60,7 @@ double SparseTensor::getFoldIndexFillFactor() const { int cnt = 0; - const_iterator start_col = m.begin(); + auto start_col = m.begin(); while (start_col != m.end()) { cnt++; @@ -78,7 +78,7 @@ double SparseTensor::getUnfoldIndexFillFactor() const { int cnt = 0; - const_iterator start_col = m.begin(); + auto start_col = m.begin(); while (start_col != m.end()) { const IntSequence &key = (*start_col).first; @@ -96,14 +96,14 @@ void SparseTensor::print() const { printf("Fill: %3.2f %%\n", 100*getFillFactor()); - const_iterator start_col = m.begin(); + auto start_col = m.begin(); while (start_col != m.end()) { const IntSequence &key = (*start_col).first; printf("Column: "); key.print(); - const_iterator end_col = m.upper_bound(key); + auto end_col = m.upper_bound(key); int cnt = 1; - for (const_iterator run = start_col; run != end_col; ++run, cnt++) + for (auto run = start_col; run != end_col; ++run, cnt++) { if ((cnt/7)*7 == cnt) printf("\n"); @@ -174,9 +174,9 @@ FSSparseTensor::multColumnAndAdd(const Tensor &t, Vector &v) const TL_RAISE_IF(key[0] < 0 || key[key.size()-1] >= nv, "Wrong coordinates of index in FSSparseTensor::multColumnAndAdd"); - const_iterator first_pos = m.lower_bound(key); - const_iterator last_pos = m.upper_bound(key); - for (const_iterator cit = first_pos; cit != last_pos; ++cit) + auto first_pos = m.lower_bound(key); + auto last_pos = m.upper_bound(key); + for (auto cit = first_pos; cit != last_pos; ++cit) { int r = (*cit).second.first; double c = (*cit).second.second; @@ -215,9 +215,9 @@ GSSparseTensor::GSSparseTensor(const FSSparseTensor &t, const IntSequence &ss, ub[i] = s_offsets[coor[i]] + ss[coor[i]] - 1; } - FSSparseTensor::const_iterator lbi = t.getMap().lower_bound(lb); - FSSparseTensor::const_iterator ubi = t.getMap().upper_bound(ub); - for (FSSparseTensor::const_iterator run = lbi; run != ubi; ++run) + auto lbi = t.getMap().lower_bound(lb); + auto ubi = t.getMap().upper_bound(ub); + for (auto run = lbi; run != ubi; ++run) { if (lb.lessEq((*run).first) && (*run).first.lessEq(ub)) { diff --git a/dynare++/tl/cc/stack_container.hh b/dynare++/tl/cc/stack_container.hh index 0276b4a49..9bc16e790 100644 --- a/dynare++/tl/cc/stack_container.hh +++ b/dynare++/tl/cc/stack_container.hh @@ -243,7 +243,7 @@ public: len++; } - Vector *res = new Vector(len); + auto *res = new Vector(len); i = 0; while (i < numStacks() && getType(i, s) == _Stype::matrix) { diff --git a/dynare++/tl/cc/sthread.cc b/dynare++/tl/cc/sthread.cc index 9ea13ebe9..b867c5018 100644 --- a/dynare++/tl/cc/sthread.cc +++ b/dynare++/tl/cc/sthread.cc @@ -117,7 +117,7 @@ namespace sthread void * posix_thread_function(void *c) { - thread_traits::_Ctype *ct + auto *ct = (thread_traits::_Ctype *)c; try { @@ -133,7 +133,7 @@ namespace sthread void * posix_detach_thread_function(void *c) { - thread_traits::_Dtype *ct + auto *ct = (thread_traits::_Dtype *)c; condition_counter *counter = ct->counter; try diff --git a/dynare++/tl/cc/sthread.hh b/dynare++/tl/cc/sthread.hh index ae9062734..e449b8b40 100644 --- a/dynare++/tl/cc/sthread.hh +++ b/dynare++/tl/cc/sthread.hh @@ -301,7 +301,7 @@ namespace sthread mmval * get(const void *c, const char *id) { - iterator it = _Tparent::find(mmkey(c, id)); + auto it = _Tparent::find(mmkey(c, id)); if (it == _Tparent::end()) return NULL; return &((*it).second); @@ -314,7 +314,7 @@ namespace sthread void remove(const void *c, const char *id) { - iterator it = _Tparent::find(mmkey(c, id)); + auto it = _Tparent::find(mmkey(c, id)); if (it != _Tparent::end()) this->erase(it); } @@ -563,7 +563,7 @@ namespace sthread run() { int mpt = max_parallel_threads; - iterator it = tlist.begin(); + auto it = tlist.begin(); while (it != tlist.end()) { if (counter.waitForChange() < mpt) diff --git a/dynare++/tl/cc/symmetry.cc b/dynare++/tl/cc/symmetry.cc index e30577f6c..6ebd71d4d 100644 --- a/dynare++/tl/cc/symmetry.cc +++ b/dynare++/tl/cc/symmetry.cc @@ -128,7 +128,7 @@ InducedSymmetries::InducedSymmetries(const Equivalence &e, const Permutation &p, { for (int i = 0; i < e.numClasses(); i++) { - Equivalence::const_seqit it = e.find(p.getMap()[i]); + auto it = e.find(p.getMap()[i]); push_back(Symmetry(s, *it)); } } diff --git a/dynare++/tl/cc/t_container.cc b/dynare++/tl/cc/t_container.cc index 55aed4623..f9603269e 100644 --- a/dynare++/tl/cc/t_container.cc +++ b/dynare++/tl/cc/t_container.cc @@ -13,7 +13,7 @@ UGSContainer::UGSContainer(const FGSContainer &c) { for (const auto & it : c) { - UGSTensor *unfolded = new UGSTensor(*(it.second)); + auto *unfolded = new UGSTensor(*(it.second)); insert(unfolded); } } @@ -59,7 +59,7 @@ FGSContainer::FGSContainer(const UGSContainer &c) { for (const auto & it : c) { - FGSTensor *folded = new FGSTensor(*(it.second)); + auto *folded = new FGSTensor(*(it.second)); insert(folded); } } diff --git a/dynare++/tl/cc/t_container.hh b/dynare++/tl/cc/t_container.hh index 96aa76194..a20e98c3e 100644 --- a/dynare++/tl/cc/t_container.hh +++ b/dynare++/tl/cc/t_container.hh @@ -115,9 +115,9 @@ public: TensorContainer(const TensorContainer<_Ttype> &c) : n(c.n), m(), ebundle(c.ebundle) { - for (const_iterator it = c.m.begin(); it != c.m.end(); ++it) + for (auto it = c.m.begin(); it != c.m.end(); ++it) { - _Ttype *ten = new _Ttype(*((*it).second)); + auto *ten = new _Ttype(*((*it).second)); insert(ten); } } @@ -128,9 +128,9 @@ public: TensorContainer(int first_row, int num, TensorContainer<_Ttype> &c) : n(c.n), ebundle(*(tls.ebundle)) { - for (iterator it = c.m.begin(); it != c.m.end(); ++it) + for (auto it = c.m.begin(); it != c.m.end(); ++it) { - _Ttype *t = new _Ttype(first_row, num, *((*it).second)); + auto *t = new _Ttype(first_row, num, *((*it).second)); insert(t); } } @@ -140,7 +140,7 @@ public: { TL_RAISE_IF(s.num() != num(), "Incompatible symmetry lookup in TensorContainer::get"); - const_iterator it = m.find(s); + auto it = m.find(s); if (it == m.end()) { TL_RAISE("Symmetry not found in TensorContainer::get"); @@ -157,7 +157,7 @@ public: { TL_RAISE_IF(s.num() != num(), "Incompatible symmetry lookup in TensorContainer::get"); - iterator it = m.find(s); + auto it = m.find(s); if (it == m.end()) { TL_RAISE("Symmetry not found in TensorContainer::get"); @@ -174,7 +174,7 @@ public: { TL_RAISE_IF(s.num() != num(), "Incompatible symmetry lookup in TensorContainer::check"); - const_iterator it = m.find(s); + auto it = m.find(s); return it != m.end(); } @@ -195,7 +195,7 @@ public: void remove(const Symmetry &s) { - iterator it = m.find(s); + auto it = m.find(s); if (it != m.end()) { _ptr t = (*it).second; @@ -218,7 +218,7 @@ public: getMaxDim() const { int res = -1; - for (const_iterator run = m.begin(); run != m.end(); ++run) + for (auto run = m.begin(); run != m.end(); ++run) { int dim = (*run).first.dimen(); if (dim > res) @@ -244,7 +244,7 @@ public: void writeMat(mat_t *fd, const char *prefix) const { - for (const_iterator it = begin(); it != end(); ++it) + for (auto it = begin(); it != end(); ++it) { char lname[100]; sprintf(lname, "%s_g", prefix); @@ -285,7 +285,7 @@ public: { vector<_const_ptr> res(e.numClasses()); int i = 0; - for (Equivalence::const_seqit it = e.begin(); + for (auto it = e.begin(); it != e.end(); ++it, i++) { Symmetry s(rsym, *it); diff --git a/dynare++/tl/cc/t_polynomial.cc b/dynare++/tl/cc/t_polynomial.cc index f2ff1fbf7..941e29584 100644 --- a/dynare++/tl/cc/t_polynomial.cc +++ b/dynare++/tl/cc/t_polynomial.cc @@ -12,7 +12,7 @@ PowerProvider::getNext(const URSingleTensor *dummy) { if (ut) { - URSingleTensor *ut_new = new URSingleTensor(nv, ut->dimen()+1); + auto *ut_new = new URSingleTensor(nv, ut->dimen()+1); KronProd::kronMult(ConstVector(origv), ConstVector(ut->getData()), ut_new->getData()); delete ut; ut = ut_new; diff --git a/dynare++/tl/cc/t_polynomial.hh b/dynare++/tl/cc/t_polynomial.hh index 9d0e27161..cdddf8b18 100644 --- a/dynare++/tl/cc/t_polynomial.hh +++ b/dynare++/tl/cc/t_polynomial.hh @@ -294,7 +294,7 @@ public: } if (d > 1) { - _Ttype *new_last = new _Ttype(*last, v); + auto *new_last = new _Ttype(*last, v); delete last; last = new_last; } @@ -364,7 +364,7 @@ public: TL_RAISE_IF(v.length() != nvars(), "Wrong length of vector for TensorPolynomial::evalPartially"); - _Ttype *res = new _Ttype(nrows(), nvars(), s); + auto *res = new _Ttype(nrows(), nvars(), s); res->zeros(); if (_Tparent::check(Symmetry(s))) @@ -375,10 +375,10 @@ public: if (_Tparent::check(Symmetry(d))) { const _Ttype <mp = *(_Tparent::get(Symmetry(d))); - _Ttype *last = new _Ttype(ltmp); + auto *last = new _Ttype(ltmp); for (int j = 0; j < d - s; j++) { - _Ttype *newlast = new _Ttype(*last, v); + auto *newlast = new _Ttype(*last, v); delete last; last = newlast; } diff --git a/dynare++/tl/cc/twod_matrix.cc b/dynare++/tl/cc/twod_matrix.cc index 04a32107b..7c6a2df25 100644 --- a/dynare++/tl/cc/twod_matrix.cc +++ b/dynare++/tl/cc/twod_matrix.cc @@ -40,7 +40,7 @@ ConstTwoDMatrix::writeMat(mat_t *fd, const char *vname) const #endif dims[0] = nrows(); dims[1] = ncols(); - double *data = new double[nrows()*ncols()]; + auto *data = new double[nrows()*ncols()]; for (int j = 0; j < ncols(); j++) for (int i = 0; i < nrows(); i++) diff --git a/dynare++/tl/testing/factory.cc b/dynare++/tl/testing/factory.cc index e2bf9fbcd..a2fbc1842 100644 --- a/dynare++/tl/testing/factory.cc +++ b/dynare++/tl/testing/factory.cc @@ -46,7 +46,7 @@ Factory::makeVector(int n) { init(n, n*n); - Vector *v = new Vector(n); + auto *v = new Vector(n); for (int i = 0; i < n; i++) (*v)[i] = get(); diff --git a/dynare++/tl/testing/factory.hh b/dynare++/tl/testing/factory.hh index 7550d3f11..37256d33b 100644 --- a/dynare++/tl/testing/factory.hh +++ b/dynare++/tl/testing/factory.hh @@ -34,7 +34,7 @@ public: _Ttype * make(int r, int nv, int dim) { - _Ttype *res = new _Ttype(r, nv, dim); + auto *res = new _Ttype(r, nv, dim); init(dim, nv); fillMatrix(*res); return res; @@ -45,14 +45,14 @@ public: makeCont(int r, const IntSequence &nvs, int maxdim) { int symnum = nvs.size(); - _Ctype *res = new _Ctype(symnum); + auto *res = new _Ctype(symnum); for (int dim = 1; dim <= maxdim; dim++) { if (symnum == 1) { // full symmetry Symmetry sym(dim); - _Ttype *t = make<_Ttype>(r, sym, nvs); + auto *t = make<_Ttype>(r, sym, nvs); res->insert(t); } else @@ -61,7 +61,7 @@ public: for (int i = 0; i <= dim; i++) { Symmetry sym(i, dim-i); - _Ttype *t = make<_Ttype>(r, sym, nvs); + auto *t = make<_Ttype>(r, sym, nvs); res->insert(t); } } @@ -73,10 +73,10 @@ public: _Ptype * makePoly(int r, int nv, int maxdim) { - _Ptype *p = new _Ptype(r, nv); + auto *p = new _Ptype(r, nv); for (int d = 1; d <= maxdim; d++) { - _Ttype *t = make<_Ttype>(r, nv, d); + auto *t = make<_Ttype>(r, nv, d); p->insert(t); } return p; diff --git a/dynare++/tl/testing/monoms.cc b/dynare++/tl/testing/monoms.cc index 3ead0d510..f85284281 100644 --- a/dynare++/tl/testing/monoms.cc +++ b/dynare++/tl/testing/monoms.cc @@ -29,7 +29,7 @@ int IntGenerator::get() const { double d = drand48(); - int num_inter = (int) (((double) 2*maxim)/(1.0-probab)); + auto num_inter = (int) (((double) 2*maxim)/(1.0-probab)); int num_zero_inter = num_inter - 2*maxim; if (d < ((double) num_zero_inter)/num_inter) return 0; @@ -223,7 +223,7 @@ Monom2Vector::deriv(const Symmetry &s) const FGSContainer * Monom2Vector::deriv(int maxdim) const { - FGSContainer *res = new FGSContainer(2); + auto *res = new FGSContainer(2); for (int dim = 1; dim <= maxdim; dim++) { for (int ydim = 0; ydim <= dim; ydim++) @@ -404,7 +404,7 @@ Monom4Vector::deriv(int dim) const IntSequence cum(4); cum[0] = 0; cum[1] = nx1; cum[2] = nx1+nx2; cum[3] = nx1+nx2+nx3; - FSSparseTensor *res = new FSSparseTensor(dim, nx1+nx2+nx3+nx4, len); + auto *res = new FSSparseTensor(dim, nx1+nx2+nx3+nx4, len); FFSTensor dummy(0, nx1+nx2+nx3+nx4, dim); for (Tensor::index run = dummy.begin(); run != dummy.end(); ++run) diff --git a/dynare++/tl/testing/tests.cc b/dynare++/tl/testing/tests.cc index 9f751ecef..940787c8e 100644 --- a/dynare++/tl/testing/tests.cc +++ b/dynare++/tl/testing/tests.cc @@ -225,7 +225,7 @@ TestRunnable::dense_prod(const Symmetry &bsym, const IntSequence &bnvs, Factory f; FGSContainer *cont = f.makeCont(hnv, bnvs, bsym.dimen()-hdim+1); - FGSTensor *fh + auto *fh = f.make(rows, Symmetry(hdim), IntSequence(1, hnv)); UGSTensor uh(*fh); FGSTensor fb(rows, TensorDimens(bsym, bnvs)); @@ -451,8 +451,8 @@ TestRunnable::folded_contraction(int r, int nv, int dim) Factory fact; Vector *x = fact.makeVector(nv); - FFSTensor *forig = fact.make(r, nv, dim); - FFSTensor *f = new FFSTensor(*forig); + auto *forig = fact.make(r, nv, dim); + auto *f = new FFSTensor(*forig); clock_t ctime = clock(); for (int d = dim-1; d > 0; d--) { @@ -493,10 +493,10 @@ TestRunnable::unfolded_contraction(int r, int nv, int dim) Factory fact; Vector *x = fact.makeVector(nv); - FFSTensor *forig = fact.make(r, nv, dim); + auto *forig = fact.make(r, nv, dim); UFSTensor uorig(*forig); delete forig; - UFSTensor *u = new UFSTensor(uorig); + auto *u = new UFSTensor(uorig); clock_t ctime = clock(); for (int d = dim-1; d > 0; d--) {