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
time-shift
Sébastien Villemot 2019-01-09 15:51:19 +01:00
parent 7e003cc591
commit 966a1c2ac0
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
56 changed files with 203 additions and 203 deletions

View File

@ -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" {
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

View File

@ -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;

View File

@ -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());

View File

@ -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);
} }
} }

View File

@ -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()()
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);

View File

@ -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,
{ {
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)
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)

View File

@ -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++)

View File

@ -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);

View File

@ -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,

View File

@ -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);
} }

View File

@ -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()
} }
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)
{ {

View File

@ -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>
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)

View File

@ -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
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;

View File

@ -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)
{ {

View File

@ -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,
// 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
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)
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)
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

View File

@ -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
// 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)
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
{ {
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,
{ {
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;

View File

@ -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';

View File

@ -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()
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
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
{ {
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
{ {
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
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)
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)
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)
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
void void
DynamicAtoms::varspan(int t, int &mlead, int &mlag) const 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) if (indices.end() == it)
{ {
mlead = INT_MIN; mlead = INT_MIN;
@ -331,7 +331,7 @@ DynamicAtoms::varspan(int t, int &mlead, int &mlag) const
void void
DynamicAtoms::varspan(const char *name, int &mlead, int &mlag) const 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) if (vars.end() == it)
{ {
mlead = INT_MIN; mlead = INT_MIN;
@ -339,8 +339,8 @@ DynamicAtoms::varspan(const char *name, int &mlead, int &mlag) const
return; return;
} }
const Tlagmap &lmap = (*it).second; const Tlagmap &lmap = (*it).second;
Tlagmap::const_iterator beg = lmap.begin(); auto beg = lmap.begin();
Tlagmap::const_reverse_iterator end = lmap.rbegin(); auto end = lmap.rbegin();
mlag = (*beg).first; mlag = (*beg).first;
mlead = (*end).first; mlead = (*end).first;
} }
@ -370,11 +370,11 @@ DynamicAtoms::is_named_atom(int t) const
int int
DynamicAtoms::index(const char *name, int ll) const DynamicAtoms::index(const char *name, int ll) const
{ {
Tvarmap::const_iterator it = vars.find(name); auto it = vars.find(name);
if (vars.end() != it) if (vars.end() != it)
{ {
const Tlagmap &lmap = (*it).second; const Tlagmap &lmap = (*it).second;
Tlagmap::const_iterator itt = lmap.find(ll); auto itt = lmap.find(ll);
if (lmap.end() != itt) if (lmap.end() != itt)
return (*itt).second; return (*itt).second;
} }
@ -384,14 +384,14 @@ DynamicAtoms::index(const char *name, int ll) const
bool bool
DynamicAtoms::is_referenced(const char *name) const DynamicAtoms::is_referenced(const char *name) const
{ {
Tvarmap::const_iterator it = vars.find(name); auto it = vars.find(name);
return it != vars.end(); return it != vars.end();
} }
const DynamicAtoms::Tlagmap & const DynamicAtoms::Tlagmap &
DynamicAtoms::lagmap(const char *name) const DynamicAtoms::lagmap(const char *name) const
{ {
Tvarmap::const_iterator it = vars.find(name); auto it = vars.find(name);
if (vars.end() == it) if (vars.end() == it)
throw ogu::Exception(__FILE__, __LINE__, throw ogu::Exception(__FILE__, __LINE__,
std::string("Couldn't find the name ") std::string("Couldn't find the name ")
@ -402,7 +402,7 @@ DynamicAtoms::lagmap(const char *name) const
const char * const char *
DynamicAtoms::name(int t) const DynamicAtoms::name(int t) const
{ {
Tindexmap::const_iterator it = indices.find(t); auto it = indices.find(t);
if (indices.end() == it) if (indices.end() == it)
throw ogu::Exception(__FILE__, __LINE__, throw ogu::Exception(__FILE__, __LINE__,
"Couldn't find tree index in DynamicAtoms::name"); "Couldn't find tree index in DynamicAtoms::name");
@ -414,7 +414,7 @@ DynamicAtoms::lead(int t) const
{ {
const char *nam = name(t); const char *nam = name(t);
const Tlagmap &lmap = lagmap(nam); const Tlagmap &lmap = lagmap(nam);
Tlagmap::const_iterator it = lmap.begin(); auto it = lmap.begin();
while (it != lmap.end() && (*it).second != t) while (it != lmap.end() && (*it).second != t)
++it; ++it;
if (lmap.end() == it) if (lmap.end() == it)
@ -462,14 +462,14 @@ VarOrdering::VarOrdering(const VarOrdering &vo, const vector<const char *> &vnam
bool bool
VarOrdering::check(int t) const VarOrdering::check(int t) const
{ {
map<int, int>::const_iterator it = positions.find(t); auto it = positions.find(t);
return it != positions.end(); return it != positions.end();
} }
int int
VarOrdering::get_pos_of(int t) const VarOrdering::get_pos_of(int t) const
{ {
map<int, int>::const_iterator it = positions.find(t); auto it = positions.find(t);
if (it != positions.end()) if (it != positions.end())
{ {
return (*it).second; return (*it).second;

View File

@ -29,7 +29,7 @@ AllvarOuterOrdering::AllvarOuterOrdering(const vector<const char *> &allvar_oute
// fill in endo2all and exo2all // fill in endo2all and exo2all
for (unsigned int i = 0; i < allvar.size(); i++) 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()) if (it != atoms.endo_outer_map.end())
endo2all[(*it).second] = i; endo2all[(*it).second] = i;
else else
@ -387,7 +387,7 @@ FineAtoms::get_exo_atoms_map() const
int int
FineAtoms::name2outer_param(const char *name) const 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()) if (it == param_outer_map.end())
throw ogu::Exception(__FILE__, __LINE__, throw ogu::Exception(__FILE__, __LINE__,
"Name is not a parameter in FineAtoms::name2outer_param"); "Name is not a parameter in FineAtoms::name2outer_param");
@ -397,7 +397,7 @@ FineAtoms::name2outer_param(const char *name) const
int int
FineAtoms::name2outer_endo(const char *name) const 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()) if (it == endo_outer_map.end())
throw ogu::Exception(__FILE__, __LINE__, throw ogu::Exception(__FILE__, __LINE__,
"Name is not an endogenous variable in FineAtoms::name2outer_endo"); "Name is not an endogenous variable in FineAtoms::name2outer_endo");
@ -407,7 +407,7 @@ FineAtoms::name2outer_endo(const char *name) const
int int
FineAtoms::name2outer_exo(const char *name) const 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()) if (it == exo_outer_map.end())
throw ogu::Exception(__FILE__, __LINE__, throw ogu::Exception(__FILE__, __LINE__,
"Name is not an exogenous variable in FineAtoms::name2outer_exo"); "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__, throw ogu::Exception(__FILE__, __LINE__,
"FineAtoms::name2outer_allvar called beore parsing_finished"); "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()) if (it != endo_outer_map.end())
return allvar_order->get_endo2all()[(*it).second]; return allvar_order->get_endo2all()[(*it).second];
else else

View File

@ -133,7 +133,7 @@ extern location_type fmla_lloc;
void void
FormulaParser::parse(int length, const char *stream) FormulaParser::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';
@ -273,7 +273,7 @@ FormulaDerivatives::derivative(const FoldMultiIndex &mi) const
throw ogu::Exception(__FILE__, __LINE__, throw ogu::Exception(__FILE__, __LINE__,
"Wrong multi-index variables in FormulaDerivatives::derivative"); "Wrong multi-index variables in FormulaDerivatives::derivative");
Tfmiintmap::const_iterator it = ind2der.find(mi); auto it = ind2der.find(mi);
if (it == ind2der.end()) if (it == ind2der.end())
return OperationTree::zero; return OperationTree::zero;
else else
@ -428,7 +428,7 @@ int
FoldMultiIndex::offset() const FoldMultiIndex::offset() const
{ {
// make copy for the recursions // make copy for the recursions
int *tmp = new int[ord]; auto *tmp = new int[ord];
for (int i = 0; i < ord; i++) for (int i = 0; i < ord; i++)
tmp[i] = data[i]; tmp[i] = data[i];
// call the recursive algorithm // call the recursive algorithm
@ -499,11 +499,11 @@ FormulaDerEvaluator::eval(const AtomValues &av, FormulaDerEvalLoader &loader, in
etree.reset_all(); etree.reset_all();
av.setValues(etree); av.setValues(etree);
int *vars = new int[order]; auto *vars = new int[order];
for (unsigned int i = 0; i < ders.size(); i++) 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) it != ders[i]->ind2der.end(); ++it)
{ {
const FoldMultiIndex &mi = (*it).first; const FoldMultiIndex &mi = (*it).first;
@ -532,7 +532,7 @@ FormulaDerEvaluator::eval(const vector<int> &mp, const AtomValues &av,
int nvar_glob = der_atoms.size(); int nvar_glob = der_atoms.size();
int nvar = mp.size(); int nvar = mp.size();
int *vars = new int[order]; auto *vars = new int[order];
for (unsigned int i = 0; i < ders.size(); i++) for (unsigned int i = 0; i < ders.size(); i++)
{ {

View File

@ -29,7 +29,7 @@ MatrixParser::parse(int length, const char *stream)
row_lengths.clear(); row_lengths.clear();
nc = 0; nc = 0;
// allocate temporary buffer and parse // allocate temporary buffer and parse
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';

View File

@ -19,7 +19,7 @@ void namelist_parse();
void void
NameListParser::namelist_parse(int length, const char *stream) NameListParser::namelist_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';

View File

@ -72,7 +72,7 @@ StaticAtoms::check(const char *name) const
int int
StaticAtoms::index(const char *name) const StaticAtoms::index(const char *name) const
{ {
Tvarmap::const_iterator it = vars.find(name); auto it = vars.find(name);
if (it == vars.end()) if (it == vars.end())
return -1; return -1;
else else
@ -82,7 +82,7 @@ StaticAtoms::index(const char *name) const
const char * const char *
StaticAtoms::inv_index(int t) const StaticAtoms::inv_index(int t) const
{ {
Tinvmap::const_iterator it = indices.find(t); auto it = indices.find(t);
if (it == indices.end()) if (it == indices.end())
return NULL; return NULL;
else else

View File

@ -135,7 +135,7 @@ StaticFineAtoms::parsing_finished()
int int
StaticFineAtoms::name2outer_param(const char *name) const 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()) if (it == param_outer_map.end())
throw ogu::Exception(__FILE__, __LINE__, throw ogu::Exception(__FILE__, __LINE__,
"Name is not a parameter in StaticFineAtoms::name2outer_param"); "Name is not a parameter in StaticFineAtoms::name2outer_param");
@ -145,7 +145,7 @@ StaticFineAtoms::name2outer_param(const char *name) const
int int
StaticFineAtoms::name2outer_endo(const char *name) const 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()) if (it == endo_outer_map.end())
throw ogu::Exception(__FILE__, __LINE__, throw ogu::Exception(__FILE__, __LINE__,
"Name is not an endogenous variable in StaticFineAtoms::name2outer_endo"); "Name is not an endogenous variable in StaticFineAtoms::name2outer_endo");
@ -155,7 +155,7 @@ StaticFineAtoms::name2outer_endo(const char *name) const
int int
StaticFineAtoms::name2outer_exo(const char *name) const 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()) if (it == exo_outer_map.end())
throw ogu::Exception(__FILE__, __LINE__, throw ogu::Exception(__FILE__, __LINE__,
"Name is not an exogenous variable in StaticFineAtoms::name2outer_exo"); "Name is not an exogenous variable in StaticFineAtoms::name2outer_exo");

View File

@ -54,7 +54,7 @@ OperationTree::add_unary(code_t code, int op)
return one; return one;
Operation unary(code, op); Operation unary(code, op);
_Topmap::const_iterator i = ((const _Topmap &) opmap).find(unary); auto i = ((const _Topmap &) opmap).find(unary);
if (i == opmap.end()) if (i == opmap.end())
{ {
int newop = terms.size(); int newop = terms.size();
@ -144,7 +144,7 @@ OperationTree::add_binary(code_t code, int op1, int op2)
// construct operation and check/add it // construct operation and check/add it
Operation binary(code, op1, op2); 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()) if (i == opmap.end())
{ {
int newop = terms.size(); int newop = terms.size();
@ -334,7 +334,7 @@ OperationTree::add_substitution(int t, const map<int, int> &subst,
const OperationTree &otree) const OperationTree &otree)
{ {
// return substitution of t if it is in the map // return substitution of t if it is in the map
map<int, int>::const_iterator it = subst.find(t); auto it = subst.find(t);
if (subst.end() != it) if (subst.end() != it)
return (*it).second; return (*it).second;
@ -374,7 +374,7 @@ void
OperationTree::nularify(int t) OperationTree::nularify(int t)
{ {
// remove the original operation from opmap // remove the original operation from opmap
_Topmap::iterator it = opmap.find(terms[t]); auto it = opmap.find(terms[t]);
if (it != opmap.end()) if (it != opmap.end())
opmap.erase(it); opmap.erase(it);
// turn the operation to nulary // turn the operation to nulary

View File

@ -333,7 +333,7 @@ DynareDerEvalLoader::DynareDerEvalLoader(const ogp::FineAtoms &a,
md.clear(); md.clear();
for (int iord = 1; iord <= order; iord++) 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); md.insert(t);
} }
} }

View File

@ -26,7 +26,7 @@ DynareStaticAtoms::check_variable(const char *name) const
{ {
if (0 == varnames.query(name)) if (0 == varnames.query(name))
throw ogp::ParserException(std::string("Unknown name <")+name+">", 0); 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()) if (it == vars.end())
return -1; return -1;
else else
@ -88,7 +88,7 @@ DynareDynamicAtoms::register_uniq_param(const char *name)
bool bool
DynareDynamicAtoms::is_type(const char *name, atype tp) const 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) if (it != atom_type.end() && (*it).second == tp)
return true; return true;
else else

View File

@ -593,7 +593,7 @@ extern ogp::location_type dynglob_lloc;
void void
DynareParser::parse_glob(int length, const char *stream) DynareParser::parse_glob(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';
@ -607,7 +607,7 @@ DynareParser::parse_glob(int length, const char *stream)
int int
DynareParser::parse_order(int len, const char *str) DynareParser::parse_order(int len, const char *str)
{ {
char *buf = new char[len+1]; auto *buf = new char[len+1];
strncpy(buf, str, len); strncpy(buf, str, len);
buf[len] = '\0'; buf[len] = '\0';
int res; int res;
@ -619,7 +619,7 @@ DynareParser::parse_order(int len, const char *str)
int int
DynareParser::parse_pldiscount(int len, const char *str) DynareParser::parse_pldiscount(int len, const char *str)
{ {
char *buf = new char[len+1]; auto *buf = new char[len+1];
strncpy(buf, str, len); strncpy(buf, str, len);
buf[len] = '\0'; buf[len] = '\0';
if (!atoms.is_type(buf, DynareDynamicAtoms::param)) if (!atoms.is_type(buf, DynareDynamicAtoms::param))

View File

@ -453,7 +453,7 @@ ConstGeneralMatrix::multInvLeft(const char *trans, int mrows, int mcols, int mld
if (rows > 0) if (rows > 0)
{ {
GeneralMatrix inv(*this); GeneralMatrix inv(*this);
lapack_int *ipiv = new lapack_int[rows]; auto *ipiv = new lapack_int[rows];
lapack_int info; lapack_int info;
lapack_int rows2 = rows, mcols2 = mcols, mld2 = mld; lapack_int rows2 = rows, mcols2 = mcols, mld2 = mld;
dgetrf(&rows2, &rows2, inv.getData().base(), &rows2, ipiv, &info); dgetrf(&rows2, &rows2, inv.getData().base(), &rows2, ipiv, &info);
@ -564,7 +564,7 @@ SVDDecomp::construct(const GeneralMatrix &A)
lapack_int lwork = -1; lapack_int lwork = -1;
lapack_int info; lapack_int info;
lapack_int *iwork = new lapack_int[8*minmn]; auto *iwork = new lapack_int[8*minmn];
// query for optimal lwork // query for optimal lwork
dgesdd("A", &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, &tmpwork, dgesdd("A", &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, &tmpwork,
&lwork, iwork, &info); &lwork, iwork, &info);

View File

@ -478,7 +478,7 @@ QuasiTriangular::QuasiTriangular(const SchurDecompZero &decomp)
} }
} }
// construct diagonal // construct diagonal
Diagonal *const d = new Diagonal(getData().base(), decomp.getDim()); auto *const d = new Diagonal(getData().base(), decomp.getDim());
diagonal = *d; diagonal = *d;
delete d; delete d;
} }

View File

@ -13,10 +13,10 @@ SchurDecomp::SchurDecomp(const SqSylvMatrix &m)
q = new SqSylvMatrix(rows); q = new SqSylvMatrix(rows);
SqSylvMatrix auxt(m); SqSylvMatrix auxt(m);
lapack_int sdim; lapack_int sdim;
double *const wr = new double[rows]; auto *const wr = new double[rows];
double *const wi = new double[rows]; auto *const wi = new double[rows];
lapack_int lwork = 6*rows; lapack_int lwork = 6*rows;
double *const work = new double[lwork]; auto *const work = new double[lwork];
lapack_int info; lapack_int info;
dgees("V", "N", 0, &rows, auxt.base(), &rows, &sdim, dgees("V", "N", 0, &rows, auxt.base(), &rows, &sdim,
wr, wi, q->base(), &rows, wr, wi, q->base(), &rows,

View File

@ -55,7 +55,7 @@ SchurDecompEig::tryToSwap(diag_iter &it, diag_iter &itadd)
lapack_int n = getDim(); lapack_int n = getDim();
lapack_int ifst = (*it).getIndex() + 1; lapack_int ifst = (*it).getIndex() + 1;
lapack_int ilst = (*itadd).getIndex() + 1; lapack_int ilst = (*itadd).getIndex() + 1;
double *work = new double[n]; auto *work = new double[n];
lapack_int info; lapack_int info;
dtrexc("V", &n, getT().base(), &n, getQ().base(), &n, &ifst, &ilst, work, dtrexc("V", &n, getT().base(), &n, getQ().base(), &n, &ifst, &ilst, work,
&info); &info);

View File

@ -242,7 +242,7 @@ SqSylvMatrix::multInvLeft2(GeneralMatrix &a, GeneralMatrix &b,
} }
// PLU factorization // PLU factorization
Vector inv(data); Vector inv(data);
lapack_int *const ipiv = new lapack_int[rows]; auto *const ipiv = new lapack_int[rows];
lapack_int info; lapack_int info;
lapack_int rows2 = rows; lapack_int rows2 = rows;
dgetrf(&rows2, &rows2, inv.base(), &rows2, ipiv, &info); dgetrf(&rows2, &rows2, inv.base(), &rows2, ipiv, &info);
@ -259,8 +259,8 @@ SqSylvMatrix::multInvLeft2(GeneralMatrix &a, GeneralMatrix &b,
delete [] ipiv; delete [] ipiv;
// condition numbers // condition numbers
double *const work = new double[4*rows]; auto *const work = new double[4*rows];
lapack_int *const iwork = new lapack_int[rows]; auto *const iwork = new lapack_int[rows];
double norm1 = getNorm1(); double norm1 = getNorm1();
dgecon("1", &rows2, inv.base(), &rows2, &norm1, &rcond1, dgecon("1", &rows2, inv.base(), &rows2, &norm1, &rcond1,
work, iwork, &info); work, iwork, &info);

View File

@ -49,8 +49,8 @@ SymSchurDecomp::SymSchurDecomp(const GeneralMatrix &mata)
lwork = (int) tmpwork; lwork = (int) tmpwork;
liwork = tmpiwork; liwork = tmpiwork;
// allocate work arrays // allocate work arrays
double *work = new double[lwork]; auto *work = new double[lwork];
lapack_int *iwork = new lapack_int[liwork]; auto *iwork = new lapack_int[liwork];
// do the calculation // do the calculation
dsyevr(jobz, range, uplo, &n, a, &lda, vl, vu, il, iu, &abstol, dsyevr(jobz, range, uplo, &n, a, &lda, vl, vu, il, iu, &abstol,

View File

@ -35,7 +35,7 @@ extern "C" {
if (nhrs != 5 || nlhs > 3 || nlhs < 2) 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."); 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 A = prhs[1];
const mxArray *const B = prhs[2]; const mxArray *const B = prhs[2];
const mxArray *const C = prhs[3]; const mxArray *const C = prhs[3];

View File

@ -46,7 +46,7 @@ OrdSequence::operator==(const OrdSequence &s) const
void void
OrdSequence::add(int i) OrdSequence::add(int i)
{ {
vector<int>::iterator vit = data.begin(); auto vit = data.begin();
while (vit != data.end() && *vit < i) while (vit != data.end() && *vit < i)
++vit; ++vit;
if (vit != data.end() && *vit == i) if (vit != data.end() && *vit == i)
@ -57,7 +57,7 @@ OrdSequence::add(int i)
void void
OrdSequence::add(const OrdSequence &s) OrdSequence::add(const OrdSequence &s)
{ {
vector<int>::const_iterator vit = s.data.begin(); auto vit = s.data.begin();
while (vit != s.data.end()) while (vit != s.data.end())
{ {
add(*vit); add(*vit);
@ -69,7 +69,7 @@ OrdSequence::add(const OrdSequence &s)
bool bool
OrdSequence::has(int i) const OrdSequence::has(int i) const
{ {
vector<int>::const_iterator vit = data.begin(); auto vit = data.begin();
while (vit != data.end()) while (vit != data.end())
{ {
if (*vit == i) if (*vit == i)
@ -133,8 +133,8 @@ Equivalence::Equivalence(const Equivalence &e, int i1, int i2)
: n(e.n), : n(e.n),
classes(e.classes) classes(e.classes)
{ {
seqit s1 = find(i1); auto s1 = find(i1);
seqit s2 = find(i2); auto s2 = find(i2);
if (s1 != s2) if (s1 != s2)
{ {
OrdSequence ns(*s1); OrdSequence ns(*s1);
@ -171,7 +171,7 @@ Equivalence::operator==(const Equivalence &e) const
Equivalence::const_seqit Equivalence::const_seqit
Equivalence::findHaving(int i) const Equivalence::findHaving(int i) const
{ {
const_seqit si = classes.begin(); auto si = classes.begin();
while (si != classes.end()) while (si != classes.end())
{ {
if ((*si).has(i)) if ((*si).has(i))
@ -186,7 +186,7 @@ Equivalence::findHaving(int i) const
Equivalence::seqit Equivalence::seqit
Equivalence::findHaving(int i) Equivalence::findHaving(int i)
{ {
seqit si = classes.begin(); auto si = classes.begin();
while (si != classes.end()) while (si != classes.end())
{ {
if ((*si).has(i)) if ((*si).has(i))
@ -203,7 +203,7 @@ Equivalence::findHaving(int i)
Equivalence::const_seqit Equivalence::const_seqit
Equivalence::find(int j) const Equivalence::find(int j) const
{ {
const_seqit si = classes.begin(); auto si = classes.begin();
int i = 0; int i = 0;
while (si != classes.end() && i < j) while (si != classes.end() && i < j)
{ {
@ -218,7 +218,7 @@ Equivalence::find(int j) const
Equivalence::seqit Equivalence::seqit
Equivalence::find(int j) Equivalence::find(int j)
{ {
seqit si = classes.begin(); auto si = classes.begin();
int i = 0; int i = 0;
while (si != classes.end() && i < j) while (si != classes.end() && i < j)
{ {
@ -234,7 +234,7 @@ Equivalence::find(int j)
void void
Equivalence::insert(const OrdSequence &s) Equivalence::insert(const OrdSequence &s)
{ {
seqit si = classes.begin(); auto si = classes.begin();
while (si != classes.end() && *si < s) while (si != classes.end() && *si < s)
++si; ++si;
classes.insert(si, s); classes.insert(si, s);
@ -251,7 +251,7 @@ Equivalence::trace(IntSequence &out, int num) const
{ {
int i = 0; int i = 0;
int nc = 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++) for (int j = 0; j < (*it).length(); j++, i++)
{ {
TL_RAISE_IF(i >= out.size(), TL_RAISE_IF(i >= out.size(),
@ -270,7 +270,7 @@ Equivalence::trace(IntSequence &out, const Permutation &per) const
int i = 0; int i = 0;
for (int iclass = 0; iclass < numClasses(); iclass++) 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++) for (int j = 0; j < (*itper).length(); j++, i++)
out[i] = (*itper)[j]; out[i] = (*itper)[j];
} }
@ -281,7 +281,7 @@ void
Equivalence::print(const char *prefix) const Equivalence::print(const char *prefix) const
{ {
int i = 0; int i = 0;
for (const_seqit it = classes.begin(); for (auto it = classes.begin();
it != classes.end(); it != classes.end();
++it, i++) ++it, i++)
{ {
@ -343,7 +343,7 @@ EquivalenceSet::EquivalenceSet(int num)
bool bool
EquivalenceSet::has(const Equivalence &e) const EquivalenceSet::has(const Equivalence &e) const
{ {
list<Equivalence>::const_reverse_iterator rit = equis.rbegin(); auto rit = equis.rbegin();
while (rit != equis.rend() && *rit != e) while (rit != equis.rend() && *rit != e)
++rit; ++rit;
if (rit != equis.rend()) if (rit != equis.rend())
@ -385,7 +385,7 @@ EquivalenceSet::print(const char *prefix) const
strcpy(tmp, prefix); strcpy(tmp, prefix);
strcat(tmp, " "); strcat(tmp, " ");
int i = 0; int i = 0;
for (list<Equivalence>::const_iterator it = equis.begin(); for (auto it = equis.begin();
it != equis.end(); it != equis.end();
++it, i++) ++it, i++)
{ {

View File

@ -184,9 +184,9 @@ FGSTensor::FGSTensor(const FSSparseTensor &t, const IntSequence &ss,
} }
zeros(); zeros();
FSSparseTensor::const_iterator lbi = t.getMap().lower_bound(lb); auto lbi = t.getMap().lower_bound(lb);
FSSparseTensor::const_iterator ubi = t.getMap().upper_bound(ub); auto ubi = t.getMap().upper_bound(ub);
for (FSSparseTensor::const_iterator run = lbi; run != ubi; ++run) for (auto run = lbi; run != ubi; ++run)
{ {
if (lb.lessEq((*run).first) && (*run).first.lessEq(ub)) if (lb.lessEq((*run).first) && (*run).first.lessEq(ub))
{ {

View File

@ -306,7 +306,7 @@ KronProdAll::mult(const ConstTwoDMatrix &in, TwoDMatrix &out) const
{ {
KronProdIAI interkron(*this, i); KronProdIAI interkron(*this, i);
c = interkron.kpd.ncols(); c = interkron.kpd.ncols();
TwoDMatrix *newlast = new TwoDMatrix(in.nrows(), c); auto *newlast = new TwoDMatrix(in.nrows(), c);
interkron.mult(*last, *newlast); interkron.mult(*last, *newlast);
delete last; delete last;
last = newlast; last = newlast;
@ -355,7 +355,7 @@ KronProdAll::multRows(const IntSequence &irows) const
row = new ConstVector(irows[j], *(matlist[j])); row = new ConstVector(irows[j], *(matlist[j]));
else else
{ {
Vector *aux = new Vector(ncols(j)); auto *aux = new Vector(ncols(j));
aux->zeros(); aux->zeros();
(*aux)[irows[j]] = 1.0; (*aux)[irows[j]] = 1.0;
to_delete.push_back(aux); to_delete.push_back(aux);

View File

@ -27,20 +27,20 @@ UNormalMoments::generateMoments(int maxdim, const TwoDMatrix &v)
"Variance-covariance matrix is not square in UNormalMoments constructor"); "Variance-covariance matrix is not square in UNormalMoments constructor");
int nv = v.nrows(); int nv = v.nrows();
URSingleTensor *mom2 = new URSingleTensor(nv, 2); auto *mom2 = new URSingleTensor(nv, 2);
mom2->getData() = v.getData(); mom2->getData() = v.getData();
insert(mom2); insert(mom2);
URSingleTensor *kronv = new URSingleTensor(nv, 2); auto *kronv = new URSingleTensor(nv, 2);
kronv->getData() = v.getData(); kronv->getData() = v.getData();
for (int d = 4; d <= maxdim; d += 2) 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()), KronProd::kronMult(ConstVector(v.getData()),
ConstVector(kronv->getData()), ConstVector(kronv->getData()),
newkronv->getData()); newkronv->getData());
delete kronv; delete kronv;
kronv = newkronv; kronv = newkronv;
URSingleTensor *mom = new URSingleTensor(nv, d); auto *mom = new URSingleTensor(nv, d);
// apply $F_n$ to |kronv| // apply $F_n$ to |kronv|
/* Here we go through all equivalences, select only those having 2 /* Here we go through all equivalences, select only those having 2
elements in each class, then go through all elements in |kronv| and 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) for (const auto & mom : moms)
{ {
FRSingleTensor *fm = new FRSingleTensor(*(mom.second)); auto *fm = new FRSingleTensor(*(mom.second));
insert(fm); insert(fm);
} }
} }

View File

@ -62,7 +62,7 @@ FTensor &
UPSTensor::fold() const UPSTensor::fold() const
{ {
TL_RAISE("Never should come to this place in UPSTensor::fold"); 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; return *nothing;
} }
@ -171,11 +171,11 @@ UPSTensor::fillFromSparseOne(const FSSparseTensor &t, const IntSequence &ss,
IntSequence c(run.getCoor()); IntSequence c(run.getCoor());
c.add(1, cum); c.add(1, cum);
c.sort(); c.sort();
FSSparseTensor::const_iterator sl = t.getMap().lower_bound(c); auto sl = t.getMap().lower_bound(c);
if (sl != t.getMap().end()) if (sl != t.getMap().end())
{ {
FSSparseTensor::const_iterator su = t.getMap().upper_bound(c); auto su = t.getMap().upper_bound(c);
for (FSSparseTensor::const_iterator srun = sl; srun != su; ++srun) for (auto srun = sl; srun != su; ++srun)
get((*srun).second.first, *run) = (*srun).second.second; get((*srun).second.first, *run) = (*srun).second.second;
} }
} }
@ -219,9 +219,9 @@ UPSTensor::fillFromSparseTwo(const FSSparseTensor &t, const IntSequence &ss,
Permutation unsort(coor); Permutation unsort(coor);
zeros(); zeros();
FSSparseTensor::const_iterator lbi = t.getMap().lower_bound(lb_srt); auto lbi = t.getMap().lower_bound(lb_srt);
FSSparseTensor::const_iterator ubi = t.getMap().upper_bound(ub_srt); auto ubi = t.getMap().upper_bound(ub_srt);
for (FSSparseTensor::const_iterator run = lbi; run != ubi; ++run) for (auto run = lbi; run != ubi; ++run)
{ {
if (lb_srt.lessEq((*run).first) && (*run).first.lessEq(ub_srt)) if (lb_srt.lessEq((*run).first) && (*run).first.lessEq(ub_srt))
{ {
@ -320,7 +320,7 @@ UTensor &
FPSTensor::unfold() const FPSTensor::unfold() const
{ {
TL_RAISE("Unfolding of FPSTensor not implemented"); TL_RAISE("Unfolding of FPSTensor not implemented");
UFSTensor *nothing = new UFSTensor(0, 0, 0); auto *nothing = new UFSTensor(0, 0, 0);
return *nothing; return *nothing;
} }
@ -383,12 +383,12 @@ FPSTensor::FPSTensor(const TensorDimens &td, const Equivalence &e, const Permuta
{ {
Tensor::index fold_ind = dummy.getFirstIndexOf(run); Tensor::index fold_ind = dummy.getFirstIndexOf(run);
const IntSequence &c = fold_ind.getCoor(); 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()) if (sl != a.getMap().end())
{ {
Vector *row_prod = kp.multRows(run.getCoor()); Vector *row_prod = kp.multRows(run.getCoor());
GSSparseTensor::const_iterator su = a.getMap().upper_bound(c); auto su = a.getMap().upper_bound(c);
for (GSSparseTensor::const_iterator srun = sl; srun != su; ++srun) for (auto srun = sl; srun != su; ++srun)
{ {
Vector out_row((*srun).second.first, *this); Vector out_row((*srun).second.first, *this);
out_row.add((*srun).second.second, *row_prod); out_row.add((*srun).second.second, *row_prod);

View File

@ -89,10 +89,10 @@ IrregTensor::IrregTensor(const IrregTensorHeader &h)
return; 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--) 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])), KronProd::kronMult(ConstVector(*(header.cols[i])),
ConstVector(*last), *newlast); ConstVector(*last), *newlast);
delete last; delete last;

View File

@ -124,10 +124,10 @@ URSingleTensor::URSingleTensor(const vector<ConstVector> &cols)
return; 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--) 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); KronProd::kronMult(cols[i], ConstVector(*last), *newlast);
delete last; delete last;
last = newlast; last = newlast;
@ -148,10 +148,10 @@ URSingleTensor::URSingleTensor(const ConstVector &v, int d)
return; return;
} }
Vector *last = new Vector(v); auto *last = new Vector(v);
for (int i = d-2; i > 0; i--) 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); KronProd::kronMult(v, ConstVector(*last), *newlast);
delete last; delete last;
last = newlast; last = newlast;

View File

@ -19,11 +19,11 @@ SparseTensor::insert(const IntSequence &key, int r, double c)
TL_RAISE_IF(!std::isfinite(c), TL_RAISE_IF(!std::isfinite(c),
"Insertion of non-finite value in SparseTensor::insert"); "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 // check that pair |key| and |r| is unique
iterator last_pos = m.upper_bound(key); auto last_pos = m.upper_bound(key);
for (iterator it = first_pos; it != last_pos; ++it) for (auto it = first_pos; it != last_pos; ++it)
if ((*it).second.first == r) if ((*it).second.first == r)
{ {
TL_RAISE("Duplicate <key, r> insertion in SparseTensor::insert"); TL_RAISE("Duplicate <key, r> insertion in SparseTensor::insert");
@ -43,7 +43,7 @@ bool
SparseTensor::isFinite() const SparseTensor::isFinite() const
{ {
bool res = true; bool res = true;
const_iterator run = m.begin(); auto run = m.begin();
while (res && run != m.end()) while (res && run != m.end())
{ {
if (!std::isfinite((*run).second.second)) if (!std::isfinite((*run).second.second))
@ -60,7 +60,7 @@ double
SparseTensor::getFoldIndexFillFactor() const SparseTensor::getFoldIndexFillFactor() const
{ {
int cnt = 0; int cnt = 0;
const_iterator start_col = m.begin(); auto start_col = m.begin();
while (start_col != m.end()) while (start_col != m.end())
{ {
cnt++; cnt++;
@ -78,7 +78,7 @@ double
SparseTensor::getUnfoldIndexFillFactor() const SparseTensor::getUnfoldIndexFillFactor() const
{ {
int cnt = 0; int cnt = 0;
const_iterator start_col = m.begin(); auto start_col = m.begin();
while (start_col != m.end()) while (start_col != m.end())
{ {
const IntSequence &key = (*start_col).first; const IntSequence &key = (*start_col).first;
@ -96,14 +96,14 @@ void
SparseTensor::print() const SparseTensor::print() const
{ {
printf("Fill: %3.2f %%\n", 100*getFillFactor()); printf("Fill: %3.2f %%\n", 100*getFillFactor());
const_iterator start_col = m.begin(); auto start_col = m.begin();
while (start_col != m.end()) while (start_col != m.end())
{ {
const IntSequence &key = (*start_col).first; const IntSequence &key = (*start_col).first;
printf("Column: "); key.print(); printf("Column: "); key.print();
const_iterator end_col = m.upper_bound(key); auto end_col = m.upper_bound(key);
int cnt = 1; 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) if ((cnt/7)*7 == cnt)
printf("\n"); 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, TL_RAISE_IF(key[0] < 0 || key[key.size()-1] >= nv,
"Wrong coordinates of index in FSSparseTensor::multColumnAndAdd"); "Wrong coordinates of index in FSSparseTensor::multColumnAndAdd");
const_iterator first_pos = m.lower_bound(key); auto first_pos = m.lower_bound(key);
const_iterator last_pos = m.upper_bound(key); auto last_pos = m.upper_bound(key);
for (const_iterator cit = first_pos; cit != last_pos; ++cit) for (auto cit = first_pos; cit != last_pos; ++cit)
{ {
int r = (*cit).second.first; int r = (*cit).second.first;
double c = (*cit).second.second; 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; ub[i] = s_offsets[coor[i]] + ss[coor[i]] - 1;
} }
FSSparseTensor::const_iterator lbi = t.getMap().lower_bound(lb); auto lbi = t.getMap().lower_bound(lb);
FSSparseTensor::const_iterator ubi = t.getMap().upper_bound(ub); auto ubi = t.getMap().upper_bound(ub);
for (FSSparseTensor::const_iterator run = lbi; run != ubi; ++run) for (auto run = lbi; run != ubi; ++run)
{ {
if (lb.lessEq((*run).first) && (*run).first.lessEq(ub)) if (lb.lessEq((*run).first) && (*run).first.lessEq(ub))
{ {

View File

@ -243,7 +243,7 @@ public:
len++; len++;
} }
Vector *res = new Vector(len); auto *res = new Vector(len);
i = 0; i = 0;
while (i < numStacks() && getType(i, s) == _Stype::matrix) while (i < numStacks() && getType(i, s) == _Stype::matrix)
{ {

View File

@ -117,7 +117,7 @@ namespace sthread
void * void *
posix_thread_function(void *c) posix_thread_function(void *c)
{ {
thread_traits<posix>::_Ctype *ct auto *ct
= (thread_traits<posix>::_Ctype *)c; = (thread_traits<posix>::_Ctype *)c;
try try
{ {
@ -133,7 +133,7 @@ namespace sthread
void * void *
posix_detach_thread_function(void *c) posix_detach_thread_function(void *c)
{ {
thread_traits<posix>::_Dtype *ct auto *ct
= (thread_traits<posix>::_Dtype *)c; = (thread_traits<posix>::_Dtype *)c;
condition_counter<posix> *counter = ct->counter; condition_counter<posix> *counter = ct->counter;
try try

View File

@ -301,7 +301,7 @@ namespace sthread
mmval * mmval *
get(const void *c, const char *id) 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()) if (it == _Tparent::end())
return NULL; return NULL;
return &((*it).second); return &((*it).second);
@ -314,7 +314,7 @@ namespace sthread
void void
remove(const void *c, const char *id) 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()) if (it != _Tparent::end())
this->erase(it); this->erase(it);
} }
@ -563,7 +563,7 @@ namespace sthread
run() run()
{ {
int mpt = max_parallel_threads; int mpt = max_parallel_threads;
iterator it = tlist.begin(); auto it = tlist.begin();
while (it != tlist.end()) while (it != tlist.end())
{ {
if (counter.waitForChange() < mpt) if (counter.waitForChange() < mpt)

View File

@ -128,7 +128,7 @@ InducedSymmetries::InducedSymmetries(const Equivalence &e, const Permutation &p,
{ {
for (int i = 0; i < e.numClasses(); i++) 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)); push_back(Symmetry(s, *it));
} }
} }

View File

@ -13,7 +13,7 @@ UGSContainer::UGSContainer(const FGSContainer &c)
{ {
for (const auto & it : c) for (const auto & it : c)
{ {
UGSTensor *unfolded = new UGSTensor(*(it.second)); auto *unfolded = new UGSTensor(*(it.second));
insert(unfolded); insert(unfolded);
} }
} }
@ -59,7 +59,7 @@ FGSContainer::FGSContainer(const UGSContainer &c)
{ {
for (const auto & it : c) for (const auto & it : c)
{ {
FGSTensor *folded = new FGSTensor(*(it.second)); auto *folded = new FGSTensor(*(it.second));
insert(folded); insert(folded);
} }
} }

View File

@ -115,9 +115,9 @@ public:
TensorContainer(const TensorContainer<_Ttype> &c) TensorContainer(const TensorContainer<_Ttype> &c)
: n(c.n), m(), ebundle(c.ebundle) : 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); insert(ten);
} }
} }
@ -128,9 +128,9 @@ public:
TensorContainer(int first_row, int num, TensorContainer<_Ttype> &c) TensorContainer(int first_row, int num, TensorContainer<_Ttype> &c)
: n(c.n), ebundle(*(tls.ebundle)) : 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); insert(t);
} }
} }
@ -140,7 +140,7 @@ public:
{ {
TL_RAISE_IF(s.num() != num(), TL_RAISE_IF(s.num() != num(),
"Incompatible symmetry lookup in TensorContainer::get"); "Incompatible symmetry lookup in TensorContainer::get");
const_iterator it = m.find(s); auto it = m.find(s);
if (it == m.end()) if (it == m.end())
{ {
TL_RAISE("Symmetry not found in TensorContainer::get"); TL_RAISE("Symmetry not found in TensorContainer::get");
@ -157,7 +157,7 @@ public:
{ {
TL_RAISE_IF(s.num() != num(), TL_RAISE_IF(s.num() != num(),
"Incompatible symmetry lookup in TensorContainer::get"); "Incompatible symmetry lookup in TensorContainer::get");
iterator it = m.find(s); auto it = m.find(s);
if (it == m.end()) if (it == m.end())
{ {
TL_RAISE("Symmetry not found in TensorContainer::get"); TL_RAISE("Symmetry not found in TensorContainer::get");
@ -174,7 +174,7 @@ public:
{ {
TL_RAISE_IF(s.num() != num(), TL_RAISE_IF(s.num() != num(),
"Incompatible symmetry lookup in TensorContainer::check"); "Incompatible symmetry lookup in TensorContainer::check");
const_iterator it = m.find(s); auto it = m.find(s);
return it != m.end(); return it != m.end();
} }
@ -195,7 +195,7 @@ public:
void void
remove(const Symmetry &s) remove(const Symmetry &s)
{ {
iterator it = m.find(s); auto it = m.find(s);
if (it != m.end()) if (it != m.end())
{ {
_ptr t = (*it).second; _ptr t = (*it).second;
@ -218,7 +218,7 @@ public:
getMaxDim() const getMaxDim() const
{ {
int res = -1; 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(); int dim = (*run).first.dimen();
if (dim > res) if (dim > res)
@ -244,7 +244,7 @@ public:
void void
writeMat(mat_t *fd, const char *prefix) const 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]; char lname[100];
sprintf(lname, "%s_g", prefix); sprintf(lname, "%s_g", prefix);
@ -285,7 +285,7 @@ public:
{ {
vector<_const_ptr> res(e.numClasses()); vector<_const_ptr> res(e.numClasses());
int i = 0; int i = 0;
for (Equivalence::const_seqit it = e.begin(); for (auto it = e.begin();
it != e.end(); ++it, i++) it != e.end(); ++it, i++)
{ {
Symmetry s(rsym, *it); Symmetry s(rsym, *it);

View File

@ -12,7 +12,7 @@ PowerProvider::getNext(const URSingleTensor *dummy)
{ {
if (ut) 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()); KronProd::kronMult(ConstVector(origv), ConstVector(ut->getData()), ut_new->getData());
delete ut; delete ut;
ut = ut_new; ut = ut_new;

View File

@ -294,7 +294,7 @@ public:
} }
if (d > 1) if (d > 1)
{ {
_Ttype *new_last = new _Ttype(*last, v); auto *new_last = new _Ttype(*last, v);
delete last; delete last;
last = new_last; last = new_last;
} }
@ -364,7 +364,7 @@ public:
TL_RAISE_IF(v.length() != nvars(), TL_RAISE_IF(v.length() != nvars(),
"Wrong length of vector for TensorPolynomial::evalPartially"); "Wrong length of vector for TensorPolynomial::evalPartially");
_Ttype *res = new _Ttype(nrows(), nvars(), s); auto *res = new _Ttype(nrows(), nvars(), s);
res->zeros(); res->zeros();
if (_Tparent::check(Symmetry(s))) if (_Tparent::check(Symmetry(s)))
@ -375,10 +375,10 @@ public:
if (_Tparent::check(Symmetry(d))) if (_Tparent::check(Symmetry(d)))
{ {
const _Ttype &ltmp = *(_Tparent::get(Symmetry(d))); const _Ttype &ltmp = *(_Tparent::get(Symmetry(d)));
_Ttype *last = new _Ttype(ltmp); auto *last = new _Ttype(ltmp);
for (int j = 0; j < d - s; j++) for (int j = 0; j < d - s; j++)
{ {
_Ttype *newlast = new _Ttype(*last, v); auto *newlast = new _Ttype(*last, v);
delete last; delete last;
last = newlast; last = newlast;
} }

View File

@ -40,7 +40,7 @@ ConstTwoDMatrix::writeMat(mat_t *fd, const char *vname) const
#endif #endif
dims[0] = nrows(); dims[0] = nrows();
dims[1] = ncols(); dims[1] = ncols();
double *data = new double[nrows()*ncols()]; auto *data = new double[nrows()*ncols()];
for (int j = 0; j < ncols(); j++) for (int j = 0; j < ncols(); j++)
for (int i = 0; i < nrows(); i++) for (int i = 0; i < nrows(); i++)

View File

@ -46,7 +46,7 @@ Factory::makeVector(int n)
{ {
init(n, n*n); init(n, n*n);
Vector *v = new Vector(n); auto *v = new Vector(n);
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
(*v)[i] = get(); (*v)[i] = get();

View File

@ -34,7 +34,7 @@ public:
_Ttype * _Ttype *
make(int r, int nv, int dim) make(int r, int nv, int dim)
{ {
_Ttype *res = new _Ttype(r, nv, dim); auto *res = new _Ttype(r, nv, dim);
init(dim, nv); init(dim, nv);
fillMatrix(*res); fillMatrix(*res);
return res; return res;
@ -45,14 +45,14 @@ public:
makeCont(int r, const IntSequence &nvs, int maxdim) makeCont(int r, const IntSequence &nvs, int maxdim)
{ {
int symnum = nvs.size(); int symnum = nvs.size();
_Ctype *res = new _Ctype(symnum); auto *res = new _Ctype(symnum);
for (int dim = 1; dim <= maxdim; dim++) for (int dim = 1; dim <= maxdim; dim++)
{ {
if (symnum == 1) if (symnum == 1)
{ {
// full symmetry // full symmetry
Symmetry sym(dim); Symmetry sym(dim);
_Ttype *t = make<_Ttype>(r, sym, nvs); auto *t = make<_Ttype>(r, sym, nvs);
res->insert(t); res->insert(t);
} }
else else
@ -61,7 +61,7 @@ public:
for (int i = 0; i <= dim; i++) for (int i = 0; i <= dim; i++)
{ {
Symmetry sym(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); res->insert(t);
} }
} }
@ -73,10 +73,10 @@ public:
_Ptype * _Ptype *
makePoly(int r, int nv, int maxdim) 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++) for (int d = 1; d <= maxdim; d++)
{ {
_Ttype *t = make<_Ttype>(r, nv, d); auto *t = make<_Ttype>(r, nv, d);
p->insert(t); p->insert(t);
} }
return p; return p;

View File

@ -29,7 +29,7 @@ int
IntGenerator::get() const IntGenerator::get() const
{ {
double d = drand48(); 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; int num_zero_inter = num_inter - 2*maxim;
if (d < ((double) num_zero_inter)/num_inter) if (d < ((double) num_zero_inter)/num_inter)
return 0; return 0;
@ -223,7 +223,7 @@ Monom2Vector::deriv(const Symmetry &s) const
FGSContainer * FGSContainer *
Monom2Vector::deriv(int maxdim) const Monom2Vector::deriv(int maxdim) const
{ {
FGSContainer *res = new FGSContainer(2); auto *res = new FGSContainer(2);
for (int dim = 1; dim <= maxdim; dim++) for (int dim = 1; dim <= maxdim; dim++)
{ {
for (int ydim = 0; ydim <= dim; ydim++) for (int ydim = 0; ydim <= dim; ydim++)
@ -404,7 +404,7 @@ Monom4Vector::deriv(int dim) const
IntSequence cum(4); IntSequence cum(4);
cum[0] = 0; cum[1] = nx1; cum[2] = nx1+nx2; cum[3] = nx1+nx2+nx3; 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); FFSTensor dummy(0, nx1+nx2+nx3+nx4, dim);
for (Tensor::index run = dummy.begin(); run != dummy.end(); ++run) for (Tensor::index run = dummy.begin(); run != dummy.end(); ++run)

View File

@ -225,7 +225,7 @@ TestRunnable::dense_prod(const Symmetry &bsym, const IntSequence &bnvs,
Factory f; Factory f;
FGSContainer *cont FGSContainer *cont
= f.makeCont<FGSTensor, FGSContainer>(hnv, bnvs, bsym.dimen()-hdim+1); = f.makeCont<FGSTensor, FGSContainer>(hnv, bnvs, bsym.dimen()-hdim+1);
FGSTensor *fh auto *fh
= f.make<FGSTensor>(rows, Symmetry(hdim), IntSequence(1, hnv)); = f.make<FGSTensor>(rows, Symmetry(hdim), IntSequence(1, hnv));
UGSTensor uh(*fh); UGSTensor uh(*fh);
FGSTensor fb(rows, TensorDimens(bsym, bnvs)); FGSTensor fb(rows, TensorDimens(bsym, bnvs));
@ -451,8 +451,8 @@ TestRunnable::folded_contraction(int r, int nv, int dim)
Factory fact; Factory fact;
Vector *x = fact.makeVector(nv); Vector *x = fact.makeVector(nv);
FFSTensor *forig = fact.make<FFSTensor>(r, nv, dim); auto *forig = fact.make<FFSTensor>(r, nv, dim);
FFSTensor *f = new FFSTensor(*forig); auto *f = new FFSTensor(*forig);
clock_t ctime = clock(); clock_t ctime = clock();
for (int d = dim-1; d > 0; d--) for (int d = dim-1; d > 0; d--)
{ {
@ -493,10 +493,10 @@ TestRunnable::unfolded_contraction(int r, int nv, int dim)
Factory fact; Factory fact;
Vector *x = fact.makeVector(nv); Vector *x = fact.makeVector(nv);
FFSTensor *forig = fact.make<FFSTensor>(r, nv, dim); auto *forig = fact.make<FFSTensor>(r, nv, dim);
UFSTensor uorig(*forig); UFSTensor uorig(*forig);
delete forig; delete forig;
UFSTensor *u = new UFSTensor(uorig); auto *u = new UFSTensor(uorig);
clock_t ctime = clock(); clock_t ctime = clock();
for (int d = dim-1; d > 0; d--) for (int d = dim-1; d > 0; d--)
{ {