Port to C++11 auto keyword

Performed using modernize-use-auto from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-auto.html
parent 7e003cc5
...@@ -34,20 +34,20 @@ extern "C" { ...@@ -34,20 +34,20 @@ extern "C" {
if (nhrs < 12 || nlhs != 2) 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"); 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) if (nhrs != 12 + order)
DYN_MEX_FUNC_ERR_MSG_TXT("dynare_simul_ must have exactly 11+order input parameters.\n"); DYN_MEX_FUNC_ERR_MSG_TXT("dynare_simul_ must have exactly 11+order input parameters.\n");
int nstat = (int) mxGetScalar(prhs[1]); auto nstat = (int) mxGetScalar(prhs[1]);
int npred = (int) mxGetScalar(prhs[2]); auto npred = (int) mxGetScalar(prhs[2]);
int nboth = (int) mxGetScalar(prhs[3]); auto nboth = (int) mxGetScalar(prhs[3]);
int nforw = (int) mxGetScalar(prhs[4]); auto nforw = (int) mxGetScalar(prhs[4]);
int nexog = (int) mxGetScalar(prhs[5]); auto nexog = (int) mxGetScalar(prhs[5]);
const mxArray *const ystart = prhs[6]; const mxArray *const ystart = prhs[6];
const mxArray *const shocks = prhs[7]; const mxArray *const shocks = prhs[7];
const mxArray *const vcov = prhs[8]; 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 mxArray *const ysteady = prhs[10];
const mwSize *const ystart_dim = mxGetDimensions(ystart); const mwSize *const ystart_dim = mxGetDimensions(ystart);
const mwSize *const shocks_dim = mxGetDimensions(shocks); const mwSize *const shocks_dim = mxGetDimensions(shocks);
...@@ -102,7 +102,7 @@ extern "C" { ...@@ -102,7 +102,7 @@ extern "C" {
ft.zeros(); ft.zeros();
ConstTwoDMatrix gk_mat(ft.nrows(), ft.ncols(), mxGetPr(gk)); ConstTwoDMatrix gk_mat(ft.nrows(), ft.ncols(), mxGetPr(gk));
ft.add(1.0, gk_mat); ft.add(1.0, gk_mat);
UFSTensor *ut = new UFSTensor(ft); auto *ut = new UFSTensor(ft);
pol.insert(ut); pol.insert(ut);
} }
// form the decision rule // form the decision rule
......
...@@ -33,7 +33,7 @@ double ...@@ -33,7 +33,7 @@ double
NormalICDF::get(double x) NormalICDF::get(double x)
{ {
double xx = (2*normal_icdf_end-1)*std::abs(x-0.5); 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 xx1 = normal_icdf_step*i;
double yy1 = normal_icdf_data[i]; double yy1 = normal_icdf_data[i];
double y; double y;
......
...@@ -150,8 +150,8 @@ main(int argc, char **argv) ...@@ -150,8 +150,8 @@ main(int argc, char **argv)
// sort and uniq // sort and uniq
OrderVec ordvec; OrderVec ordvec;
std::sort(points.begin(), points.end(), ordvec); std::sort(points.begin(), points.end(), ordvec);
std::vector<Vector *>::iterator new_end = std::unique(points.begin(), points.end()); auto new_end = std::unique(points.begin(), points.end());
for (std::vector<Vector *>::iterator it = new_end; it != points.end(); ++it) for (auto it = new_end; it != points.end(); ++it)
delete *it; delete *it;
points.erase(new_end, points.end()); points.erase(new_end, points.end());
......
...@@ -261,7 +261,7 @@ Approximation::saveRuleDerivs(const FGSContainer &g) ...@@ -261,7 +261,7 @@ Approximation::saveRuleDerivs(const FGSContainer &g)
rule_ders_ss = new FGSContainer(4); rule_ders_ss = new FGSContainer(4);
for (auto & run : (*rule_ders)) 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); rule_ders_ss->insert(ten);
} }
} }
......
...@@ -489,7 +489,7 @@ IRFResults::writeMat(mat_t *fd, const char *prefix) const ...@@ -489,7 +489,7 @@ IRFResults::writeMat(mat_t *fd, const char *prefix) const
void void
SimulationWorker::operator()() SimulationWorker::operator()()
{ {
ExplicitShockRealization *esr = new ExplicitShockRealization(sr, np); auto *esr = new ExplicitShockRealization(sr, np);
TwoDMatrix *m = dr.simulate(em, np, st, *esr); TwoDMatrix *m = dr.simulate(em, np, st, *esr);
{ {
SYNCHRO syn(&res, "simulation"); SYNCHRO syn(&res, "simulation");
...@@ -503,7 +503,7 @@ SimulationWorker::operator()() ...@@ -503,7 +503,7 @@ SimulationWorker::operator()()
void void
SimulationIRFWorker::operator()() SimulationIRFWorker::operator()()
{ {
ExplicitShockRealization *esr auto *esr
= new ExplicitShockRealization(res.control.getShocks(idata)); = new ExplicitShockRealization(res.control.getShocks(idata));
esr->addToShock(ishock, 0, imp); esr->addToShock(ishock, 0, imp);
const TwoDMatrix &data = res.control.getData(idata); const TwoDMatrix &data = res.control.getData(idata);
......
...@@ -200,7 +200,7 @@ DecisionRuleImpl<t>::fillTensors(const _Tg &g, double sigma) ...@@ -200,7 +200,7 @@ DecisionRuleImpl<t>::fillTensors(const _Tg &g, double sigma)
int dfact = 1; int dfact = 1;
for (int d = 0; d <= g.getMaxDim(); d++, dfact *= d) 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(); g_yud->zeros();
// fill tensor of |g_yud| of dimension |d| // fill tensor of |g_yud| of dimension |d|
...@@ -287,7 +287,7 @@ DecisionRuleImpl<t>::simulate(emethod em, int np, const Vector &ystart, ...@@ -287,7 +287,7 @@ DecisionRuleImpl<t>::simulate(emethod em, int np, const Vector &ystart,
{ {
KORD_RAISE_IF(ysteady.length() != ystart.length(), KORD_RAISE_IF(ysteady.length() != ystart.length(),
"Start and steady lengths differ in DecisionRuleImpl::simulate"); "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 // initialize vectors and subvectors for simulation
/* Here allocate the stack vector $(\Delta y^*, u)$, define the /* Here allocate the stack vector $(\Delta y^*, u)$, define the
...@@ -569,7 +569,7 @@ DRFixPoint<t>::fillTensors(const _Tg &g, double sigma) ...@@ -569,7 +569,7 @@ DRFixPoint<t>::fillTensors(const _Tg &g, double sigma)
int dfact = 1; int dfact = 1;
for (int d = 0; d <= g.getMaxDim(); d++, dfact *= d) 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(); g_yd->zeros();
int kfact = 1; int kfact = 1;
for (int k = 0; d+k <= g.getMaxDim(); k++, kfact *= k) for (int k = 0; d+k <= g.getMaxDim(); k++, kfact *= k)
......
...@@ -20,7 +20,7 @@ NameList::writeMat(mat_t *fd, const char *vname) const ...@@ -20,7 +20,7 @@ NameList::writeMat(mat_t *fd, const char *vname) const
if (maxlen == 0) if (maxlen == 0)
return; return;
char *m = new char[getNum()*maxlen]; auto *m = new char[getNum()*maxlen];
for (int i = 0; i < getNum(); i++) for (int i = 0; i < getNum(); i++)
for (int j = 0; j < maxlen; j++) for (int j = 0; j < maxlen; j++)
......
...@@ -122,7 +122,7 @@ FaaDiBruno::estimRefinment(const TensorDimens &tdims, int nr, int l, ...@@ -122,7 +122,7 @@ FaaDiBruno::estimRefinment(const TensorDimens &tdims, int nr, int l,
{ {
int nthreads = THREAD_GROUP::max_parallel_threads; int nthreads = THREAD_GROUP::max_parallel_threads;
long int per_size1 = tdims.calcUnfoldMaxOffset(); 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; double lambda = 0.0;
long int per_size = sizeof(double)*nr long int per_size = sizeof(double)*nr
*(long int) (lambda*per_size1+(1-lambda)*per_size2); *(long int) (lambda*per_size1+(1-lambda)*per_size2);
......
...@@ -161,7 +161,7 @@ FirstOrder::solve(const TwoDMatrix &fd) ...@@ -161,7 +161,7 @@ FirstOrder::solve(const TwoDMatrix &fd)
TwoDMatrix vsr(n, n); TwoDMatrix vsr(n, n);
lapack_int lwork = 100*n+16; lapack_int lwork = 100*n+16;
Vector work(lwork); Vector work(lwork);
lapack_int *bwork = new lapack_int[n]; auto *bwork = new lapack_int[n];
lapack_int info; lapack_int info;
lapack_int sdim2 = sdim; lapack_int sdim2 = sdim;
dgges("N", "V", "S", order_eigs, &n, matE.getData().base(), &n, dgges("N", "V", "S", order_eigs, &n, matE.getData().base(), &n,
......
...@@ -101,7 +101,7 @@ ResidFunction::setYU(const Vector &ys, const Vector &xx) ...@@ -101,7 +101,7 @@ ResidFunction::setYU(const Vector &ys, const Vector &xx)
} }
else else
{ {
FFSTensor *ten = new FFSTensor(hss->nrows(), hss->nvars(), 0); auto *ten = new FFSTensor(hss->nrows(), hss->nvars(), 0);
ten->getData() = ysteady_ss; ten->getData() = ysteady_ss;
hss->insert(ten); hss->insert(ten);
} }
......
...@@ -346,7 +346,7 @@ KOrder::switchToFolded() ...@@ -346,7 +346,7 @@ KOrder::switchToFolded()
{ {
if ((*si)[2] == 0 && g<unfold>().check(*si)) if ((*si)[2] == 0 && g<unfold>().check(*si))
{ {
FGSTensor *ft = new FGSTensor(*(g<unfold>().get(*si))); auto *ft = new FGSTensor(*(g<unfold>().get(*si)));
insertDerivative<fold>(ft); insertDerivative<fold>(ft);
if (dim > 1) if (dim > 1)
{ {
...@@ -357,7 +357,7 @@ KOrder::switchToFolded() ...@@ -357,7 +357,7 @@ KOrder::switchToFolded()
} }
if (G<unfold>().check(*si)) if (G<unfold>().check(*si))
{ {
FGSTensor *ft = new FGSTensor(*(G<unfold>().get(*si))); auto *ft = new FGSTensor(*(G<unfold>().get(*si)));
G<fold>().insert(ft); G<fold>().insert(ft);
if (dim > 1) if (dim > 1)
{ {
......
...@@ -450,7 +450,7 @@ KOrder::faaDiBrunoG(const Symmetry &sym) const ...@@ -450,7 +450,7 @@ KOrder::faaDiBrunoG(const Symmetry &sym) const
JournalRecordPair pa(journal); JournalRecordPair pa(journal);
pa << "Faa Di Bruno G container for " << sym << endrec; pa << "Faa Di Bruno G container for " << sym << endrec;
TensorDimens tdims(sym, nvs); TensorDimens tdims(sym, nvs);
_Ttensor *res = new _Ttensor(ypart.nyss(), tdims); auto *res = new _Ttensor(ypart.nyss(), tdims);
FaaDiBruno bruno(journal); FaaDiBruno bruno(journal);
bruno.calculate(Gstack<t>(), gss<t>(), *res); bruno.calculate(Gstack<t>(), gss<t>(), *res);
return res; return res;
...@@ -926,7 +926,7 @@ template <int t> ...@@ -926,7 +926,7 @@ template <int t>
Vector * Vector *
KOrder::calcStochShift(int order, double sigma) const KOrder::calcStochShift(int order, double sigma) const
{ {
Vector *res = new Vector(ny); auto *res = new Vector(ny);
res->zeros(); res->zeros();
int jfac = 1; int jfac = 1;
for (int j = 1; j <= order; j++, jfac *= j) for (int j = 1; j <= order; j++, jfac *= j)
......
...@@ -182,7 +182,7 @@ StochForwardDerivs<t>::StochForwardDerivs(const PartitionY &ypart, int nu, ...@@ -182,7 +182,7 @@ StochForwardDerivs<t>::StochForwardDerivs(const PartitionY &ypart, int nu,
_Tpol g_int_sym(r, ypart.nys()+1); _Tpol g_int_sym(r, ypart.nys()+1);
for (int d = 1; d <= maxd; d++) 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(); ten->zeros();
for (int i = 0; i <= d; i++) for (int i = 0; i <= d; i++)
{ {
...@@ -492,7 +492,7 @@ KOrderStoch::faaDiBrunoG(const Symmetry &sym) const ...@@ -492,7 +492,7 @@ KOrderStoch::faaDiBrunoG(const Symmetry &sym) const
JournalRecordPair pa(journal); JournalRecordPair pa(journal);
pa << "Faa Di Bruno GX container for " << sym << endrec; pa << "Faa Di Bruno GX container for " << sym << endrec;
TensorDimens tdims(sym, nvs); TensorDimens tdims(sym, nvs);
_Ttensor *res = new _Ttensor(ypart.nyss(), tdims); auto *res = new _Ttensor(ypart.nyss(), tdims);
FaaDiBruno bruno(journal); FaaDiBruno bruno(journal);
bruno.calculate(Gstack<t>(), h<t>(), *res); bruno.calculate(Gstack<t>(), h<t>(), *res);
return res; return res;
......
...@@ -54,7 +54,7 @@ FSSparseTensor * ...@@ -54,7 +54,7 @@ FSSparseTensor *
SparseGenerator::makeTensor(int dim, int nv, int r, SparseGenerator::makeTensor(int dim, int nv, int r,
double fill, double m) double fill, double m)
{ {
FSSparseTensor *res = new FSSparseTensor(dim, nv, r); auto *res = new FSSparseTensor(dim, nv, r);
FFSTensor dummy(0, nv, dim); FFSTensor dummy(0, nv, dim);
for (Tensor::index fi = dummy.begin(); fi != dummy.end(); ++fi) for (Tensor::index fi = dummy.begin(); fi != dummy.end(); ++fi)
{ {
......
...@@ -36,7 +36,7 @@ extern location_type asgn_lloc; ...@@ -36,7 +36,7 @@ extern location_type asgn_lloc;
void void
AtomAssignings::parse(int length, const char *stream) AtomAssignings::parse(int length, const char *stream)
{ {
char *buffer = new char[length+2]; auto *buffer = new char[length+2];
strncpy(buffer, stream, length); strncpy(buffer, stream, length);
buffer[length] = '\0'; buffer[length] = '\0';
buffer[length+1] = '\0'; buffer[length+1] = '\0';
...@@ -104,7 +104,7 @@ AtomAssignings::add_assignment(int asgn_off, const char *str, int name_len, ...@@ -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 // find the name in the atoms, make copy of name to be able to put
// '\0' at the end // '\0' at the end
char *buf = new char[name_len+1]; auto *buf = new char[name_len+1];
strncpy(buf, str, name_len); strncpy(buf, str, name_len);
buf[name_len] = '\0'; buf[name_len] = '\0';
// if left hand side is a registered atom, insert it to tree // if left hand side is a registered atom, insert it to tree
...@@ -203,7 +203,7 @@ AtomAsgnEvaluator::setValues(EvalTree &et) const ...@@ -203,7 +203,7 @@ AtomAsgnEvaluator::setValues(EvalTree &et) const
int t = aa.atoms.index(ss); int t = aa.atoms.index(ss);
if (t >= 0) if (t >= 0)
{ {
Tusrvalmap::const_iterator it = user_values.find(t); auto it = user_values.find(t);
if (it == user_values.end()) if (it == user_values.end())
et.set_nulary(t, nan); et.set_nulary(t, nan);
else else
...@@ -218,7 +218,7 @@ AtomAsgnEvaluator::set_user_value(const char *name, double val) ...@@ -218,7 +218,7 @@ AtomAsgnEvaluator::set_user_value(const char *name, double val)
int t = aa.atoms.index(name); int t = aa.atoms.index(name);
if (t >= 0) if (t >= 0)
{ {
Tusrvalmap::iterator it = user_values.find(t); auto it = user_values.find(t);
if (it == user_values.end()) if (it == user_values.end())
user_values.insert(Tusrvalmap::value_type(t, val)); user_values.insert(Tusrvalmap::value_type(t, val));
else else
...@@ -240,7 +240,7 @@ AtomAsgnEvaluator::load(int i, double res) ...@@ -240,7 +240,7 @@ AtomAsgnEvaluator::load(int i, double res)
double double
AtomAsgnEvaluator::get_value(const char *name) const 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()) if (it == aa.lname2expr.end())
return std::numeric_limits<double>::quiet_NaN(); return std::numeric_limits<double>::quiet_NaN();
else else
......
...@@ -22,7 +22,7 @@ AtomSubstitutions::AtomSubstitutions(const AtomSubstitutions &as, const FineAtom ...@@ -22,7 +22,7 @@ AtomSubstitutions::AtomSubstitutions(const AtomSubstitutions &as, const FineAtom
for (const auto & it : as.old2new) for (const auto & it : as.old2new)
{ {
Tshiftnameset sset; Tshiftnameset sset;
for (Tshiftnameset::const_iterator itt = it.second.begin(); for (auto itt = it.second.begin();
itt != it.second.end(); ++itt) itt != it.second.end(); ++itt)
sset.insert(Tshiftname(ns.query((*itt).first), (*itt).second)); sset.insert(Tshiftname(ns.query((*itt).first), (*itt).second));
old2new.insert(Toldnamemap::value_type(ns.query(it.first), sset)); old2new.insert(Toldnamemap::value_type(ns.query(it.first), sset));
...@@ -42,7 +42,7 @@ AtomSubstitutions::add_substitution(const char *newname, const char *oldname, in ...@@ -42,7 +42,7 @@ AtomSubstitutions::add_substitution(const char *newname, const char *oldname, in
// insert to new2old map // insert to new2old map
new2old.insert(Tshiftmap::value_type(newname, Tshiftname(oldname, tshift))); new2old.insert(Tshiftmap::value_type(newname, Tshiftname(oldname, tshift)));
// insert to old2new map // insert to old2new map
Toldnamemap::iterator it = old2new.find(oldname); auto it = old2new.find(oldname);
if (it != old2new.end()) if (it != old2new.end())
(*it).second.insert(Tshiftname(newname, -tshift)); (*it).second.insert(Tshiftname(newname, -tshift));
else else
...@@ -80,7 +80,7 @@ AtomSubstitutions::substitutions_finished(VarOrdering::ord_type ot) ...@@ -80,7 +80,7 @@ AtomSubstitutions::substitutions_finished(VarOrdering::ord_type ot)
const char * const char *
AtomSubstitutions::get_new4old(const char *oldname, int tshift) const 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()) if (it != old2new.end())
{ {
const Tshiftnameset &sset = (*it).second; const Tshiftnameset &sset = (*it).second;
...@@ -96,7 +96,7 @@ AtomSubstitutions::print() const ...@@ -96,7 +96,7 @@ AtomSubstitutions::print() const
{ {
printf("Atom Substitutions:\nOld ==> New:\n"); printf("Atom Substitutions:\nOld ==> New:\n");
for (const auto & it : old2new) for (const auto & it : old2new)
for (Tshiftnameset::const_iterator itt = it.second.begin(); for (auto itt = it.second.begin();
itt != it.second.end(); ++itt) itt != it.second.end(); ++itt)
printf(" %s ==> [%s, %d]\n", it.first, (*itt).first, (*itt).second); printf(" %s ==> [%s, %d]\n", it.first, (*itt).first, (*itt).second);
...@@ -164,7 +164,7 @@ SAtoms::findNameWithLeadInInterval(const vector<const char *> &names, ...@@ -164,7 +164,7 @@ SAtoms::findNameWithLeadInInterval(const vector<const char *> &names,
{ {
for (auto name : names) for (auto name : names)
{ {
DynamicAtoms::Tvarmap::const_iterator it = vars.find(name); auto it = vars.find(name);
if (it != vars.end()) if (it != vars.end())
{ {
const DynamicAtoms::Tlagmap &lmap = (*it).second; const DynamicAtoms::Tlagmap &lmap = (*it).second;
......
...@@ -28,7 +28,7 @@ void ...@@ -28,7 +28,7 @@ void
CSVParser::csv_parse(int length, const char *str) CSVParser::csv_parse(int length, const char *str)
{ {
// allocate temporary buffer and parse // allocate temporary buffer and parse
char *buffer = new char[length+2]; auto *buffer = new char[length+2];
strncpy(buffer, str, length); strncpy(buffer, str, length);
buffer[length] = '\0'; buffer[length] = '\0';
buffer[length+1] = '\0'; buffer[length+1] = '\0';
......
...@@ -14,7 +14,7 @@ NameStorage::NameStorage(const NameStorage &stor) ...@@ -14,7 +14,7 @@ NameStorage::NameStorage(const NameStorage &stor)
{ {
for (auto i : stor.name_store) for (auto i : stor.name_store)
{ {
char *str = new char[strlen(i)+1]; auto *str = new char[strlen(i)+1];
strcpy(str, i); strcpy(str, i);
name_store.push_back(str); name_store.push_back(str);
name_set.insert(str); name_set.insert(str);
...@@ -33,7 +33,7 @@ NameStorage::~NameStorage() ...@@ -33,7 +33,7 @@ NameStorage::~NameStorage()
const char * const char *
NameStorage::query(const char *name) const NameStorage::query(const char *name) const
{ {
set<const char *, ltstr>::const_iterator it = name_set.find(name); auto it = name_set.find(name);
if (it == name_set.end()) if (it == name_set.end())
return NULL; return NULL;
else else
...@@ -43,10 +43,10 @@ NameStorage::query(const char *name) const ...@@ -43,10 +43,10 @@ NameStorage::query(const char *name) const
const char * const char *
NameStorage::insert(const char *name) NameStorage::insert(const char *name)
{ {
set<const char *, ltstr>::const_iterator it = name_set.find(name); auto it = name_set.find(name);
if (it == name_set.end()) if (it == name_set.end())
{ {
char *str = new char[strlen(name)+1]; auto *str = new char[strlen(name)+1];
strcpy(str, name); strcpy(str, name);
name_store.push_back(str); name_store.push_back(str);
name_set.insert(str); name_set.insert(str);
...@@ -97,14 +97,14 @@ Constants::is_constant(int t) const ...@@ -97,14 +97,14 @@ Constants::is_constant(int t) const
{ {
if (t < OperationTree::num_constants) if (t < OperationTree::num_constants)
return true; return true;
Tconstantmap::const_iterator it = cmap.find(t); auto it = cmap.find(t);
return (it != cmap.end()); return (it != cmap.end());
} }
double double
Constants::get_constant_value(int t) const Constants::get_constant_value(int t) const
{ {
Tconstantmap::const_iterator it = cmap.find(t); auto it = cmap.find(t);
if (it != cmap.end()) if (it != cmap.end())
return (*it).second; return (*it).second;
else else
...@@ -120,7 +120,7 @@ Constants::check(const char *str) const ...@@ -120,7 +120,7 @@ Constants::check(const char *str) const
{ {
double d; double d;
sscanf(str, "%lf", &d); sscanf(str, "%lf", &d);
Tconstantinvmap::const_iterator it = cinvmap.find(d); auto it = cinvmap.find(d);
if (it != cinvmap.end()) if (it != cinvmap.end())
return (*it).second; return (*it).second;
else else
...@@ -170,12 +170,12 @@ DynamicAtoms::check_variable(const char *name) const ...@@ -170,12 +170,12 @@ DynamicAtoms::check_variable(const char *name) const
string str; string str;
int ll; int ll;
parse_variable(name, str, 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()) if (it != vars.end())
{ {
const Tlagmap &lmap = (*it).second; const Tlagmap &lmap = (*it).second;
Tlagmap::const_iterator itt = lmap.find(ll); auto itt = lmap.find(ll);
if (itt != lmap.end()) if (itt != lmap.end())
return (*itt).second; return (*itt).second;
} }
...@@ -220,7 +220,7 @@ DynamicAtoms::assign_variable(const char *varname, int ll, int t) ...@@ -220,7 +220,7 @@ DynamicAtoms::assign_variable(const char *varname, int ll, int t)
throw ogu::Exception(__FILE__, __LINE__, throw ogu::Exception(__FILE__, __LINE__,
"Attempt to assign already allocated tree index"); "Attempt to assign already allocated tree index");
Tvarmap::iterator it = vars.find(varname); auto it = vars.find(varname);
if (it != vars.end()) if (it != vars.end())
{ {
Tlagmap &lmap = (*it).second; Tlagmap &lmap = (*it).second;
...@@ -247,11 +247,11 @@ DynamicAtoms::assign_variable(const char *varname, int ll, int t) ...@@ -247,11 +247,11 @@ DynamicAtoms::assign_variable(const char *varname, int ll, int t)
void void
DynamicAtoms::unassign_variable(const char *varname, int ll, int t) 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()) if (it != vars.end())
{ {
Tlagmap &lmap = (*it).second; Tlagmap &lmap = (*it).second;
Tlagmap::iterator itt = lmap.find(ll); auto itt = lmap.find(ll);
if (itt != lmap.end()) if (itt != lmap.end())
{ {
if ((*itt).second == t) if ((*itt).second == t)
...@@ -262,7 +262,7 @@ DynamicAtoms::unassign_variable(const char *varname, int ll, int t) ...@@ -262,7 +262,7 @@ DynamicAtoms::unassign_variable(const char *varname, int ll, int t)
if (lmap.size() == 0) if (lmap.size() == 0)
vars.erase(it); vars.erase(it);
// erase it from the indices // erase it from the indices
Tindexmap::iterator ittt = indices.find(t); auto ittt = indices.find(t);
if (ittt != indices.end()) if (ittt != indices.end())
indices.erase(ittt); indices.erase(ittt);
...@@ -318,7 +318,7 @@ DynamicAtoms::variables() const ...@@ -318,7 +318,7 @@ DynamicAtoms::variables() const
void void
DynamicAtoms::varspan(int t, int &mlead, int &mlag) const DynamicAtoms::varspan(int t, int &mlead, int &mlag) const
{