[pynac] 01/01: Imported Upstream version 0.4.0
Julien Puydt
julien.puydt at laposte.net
Mon Jun 15 18:38:24 UTC 2015
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to annotated tag upstream/0.4.0
in repository pynac.
commit 1503054219be8dd9c20749931ef51dc9691d4a65
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Tue Jun 2 20:34:23 2015 +0200
Imported Upstream version 0.4.0
---
configure.ac | 5 +-
ginac/add.cpp | 90 ++++++++++++-------------
ginac/add.h | 4 +-
ginac/archive.cpp | 30 ++++-----
ginac/archive.h | 2 +-
ginac/basic.cpp | 20 +++---
ginac/basic.h | 12 ++--
ginac/class_info.h | 4 +-
ginac/clifford.cpp | 44 ++++++------
ginac/clifford.h | 8 +--
ginac/color.cpp | 16 ++---
ginac/color.h | 4 +-
ginac/constant.cpp | 12 ++--
ginac/constant.h | 6 +-
ginac/container.h | 64 +++++++++---------
ginac/ex.cpp | 10 +--
ginac/ex.h | 12 ++--
ginac/expair.h | 2 +-
ginac/expairseq.cpp | 162 ++++++++++++++++++++++----------------------
ginac/expairseq.h | 22 +++---
ginac/fderivative.cpp | 25 ++++---
ginac/fderivative.h | 8 +--
ginac/function.cpp | 46 ++++++-------
ginac/function.h | 14 ++--
ginac/idx.cpp | 6 +-
ginac/idx.h | 4 +-
ginac/indexed.cpp | 58 ++++++++--------
ginac/indexed.h | 8 +--
ginac/infinity.h | 2 +-
ginac/inifcns_nstdsums.cpp | 34 +++++-----
ginac/integral.cpp | 10 +--
ginac/integral.h | 2 +-
ginac/lst.cpp | 6 +-
ginac/matrix.cpp | 48 ++++++-------
ginac/matrix.h | 4 +-
ginac/mul.cpp | 165 ++++++++++++++++++++++-----------------------
ginac/mul.h | 8 +--
ginac/ncmul.cpp | 44 ++++++------
ginac/ncmul.h | 6 +-
ginac/normal.cpp | 42 ++++++------
ginac/normal.h | 2 +-
ginac/numeric.cpp | 6 +-
ginac/numeric.h | 10 +--
ginac/operators.cpp | 28 ++++----
ginac/order.cpp | 18 ++---
ginac/power.cpp | 32 ++++-----
ginac/power.h | 6 +-
ginac/print.h | 12 ++--
ginac/pseries.cpp | 64 +++++++++---------
ginac/pseries.h | 4 +-
ginac/py_funcs.h | 4 +-
ginac/relational.cpp | 4 +-
ginac/relational.h | 2 +-
ginac/remember.cpp | 16 ++---
ginac/remember.h | 2 +-
ginac/structure.h | 2 +-
ginac/symbol.cpp | 24 +++----
ginac/symbol.h | 8 +--
ginac/symmetry.cpp | 36 +++++-----
59 files changed, 674 insertions(+), 675 deletions(-)
diff --git a/configure.ac b/configure.ac
index db5ecd6..5500e01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,8 +18,8 @@ dnl The following article is helpful too:
dnl http://www.freesoftwaremagazine.com/articles/building_shared_libraries_once_using_autotools
m4_define([ginac_major_version], [0])
-m4_define([ginac_minor_version], [3])
-m4_define([ginac_micro_version], [8])
+m4_define([ginac_minor_version], [4])
+m4_define([ginac_micro_version], [0])
m4_define([lt_current], [0])
m4_define([lt_revision], [0])
@@ -105,6 +105,7 @@ AC_CHECK_SIZEOF(void *)
dnl Switch to C++ language mode for the following libraries and headers.
AC_LANG([C++])
+AX_CXX_COMPILE_STDCXX_11
dnl Make sure all the necessary standard headers are installed on the system.
AC_CHECK_HEADER(iosfwd, , GINAC_ERROR([The standard <iosfwd> header file could not be found.]))
diff --git a/ginac/add.cpp b/ginac/add.cpp
index ec8fd5c..db5d951 100644
--- a/ginac/add.cpp
+++ b/ginac/add.cpp
@@ -95,7 +95,7 @@ add::add(const epvector & v, const ex & oc)
GINAC_ASSERT(is_canonical());
}
-add::add(std::auto_ptr<epvector> vp, const ex & oc)
+add::add(std::unique_ptr<epvector> vp, const ex & oc)
{
tinfo_key = &add::tinfo_static;
GINAC_ASSERT(vp.get()!=0);
@@ -130,7 +130,7 @@ void add::print_add(const print_context & c, unsigned level, bool latex) const
const epvector & sorted_seq = get_sorted_seq();
// Then proceed with the remaining factors
- epvector::const_iterator it = sorted_seq.begin(), itend = sorted_seq.end();
+ auto it = sorted_seq.begin(), itend = sorted_seq.end();
while (it != itend) {
std::stringstream tstream;
print_context *tcontext_p;
@@ -202,7 +202,7 @@ void add::do_print_csrc(const print_csrc & c, unsigned level) const
c.s << "(";
// Print arguments, separated by "+" or "-"
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
char separator = ' ';
while (it != itend) {
@@ -270,7 +270,7 @@ bool add::info(unsigned inf) const
case info_flags::even:
case info_flags::crational_polynomial:
case info_flags::rational_function: {
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
if (!(recombine_pair_to_ex(*i).info(inf)))
return false;
@@ -281,7 +281,7 @@ bool add::info(unsigned inf) const
return overall_coeff.info(inf);
}
case info_flags::algebraic: {
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
if ((recombine_pair_to_ex(*i).info(inf)))
return true;
@@ -295,8 +295,8 @@ bool add::info(unsigned inf) const
bool add::is_polynomial(const ex & var) const
{
- for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
- if (!(i->rest).is_polynomial(var)) {
+ for (const auto & elem : seq) {
+ if (!(elem.rest).is_polynomial(var)) {
return false;
}
}
@@ -310,7 +310,7 @@ int add::degree(const ex & s) const
deg = 0;
// Find maximum of degrees of individual terms
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
int cur_deg = i->rest.degree(s);
if (cur_deg > deg)
@@ -327,7 +327,7 @@ int add::ldegree(const ex & s) const
deg = 0;
// Find minimum of degrees of individual terms
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
int cur_deg = i->rest.ldegree(s);
if (cur_deg < deg)
@@ -339,14 +339,14 @@ int add::ldegree(const ex & s) const
ex add::coeff(const ex & s, int n) const
{
- std::auto_ptr<epvector> coeffseq(new epvector);
- std::auto_ptr<epvector> coeffseq_cliff(new epvector);
+ std::unique_ptr<epvector> coeffseq(new epvector);
+ std::unique_ptr<epvector> coeffseq_cliff(new epvector);
int rl = clifford_max_label(s);
bool do_clifford = (rl != -1);
bool nonscalar = false;
// Calculate sum of coefficients in each term
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
ex restcoeff = i->rest.coeff(s, n);
if (!restcoeff.is_zero()) {
@@ -363,7 +363,7 @@ ex add::coeff(const ex & s, int n) const
++i;
}
- return (new add(nonscalar ? coeffseq_cliff : coeffseq,
+ return (new add(std::move(nonscalar ? coeffseq_cliff : coeffseq),
n==0 ? overall_coeff : _ex0))->setflag(status_flags::dynallocated);
}
@@ -376,10 +376,10 @@ ex add::coeff(const ex & s, int n) const
* @param level cut-off in recursive evaluation */
ex add::eval(int level) const
{
- std::auto_ptr<epvector> evaled_seqp = evalchildren(level);
+ std::unique_ptr<epvector> evaled_seqp = evalchildren(level);
if (evaled_seqp.get()) {
// do more evaluation later
- return (new add(evaled_seqp, overall_coeff))->
+ return (new add(std::move(evaled_seqp), overall_coeff))->
setflag(status_flags::dynallocated);
}
@@ -401,7 +401,7 @@ ex add::eval(int level) const
}
// handle infinity
- for (epvector::const_iterator i = seq.begin(); i != seq.end(); i++)
+ for (auto i = seq.begin(); i != seq.end(); i++)
if (unlikely(is_exactly_a<infinity>(i->rest)))
return eval_infinity(i);
@@ -420,19 +420,19 @@ ex add::eval(int level) const
// if any terms in the sum still are purely numeric, then they are more
// appropriately collected into the overall coefficient
int terms_to_collect = 0;
- for (epvector::const_iterator j = seq.begin(); j != seq.end(); j++)
+ for (auto j = seq.begin(); j != seq.end(); j++)
if (unlikely(is_a<numeric>(j->rest)))
++terms_to_collect;
if (terms_to_collect) {
- std::auto_ptr<epvector> s(new epvector);
+ std::unique_ptr<epvector> s(new epvector);
s->reserve(seq_size - terms_to_collect);
numeric oc = *_num0_p;
- for (epvector::const_iterator j = seq.begin(); j != seq.end(); j++)
+ for (auto j = seq.begin(); j != seq.end(); j++)
if (unlikely(is_a<numeric>(j->rest)))
oc = oc.add((ex_to<numeric>(j->rest)).mul(ex_to<numeric>(j->coeff)));
else
s->push_back(*j);
- return (new add(s, ex_to<numeric>(overall_coeff).add_dyn(oc)))
+ return (new add(std::move(s), ex_to<numeric>(overall_coeff).add_dyn(oc)))
->setflag(status_flags::dynallocated);
}
@@ -458,7 +458,7 @@ ex add::eval_infinity(epvector::const_iterator infinity_iter) const
GINAC_ASSERT(is_exactly_a<infinity>(infinity_iter->rest));
infinity result = infinity_from_iter(infinity_iter);
- for (epvector::const_iterator i = seq.begin(); i != seq.end(); i++) {
+ for (auto i = seq.begin(); i != seq.end(); i++) {
if (not is_exactly_a<infinity>(i->rest)) continue;
if (i == infinity_iter) continue;
infinity i_infty = infinity_from_iter(i);
@@ -472,14 +472,14 @@ ex add::evalm() const
{
// Evaluate children first and add up all matrices. Stop if there's one
// term that is not a matrix.
- std::auto_ptr<epvector> s(new epvector);
+ std::unique_ptr<epvector> s(new epvector);
s->reserve(seq.size());
bool all_matrices = true;
bool first_term = true;
matrix sum;
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
while (it != itend) {
const ex &m = recombine_pair_to_ex(*it).evalm();
s->push_back(split_ex_to_pair(m));
@@ -497,12 +497,12 @@ ex add::evalm() const
if (all_matrices)
return sum + overall_coeff;
else
- return (new add(s, overall_coeff))->setflag(status_flags::dynallocated);
+ return (new add(std::move(s), overall_coeff))->setflag(status_flags::dynallocated);
}
ex add::conjugate() const
{
- exvector *v = 0;
+ exvector *v = nullptr;
for (size_t i=0; i<nops(); ++i) {
if (v) {
v->push_back(op(i).conjugate());
@@ -530,13 +530,13 @@ ex add::real_part() const
{
epvector v;
v.reserve(seq.size());
- for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i)
- if ((i->coeff).info(info_flags::real)) {
- ex rp = (i->rest).real_part();
+ for (const auto & elem : seq)
+ if ((elem.coeff).info(info_flags::real)) {
+ ex rp = (elem.rest).real_part();
if (!rp.is_zero())
- v.push_back(expair(rp, i->coeff));
+ v.push_back(expair(rp, elem.coeff));
} else {
- ex rp=recombine_pair_to_ex(*i).real_part();
+ ex rp=recombine_pair_to_ex(elem).real_part();
if (!rp.is_zero())
v.push_back(split_ex_to_pair(rp));
}
@@ -548,13 +548,13 @@ ex add::imag_part() const
{
epvector v;
v.reserve(seq.size());
- for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i)
- if ((i->coeff).info(info_flags::real)) {
- ex ip = (i->rest).imag_part();
+ for (const auto & elem : seq)
+ if ((elem.coeff).info(info_flags::real)) {
+ ex ip = (elem.rest).imag_part();
if (!ip.is_zero())
- v.push_back(expair(ip, i->coeff));
+ v.push_back(expair(ip, elem.coeff));
} else {
- ex ip=recombine_pair_to_ex(*i).imag_part();
+ ex ip=recombine_pair_to_ex(elem).imag_part();
if (!ip.is_zero())
v.push_back(split_ex_to_pair(ip));
}
@@ -576,18 +576,18 @@ ex add::eval_ncmul(const exvector & v) const
* @see ex::diff */
ex add::derivative(const symbol & y) const
{
- std::auto_ptr<epvector> s(new epvector);
+ std::unique_ptr<epvector> s(new epvector);
s->reserve(seq.size());
// Only differentiate the "rest" parts of the expairs. This is faster
// than the default implementation in basic::derivative() although
// if performs the same function (differentiate each term).
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
s->push_back(combine_ex_with_coeff_to_pair(i->rest.diff(y), i->coeff));
++i;
}
- return (new add(s, _ex0))->setflag(status_flags::dynallocated);
+ return (new add(std::move(s), _ex0))->setflag(status_flags::dynallocated);
}
int add::compare_same_type(const basic & other) const
@@ -618,9 +618,9 @@ ex add::thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming)
}
// Note: do_index_renaming is ignored because it makes no sense for an add.
-ex add::thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc, bool do_index_renaming) const
+ex add::thisexpairseq(std::unique_ptr<epvector> vp, const ex & oc, bool do_index_renaming) const
{
- return (new add(vp,oc))->setflag(status_flags::dynallocated);
+ return (new add(std::move(vp),oc))->setflag(status_flags::dynallocated);
}
expair add::split_ex_to_pair(const ex & e) const
@@ -628,7 +628,7 @@ expair add::split_ex_to_pair(const ex & e) const
if (is_exactly_a<mul>(e)) {
const mul &mulref(ex_to<mul>(e));
const ex &numfactor = mulref.overall_coeff;
- mul *mulcopyp = new mul(mulref);
+ auto mulcopyp = new mul(mulref);
mulcopyp->overall_coeff = _ex1;
mulcopyp->clearflag(status_flags::evaluated);
mulcopyp->clearflag(status_flags::hash_calculated);
@@ -645,7 +645,7 @@ expair add::combine_ex_with_coeff_to_pair(const ex & e,
if (is_exactly_a<mul>(e)) {
const mul &mulref(ex_to<mul>(e));
const ex &numfactor = mulref.overall_coeff;
- mul *mulcopyp = new mul(mulref);
+ auto mulcopyp = new mul(mulref);
mulcopyp->overall_coeff = _ex1;
mulcopyp->clearflag(status_flags::evaluated);
mulcopyp->clearflag(status_flags::hash_calculated);
@@ -688,13 +688,13 @@ ex add::recombine_pair_to_ex(const expair & p) const
ex add::expand(unsigned options) const
{
- std::auto_ptr<epvector> vp = expandchildren(options);
- if (vp.get() == 0) {
+ std::unique_ptr<epvector> vp = expandchildren(options);
+ if (vp.get() == nullptr) {
// the terms have not changed, so it is safe to declare this expanded
return (options == 0) ? setflag(status_flags::expanded) : *this;
}
- return (new add(vp, overall_coeff))->setflag(status_flags::dynallocated | (options == 0 ? status_flags::expanded : 0));
+ return (new add(std::move(vp), overall_coeff))->setflag(status_flags::dynallocated | (options == 0 ? status_flags::expanded : 0));
}
const epvector & add::get_sorted_seq() const
diff --git a/ginac/add.h b/ginac/add.h
index fb1d13d..dc40dcc 100644
--- a/ginac/add.h
+++ b/ginac/add.h
@@ -41,7 +41,7 @@ public:
add(const exvector & v, bool hold=false);
add(const epvector & v);
add(const epvector & v, const ex & oc);
- add(std::auto_ptr<epvector> vp, const ex & oc);
+ add(std::unique_ptr<epvector> vp, const ex & oc);
// functions overriding virtual functions from base classes
public:
@@ -70,7 +70,7 @@ protected:
unsigned return_type() const;
tinfo_t return_type_tinfo() const;
ex thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming = false) const;
- ex thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc, bool do_index_renaming = false) const;
+ ex thisexpairseq(std::unique_ptr<epvector> vp, const ex & oc, bool do_index_renaming = false) const;
expair split_ex_to_pair(const ex & e) const;
expair combine_ex_with_coeff_to_pair(const ex & e,
const ex & c) const;
diff --git a/ginac/archive.cpp b/ginac/archive.cpp
index aa6700b..d044556 100644
--- a/ginac/archive.cpp
+++ b/ginac/archive.cpp
@@ -54,7 +54,7 @@ archive_node_id archive::add_node(const archive_node &n)
{
// Look if expression is known to be in some node already.
if (n.has_ex()) {
- mapit i = exprtable.find(n.get_ex());
+ auto i = exprtable.find(n.get_ex());
if (i != exprtable.end())
return i->second;
nodes.push_back(n);
@@ -83,7 +83,7 @@ ex archive::unarchive_ex(const lst &sym_lst, const char *name) const
// Find root node
std::string name_string = name;
archive_atom id = atomize(name_string);
- std::vector<archived_ex>::const_iterator i = exprs.begin(), iend = exprs.end();
+ auto i = exprs.begin(), iend = exprs.end();
while (i != iend) {
if (i->name == id)
goto found;
@@ -358,7 +358,7 @@ archive_node::archive_node_cit
archive_node::find_first(const std::string &name) const
{
archive_atom name_atom = a.atomize(name);
- for (archive_node_cit i=props.begin(); i!=props.end(); ++i)
+ for (auto i=props.begin(); i!=props.end(); ++i)
if (i->name == name_atom)
return i;
return props.end();;
@@ -368,7 +368,7 @@ archive_node::archive_node_cit
archive_node::find_last(const std::string &name) const
{
archive_atom name_atom = a.atomize(name);
- for (archive_node_cit i=props.end(); i!=props.begin();) {
+ for (auto i=props.end(); i!=props.begin();) {
--i;
if (i->name == name_atom)
return i;
@@ -402,7 +402,7 @@ void archive_node::add_ex(const std::string &name, const ex &value)
bool archive_node::find_bool(const std::string &name, bool &ret, unsigned index) const
{
archive_atom name_atom = a.atomize(name);
- archive_node_cit i = props.begin(), iend = props.end();
+ auto i = props.begin(), iend = props.end();
unsigned found_index = 0;
while (i != iend) {
if (i->type == PTYPE_BOOL && i->name == name_atom) {
@@ -420,7 +420,7 @@ bool archive_node::find_bool(const std::string &name, bool &ret, unsigned index)
bool archive_node::find_unsigned(const std::string &name, unsigned &ret, unsigned index) const
{
archive_atom name_atom = a.atomize(name);
- archive_node_cit i = props.begin(), iend = props.end();
+ auto i = props.begin(), iend = props.end();
unsigned found_index = 0;
while (i != iend) {
if (i->type == PTYPE_UNSIGNED && i->name == name_atom) {
@@ -438,7 +438,7 @@ bool archive_node::find_unsigned(const std::string &name, unsigned &ret, unsigne
bool archive_node::find_string(const std::string &name, std::string &ret, unsigned index) const
{
archive_atom name_atom = a.atomize(name);
- archive_node_cit i = props.begin(), iend = props.end();
+ auto i = props.begin(), iend = props.end();
unsigned found_index = 0;
while (i != iend) {
if (i->type == PTYPE_STRING && i->name == name_atom) {
@@ -462,7 +462,7 @@ void archive_node::find_ex_by_loc(archive_node_cit loc, ex &ret, lst &sym_lst)
bool archive_node::find_ex(const std::string &name, ex &ret, lst &sym_lst, unsigned index) const
{
archive_atom name_atom = a.atomize(name);
- archive_node_cit i = props.begin(), iend = props.end();
+ auto i = props.begin(), iend = props.end();
unsigned found_index = 0;
while (i != iend) {
if (i->type == PTYPE_NODE && i->name == name_atom) {
@@ -480,7 +480,7 @@ bool archive_node::find_ex(const std::string &name, ex &ret, lst &sym_lst, unsig
const archive_node &archive_node::find_ex_node(const std::string &name, unsigned index) const
{
archive_atom name_atom = a.atomize(name);
- archive_node_cit i = props.begin(), iend = props.end();
+ auto i = props.begin(), iend = props.end();
unsigned found_index = 0;
while (i != iend) {
if (i->type == PTYPE_NODE && i->name == name_atom) {
@@ -497,12 +497,12 @@ const archive_node &archive_node::find_ex_node(const std::string &name, unsigned
void archive_node::get_properties(propinfovector &v) const
{
v.clear();
- archive_node_cit i = props.begin(), iend = props.end();
+ auto i = props.begin(), iend = props.end();
while (i != iend) {
property_type type = i->type;
std::string name = a.unatomize(i->name);
- propinfovector::iterator a = v.begin(), aend = v.end();
+ auto a = v.begin(), aend = v.end();
bool found = false;
while (a != aend) {
if (a->type == type && a->name == name) {
@@ -581,7 +581,7 @@ void archive::printraw(std::ostream &os) const
// Dump expressions
os << "Expressions:\n";
{
- std::vector<archived_ex>::const_iterator i = exprs.begin(), iend = exprs.end();
+ auto i = exprs.begin(), iend = exprs.end();
unsigned index = 0;
while (i != iend) {
os << " " << index << " \"" << unatomize(i->name) << "\" root node " << i->root << std::endl;
@@ -593,7 +593,7 @@ void archive::printraw(std::ostream &os) const
// Dump nodes
os << "Nodes:\n";
{
- std::vector<archive_node>::const_iterator i = nodes.begin(), iend = nodes.end();
+ auto i = nodes.begin(), iend = nodes.end();
archive_node_id id = 0;
while (i != iend) {
os << " " << id << " ";
@@ -613,7 +613,7 @@ void archive_node::printraw(std::ostream &os) const
os << "\n";
// Dump properties
- archive_node_cit i = props.begin(), iend = props.end();
+ auto i = props.begin(), iend = props.end();
while (i != iend) {
os << " ";
switch (i->type) {
@@ -632,7 +632,7 @@ void archive_node::printraw(std::ostream &os) const
* ctor, which is currently a Cint-requirement. */
archive* archive_node::dummy_ar_creator()
{
- static archive* some_ar = new archive;
+ static auto some_ar = new archive;
return some_ar;
}
diff --git a/ginac/archive.h b/ginac/archive.h
index 0c2a1af..850c698 100644
--- a/ginac/archive.h
+++ b/ginac/archive.h
@@ -64,7 +64,7 @@ public:
* @see get_properties */
struct property_info {
property_info() {}
- property_info(property_type t, const std::string &n, unsigned c = 1) : type(t), name(n), count(c) {}
+ property_info(property_type t, std::string n, unsigned c = 1) : type(t), name(std::move(n)), count(c) {}
property_type type; /**< Data type of property. */
std::string name; /**< Name of property. */
diff --git a/ginac/basic.cpp b/ginac/basic.cpp
index 3aa1415..74765fb 100644
--- a/ginac/basic.cpp
+++ b/ginac/basic.cpp
@@ -308,12 +308,12 @@ ex basic::map(map_function & f) const
if (num == 0)
return *this;
- basic *copy = NULL;
+ basic *copy = nullptr;
for (size_t i=0; i<num; i++) {
const ex & o = op(i);
const ex & n = f(o);
if (!are_ex_trivially_equal(o, n)) {
- if (copy == NULL)
+ if (copy == nullptr)
copy = duplicate();
copy->let_op(i) = n;
}
@@ -380,12 +380,12 @@ ex basic::collect(const ex & s, bool distributed) const
for (const_iterator xi=x.begin(); xi!=x.end(); ++xi) {
ex key = _ex1;
ex pre_coeff = *xi;
- for (lst::const_iterator li=l.begin(); li!=l.end(); ++li) {
- int cexp = pre_coeff.degree(*li);
- pre_coeff = pre_coeff.coeff(*li, cexp);
- key *= pow(*li, cexp);
+ for (const auto & elem : l) {
+ int cexp = pre_coeff.degree(elem);
+ pre_coeff = pre_coeff.coeff(elem, cexp);
+ key *= pow(elem, cexp);
}
- exmap::iterator ci = cmap.find(key);
+ auto ci = cmap.find(key);
if (ci != cmap.end())
ci->second += pre_coeff;
else
@@ -560,9 +560,9 @@ bool basic::match(const ex & pattern, lst & repl_lst) const
// Wildcard matches anything, but check whether we already have found
// a match for that wildcard first (if so, the earlier match must be
// the same expression)
- for (lst::const_iterator it = repl_lst.begin(); it != repl_lst.end(); ++it) {
- if (it->op(0).is_equal(pattern))
- return is_equal(ex_to<basic>(it->op(1)));
+ for (const auto & elem : repl_lst) {
+ if (elem.op(0).is_equal(pattern))
+ return is_equal(ex_to<basic>(elem.op(1)));
}
repl_lst.append(pattern == *this);
return true;
diff --git a/ginac/basic.h b/ginac/basic.h
index 693b462..2a571a3 100644
--- a/ginac/basic.h
+++ b/ginac/basic.h
@@ -23,7 +23,7 @@
#ifndef __GINAC_BASIC_H__
#define __GINAC_BASIC_H__
-#include "Python.h"
+#include <Python.h>
#include <cstddef> // for size_t
#include <vector>
@@ -106,7 +106,7 @@ protected:
class basic : public refcounted
{
GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(basic, void)
-
+
friend class ex;
friend struct print_order;
friend struct print_order_pair;
@@ -128,7 +128,7 @@ protected:
/** Constructor with specified tinfo_key (used by derived classes instead
* of the default constructor to avoid assigning tinfo_key twice). */
basic(tinfo_t ti) : tinfo_key(ti), flags(0) {}
-
+
// new virtual functions which can be overridden by derived classes
public: // only const functions please (may break reference counting)
@@ -139,7 +139,7 @@ public: // only const functions please (may break reference counting)
// evaluation
virtual ex eval(int level = 0) const;
- virtual ex evalf(int level = 0, PyObject* parent=NULL) const;
+ virtual ex evalf(int level = 0, PyObject* parent=nullptr) const;
virtual ex evalm() const;
virtual ex eval_integ() const;
protected:
@@ -237,7 +237,7 @@ protected:
virtual bool is_equal_same_type(const basic & other) const;
virtual unsigned calchash() const;
-
+
// non-virtual functions in this class
public:
/** Like print(), but dispatch to the specified class. Can be used by
@@ -303,7 +303,7 @@ extern int max_recursion_level;
template <class T>
inline bool is_a(const basic &obj)
{
- return dynamic_cast<const T *>(&obj) != 0;
+ return dynamic_cast<const T *>(&obj) != nullptr;
}
/** Check if obj is a T, not including base classes. */
diff --git a/ginac/class_info.h b/ginac/class_info.h
index c889dfc..e5b7d14 100644
--- a/ginac/class_info.h
+++ b/ginac/class_info.h
@@ -40,7 +40,7 @@ namespace GiNaC {
template <class OPT>
class class_info {
public:
- class_info(const OPT & o) : options(o), next(first), parent(NULL)
+ class_info(OPT o) : options(std::move(o)), next(first), parent(nullptr)
{
first = this;
parents_identified = false;
@@ -190,7 +190,7 @@ void class_info<OPT>::identify_parents()
}
}
-template <class OPT> class_info<OPT> *class_info<OPT>::first = NULL;
+template <class OPT> class_info<OPT> *class_info<OPT>::first = nullptr;
template <class OPT> bool class_info<OPT>::parents_identified = false;
} // namespace GiNaC
diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp
index 07ca002..05b08d5 100644
--- a/ginac/clifford.cpp
+++ b/ginac/clifford.cpp
@@ -105,18 +105,18 @@ clifford::clifford(const ex & b, unsigned char rl) : inherited(b), representatio
* use only. Use the clifford_unit() or dirac_gamma() functions instead.
* @see clifford_unit
* @see dirac_gamma */
-clifford::clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl, int comm_sign) : inherited(b, mu), representation_label(rl), metric(metr), commutator_sign(comm_sign)
+clifford::clifford(const ex & b, const ex & mu, ex metr, unsigned char rl, int comm_sign) : inherited(b, mu), representation_label(rl), metric(std::move(metr)), commutator_sign(comm_sign)
{
GINAC_ASSERT(is_a<varidx>(mu));
tinfo_key = &clifford::tinfo_static;
}
-clifford::clifford(unsigned char rl, const ex & metr, int comm_sign, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl), metric(metr), commutator_sign(comm_sign)
+clifford::clifford(unsigned char rl, ex metr, int comm_sign, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl), metric(std::move(metr)), commutator_sign(comm_sign)
{
tinfo_key = &clifford::tinfo_static;
}
-clifford::clifford(unsigned char rl, const ex & metr, int comm_sign, std::auto_ptr<exvector> vp) : inherited(not_symmetric(), vp), representation_label(rl), metric(metr), commutator_sign(comm_sign)
+clifford::clifford(unsigned char rl, ex metr, int comm_sign, std::unique_ptr<exvector> vp) : inherited(not_symmetric(), std::move(vp)), representation_label(rl), metric(std::move(metr)), commutator_sign(comm_sign)
{
tinfo_key = &clifford::tinfo_static;
}
@@ -413,7 +413,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
if (std::find_if(self + 1, other, is_not_a_clifford()) != other)
return false;
- exvector::iterator next_to_last = other - 1;
+ auto next_to_last = other - 1;
ex S = ncmul(exvector(self + 1, next_to_last), true);
ex SR = ncmul(exvector(std::reverse_iterator<exvector::const_iterator>(next_to_last), std::reverse_iterator<exvector::const_iterator>(self + 1)), true);
@@ -429,7 +429,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
if (std::find_if(self + 1, other, is_not_a_clifford()) != other)
return false;
- exvector::iterator next_to_last = other - 1;
+ auto next_to_last = other - 1;
ex S = ncmul(exvector(self + 1, next_to_last), true);
*self = 2 * (*next_to_last) * S - (*self) * S * (*other) * (*next_to_last);
@@ -464,7 +464,7 @@ bool cliffordunit::contract_with(exvector::iterator self, exvector::iterator oth
&& unit.same_metric(*other))
return false;
- exvector::iterator before_other = other - 1;
+ auto before_other = other - 1;
ex mu = self->op(1);
ex mu_toggle = other->op(1);
ex alpha = before_other->op(1);
@@ -522,7 +522,7 @@ ex clifford::eval_ncmul(const exvector & v) const
s.reserve(v.size());
// Remove superfluous ONEs
- exvector::const_iterator cit = v.begin(), citend = v.end();
+ auto cit = v.begin(), citend = v.end();
while (cit != citend) {
if (!is_a<clifford>(*cit) || !is_a<diracone>(cit->op(0)))
s.push_back(*cit);
@@ -534,11 +534,11 @@ ex clifford::eval_ncmul(const exvector & v) const
// Anticommutate gamma5/L/R's to the front
if (s.size() >= 2) {
- exvector::iterator first = s.begin(), next_to_last = s.end() - 2;
+ auto first = s.begin(), next_to_last = s.end() - 2;
while (true) {
- exvector::iterator it = next_to_last;
+ auto it = next_to_last;
while (true) {
- exvector::iterator it2 = it + 1;
+ auto it2 = it + 1;
if (is_a<clifford>(*it) && is_a<clifford>(*it2)) {
ex e1 = it->op(0), e2 = it2->op(0);
@@ -687,9 +687,9 @@ ex clifford::thiscontainer(const exvector & v) const
return clifford(representation_label, metric, commutator_sign, v);
}
-ex clifford::thiscontainer(std::auto_ptr<exvector> vp) const
+ex clifford::thiscontainer(std::unique_ptr<exvector> vp) const
{
- return clifford(representation_label, metric, commutator_sign, vp);
+ return clifford(representation_label, metric, commutator_sign, std::move(vp));
}
ex diracgamma5::conjugate() const
@@ -924,7 +924,7 @@ ex dirac_trace(const ex & e, const std::set<unsigned char> & rls, const ex & trO
for (size_t i=1; i<num; i++)
base_and_index(e.op(i), bv[i-1], ix[i-1]);
num--;
- int *iv = new int[num];
+ auto iv = new int[num];
ex result;
for (size_t i=0; i<num-3; i++) {
ex idx1 = ix[i];
@@ -988,9 +988,9 @@ ex dirac_trace(const ex & e, const lst & rll, const ex & trONE)
{
// Convert list to set
std::set<unsigned char> rls;
- for (lst::const_iterator i = rll.begin(); i != rll.end(); ++i) {
- if (i->info(info_flags::nonnegint))
- rls.insert(ex_to<numeric>(*i).to_int());
+ for (const auto & elem : rll) {
+ if (elem.info(info_flags::nonnegint))
+ rls.insert(ex_to<numeric>(elem).to_int());
}
return dirac_trace(e, rls, trONE);
@@ -1018,10 +1018,10 @@ ex canonicalize_clifford(const ex & e_)
// Scan for any ncmul objects
exmap srl;
ex aux = e.to_rational(srl);
- for (exmap::iterator i = srl.begin(); i != srl.end(); ++i) {
+ for (auto & elem : srl) {
- ex lhs = i->first;
- ex rhs = i->second;
+ ex lhs = elem.first;
+ ex rhs = elem.second;
if (is_exactly_a<ncmul>(rhs)
&& rhs.return_type() == return_types::noncommutative
@@ -1030,7 +1030,7 @@ ex canonicalize_clifford(const ex & e_)
// Expand product, if necessary
ex rhs_expanded = rhs.expand();
if (!is_a<ncmul>(rhs_expanded)) {
- i->second = canonicalize_clifford(rhs_expanded);
+ elem.second = canonicalize_clifford(rhs_expanded);
continue;
} else if (!is_a<clifford>(rhs.op(0)))
@@ -1042,7 +1042,7 @@ ex canonicalize_clifford(const ex & e_)
v.push_back(rhs.op(j));
// Stupid recursive bubble sort because we only want to swap adjacent gammas
- exvector::iterator it = v.begin(), next_to_last = v.end() - 1;
+ auto it = v.begin(), next_to_last = v.end() - 1;
if (is_a<diracgamma5>(it->op(0)) || is_a<diracgammaL>(it->op(0)) || is_a<diracgammaR>(it->op(0)))
++it;
@@ -1060,7 +1060,7 @@ ex canonicalize_clifford(const ex & e_)
it[0] = save1;
it[1] = save0;
sum += ex_to<clifford>(save0).get_commutator_sign() * ncmul(v, true);
- i->second = canonicalize_clifford(sum);
+ elem.second = canonicalize_clifford(sum);
goto next_sym;
}
++it;
diff --git a/ginac/clifford.h b/ginac/clifford.h
index 471a1ce..c628fa1 100644
--- a/ginac/clifford.h
+++ b/ginac/clifford.h
@@ -47,11 +47,11 @@ public:
// other constructors
public:
clifford(const ex & b, unsigned char rl = 0);
- clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl = 0, int comm_sign = -1);
+ clifford(const ex & b, const ex & mu, ex metr, unsigned char rl = 0, int comm_sign = -1);
// internal constructors
- clifford(unsigned char rl, const ex & metr, int comm_sign, const exvector & v, bool discardable = false);
- clifford(unsigned char rl, const ex & metr, int comm_sign, std::auto_ptr<exvector> vp);
+ clifford(unsigned char rl, ex metr, int comm_sign, const exvector & v, bool discardable = false);
+ clifford(unsigned char rl, ex metr, int comm_sign, std::unique_ptr<exvector> vp);
// functions overriding virtual functions from base classes
public:
@@ -60,7 +60,7 @@ protected:
ex eval_ncmul(const exvector & v) const;
bool match_same_type(const basic & other) const;
ex thiscontainer(const exvector & v) const;
- ex thiscontainer(std::auto_ptr<exvector> vp) const;
+ ex thiscontainer(std::unique_ptr<exvector> vp) const;
unsigned return_type() const { return return_types::noncommutative; }
tinfo_t return_type_tinfo() const { return clifford::return_type_tinfo_static+representation_label; }
diff --git a/ginac/color.cpp b/ginac/color.cpp
index 7708df3..92c0275 100644
--- a/ginac/color.cpp
+++ b/ginac/color.cpp
@@ -96,7 +96,7 @@ color::color(unsigned char rl, const exvector & v, bool discardable) : inherited
tinfo_key = &color::tinfo_static;
}
-color::color(unsigned char rl, std::auto_ptr<exvector> vp) : inherited(not_symmetric(), vp), representation_label(rl)
+color::color(unsigned char rl, std::unique_ptr<exvector> vp) : inherited(not_symmetric(), std::move(vp)), representation_label(rl)
{
tinfo_key = &color::tinfo_static;
}
@@ -167,7 +167,7 @@ ex color::eval_ncmul(const exvector & v) const
s.reserve(v.size());
// Remove superfluous ONEs
- exvector::const_iterator it = v.begin(), itend = v.end();
+ auto it = v.begin(), itend = v.end();
while (it != itend) {
if (!is_a<su3one>(it->op(0)))
s.push_back(*it);
@@ -185,9 +185,9 @@ ex color::thiscontainer(const exvector & v) const
return color(representation_label, v);
}
-ex color::thiscontainer(std::auto_ptr<exvector> vp) const
+ex color::thiscontainer(std::unique_ptr<exvector> vp) const
{
- return color(representation_label, vp);
+ return color(representation_label, std::move(vp));
}
/** Given a vector iv3 of three indices and a vector iv2 of two indices that
@@ -335,7 +335,7 @@ bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exve
// T.a S T.a = 1/2 Tr(S) - 1/6 S
} else {
- exvector::iterator it = self + 1;
+ auto it = self + 1;
while (it != other) {
if (!is_a<color>(*it)) {
return false;
@@ -627,9 +627,9 @@ ex color_trace(const ex & e, const lst & rll)
{
// Convert list to set
std::set<unsigned char> rls;
- for (lst::const_iterator i = rll.begin(); i != rll.end(); ++i) {
- if (i->info(info_flags::nonnegint))
- rls.insert(ex_to<numeric>(*i).to_int());
+ for (const auto & elem : rll) {
+ if (elem.info(info_flags::nonnegint))
+ rls.insert(ex_to<numeric>(elem).to_int());
}
return color_trace(e, rls);
diff --git a/ginac/color.h b/ginac/color.h
index ebe2122..8784206 100644
--- a/ginac/color.h
+++ b/ginac/color.h
@@ -51,14 +51,14 @@ public:
// internal constructors
color(unsigned char rl, const exvector & v, bool discardable = false);
- color(unsigned char rl, std::auto_ptr<exvector> vp);
+ color(unsigned char rl, std::unique_ptr<exvector> vp);
// functions overriding virtual functions from base classes
protected:
ex eval_ncmul(const exvector & v) const;
bool match_same_type(const basic & other) const;
ex thiscontainer(const exvector & v) const;
- ex thiscontainer(std::auto_ptr<exvector> vp) const;
+ ex thiscontainer(std::unique_ptr<exvector> vp) const;
unsigned return_type() const { return return_types::noncommutative; }
tinfo_t return_type_tinfo() const { return color::return_type_tinfo_static+representation_label; }
diff --git a/ginac/constant.cpp b/ginac/constant.cpp
index 182d04f..92ddefc 100644
--- a/ginac/constant.cpp
+++ b/ginac/constant.cpp
@@ -46,7 +46,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(constant, basic,
// public
-constant::constant() : basic(&constant::tinfo_static), ef(0), serial(next_serial++), domain(domain::complex)
+constant::constant() : basic(&constant::tinfo_static), ef(nullptr), serial(next_serial++), domain(domain::complex)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
@@ -57,8 +57,8 @@ constant::constant() : basic(&constant::tinfo_static), ef(0), serial(next_serial
// public
-constant::constant(const std::string & initname, evalffunctype efun, const std::string & texname, unsigned dm)
- : basic(&constant::tinfo_static), name(initname), ef(efun), serial(next_serial++), domain(dm)
+constant::constant(std::string initname, evalffunctype efun, const std::string & texname, unsigned dm)
+ : basic(&constant::tinfo_static), name(std::move(initname)), ef(efun), serial(next_serial++), domain(dm)
{
if (texname.empty())
TeX_name = "\\mbox{" + name + "}";
@@ -67,8 +67,8 @@ constant::constant(const std::string & initname, evalffunctype efun, const std::
setflag(status_flags::evaluated | status_flags::expanded);
}
-constant::constant(const std::string & initname, const numeric & initnumber, const std::string & texname, unsigned dm)
- : basic(&constant::tinfo_static), name(initname), ef(0), number(initnumber), serial(next_serial++), domain(dm)
+constant::constant(std::string initname, const numeric & initnumber, const std::string & texname, unsigned dm)
+ : basic(&constant::tinfo_static), name(std::move(initname)), ef(nullptr), number(initnumber), serial(next_serial++), domain(dm)
{
if (texname.empty())
TeX_name = "\\mbox{" + name + "}";
@@ -164,7 +164,7 @@ bool constant::info(unsigned inf) const
ex constant::evalf(int level, PyObject* parent) const
{
- if (ef!=0) {
+ if (ef!=nullptr) {
return ef(serial, parent);
} else {
return number.evalf(level, parent);
diff --git a/ginac/constant.h b/ginac/constant.h
index 12f46a2..1ab66aa 100644
--- a/ginac/constant.h
+++ b/ginac/constant.h
@@ -44,13 +44,13 @@ class constant : public basic
// other constructors
public:
- constant(const std::string & initname, evalffunctype efun = 0, const std::string & texname = std::string(), unsigned domain = domain::complex);
- constant(const std::string & initname, const numeric & initnumber, const std::string & texname = std::string(), unsigned domain = domain::complex);
+ constant(std::string initname, evalffunctype efun = nullptr, const std::string & texname = std::string(), unsigned domain = domain::complex);
+ constant(std::string initname, const numeric & initnumber, const std::string & texname = std::string(), unsigned domain = domain::complex);
// functions overriding virtual functions from base classes
public:
bool info(unsigned inf) const;
- ex evalf(int level = 0, PyObject* parent=NULL) const;
+ ex evalf(int level = 0, PyObject* parent=nullptr) const;
bool is_polynomial(const ex & var) const;
ex conjugate() const;
ex real_part() const;
diff --git a/ginac/container.h b/ginac/container.h
index 05335e7..87c08fb 100644
--- a/ginac/container.h
+++ b/ginac/container.h
@@ -140,7 +140,7 @@ public:
protected:
// helpers
- static tinfo_t get_tinfo() { return NULL; }
+ static tinfo_t get_tinfo() { return nullptr; }
static unsigned get_default_flags() { return 0; }
static const char* get_open_delim() { return "("; }
static const char* get_close_delim() { return ")"; }
@@ -157,7 +157,7 @@ public:
this->seq = s;
}
- explicit container(std::auto_ptr<STLT> vp) : inherited(get_tinfo())
+ explicit container(std::unique_ptr<STLT> vp) : inherited(get_tinfo())
{
setflag(get_default_flags());
this->seq.swap(*vp);
@@ -372,8 +372,8 @@ public:
protected:
ex conjugate() const
{
- STLT *newcont = NULL;
- for (const_iterator i=this->seq.begin(); i!=this->seq.end(); ++i) {
+ STLT *newcont = nullptr;
+ for (auto i=this->seq.begin(); i!=this->seq.end(); ++i) {
if (newcont) {
newcont->push_back(i->conjugate());
continue;
@@ -384,7 +384,7 @@ protected:
}
newcont = new STLT;
this->reserve(*newcont, this->seq.size());
- for (const_iterator j=this->seq.begin(); j!=i; ++j) {
+ for (auto j=this->seq.begin(); j!=i; ++j) {
newcont->push_back(*j);
}
newcont->push_back(x);
@@ -401,9 +401,9 @@ protected:
{
STLT cont;
this->reserve(cont, nops());
- const_iterator b = begin();
- const_iterator e = end();
- for(const_iterator i=b; i!=e; ++i)
+ auto b = begin();
+ auto e = end();
+ for(auto i=b; i!=e; ++i)
cont.push_back(i->real_part());
return thiscontainer(cont);
}
@@ -412,9 +412,9 @@ protected:
{
STLT cont;
this->reserve(cont, nops());
- const_iterator b = begin();
- const_iterator e = end();
- for(const_iterator i=b; i!=e; ++i)
+ auto b = begin();
+ auto e = end();
+ for(auto i=b; i!=e; ++i)
cont.push_back(i->imag_part());
return thiscontainer(cont);
}
@@ -429,7 +429,7 @@ protected:
/** Similar to duplicate(), but with a preset sequence (which gets
* deleted). Must be overridden by derived classes. */
- virtual ex thiscontainer(std::auto_ptr<STLT> vp) const { return container(vp); }
+ virtual ex thiscontainer(std::unique_ptr<STLT> vp) const { return container(std::move(vp)); }
virtual void printseq(const print_context & c, const char* openbracket,
char delim, const char* closebracket,
@@ -445,7 +445,7 @@ private:
void unique_()
{
- typename STLT::iterator p = std::unique(this->seq.begin(), this->seq.end(), ex_is_equal());
+ auto p = std::unique(this->seq.begin(), this->seq.end(), ex_is_equal());
this->seq.erase(p, this->seq.end());
}
@@ -469,7 +469,7 @@ protected:
void do_print_python(const print_python & c, unsigned level) const;
void do_print_python_repr(const print_python_repr & c, unsigned level) const;
STLT evalchildren(int level) const;
- std::auto_ptr<STLT> subschildren(const exmap & m, unsigned options = 0) const;
+ std::unique_ptr<STLT> subschildren(const exmap & m, unsigned options = 0) const;
};
/** Default constructor */
@@ -485,11 +485,11 @@ container<C>::container(const archive_node &n, lst &sym_lst) : inherited(n, sym_
{
setflag(get_default_flags());
- archive_node::archive_node_cit first = n.find_first("seq");
- archive_node::archive_node_cit last = n.find_last("seq");
+ auto first = n.find_first("seq");
+ auto last = n.find_last("seq");
++last;
this->reserve(this->seq, last - first);
- for (archive_node::archive_node_cit i=first; i<last; ++i) {
+ for (auto i=first; i<last; ++i) {
ex e;
n.find_ex_by_loc(i, e, sym_lst);
this->seq.push_back(e);
@@ -508,7 +508,7 @@ template <template <class T, class = std::allocator<T> > class C>
void container<C>::archive(archive_node &n) const
{
inherited::archive(n);
- const_iterator i = this->seq.begin(), end = this->seq.end();
+ auto i = this->seq.begin(), end = this->seq.end();
while (i != end) {
n.add_ex("seq", *i);
++i;
@@ -529,7 +529,7 @@ void container<C>::do_print_tree(const print_tree & c, unsigned level) const
<< std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
<< ", nops=" << nops()
<< std::endl;
- const_iterator i = this->seq.begin(), end = this->seq.end();
+ auto i = this->seq.begin(), end = this->seq.end();
while (i != end) {
i->print(c, level + c.delta_indent);
++i;
@@ -555,7 +555,7 @@ ex container<C>::op(size_t i) const
{
GINAC_ASSERT(i < nops());
- const_iterator it = this->seq.begin();
+ auto it = this->seq.begin();
advance(it, i);
return *it;
}
@@ -566,7 +566,7 @@ ex & container<C>::let_op(size_t i)
GINAC_ASSERT(i < nops());
ensure_if_modifiable();
- typename STLT::iterator it = this->seq.begin();
+ auto it = this->seq.begin();
advance(it, i);
return *it;
}
@@ -591,9 +591,9 @@ ex container<C>::subs(const exmap & m, unsigned options) const
// f(x).subs(x==f^-1(x))
// -> f(f^-1(x)) [subschildren]
// -> x [eval] /* must not subs(x==f^-1(x))! */
- std::auto_ptr<STLT> vp = subschildren(m, options);
+ std::unique_ptr<STLT> vp = subschildren(m, options);
if (vp.get()) {
- ex result(thiscontainer(vp));
+ ex result(thiscontainer(std::move(vp)));
if (is_a<container<C> >(result))
return ex_to<basic>(result).subs_one_level(m, options);
else
@@ -613,7 +613,7 @@ int container<C>::compare_same_type(const basic & other) const
GINAC_ASSERT(is_a<container>(other));
const container & o = static_cast<const container &>(other);
- const_iterator it1 = this->seq.begin(), it1end = this->seq.end(),
+ auto it1 = this->seq.begin(), it1end = this->seq.end(),
it2 = o.seq.begin(), it2end = o.seq.end();
while (it1 != it1end && it2 != it2end) {
@@ -635,7 +635,7 @@ bool container<C>::is_equal_same_type(const basic & other) const
if (this->seq.size() != o.seq.size())
return false;
- const_iterator it1 = this->seq.begin(), it1end = this->seq.end(), it2 = o.seq.begin();
+ auto it1 = this->seq.begin(), it1end = this->seq.end(), it2 = o.seq.begin();
while (it1 != it1end) {
if (!it1->is_equal(*it2))
return false;
@@ -746,7 +746,7 @@ void container<C>::printseq(const print_context & c, const char* openbracket,
c.s << openbracket;
if (!this->seq.empty()) {
- const_iterator it = this->seq.begin(), itend = this->seq.end();
+ auto it = this->seq.begin(), itend = this->seq.end();
--itend;
while (it != itend) {
it->print(c, this_precedence);
@@ -772,7 +772,7 @@ typename container<C>::STLT container<C>::evalchildren(int level) const
this->reserve(s, this->seq.size());
--level;
- const_iterator it = this->seq.begin(), itend = this->seq.end();
+ auto it = this->seq.begin(), itend = this->seq.end();
while (it != itend) {
s.push_back(it->eval(level));
++it;
@@ -782,19 +782,19 @@ typename container<C>::STLT container<C>::evalchildren(int level) const
}
template <template <class T, class = std::allocator<T> > class C>
-std::auto_ptr<typename container<C>::STLT> container<C>::subschildren(const exmap & m, unsigned options) const
+std::unique_ptr<typename container<C>::STLT> container<C>::subschildren(const exmap & m, unsigned options) const
{
// returns a NULL pointer if nothing had to be substituted
// returns a pointer to a newly created STLT otherwise
// (and relinquishes responsibility for the STLT)
- const_iterator cit = this->seq.begin(), end = this->seq.end();
+ auto cit = this->seq.begin(), end = this->seq.end();
while (cit != end) {
const ex & subsed_ex = cit->subs(m, options);
if (!are_ex_trivially_equal(*cit, subsed_ex)) {
// copy first part of seq which hasn't changed
- std::auto_ptr<STLT> s(new STLT(this->seq.begin(), cit));
+ std::unique_ptr<STLT> s(new STLT(this->seq.begin(), cit));
this->reserve(*s, this->seq.size());
// insert changed element
@@ -807,13 +807,13 @@ std::auto_ptr<typename container<C>::STLT> container<C>::subschildren(const exma
++cit;
}
- return s;
+ return std::move(s);
}
++cit;
}
- return std::auto_ptr<STLT>(0); // nothing has changed
+ return std::unique_ptr<STLT>(nullptr); // nothing has changed
}
} // namespace GiNaC
diff --git a/ginac/ex.cpp b/ginac/ex.cpp
index 1ecbf9a..50cef0e 100644
--- a/ginac/ex.cpp
+++ b/ginac/ex.cpp
@@ -126,7 +126,7 @@ ex ex::subs(const lst & ls, const lst & lr, unsigned options) const
// Convert the lists to a map
exmap m;
- for (lst::const_iterator its = ls.begin(), itr = lr.begin(); its != ls.end(); ++its, ++itr) {
+ for (auto its = ls.begin(), itr = lr.begin(); its != ls.end(); ++its, ++itr) {
m.insert(std::make_pair(*its, *itr));
// Search for products and powers in the expressions to be substituted
@@ -165,8 +165,8 @@ ex ex::subs(const ex & e, unsigned options) const
// Argument is a list: convert it to a map
exmap m;
GINAC_ASSERT(is_a<lst>(e));
- for (lst::const_iterator it = ex_to<lst>(e).begin(); it != ex_to<lst>(e).end(); ++it) {
- ex r = *it;
+ for (auto r : ex_to<lst>(e)) {
+
if (!r.info(info_flags::relation_equal))
throw(std::invalid_argument("basic::subs(ex): argument must be a list of equations"));
const ex & s = r.op(0);
@@ -246,8 +246,8 @@ bool ex::is_polynomial(const ex & vars) const
{
if (is_a<lst>(vars)) {
const lst & varlst = ex_to<lst>(vars);
- for (lst::const_iterator i=varlst.begin(); i!=varlst.end(); ++i)
- if (!bp->is_polynomial(*i))
+ for (const auto & elem : varlst)
+ if (!bp->is_polynomial(elem))
return false;
return true;
}
diff --git a/ginac/ex.h b/ginac/ex.h
index d121632..52a9b3c 100644
--- a/ginac/ex.h
+++ b/ginac/ex.h
@@ -127,7 +127,7 @@ public:
// evaluation
ex eval(int level = 0) const { return bp->eval(level); }
- ex evalf(int level = 0, PyObject* parent=NULL) const
+ ex evalf(int level = 0, PyObject* parent=nullptr) const
{ return bp->evalf(level, parent); }
ex evalm() const { return bp->evalm(); }
ex eval_ncmul(const exvector & v) const { return bp->eval_ncmul(v); }
@@ -385,7 +385,7 @@ public:
const_iterator() throw() {}
private:
- const_iterator(const ex &e_, size_t i_) throw() : e(e_), i(i_) {}
+ const_iterator(ex e_, size_t i_) throw() : e(std::move(e_)), i(i_) {}
public:
// This should return an ex&, but that would be a reference to a
@@ -397,9 +397,9 @@ public:
// This should return an ex*, but that would be a pointer to a
// temporary value
- std::auto_ptr<ex> operator->() const
+ std::unique_ptr<ex> operator->() const
{
- return std::auto_ptr<ex>(new ex(operator*()));
+ return std::unique_ptr<ex>(new ex(operator*()));
}
ex operator[](difference_type n) const
@@ -503,7 +503,7 @@ protected:
namespace internal {
struct _iter_rep {
- _iter_rep(const ex &e_, size_t i_, size_t i_end_) : e(e_), i(i_), i_end(i_end_) {}
+ _iter_rep(ex e_, size_t i_, size_t i_end_) : e(std::move(e_)), i(i_), i_end(i_end_) {}
bool operator==(const _iter_rep &other) const throw()
{
@@ -782,7 +782,7 @@ inline ex collect(const ex & thisex, const ex & s, bool distributed = false)
inline ex eval(const ex & thisex, int level = 0)
{ return thisex.eval(level); }
-inline ex evalf(const ex & thisex, int level = 0, PyObject* parent=NULL)
+inline ex evalf(const ex & thisex, int level = 0, PyObject* parent=nullptr)
{ return thisex.evalf(level, parent); }
inline ex evalm(const ex & thisex)
diff --git a/ginac/expair.h b/ginac/expair.h
index 6767e44..9c651bf 100644
--- a/ginac/expair.h
+++ b/ginac/expair.h
@@ -40,7 +40,7 @@ public:
expair() : rest(0), coeff(1) { }
/** Construct an expair from two ex. */
- expair(const ex & r, const ex & c) : rest(r), coeff(c)
+ expair(ex r, ex c) : rest(std::move(r)), coeff(std::move(c))
{
GINAC_ASSERT(is_exactly_a<numeric>(coeff));
}
diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp
index fd78764..5005386 100644
--- a/ginac/expairseq.cpp
+++ b/ginac/expairseq.cpp
@@ -122,16 +122,16 @@ expairseq::expairseq(const exvector &v) : inherited(&expairseq::tinfo_static)
GINAC_ASSERT(is_canonical());
}
-expairseq::expairseq(const epvector &v, const ex &oc, bool do_index_renaming)
- : inherited(&expairseq::tinfo_static), overall_coeff(oc)
+expairseq::expairseq(const epvector &v, ex oc, bool do_index_renaming)
+ : inherited(&expairseq::tinfo_static), overall_coeff(std::move(oc))
{
GINAC_ASSERT(is_a<numeric>(oc));
construct_from_epvector(v, do_index_renaming);
GINAC_ASSERT(is_canonical());
}
-expairseq::expairseq(std::auto_ptr<epvector> vp, const ex &oc, bool do_index_renaming)
- : inherited(&expairseq::tinfo_static), overall_coeff(oc)
+expairseq::expairseq(std::unique_ptr<epvector> vp, ex oc, bool do_index_renaming)
+ : inherited(&expairseq::tinfo_static), overall_coeff(std::move(oc))
{
GINAC_ASSERT(vp.get()!=0);
GINAC_ASSERT(is_a<numeric>(oc));
@@ -148,12 +148,12 @@ expairseq::expairseq(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst
, hashtabsize(0)
#endif
{
- archive_node::archive_node_cit first = n.find_first("rest");
- archive_node::archive_node_cit last = n.find_last("coeff");
+ auto first = n.find_first("rest");
+ auto last = n.find_last("coeff");
++last;
seq.reserve((last-first)/2);
- for (archive_node::archive_node_cit loc = first; loc < last;) {
+ for (auto loc = first; loc < last;) {
ex rest;
ex coeff;
n.find_ex_by_loc(loc++, rest, sym_lst);
@@ -170,7 +170,7 @@ expairseq::expairseq(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst
void expairseq::archive(archive_node &n) const
{
inherited::archive(n);
- epvector::const_iterator i = seq.begin(), iend = seq.end();
+ auto i = seq.begin(), iend = seq.end();
while (i != iend) {
n.add_ex("rest", i->rest);
n.add_ex("coeff", i->coeff);
@@ -278,8 +278,8 @@ bool expairseq::info(unsigned inf) const
return true;
else if (flags & status_flags::has_no_indices)
return false;
- for (epvector::const_iterator i = seq.begin(); i != seq.end(); ++i) {
- if (i->rest.info(info_flags::has_indices)) {
+ for (const auto & elem : seq) {
+ if (elem.rest.info(info_flags::has_indices)) {
this->setflag(status_flags::has_indices);
this->clearflag(status_flags::has_no_indices);
return true;
@@ -320,24 +320,24 @@ ex expairseq::stable_op(size_t i) const
ex expairseq::map(map_function &f) const
{
- std::auto_ptr<epvector> v(new epvector);
+ std::unique_ptr<epvector> v(new epvector);
v->reserve(seq.size()+1);
- epvector::const_iterator cit = seq.begin(), last = seq.end();
+ auto cit = seq.begin(), last = seq.end();
while (cit != last) {
v->push_back(split_ex_to_pair(f(recombine_pair_to_ex(*cit))));
++cit;
}
if (overall_coeff_equals_default())
- return thisexpairseq(v, default_overall_coeff(), true);
+ return thisexpairseq(std::move(v), default_overall_coeff(), true);
else {
ex newcoeff = f(overall_coeff);
if(is_a<numeric>(newcoeff))
- return thisexpairseq(v, newcoeff, true);
+ return thisexpairseq(std::move(v), newcoeff, true);
else {
v->push_back(split_ex_to_pair(newcoeff));
- return thisexpairseq(v, default_overall_coeff(), true);
+ return thisexpairseq(std::move(v), default_overall_coeff(), true);
}
}
}
@@ -348,17 +348,17 @@ ex expairseq::eval(int level) const
if ((level==1) && (flags &status_flags::evaluated))
return *this;
- std::auto_ptr<epvector> vp = evalchildren(level);
- if (vp.get() == 0)
+ std::unique_ptr<epvector> vp = evalchildren(level);
+ if (vp.get() == nullptr)
return this->hold();
- return (new expairseq(vp, overall_coeff))->setflag(status_flags::dynallocated | status_flags::evaluated);
+ return (new expairseq(std::move(vp), overall_coeff))->setflag(status_flags::dynallocated | status_flags::evaluated);
}
epvector* conjugateepvector(const epvector&epv)
{
- epvector *newepv = 0;
- for (epvector::const_iterator i=epv.begin(); i!=epv.end(); ++i) {
+ epvector *newepv = nullptr;
+ for (auto i=epv.begin(); i!=epv.end(); ++i) {
if(newepv) {
newepv->push_back(i->conjugate());
continue;
@@ -369,7 +369,7 @@ epvector* conjugateepvector(const epvector&epv)
}
newepv = new epvector;
newepv->reserve(epv.size());
- for (epvector::const_iterator j=epv.begin(); j!=i; ++j) {
+ for (auto j=epv.begin(); j!=i; ++j) {
newepv->push_back(*j);
}
newepv->push_back(x);
@@ -429,16 +429,16 @@ bool expairseq::match(const ex & pattern, lst & repl_lst) const
ex p = ex_to<expairseq>(pattern).stable_op(i);
if (has_global_wildcard && p.is_equal(global_wildcard))
continue;
- exvector::iterator it = ops.begin(), itend = ops.end();
+ auto it = ops.begin(), itend = ops.end();
while (it != itend) {
- lst::const_iterator last_el = repl_lst.end();
+ auto last_el = repl_lst.end();
--last_el;
if (it->match(p, tmp_repl)) {
ops.erase(it);
goto found;
}
while(true) {
- lst::const_iterator next_el = last_el;
+ auto next_el = last_el;
++next_el;
if(next_el == repl_lst.end())
break;
@@ -457,12 +457,12 @@ found: ;
// it has already been matched before, in which case the matches
// must be equal)
size_t num = ops.size();
- std::auto_ptr<epvector> vp(new epvector);
+ std::unique_ptr<epvector> vp(new epvector);
vp->reserve(num);
for (size_t i=0; i<num; i++)
vp->push_back(split_ex_to_pair(ops[i]));
- ex rest = thisexpairseq(vp, default_overall_coeff());
- for (lst::const_iterator it = tmp_repl.begin(); it != tmp_repl.end(); ++it) {
+ ex rest = thisexpairseq(std::move(vp), default_overall_coeff());
+ for (auto it = tmp_repl.begin(); it != tmp_repl.end(); ++it) {
if (it->op(0).is_equal(global_wildcard)) {
if (rest.is_equal(it->op(1))) {
repl_lst = tmp_repl;
@@ -491,9 +491,9 @@ found: ;
ex expairseq::subs(const exmap & m, unsigned options) const
{
- std::auto_ptr<epvector> vp = subschildren(m, options);
+ std::unique_ptr<epvector> vp = subschildren(m, options);
if (vp.get())
- return ex_to<basic>(thisexpairseq(vp, overall_coeff, (options & subs_options::no_index_renaming) == 0));
+ return ex_to<basic>(thisexpairseq(std::move(vp), overall_coeff, (options & subs_options::no_index_renaming) == 0));
else if ((options & subs_options::algebraic) && is_exactly_a<mul>(*this))
return static_cast<const mul *>(this)->algebraic_subs_mul(m, options);
else
@@ -504,8 +504,8 @@ ex expairseq::subs(const exmap & m, unsigned options) const
numeric expairseq::calc_total_degree() const
{
numeric deg = 0;
- epvector::const_iterator cit = seq.begin();
- epvector::const_iterator last = seq.end();
+ auto cit = seq.begin();
+ auto last = seq.end();
for (; (cit!=last); ++cit) {
deg = deg.add(ex_to<numeric>(cit->coeff));
}
@@ -534,10 +534,10 @@ int expairseq::compare_same_type(const basic &other) const
if (hashtabsize==0) {
#endif // EXPAIRSEQ_USE_HASHTAB
- epvector::const_iterator cit1 = seq.begin();
- epvector::const_iterator cit2 = o.seq.begin();
- epvector::const_iterator last1 = seq.end();
- epvector::const_iterator last2 = o.seq.end();
+ auto cit1 = seq.begin();
+ auto cit2 = o.seq.begin();
+ auto last1 = seq.end();
+ auto last2 = o.seq.end();
for (; (cit1!=last1)&&(cit2!=last2); ++cit1, ++cit2) {
cmpval = (*cit1).compare(*cit2);
@@ -603,9 +603,9 @@ bool expairseq::is_equal_same_type(const basic &other) const
if (hashtabsize==0) {
#endif // EXPAIRSEQ_USE_HASHTAB
- epvector::const_iterator cit1 = seq.begin();
- epvector::const_iterator cit2 = o.seq.begin();
- epvector::const_iterator last1 = seq.end();
+ auto cit1 = seq.begin();
+ auto cit2 = o.seq.begin();
+ auto last1 = seq.end();
while (cit1!=last1) {
if (!(*cit1).is_equal(*cit2)) return false;
@@ -650,7 +650,7 @@ unsigned expairseq::return_type() const
unsigned expairseq::calchash() const
{
unsigned v = golden_ratio_hash((p_int)this->tinfo());
- epvector::const_iterator i = seq.begin();
+ auto i = seq.begin();
const epvector::const_iterator end = seq.end();
while (i != end) {
v ^= i->rest.gethash();
@@ -675,9 +675,9 @@ unsigned expairseq::calchash() const
ex expairseq::expand(unsigned options) const
{
- std::auto_ptr<epvector> vp = expandchildren(options);
+ std::unique_ptr<epvector> vp = expandchildren(options);
if (vp.get())
- return thisexpairseq(vp, overall_coeff);
+ return thisexpairseq(std::move(vp), overall_coeff);
else {
// The terms have not changed, so it is safe to declare this expanded
return (options == 0) ? setflag(status_flags::expanded) : *this;
@@ -703,9 +703,9 @@ ex expairseq::thisexpairseq(const epvector &v, const ex &oc, bool do_index_renam
return expairseq(v, oc, do_index_renaming);
}
-ex expairseq::thisexpairseq(std::auto_ptr<epvector> vp, const ex &oc, bool do_index_renaming) const
+ex expairseq::thisexpairseq(std::unique_ptr<epvector> vp, const ex &oc, bool do_index_renaming) const
{
- return expairseq(vp, oc, do_index_renaming);
+ return expairseq(std::move(vp), oc, do_index_renaming);
}
void expairseq::printpair(const print_context & c, const expair & p, unsigned upper_precedence) const
@@ -935,10 +935,10 @@ void expairseq::construct_from_2_expairseq(const expairseq &s1,
combine_overall_coeff(s1.overall_coeff);
combine_overall_coeff(s2.overall_coeff);
- epvector::const_iterator first1 = s1.seq.begin();
- epvector::const_iterator last1 = s1.seq.end();
- epvector::const_iterator first2 = s2.seq.begin();
- epvector::const_iterator last2 = s2.seq.end();
+ auto first1 = s1.seq.begin();
+ auto last1 = s1.seq.end();
+ auto first2 = s2.seq.begin();
+ auto last2 = s2.seq.end();
seq.reserve(s1.seq.size()+s2.seq.size());
@@ -1001,8 +1001,8 @@ void expairseq::construct_from_expairseq_ex(const expairseq &s,
return;
}
- epvector::const_iterator first = s.seq.begin();
- epvector::const_iterator last = s.seq.end();
+ auto first = s.seq.begin();
+ auto last = s.seq.end();
expair p = split_ex_to_pair(e);
// infinity evaluation is handled in eval()
// do not let infinities cancel each other here
@@ -1132,7 +1132,7 @@ void expairseq::make_flat(const exvector &v, bool hold)
ex newfactor = mf.handle_factor(*cit, _ex1);
const expairseq &subseqref = ex_to<expairseq>(newfactor);
combine_overall_coeff(subseqref.overall_coeff);
- epvector::const_iterator cit_s = subseqref.seq.begin();
+ auto cit_s = subseqref.seq.begin();
while (cit_s!=subseqref.seq.end()) {
seq.push_back(*cit_s);
++cit_s;
@@ -1187,7 +1187,7 @@ void expairseq::make_flat(const epvector &v, bool do_index_renaming)
const expairseq &subseqref = ex_to<expairseq>(newrest);
combine_overall_coeff(ex_to<numeric>(subseqref.overall_coeff),
ex_to<numeric>(cit->coeff));
- epvector::const_iterator cit_s = subseqref.seq.begin();
+ auto cit_s = subseqref.seq.begin();
while (cit_s!=subseqref.seq.end()) {
seq.push_back(expair(cit_s->rest,
ex_to<numeric>(cit_s->coeff).mul_dyn(ex_to<numeric>(cit->coeff))));
@@ -1228,10 +1228,10 @@ void expairseq::combine_same_terms_sorted_seq()
bool needs_further_processing = false;
- epvector::iterator itin1 = seq.begin();
- epvector::iterator itin2 = itin1+1;
- epvector::iterator itout = itin1;
- epvector::iterator last = seq.end();
+ auto itin1 = seq.begin();
+ auto itin2 = itin1+1;
+ auto itout = itin1;
+ auto last = seq.end();
// must_copy will be set to true the first time some combination is
// possible from then on the sequence has changed and must be compacted
bool must_copy = false;
@@ -1585,8 +1585,8 @@ bool expairseq::is_canonical() const
if (hashtabsize > 0) return 1; // not canoncalized
#endif // EXPAIRSEQ_USE_HASHTAB
- epvector::const_iterator it = seq.begin(), itend = seq.end();
- epvector::const_iterator it_last = it;
+ auto it = seq.begin(), itend = seq.end();
+ auto it_last = it;
for (++it; it!=itend; it_last=it, ++it) {
if (!(it_last->is_less(*it) || it_last->is_equal(*it))) {
if (!is_exactly_a<numeric>(it_last->rest) ||
@@ -1618,20 +1618,20 @@ bool expairseq::is_canonical() const
* @see expairseq::expand()
* @return pointer to epvector containing expanded pairs or zero pointer,
* if no members were changed. */
-std::auto_ptr<epvector> expairseq::expandchildren(unsigned options) const
+std::unique_ptr<epvector> expairseq::expandchildren(unsigned options) const
{
const epvector::const_iterator last = seq.end();
- epvector::const_iterator cit = seq.begin();
+ auto cit = seq.begin();
while (cit!=last) {
const ex &expanded_ex = cit->rest.expand(options);
if (!are_ex_trivially_equal(cit->rest,expanded_ex)) {
// something changed, copy seq, eval and return it
- std::auto_ptr<epvector> s(new epvector);
+ std::unique_ptr<epvector> s(new epvector);
s->reserve(seq.size());
// copy parts of seq which are known not to have changed
- epvector::const_iterator cit2 = seq.begin();
+ auto cit2 = seq.begin();
while (cit2!=cit) {
s->push_back(*cit2);
++cit2;
@@ -1648,12 +1648,12 @@ std::auto_ptr<epvector> expairseq::expandchildren(unsigned options) const
cit2->coeff));
++cit2;
}
- return s;
+ return std::move(s);
}
++cit;
}
- return std::auto_ptr<epvector>(0); // signalling nothing has changed
+ return std::unique_ptr<epvector>(nullptr); // signalling nothing has changed
}
@@ -1662,31 +1662,31 @@ std::auto_ptr<epvector> expairseq::expandchildren(unsigned options) const
* @see expairseq::eval()
* @return pointer to epvector containing evaluated pairs or zero pointer,
* if no members were changed. */
-std::auto_ptr<epvector> expairseq::evalchildren(int level) const
+std::unique_ptr<epvector> expairseq::evalchildren(int level) const
{
// returns a NULL pointer if nothing had to be evaluated
// returns a pointer to a newly created epvector otherwise
// (which has to be deleted somewhere else)
if (level==1)
- return std::auto_ptr<epvector>(0);
+ return std::unique_ptr<epvector>(nullptr);
if (level == -max_recursion_level)
throw(std::runtime_error("max recursion level reached"));
--level;
- epvector::const_iterator last = seq.end();
- epvector::const_iterator cit = seq.begin();
+ auto last = seq.end();
+ auto cit = seq.begin();
while (cit!=last) {
const ex &evaled_ex = cit->rest.eval(level);
if (!are_ex_trivially_equal(cit->rest,evaled_ex)) {
// something changed, copy seq, eval and return it
- std::auto_ptr<epvector> s(new epvector);
+ std::unique_ptr<epvector> s(new epvector);
s->reserve(seq.size());
// copy parts of seq which are known not to have changed
- epvector::const_iterator cit2=seq.begin();
+ auto cit2=seq.begin();
while (cit2!=cit) {
s->push_back(*cit2);
++cit2;
@@ -1703,12 +1703,12 @@ std::auto_ptr<epvector> expairseq::evalchildren(int level) const
cit2->coeff));
++cit2;
}
- return s;
+ return std::move(s);
}
++cit;
}
- return std::auto_ptr<epvector>(0); // signalling nothing has changed
+ return std::unique_ptr<epvector>(nullptr); // signalling nothing has changed
}
/** Member-wise substitute in this sequence.
@@ -1716,7 +1716,7 @@ std::auto_ptr<epvector> expairseq::evalchildren(int level) const
* @see expairseq::subs()
* @return pointer to epvector containing pairs after application of subs,
* or NULL pointer if no members were changed. */
-std::auto_ptr<epvector> expairseq::subschildren(const exmap & m, unsigned options) const
+std::unique_ptr<epvector> expairseq::subschildren(const exmap & m, unsigned options) const
{
// When any of the objects to be substituted is a product or power
// we have to recombine the pairs because the numeric coefficients may
@@ -1724,8 +1724,8 @@ std::auto_ptr<epvector> expairseq::subschildren(const exmap & m, unsigned option
if (!(options & (subs_options::pattern_is_product | subs_options::pattern_is_not_product))) {
// Search the list of substitutions and cache our findings
- for (exmap::const_iterator it = m.begin(); it != m.end(); ++it) {
- if (is_exactly_a<mul>(it->first) || is_exactly_a<power>(it->first)) {
+ for (const auto & elem : m) {
+ if (is_exactly_a<mul>(elem.first) || is_exactly_a<power>(elem.first)) {
options |= subs_options::pattern_is_product;
break;
}
@@ -1737,7 +1737,7 @@ std::auto_ptr<epvector> expairseq::subschildren(const exmap & m, unsigned option
if (options & subs_options::pattern_is_product) {
// Substitute in the recombined pairs
- epvector::const_iterator cit = seq.begin(), last = seq.end();
+ auto cit = seq.begin(), last = seq.end();
while (cit != last) {
const ex &orig_ex = recombine_pair_to_ex(*cit);
@@ -1745,7 +1745,7 @@ std::auto_ptr<epvector> expairseq::subschildren(const exmap & m, unsigned option
if (!are_ex_trivially_equal(orig_ex, subsed_ex)) {
// Something changed, copy seq, subs and return it
- std::auto_ptr<epvector> s(new epvector);
+ std::unique_ptr<epvector> s(new epvector);
s->reserve(seq.size());
// Copy parts of seq which are known not to have changed
@@ -1760,7 +1760,7 @@ std::auto_ptr<epvector> expairseq::subschildren(const exmap & m, unsigned option
s->push_back(split_ex_to_pair(recombine_pair_to_ex(*cit).subs(m, options)));
++cit;
}
- return s;
+ return std::move(s);
}
++cit;
@@ -1769,14 +1769,14 @@ std::auto_ptr<epvector> expairseq::subschildren(const exmap & m, unsigned option
} else {
// Substitute only in the "rest" part of the pairs
- epvector::const_iterator cit = seq.begin(), last = seq.end();
+ auto cit = seq.begin(), last = seq.end();
while (cit != last) {
const ex &subsed_ex = cit->rest.subs(m, options);
if (!are_ex_trivially_equal(cit->rest, subsed_ex)) {
// Something changed, copy seq, subs and return it
- std::auto_ptr<epvector> s(new epvector);
+ std::unique_ptr<epvector> s(new epvector);
s->reserve(seq.size());
// Copy parts of seq which are known not to have changed
@@ -1791,7 +1791,7 @@ std::auto_ptr<epvector> expairseq::subschildren(const exmap & m, unsigned option
s->push_back(combine_ex_with_coeff_to_pair(cit->rest.subs(m, options), cit->coeff));
++cit;
}
- return s;
+ return std::move(s);
}
++cit;
@@ -1799,7 +1799,7 @@ std::auto_ptr<epvector> expairseq::subschildren(const exmap & m, unsigned option
}
// Nothing has changed
- return std::auto_ptr<epvector>(0);
+ return std::unique_ptr<epvector>(nullptr);
}
diff --git a/ginac/expairseq.h b/ginac/expairseq.h
index 219dfa1..71a8de1 100644
--- a/ginac/expairseq.h
+++ b/ginac/expairseq.h
@@ -73,8 +73,8 @@ class expairseq : public basic
public:
expairseq(const ex & lh, const ex & rh);
expairseq(const exvector & v);
- expairseq(const epvector & v, const ex & oc, bool do_index_renaming = false);
- expairseq(std::auto_ptr<epvector>, const ex & oc, bool do_index_renaming = false);
+ expairseq(const epvector & v, ex oc, bool do_index_renaming = false);
+ expairseq(std::unique_ptr<epvector>, ex oc, bool do_index_renaming = false);
// functions overriding virtual functions from base classes
public:
@@ -101,7 +101,7 @@ protected:
// new virtual functions which can be overridden by derived classes
protected:
virtual ex thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming = false) const;
- virtual ex thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc, bool do_index_renaming = false) const;
+ virtual ex thisexpairseq(std::unique_ptr<epvector> vp, const ex & oc, bool do_index_renaming = false) const;
virtual void printseq(const print_context & c, char delim,
unsigned this_precedence,
unsigned upper_precedence) const;
@@ -158,9 +158,9 @@ protected:
epvector::const_iterator last_non_zero);
#endif // EXPAIRSEQ_USE_HASHTAB
bool is_canonical() const;
- std::auto_ptr<epvector> expandchildren(unsigned options) const;
- std::auto_ptr<epvector> evalchildren(int level) const;
- std::auto_ptr<epvector> subschildren(const exmap & m, unsigned options = 0) const;
+ std::unique_ptr<epvector> expandchildren(unsigned options) const;
+ std::unique_ptr<epvector> evalchildren(int level) const;
+ std::unique_ptr<epvector> subschildren(const exmap & m, unsigned options = 0) const;
// member variables
@@ -189,16 +189,16 @@ class make_flat_inserter
{
if (!do_renaming)
return;
- for (epvector::const_iterator i=epv.begin(); i!=epv.end(); ++i)
- if(are_ex_trivially_equal(i->coeff, 1))
- combine_indices(i->rest.get_free_indices());
+ for (const auto & elem : epv)
+ if(are_ex_trivially_equal(elem.coeff, 1))
+ combine_indices(elem.rest.get_free_indices());
}
make_flat_inserter(const exvector &v, bool b): do_renaming(b)
{
if (!do_renaming)
return;
- for (exvector::const_iterator i=v.begin(); i!=v.end(); ++i)
- combine_indices(i->get_free_indices());
+ for (const auto & elem : v)
+ combine_indices(elem.get_free_indices());
}
ex handle_factor(const ex &x, const ex &coeff)
{
diff --git a/ginac/fderivative.cpp b/ginac/fderivative.cpp
index e84c2f8..abf2cdc 100644
--- a/ginac/fderivative.cpp
+++ b/ginac/fderivative.cpp
@@ -54,12 +54,12 @@ fderivative::fderivative(unsigned ser, unsigned param, const exvector & args) :
tinfo_key = &fderivative::tinfo_static;
}
-fderivative::fderivative(unsigned ser, const paramset & params, const exvector & args) : function(ser, args), parameter_set(params)
+fderivative::fderivative(unsigned ser, paramset params, const exvector & args) : function(ser, args), parameter_set(std::move(params))
{
tinfo_key = &fderivative::tinfo_static;
}
-fderivative::fderivative(unsigned ser, const paramset & params, std::auto_ptr<exvector> vp) : function(ser, vp), parameter_set(params)
+fderivative::fderivative(unsigned ser, paramset params, std::unique_ptr<exvector> vp) : function(ser, std::move(vp)), parameter_set(std::move(params))
{
tinfo_key = &fderivative::tinfo_static;
}
@@ -84,7 +84,7 @@ fderivative::fderivative(const archive_node &n, lst &sym_lst) : inherited(n, sym
void fderivative::archive(archive_node &n) const
{
inherited::archive(n);
- paramset::const_iterator i = parameter_set.begin(), end = parameter_set.end();
+ auto i = parameter_set.begin(), end = parameter_set.end();
while (i != end) {
n.add_unsigned("param", *i);
++i;
@@ -140,7 +140,7 @@ void fderivative::do_print(const print_context & c, unsigned level) const
void fderivative::do_print_csrc(const print_csrc & c, unsigned level) const
{
c.s << "D_";
- paramset::const_iterator i = parameter_set.begin(), end = parameter_set.end();
+ auto i = parameter_set.begin(), end = parameter_set.end();
--end;
while (i != end)
c.s << *i++ << "_";
@@ -155,13 +155,13 @@ void fderivative::do_print_tree(const print_tree & c, unsigned level) const
<< std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
<< ", nops=" << nops()
<< ", params=";
- paramset::const_iterator i = parameter_set.begin(), end = parameter_set.end();
+ auto i = parameter_set.begin(), end = parameter_set.end();
--end;
while (i != end)
c.s << *i++ << ",";
c.s << *i << std::endl;
- for (size_t i=0; i<seq.size(); ++i)
- seq[i].print(c, level + c.delta_indent);
+ for (auto & elem : seq)
+ elem.print(c, level + c.delta_indent);
c.s << std::string(level + c.delta_indent, ' ') << "=====" << std::endl;
}
@@ -202,9 +202,9 @@ ex fderivative::thiscontainer(const exvector & v) const
return fderivative(serial, parameter_set, v);
}
-ex fderivative::thiscontainer(std::auto_ptr<exvector> vp) const
+ex fderivative::thiscontainer(std::unique_ptr<exvector> vp) const
{
- return fderivative(serial, parameter_set, vp);
+ return fderivative(serial, parameter_set, std::move(vp));
}
/** Implementation of ex::diff() for derivatives. It applies the chain rule.
@@ -260,10 +260,9 @@ unsigned fderivative::calchash() const
// FNV hash with custom prime and initial value
unsigned h = 2166136285;
- for (paramset::const_iterator i = parameter_set.begin(),
- end = parameter_set.end(); i != end; ++i) {
- h = ( h * 2097287 ) ^ (*i-prev);
- prev = *i;
+ for (const auto & elem : parameter_set) {
+ h = ( h * 2097287 ) ^ (elem-prev);
+ prev = elem;
}
res=h^res;
diff --git a/ginac/fderivative.h b/ginac/fderivative.h
index 184703f..66a7e87 100644
--- a/ginac/fderivative.h
+++ b/ginac/fderivative.h
@@ -55,19 +55,19 @@ public:
* @param ser Serial number of function
* @param params Set of numbers of parameters with respect to which to take the derivative
* @param args Arguments of derivative function */
- fderivative(unsigned ser, const paramset & params, const exvector & args);
+ fderivative(unsigned ser, paramset params, const exvector & args);
// internal constructors
- fderivative(unsigned ser, const paramset & params, std::auto_ptr<exvector> vp);
+ fderivative(unsigned ser, paramset params, std::unique_ptr<exvector> vp);
// functions overriding virtual functions from base classes
public:
void print(const print_context & c, unsigned level = 0) const;
ex eval(int level = 0) const;
- ex evalf(int level = 0, PyObject* parent=NULL) const;
+ ex evalf(int level = 0, PyObject* parent=nullptr) const;
ex series(const relational & r, int order, unsigned options = 0) const;
ex thiscontainer(const exvector & v) const;
- ex thiscontainer(std::auto_ptr<exvector> vp) const;
+ ex thiscontainer(std::unique_ptr<exvector> vp) const;
paramset get_parameter_set() const { return parameter_set; };
unsigned calchash() const;
diff --git a/ginac/function.cpp b/ginac/function.cpp
index e3ef97f..0e08feb 100644
--- a/ginac/function.cpp
+++ b/ginac/function.cpp
@@ -80,8 +80,8 @@ void function_options::initialize()
set_name("unnamed_function", "\\mbox{unnamed}");
nparams = 0;
eval_f = real_part_f = imag_part_f = conjugate_f = derivative_f
- = power_f = series_f = 0;
- evalf_f = 0;
+ = power_f = series_f = nullptr;
+ evalf_f = nullptr;
evalf_params_first = true;
apply_chain_rule = true;
use_return_type = false;
@@ -513,7 +513,7 @@ function::function(unsigned ser, const ex & param1, const ex & param2, const ex
// end of generated lines
-function::function(unsigned ser, const exprseq & es) : exprseq(es), serial(ser)
+function::function(unsigned ser, exprseq es) : exprseq(std::move(es)), serial(ser)
{
tinfo_key = &function::tinfo_static;
@@ -528,8 +528,8 @@ function::function(unsigned ser, const exvector & v, bool discardable)
tinfo_key = &function::tinfo_static;
}
-function::function(unsigned ser, std::auto_ptr<exvector> vp)
- : exprseq(vp), serial(ser)
+function::function(unsigned ser, std::unique_ptr<exvector> vp)
+ : exprseq(std::move(vp)), serial(ser)
{
tinfo_key = &function::tinfo_static;
}
@@ -674,7 +674,7 @@ void function::print(const print_context & c, unsigned level) const
next_context:
unsigned id = pc_info->options.get_id();
- if (id >= pdt.size() || pdt[id] == NULL) {
+ if (id >= pdt.size() || pdt[id] == nullptr) {
// Method not found, try parent print_context class
const print_context_class_info *parent_pc_info = pc_info->get_parent();
@@ -692,8 +692,8 @@ next_context:
<< ", nops=" << nops()
<< std::endl;
unsigned delta_indent = static_cast<const print_tree &>(c).delta_indent;
- for (size_t i=0; i<seq.size(); ++i)
- seq[i].print(c, level + delta_indent);
+ for (auto & elem : seq)
+ elem.print(c, level + delta_indent);
c.s << std::string(level + delta_indent, ' ') << "=====" << std::endl;
} else if (is_a<print_csrc>(c)) {
@@ -772,7 +772,7 @@ ex function::eval(int level) const
}
}
- if (opt.eval_f==0) {
+ if (opt.eval_f==nullptr) {
return this->hold();
}
@@ -842,14 +842,14 @@ ex function::evalf(int level, PyObject* kwds) const
else {
eseq.reserve(seq.size());
--level;
- exvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
while (it != itend) {
eseq.push_back(it->evalf(level, kwds));
++it;
}
}
- if (opt.evalf_f==0) {
+ if (opt.evalf_f==nullptr) {
return function(serial,eseq).hold();
}
current_serial = serial;
@@ -908,9 +908,9 @@ ex function::thiscontainer(const exvector & v) const
return function(serial, v);
}
-ex function::thiscontainer(std::auto_ptr<exvector> vp) const
+ex function::thiscontainer(std::unique_ptr<exvector> vp) const
{
- return function(serial, vp);
+ return function(serial, std::move(vp));
}
/** Implementation of ex::series for functions.
@@ -920,7 +920,7 @@ ex function::series(const relational & r, int order, unsigned options) const
GINAC_ASSERT(serial<registered_functions().size());
const function_options &opt = registered_functions()[serial];
- if (opt.series_f==0) {
+ if (opt.series_f==nullptr) {
return basic::series(r, order);
}
ex res;
@@ -1023,7 +1023,7 @@ ex function::conjugate() const
GINAC_ASSERT(serial<registered_functions().size());
const function_options & opt = registered_functions()[serial];
- if (opt.conjugate_f==0) {
+ if (opt.conjugate_f==nullptr) {
return conjugate_function(*this).hold();
}
@@ -1070,7 +1070,7 @@ ex function::real_part() const
GINAC_ASSERT(serial<registered_functions().size());
const function_options & opt = registered_functions()[serial];
- if (opt.real_part_f==0)
+ if (opt.real_part_f==nullptr)
return basic::real_part();
if (opt.python_func & function_options::real_part_python_f) {
@@ -1114,7 +1114,7 @@ ex function::imag_part() const
GINAC_ASSERT(serial<registered_functions().size());
const function_options & opt = registered_functions()[serial];
- if (opt.imag_part_f==0)
+ if (opt.imag_part_f==nullptr)
return basic::imag_part();
if (opt.python_func & function_options::imag_part_python_f) {
@@ -1171,7 +1171,7 @@ ex function::derivative(const symbol & s) const
// Check if we need to apply chain rule
if (!opt.apply_chain_rule) {
- if (opt.derivative_f == NULL)
+ if (opt.derivative_f == nullptr)
throw(std::runtime_error("function::derivative(): custom derivative function must be defined"));
if (opt.python_func & function_options::derivative_python_f) {
@@ -1329,7 +1329,7 @@ ex function::pderivative(unsigned diff_param) const // partial differentiation
const function_options &opt = registered_functions()[serial];
// No derivative defined? Then return abstract derivative object
- if (opt.derivative_f == NULL)
+ if (opt.derivative_f == nullptr)
return fderivative(serial, diff_param, seq);
current_serial = serial;
@@ -1380,7 +1380,7 @@ ex function::power(const ex & power_param) const // power of function
const function_options &opt = registered_functions()[serial];
// No derivative defined? Then return abstract derivative object
- if (opt.power_f == NULL)
+ if (opt.power_f == nullptr)
return (new GiNaC::power(*this, power_param))->setflag(status_flags::dynallocated |
status_flags::evaluated);
@@ -1426,7 +1426,7 @@ ex function::power(const ex & power_param) const // power of function
std::vector<function_options> & function::registered_functions()
{
- static std::vector<function_options> * rf = new std::vector<function_options>;
+ static auto rf = new std::vector<function_options>;
return *rf;
}
@@ -1445,8 +1445,8 @@ void function::store_remember_table(ex const & result) const
unsigned function::register_new(function_options const & opt)
{
size_t same_name = 0;
- for (size_t i=0; i<registered_functions().size(); ++i) {
- if (registered_functions()[i].name==opt.name) {
+ for (auto & elem : registered_functions()) {
+ if (elem.name==opt.name) {
++same_name;
}
}
diff --git a/ginac/function.h b/ginac/function.h
index 332cdec..0635e53 100644
--- a/ginac/function.h
+++ b/ginac/function.h
@@ -219,7 +219,7 @@ public:
function_options & series_func(PyObject* e);
function_options & subs_func(PyObject* e);
- function_options & set_return_type(unsigned rt, tinfo_t rtt=NULL);
+ function_options & set_return_type(unsigned rt, tinfo_t rtt=nullptr);
function_options & do_not_evalf_params();
function_options & do_not_apply_chain_rule();
function_options & remember(unsigned size, unsigned assoc_size=0,
@@ -248,8 +248,8 @@ public:
};
protected:
- bool has_derivative() const { return derivative_f != NULL; }
- bool has_power() const { return power_f != NULL; }
+ bool has_derivative() const { return derivative_f != nullptr; }
+ bool has_power() const { return power_f != nullptr; }
void test_and_set_nparams(unsigned n);
void set_print_func(unsigned id, print_funcp f);
@@ -330,9 +330,9 @@ public:
function(unsigned ser, const ex & param1, const ex & param2);
function(unsigned ser, const ex & param1, const ex & param2, const ex & param3);
// end of generated lines
- function(unsigned ser, const exprseq & es);
+ function(unsigned ser, exprseq es);
function(unsigned ser, const exvector & v, bool discardable = false);
- function(unsigned ser, std::auto_ptr<exvector> vp);
+ function(unsigned ser, std::unique_ptr<exvector> vp);
// functions overriding virtual functions from base classes
public:
@@ -340,12 +340,12 @@ public:
unsigned precedence() const {return 70;}
ex expand(unsigned options=0) const;
ex eval(int level=0) const;
- ex evalf(int level=0, PyObject* parent=NULL) const;
+ ex evalf(int level=0, PyObject* parent=nullptr) const;
unsigned calchash() const;
ex series(const relational & r, int order, unsigned options = 0) const;
ex subs(const exmap & m, unsigned options = 0) const;
ex thiscontainer(const exvector & v) const;
- ex thiscontainer(std::auto_ptr<exvector> vp) const;
+ ex thiscontainer(std::unique_ptr<exvector> vp) const;
ex conjugate() const;
ex real_part() const;
ex imag_part() const;
diff --git a/ginac/idx.cpp b/ginac/idx.cpp
index 8740dd9..716aa62 100644
--- a/ginac/idx.cpp
+++ b/ginac/idx.cpp
@@ -70,7 +70,7 @@ spinidx::spinidx() : dotted(false)
// other constructors
//////////
-idx::idx(const ex & v, const ex & d) : inherited(&idx::tinfo_static), value(v), dim(d)
+idx::idx(ex v, ex d) : inherited(&idx::tinfo_static), value(std::move(v)), dim(std::move(d))
{
if (is_dim_numeric())
if (!dim.info(info_flags::posint))
@@ -375,7 +375,7 @@ ex idx::evalf(int level, PyObject* parent) const
ex idx::subs(const exmap & m, unsigned options) const
{
// First look for index substitutions
- exmap::const_iterator it = m.find(*this);
+ auto it = m.find(*this);
if (it != m.end()) {
// Substitution index->index
@@ -543,7 +543,7 @@ void find_free_and_dummy(exvector::const_iterator it, exvector::const_iterator i
// Find dummy pairs and free indices
it = v.begin(); itend = v.end();
- exvector::const_iterator last = it++;
+ auto last = it++;
while (it != itend) {
if (is_dummy_pair(*it, *last)) {
out_dummy.push_back(*last);
diff --git a/ginac/idx.h b/ginac/idx.h
index 4f11919..88880d1 100644
--- a/ginac/idx.h
+++ b/ginac/idx.h
@@ -44,7 +44,7 @@ public:
* @param v Value of index (numeric or symbolic)
* @param dim Dimension of index space (numeric or symbolic)
* @return newly constructed index */
- explicit idx(const ex & v, const ex & dim);
+ explicit idx(ex v, ex dim);
// functions overriding virtual functions from base classes
public:
@@ -52,7 +52,7 @@ public:
size_t nops() const;
ex op(size_t i) const;
ex map(map_function & f) const;
- ex evalf(int level = 0, PyObject* parent = NULL) const;
+ ex evalf(int level = 0, PyObject* parent = nullptr) const;
ex subs(const exmap & m, unsigned options = 0) const;
protected:
diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp
index 0b40b99..a2e3839 100644
--- a/ginac/indexed.cpp
+++ b/ginac/indexed.cpp
@@ -124,7 +124,7 @@ indexed::indexed(const ex & b, const symmetry & symm, const exvector & v) : inhe
validate();
}
-indexed::indexed(const symmetry & symm, const exprseq & es) : inherited(es), symtree(symm)
+indexed::indexed(const symmetry & symm, exprseq es) : inherited(std::move(es)), symtree(symm)
{
tinfo_key = &indexed::tinfo_static;
}
@@ -134,7 +134,7 @@ indexed::indexed(const symmetry & symm, const exvector & v, bool discardable) :
tinfo_key = &indexed::tinfo_static;
}
-indexed::indexed(const symmetry & symm, std::auto_ptr<exvector> vp) : inherited(vp), symtree(symm)
+indexed::indexed(const symmetry & symm, std::unique_ptr<exvector> vp) : inherited(std::move(vp)), symtree(symm)
{
tinfo_key = &indexed::tinfo_static;
}
@@ -180,7 +180,7 @@ void indexed::printindices(const print_context & c, unsigned level) const
{
if (seq.size() > 1) {
- exvector::const_iterator it=seq.begin() + 1, itend = seq.end();
+ auto it=seq.begin() + 1, itend = seq.end();
if (is_a<print_latex>(c)) {
@@ -338,9 +338,9 @@ ex indexed::thiscontainer(const exvector & v) const
return indexed(ex_to<symmetry>(symtree), v);
}
-ex indexed::thiscontainer(std::auto_ptr<exvector> vp) const
+ex indexed::thiscontainer(std::unique_ptr<exvector> vp) const
{
- return indexed(ex_to<symmetry>(symtree), vp);
+ return indexed(ex_to<symmetry>(symtree), std::move(vp));
}
unsigned indexed::return_type() const
@@ -391,7 +391,7 @@ ex indexed::expand(unsigned options) const
void indexed::validate() const
{
GINAC_ASSERT(seq.size() > 0);
- exvector::const_iterator it = seq.begin() + 1, itend = seq.end();
+ auto it = seq.begin() + 1, itend = seq.end();
while (it != itend) {
if (!is_a<idx>(*it))
throw(std::invalid_argument("indices of indexed object must be of type idx"));
@@ -468,7 +468,7 @@ exvector indexed::get_dummy_indices(const indexed & other) const
bool indexed::has_dummy_index_for(const ex & i) const
{
- exvector::const_iterator it = seq.begin() + 1, itend = seq.end();
+ auto it = seq.begin() + 1, itend = seq.end();
while (it != itend) {
if (is_dummy_pair(*it, i))
return true;
@@ -546,8 +546,8 @@ exvector integral::get_free_indices() const
template<class T> size_t number_of_type(const exvector&v)
{
size_t number = 0;
- for(exvector::const_iterator i=v.begin(); i!=v.end(); ++i)
- if(is_exactly_a<T>(*i))
+ for(const auto & elem : v)
+ if(is_exactly_a<T>(elem))
++number;
return number;
}
@@ -649,7 +649,7 @@ bool reposition_dummy_indices(ex & e, exvector & variant_dummy_indices, exvector
for (size_t j=i+1; j<e.nops(); ++j) {
if (is_dummy_pair(e.op(i), e.op(j))) {
local_var_dummies.push_back(e.op(i));
- for (exvector::iterator k = variant_dummy_indices.begin();
+ for (auto k = variant_dummy_indices.begin();
k!=variant_dummy_indices.end(); ++k) {
if (e.op(i).op(0) == k->op(0)) {
variant_dummy_indices.erase(k);
@@ -692,7 +692,7 @@ bool reposition_dummy_indices(ex & e, exvector & variant_dummy_indices, exvector
// If a dummy index is encountered for the first time in the
// product, pull it up, otherwise, pull it down
- for (exvector::iterator it2 = seq.begin()+1, it2end = seq.end();
+ for (auto it2 = seq.begin()+1, it2end = seq.end();
it2 != it2end; ++it2) {
if (!is_exactly_a<varidx>(*it2))
continue;
@@ -785,9 +785,9 @@ static void product_to_exvector(const ex & e, exvector & v, bool & non_commutati
template<class T> ex idx_symmetrization(const ex& r,const exvector& local_dummy_indices)
{ exvector dummy_syms;
dummy_syms.reserve(r.nops());
- for (exvector::const_iterator it = local_dummy_indices.begin(); it != local_dummy_indices.end(); ++it)
- if(is_exactly_a<T>(*it))
- dummy_syms.push_back(it->op(0));
+ for (const auto & local_dummy_indice : local_dummy_indices)
+ if(is_exactly_a<T>(local_dummy_indice))
+ dummy_syms.push_back(local_dummy_indice.op(0));
if(dummy_syms.size() < 2)
return r;
ex q=symmetrize(r, dummy_syms);
@@ -999,7 +999,7 @@ contraction_done:
* obtained during the simplification of sums. */
class terminfo {
public:
- terminfo(const ex & orig_, const ex & symm_) : orig(orig_), symm(symm_) {}
+ terminfo(ex orig_, ex symm_) : orig(std::move(orig_)), symm(std::move(symm_)) {}
ex orig; /**< original term */
ex symm; /**< symmtrized term */
@@ -1019,7 +1019,7 @@ class symminfo {
public:
symminfo() : num(0) {}
- symminfo(const ex & symmterm_, const ex & orig_, size_t num_) : orig(orig_), num(num_)
+ symminfo(const ex & symmterm_, ex orig_, size_t num_) : orig(std::move(orig_)), num(num_)
{
if (is_exactly_a<mul>(symmterm_) && is_exactly_a<numeric>(symmterm_.op(symmterm_.nops()-1))) {
coeff = symmterm_.op(symmterm_.nops()-1);
@@ -1145,9 +1145,9 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi
const ex & term = sum.op(i);
exvector dummy_indices_of_term;
dummy_indices_of_term.reserve(dummy_indices.size());
- for(exvector::iterator i=dummy_indices.begin(); i!=dummy_indices.end(); ++i)
- if(hasindex(term,i->op(0)))
- dummy_indices_of_term.push_back(*i);
+ for(auto & dummy_indice : dummy_indices)
+ if(hasindex(term,dummy_indice.op(0)))
+ dummy_indices_of_term.push_back(dummy_indice);
ex term_symm = idx_symmetrization<idx>(term, dummy_indices_of_term);
term_symm = idx_symmetrization<varidx>(term_symm, dummy_indices_of_term);
term_symm = idx_symmetrization<spinidx>(term_symm, dummy_indices_of_term);
@@ -1163,7 +1163,7 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi
std::vector<terminfo> terms_pass2;
for (std::vector<terminfo>::const_iterator i=terms.begin(); i!=terms.end(); ) {
size_t num = 1;
- std::vector<terminfo>::const_iterator j = i + 1;
+ auto j = i + 1;
while (j != terms.end() && j->symm == i->symm) {
num++;
j++;
@@ -1196,7 +1196,7 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi
for (std::vector<symminfo>::const_iterator i=sy.begin(); i!=sy.end(); ) {
// Combine equal terms
- std::vector<symminfo>::const_iterator j = i + 1;
+ auto j = i + 1;
if (j != sy.end() && j->symmterm == i->symmterm) {
// More than one term, collect the coefficients
@@ -1229,7 +1229,7 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi
// How many symmetrized terms of this original term are left?
size_t num = 1;
- std::vector<symminfo>::const_iterator j = i + 1;
+ auto j = i + 1;
while (j != sy_pass2.end() && j->orig == i->orig) {
num++;
j++;
@@ -1319,7 +1319,7 @@ ex ex::symmetrize_cyclic() const
// helper classes
//////////
-spmapkey::spmapkey(const ex & v1_, const ex & v2_, const ex & dim_) : dim(dim_)
+spmapkey::spmapkey(const ex & v1_, const ex & v2_, ex dim_) : dim(std::move(dim_))
{
// If indexed, extract base objects
ex s1 = is_a<indexed>(v1_) ? v1_.op(0) : v1_;
@@ -1381,9 +1381,9 @@ void scalar_products::add(const ex & v1, const ex & v2, const ex & dim, const ex
void scalar_products::add_vectors(const lst & l, const ex & dim)
{
// Add all possible pairs of products
- for (lst::const_iterator it1 = l.begin(); it1 != l.end(); ++it1)
- for (lst::const_iterator it2 = l.begin(); it2 != l.end(); ++it2)
- add(*it1, *it2, *it1 * *it2);
+ for (auto it1 = l.begin(); it1 != l.end(); ++it1)
+ for (const auto & elem : l)
+ add(*it1, elem, *it1 * elem);
}
void scalar_products::clear()
@@ -1406,7 +1406,7 @@ ex scalar_products::evaluate(const ex & v1, const ex & v2, const ex & dim) const
void scalar_products::debugprint() const
{
std::cerr << "map size=" << spm.size() << std::endl;
- spmap::const_iterator i = spm.begin(), end = spm.end();
+ auto i = spm.begin(), end = spm.end();
while (i != end) {
const spmapkey & k = i->first;
std::cerr << "item key=";
@@ -1468,7 +1468,7 @@ exvector get_all_dummy_indices(const ex & e)
if (is_a<indexed>(*ip)) {
v1 = ex_to<indexed>(*ip).get_dummy_indices();
v.insert(v.end(), v1.begin(), v1.end());
- exvector::const_iterator ip1 = ip+1;
+ auto ip1 = ip+1;
while (ip1 != ipend) {
if (is_a<indexed>(*ip1)) {
v1 = ex_to<indexed>(*ip).get_dummy_indices(ex_to<indexed>(*ip1));
@@ -1551,7 +1551,7 @@ ex rename_dummy_indices_uniquely(exvector & va, const ex & b, bool modify_va)
lst indices_subs = rename_dummy_indices_uniquely(va, vb);
if (indices_subs.op(0).nops() > 0) {
if (modify_va) {
- for (lst::const_iterator i = ex_to<lst>(indices_subs.op(1)).begin(); i != ex_to<lst>(indices_subs.op(1)).end(); ++i)
+ for (auto i = ex_to<lst>(indices_subs.op(1)).begin(); i != ex_to<lst>(indices_subs.op(1)).end(); ++i)
va.push_back(*i);
exvector uncommon_indices;
set_difference(vb.begin(), vb.end(), indices_subs.op(0).begin(), indices_subs.op(0).end(), std::back_insert_iterator<exvector>(uncommon_indices), ex_is_less());
diff --git a/ginac/indexed.h b/ginac/indexed.h
index 70406f6..0567a71 100644
--- a/ginac/indexed.h
+++ b/ginac/indexed.h
@@ -139,9 +139,9 @@ public:
indexed(const ex & b, const symmetry & symm, const exvector & iv);
// internal constructors
- indexed(const symmetry & symm, const exprseq & es);
+ indexed(const symmetry & symm, exprseq es);
indexed(const symmetry & symm, const exvector & v, bool discardable = false);
- indexed(const symmetry & symm, std::auto_ptr<exvector> vp);
+ indexed(const symmetry & symm, std::unique_ptr<exvector> vp);
// functions overriding virtual functions from base classes
public:
@@ -155,7 +155,7 @@ public:
protected:
ex derivative(const symbol & s) const;
ex thiscontainer(const exvector & v) const;
- ex thiscontainer(std::auto_ptr<exvector> vp) const;
+ ex thiscontainer(std::unique_ptr<exvector> vp) const;
unsigned return_type() const;
tinfo_t return_type_tinfo() const { return op(0).return_type_tinfo(); }
ex expand(unsigned options = 0) const;
@@ -204,7 +204,7 @@ protected:
class spmapkey {
public:
spmapkey() : dim(wild()) {}
- spmapkey(const ex & v1, const ex & v2, const ex & dim = wild());
+ spmapkey(const ex & v1, const ex & v2, ex dim = wild());
bool operator==(const spmapkey &other) const;
bool operator<(const spmapkey &other) const;
diff --git a/ginac/infinity.h b/ginac/infinity.h
index 86f7fd0..25946f1 100644
--- a/ginac/infinity.h
+++ b/ginac/infinity.h
@@ -46,7 +46,7 @@ public:
// functions overriding virtual functions from base classes
public:
bool info(unsigned inf) const;
- ex evalf(int level = 0, PyObject* parent=NULL) const;
+ ex evalf(int level = 0, PyObject* parent=nullptr) const;
ex conjugate() const;
ex real_part() const;
ex imag_part() const;
diff --git a/ginac/inifcns_nstdsums.cpp b/ginac/inifcns_nstdsums.cpp
index 1b364fa..e132d93 100644
--- a/ginac/inifcns_nstdsums.cpp
+++ b/ginac/inifcns_nstdsums.cpp
@@ -1452,7 +1452,7 @@ static ex Li_evalf(const ex& m_, const ex& x_, PyObject* parent)
return Li(m_,x_).hold();
}
- for (lst::const_iterator itm = m.begin(), itx = x.begin(); itm != m.end(); ++itm, ++itx) {
+ for (auto itm = m.begin(), itx = x.begin(); itm != m.end(); ++itm, ++itx) {
if (!(*itm).info(info_flags::posint)) {
return Li(m_, x_).hold();
}
@@ -1488,7 +1488,7 @@ static ex Li_eval(const ex& m_, const ex& x_)
bool is_zeta = true;
bool do_evalf = true;
bool crational = true;
- for (lst::const_iterator itm = m.begin(), itx = x.begin(); itm != m.end(); ++itm, ++itx) {
+ for (auto itm = m.begin(), itx = x.begin(); itm != m.end(); ++itm, ++itx) {
if (!(*itm).info(info_flags::posint)) {
return Li(m_,x_).hold();
}
@@ -1634,7 +1634,7 @@ static void Li_print_latex(const ex& m_, const ex& x_, const print_context& c)
x = lst(x_);
}
c.s << "{\\rm Li}_{";
- lst::const_iterator itm = m.begin();
+ auto itm = m.begin();
(*itm).print(c);
itm++;
for (; itm != m.end(); itm++) {
@@ -1642,7 +1642,7 @@ static void Li_print_latex(const ex& m_, const ex& x_, const print_context& c)
(*itm).print(c);
}
c.s << "}(";
- lst::const_iterator itx = x.begin();
+ auto itx = x.begin();
(*itx).print(c);
itx++;
for (; itx != x.end(); itx++) {
@@ -3250,7 +3250,7 @@ static ex H_eval(const ex& m_, const ex& x)
pos1 = *m.begin();
p = _ex1;
}
- for (lst::const_iterator it = ++m.begin(); it != m.end(); it++) {
+ for (auto it = ++m.begin(); it != m.end(); it++) {
if ((*it).info(info_flags::integer)) {
if (step == 0) {
if (*it > _ex1) {
@@ -3379,7 +3379,7 @@ static void H_print_latex(const ex& m_, const ex& x, const print_context& c)
m = lst(m_);
}
c.s << "{\\rm H}_{";
- lst::const_iterator itm = m.begin();
+ auto itm = m.begin();
(*itm).print(c);
itm++;
for (; itm != m.end(); itm++) {
@@ -3789,8 +3789,8 @@ static ex zeta1_evalf(const ex& x, PyObject* parent)
std::vector<int> r(count);
// check parameters and convert them
- lst::const_iterator it1 = xlst.begin();
- std::vector<int>::iterator it2 = r.begin();
+ auto it1 = xlst.begin();
+ auto it2 = r.begin();
do {
if (!(*it1).info(info_flags::posint)) {
return zeta(x).hold();
@@ -3897,7 +3897,7 @@ static void zeta1_print_latex(const ex& m_, const print_context& c)
c.s << "\\zeta(";
if (is_a<lst>(m_)) {
const lst& m = ex_to<lst>(m_);
- lst::const_iterator it = m.begin();
+ auto it = m.begin();
(*it).print(c);
it++;
for (; it != m.end(); it++) {
@@ -3942,10 +3942,10 @@ static ex zeta2_evalf(const ex& x, const ex& s, PyObject* parent)
std::vector<int> si(count);
// check parameters and convert them
- lst::const_iterator it_xread = xlst.begin();
- lst::const_iterator it_sread = slst.begin();
- std::vector<int>::iterator it_xwrite = xi.begin();
- std::vector<int>::iterator it_swrite = si.begin();
+ auto it_xread = xlst.begin();
+ auto it_sread = slst.begin();
+ auto it_xwrite = xi.begin();
+ auto it_swrite = si.begin();
do {
if (!(*it_xread).info(info_flags::posint)) {
return zeta(x, s).hold();
@@ -3979,8 +3979,8 @@ static ex zeta2_eval(const ex& m, const ex& s_)
{
if (is_exactly_a<lst>(s_)) {
const lst& s = ex_to<lst>(s_);
- for (lst::const_iterator it = s.begin(); it != s.end(); it++) {
- if ((*it).info(info_flags::positive)) {
+ for (const auto & elem : s) {
+ if ((elem).info(info_flags::positive)) {
continue;
}
return zeta(m, s_).hold();
@@ -4024,8 +4024,8 @@ static void zeta2_print_latex(const ex& m_, const ex& s_, const print_context& c
s = lst(s_);
}
c.s << "\\zeta(";
- lst::const_iterator itm = m.begin();
- lst::const_iterator its = s.begin();
+ auto itm = m.begin();
+ auto its = s.begin();
if (*its < 0) {
c.s << "\\overline{";
(*itm).print(c);
diff --git a/ginac/integral.cpp b/ginac/integral.cpp
index 2a33208..ebf17b1 100644
--- a/ginac/integral.cpp
+++ b/ginac/integral.cpp
@@ -58,8 +58,8 @@ integral::integral()
// public
-integral::integral(const ex & x_, const ex & a_, const ex & b_, const ex & f_)
- : inherited(&integral::tinfo_static), x(x_), a(a_), b(b_), f(f_)
+integral::integral(ex x_, ex a_, ex b_, ex f_)
+ : inherited(&integral::tinfo_static), x(std::move(x_)), a(std::move(a_)), b(std::move(b_)), f(std::move(f_))
{
if (!is_a<symbol>(x)) {
throw(std::invalid_argument("first argument of integral must be of type symbol"));
@@ -215,8 +215,8 @@ ex subsvalue(const ex & var, const ex & value, const ex & fun)
struct error_and_integral
{
- error_and_integral(const ex &err, const ex &integ)
- :error(err), integral(integ){}
+ error_and_integral(ex err, ex integ)
+ :error(std::move(err)), integral(std::move(integ)){}
ex error;
ex integral;
};
@@ -257,7 +257,7 @@ ex adaptivesimpson(const ex & x, const ex & a_in, const ex & b_in, const ex & f,
static lookup_map lookup;
static symbol ivar("ivar");
ex lookupex = integral(ivar,a,b,f.subs(x==ivar));
- lookup_map::iterator emi = lookup.find(error_and_integral(error, lookupex));
+ auto emi = lookup.find(error_and_integral(error, lookupex));
if (emi!=lookup.end())
return emi->second;
diff --git a/ginac/integral.h b/ginac/integral.h
index c85a682..6104f97 100644
--- a/ginac/integral.h
+++ b/ginac/integral.h
@@ -35,7 +35,7 @@ class integral : public basic
// other constructors
public:
- integral(const ex & x_, const ex & a_, const ex & b_, const ex & f_);
+ integral(ex x_, ex a_, ex b_, ex f_);
// functions overriding virtual functions from base classes
public:
diff --git a/ginac/lst.cpp b/ginac/lst.cpp
index f4c247f..3465170 100644
--- a/ginac/lst.cpp
+++ b/ginac/lst.cpp
@@ -24,9 +24,9 @@
namespace GiNaC {
-template <> GINAC_IMPLEMENT_REGISTERED_CLASS_OPT_T(lst, basic,
- print_func<print_context>(&lst::do_print).
- print_func<print_tree>(&lst::do_print_tree))
+ //
+template <> registered_class_info lst::reg_info = registered_class_info(registered_class_options("lst", "basic", &lst::tinfo_static, &lst::unarchive).print_func<print_context>(&lst::do_print).print_func<print_tree>(&lst::do_print_tree));
+template<> const tinfo_static_t lst::tinfo_static = {};
/** Specialization of container::info() for lst. */
template <> bool lst::info(unsigned inf) const
diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp
index b7fc946..a2ff373 100644
--- a/ginac/matrix.cpp
+++ b/ginac/matrix.cpp
@@ -77,8 +77,8 @@ matrix::matrix(unsigned r, unsigned c)
// protected
/** Ctor from representation, for internal use only. */
-matrix::matrix(unsigned r, unsigned c, const exvector & m2)
- : inherited(&matrix::tinfo_static), row(r), col(c), m(m2)
+matrix::matrix(unsigned r, unsigned c, exvector m2)
+ : inherited(&matrix::tinfo_static), row(r), col(c), m(std::move(m2))
{
setflag(status_flags::not_shareable);
}
@@ -93,7 +93,7 @@ matrix::matrix(unsigned r, unsigned c, const lst & l)
setflag(status_flags::not_shareable);
size_t i = 0;
- for (lst::const_iterator it = l.begin(); it != l.end(); ++it, ++i) {
+ for (auto it = l.begin(); it != l.end(); ++it, ++i) {
size_t x = i % c;
size_t y = i / c;
if (y >= r)
@@ -113,10 +113,10 @@ matrix::matrix(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
if (!(n.find_unsigned("row", row)) || !(n.find_unsigned("col", col)))
throw (std::runtime_error("unknown matrix dimensions in archive"));
m.reserve(row * col);
- archive_node::archive_node_cit first = n.find_first("m");
- archive_node::archive_node_cit last = n.find_last("m");
+ auto first = n.find_first("m");
+ auto last = n.find_last("m");
++last;
- for (archive_node::archive_node_cit i=first; i<last; ++i) {
+ for (auto i=first; i<last; ++i) {
ex e;
n.find_ex_by_loc(i, e, sym_lst);
m.push_back(e);
@@ -128,7 +128,7 @@ void matrix::archive(archive_node &n) const
inherited::archive(n);
n.add_unsigned("row", row);
n.add_unsigned("col", col);
- exvector::const_iterator i = m.begin(), iend = m.end();
+ auto i = m.begin(), iend = m.end();
while (i != iend) {
n.add_ex("m", *i);
++i;
@@ -238,8 +238,8 @@ ex matrix::subs(const exmap & mp, unsigned options) const
/** Complex conjugate every matrix entry. */
ex matrix::conjugate() const
{
- exvector * ev = 0;
- for (exvector::const_iterator i=m.begin(); i!=m.end(); ++i) {
+ exvector * ev = nullptr;
+ for (auto i=m.begin(); i!=m.end(); ++i) {
ex x = i->conjugate();
if (ev) {
ev->push_back(x);
@@ -250,7 +250,7 @@ ex matrix::conjugate() const
}
ev = new exvector;
ev->reserve(m.size());
- for (exvector::const_iterator j=m.begin(); j!=i; ++j) {
+ for (auto j=m.begin(); j!=i; ++j) {
ev->push_back(*j);
}
ev->push_back(x);
@@ -267,8 +267,8 @@ ex matrix::real_part() const
{
exvector v;
v.reserve(m.size());
- for (exvector::const_iterator i=m.begin(); i!=m.end(); ++i)
- v.push_back(i->real_part());
+ for (const auto & elem : m)
+ v.push_back(elem.real_part());
return matrix(row, col, v);
}
@@ -276,8 +276,8 @@ ex matrix::imag_part() const
{
exvector v;
v.reserve(m.size());
- for (exvector::const_iterator i=m.begin(); i!=m.end(); ++i)
- v.push_back(i->imag_part());
+ for (const auto & elem : m)
+ v.push_back(elem.imag_part());
return matrix(row, col, v);
}
@@ -560,8 +560,8 @@ matrix matrix::add(const matrix & other) const
throw std::logic_error("matrix::add(): incompatible matrices");
exvector sum(this->m);
- exvector::iterator i = sum.begin(), end = sum.end();
- exvector::const_iterator ci = other.m.begin();
+ auto i = sum.begin(), end = sum.end();
+ auto ci = other.m.begin();
while (i != end)
*i++ += *ci++;
@@ -578,8 +578,8 @@ matrix matrix::sub(const matrix & other) const
throw std::logic_error("matrix::sub(): incompatible matrices");
exvector dif(this->m);
- exvector::iterator i = dif.begin(), end = dif.end();
- exvector::const_iterator ci = other.m.begin();
+ auto i = dif.begin(), end = dif.end();
+ auto ci = other.m.begin();
while (i != end)
*i++ -= *ci++;
@@ -748,7 +748,7 @@ ex matrix::determinant(unsigned algo) const
bool numeric_flag = true;
bool normal_flag = false;
unsigned sparse_count = 0; // counts non-zero elements
- exvector::const_iterator r = m.begin(), rend = m.end();
+ auto r = m.begin(), rend = m.end();
while (r != rend) {
if (!r->info(info_flags::numeric))
numeric_flag = false;
@@ -904,7 +904,7 @@ ex matrix::charpoly(const ex & lambda) const
throw (std::logic_error("matrix::charpoly(): matrix not square"));
bool numeric_flag = true;
- exvector::const_iterator r = m.begin(), rend = m.end();
+ auto r = m.begin(), rend = m.end();
while (r!=rend && numeric_flag==true) {
if (!r->info(info_flags::numeric))
numeric_flag = false;
@@ -1404,7 +1404,7 @@ int matrix::fraction_free_elimination(const bool det)
matrix tmp_d(m,n); // for denominators, if needed
exmap srl; // symbol replacement list
exvector::const_iterator cit = this->m.begin(), citend = this->m.end();
- exvector::iterator tmp_n_it = tmp_n.m.begin(), tmp_d_it = tmp_d.m.begin();
+ auto tmp_n_it = tmp_n.m.begin(), tmp_d_it = tmp_d.m.begin();
while (cit != citend) {
ex nd = cit->normal().to_rational(srl).numer_denom();
++cit;
@@ -1476,7 +1476,7 @@ int matrix::fraction_free_elimination(const bool det)
}
// repopulate *this matrix:
- exvector::iterator it = this->m.begin(), itend = this->m.end();
+ auto it = this->m.begin(), itend = this->m.end();
tmp_n_it = tmp_n.m.begin();
tmp_d_it = tmp_d.m.begin();
while (it != itend)
@@ -1541,8 +1541,8 @@ int matrix::pivot(unsigned ro, unsigned co, bool symbolic)
*/
bool matrix::is_zero_matrix() const
{
- for (exvector::const_iterator i=m.begin(); i!=m.end(); ++i)
- if(!(i->is_zero()))
+ for (const auto & elem : m)
+ if(!(elem.is_zero()))
return false;
return true;
}
diff --git a/ginac/matrix.h b/ginac/matrix.h
index 57f1dec..04dabeb 100644
--- a/ginac/matrix.h
+++ b/ginac/matrix.h
@@ -37,7 +37,7 @@ namespace GiNaC {
template <typename T, typename It>
class matrix_init {
public:
- matrix_init(It i) : iter(i) {}
+ matrix_init(It i) : iter(std::move(i)) {}
matrix_init<T, It> operator,(const T & x)
{
@@ -98,7 +98,7 @@ class matrix : public basic
// other constructors
public:
matrix(unsigned r, unsigned c);
- matrix(unsigned r, unsigned c, const exvector & m2);
+ matrix(unsigned r, unsigned c, exvector m2);
matrix(unsigned r, unsigned c, const lst & l);
// First step of initialization of matrix with a comma-separated seqeuence
diff --git a/ginac/mul.cpp b/ginac/mul.cpp
index f5f5217..1c0d217 100644
--- a/ginac/mul.cpp
+++ b/ginac/mul.cpp
@@ -103,7 +103,7 @@ mul::mul(const epvector & v, const ex & oc, bool do_index_renaming)
GINAC_ASSERT(is_canonical());
}
-mul::mul(std::auto_ptr<epvector> vp, const ex & oc, bool do_index_renaming)
+mul::mul(std::unique_ptr<epvector> vp, const ex & oc, bool do_index_renaming)
{
tinfo_key = &mul::tinfo_static;
GINAC_ASSERT(vp.get()!=0);
@@ -234,7 +234,7 @@ void mul::print_exvector(const exvector & v, const print_context & c,
const char* sep) const
{
bool first = true;
- exvector::const_iterator vit = v.begin(), vitend = v.end();
+ auto vit = v.begin(), vitend = v.end();
while (vit != vitend) {
if (!first)
c.s << sep;
@@ -265,7 +265,7 @@ void mul::do_print_rat_func(const print_context & c, unsigned level,
// Separate factors into those with negative numeric exponent
// and all others
const epvector & sorted_seq = get_sorted_seq();
- epvector::const_iterator it = sorted_seq.begin(), itend = sorted_seq.end();
+ auto it = sorted_seq.begin(), itend = sorted_seq.end();
exvector neg_powers, others;
while (it != itend) {
GINAC_ASSERT(is_exactly_a<numeric>(it->coeff));
@@ -405,7 +405,7 @@ void mul::do_print_csrc(const print_csrc & c, unsigned level) const
}
// Print arguments, separated by "*" or "/"
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
while (it != itend) {
// If the first argument is a negative integer power, it gets printed as "1.0/<expr>"
@@ -474,7 +474,7 @@ bool mul::info(unsigned inf) const
case info_flags::rational_function: {
if (not overall_coeff.info(info_flags::real))
return false;
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
if (!(recombine_pair_to_ex(*i).info(inf)))
return false;
@@ -485,7 +485,7 @@ bool mul::info(unsigned inf) const
return overall_coeff.info(inf);
}
case info_flags::algebraic: {
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
if ((recombine_pair_to_ex(*i).info(inf)))
return true;
@@ -498,7 +498,7 @@ bool mul::info(unsigned inf) const
if (not overall_coeff.info(info_flags::real))
return false;
bool pos = true;
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
const ex& factor = recombine_pair_to_ex(*i++);
if (factor.info(info_flags::positive))
@@ -516,7 +516,7 @@ bool mul::info(unsigned inf) const
if (not overall_coeff.info(info_flags::real))
return false;
bool pos = true;
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
const ex& factor = recombine_pair_to_ex(*i++);
if (factor.info(info_flags::nonnegative) || factor.info(info_flags::positive))
@@ -533,7 +533,7 @@ bool mul::info(unsigned inf) const
if (not overall_coeff.info(info_flags::real))
return false;
bool pos = true;
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
const ex& factor = recombine_pair_to_ex(*i++);
if (factor.info(info_flags::posint))
@@ -553,7 +553,7 @@ bool mul::info(unsigned inf) const
if (not overall_coeff.info(info_flags::real))
return false;
bool pos = true;
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
const ex& factor = recombine_pair_to_ex(*i++);
if (factor.info(info_flags::nonnegint) || factor.info(info_flags::posint))
@@ -575,9 +575,9 @@ bool mul::info(unsigned inf) const
bool mul::is_polynomial(const ex & var) const
{
- for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
- if (!i->rest.is_polynomial(var) ||
- (i->rest.has(var) && !i->coeff.info(info_flags::nonnegint))) {
+ for (const auto & elem : seq) {
+ if (!elem.rest.is_polynomial(var) ||
+ (elem.rest.has(var) && !elem.coeff.info(info_flags::nonnegint))) {
return false;
}
}
@@ -588,7 +588,7 @@ int mul::degree(const ex & s) const
{
// Sum up degrees of factors
int deg_sum = 0;
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
if (ex_to<numeric>(i->coeff).is_integer())
deg_sum += recombine_pair_to_ex(*i).degree(s);
@@ -605,7 +605,7 @@ int mul::ldegree(const ex & s) const
{
// Sum up degrees of factors
int deg_sum = 0;
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
if (ex_to<numeric>(i->coeff).is_integer())
deg_sum += recombine_pair_to_ex(*i).ldegree(s);
@@ -626,7 +626,7 @@ ex mul::coeff(const ex & s, int n) const
if (n==0) {
// product of individual coeffs
// if a non-zero power of s is found, the resulting product will be 0
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
coeffseq.push_back(recombine_pair_to_ex(*i).coeff(s,n));
++i;
@@ -635,7 +635,7 @@ ex mul::coeff(const ex & s, int n) const
return (new mul(coeffseq))->setflag(status_flags::dynallocated);
}
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
bool coeff_found = false;
while (i != end) {
ex t = recombine_pair_to_ex(*i);
@@ -667,10 +667,10 @@ ex mul::coeff(const ex & s, int n) const
* @param level cut-off in recursive evaluation */
ex mul::eval(int level) const
{
- std::auto_ptr<epvector> evaled_seqp = evalchildren(level);
+ std::unique_ptr<epvector> evaled_seqp = evalchildren(level);
if (evaled_seqp.get()) {
// do more evaluation later
- return (new mul(evaled_seqp, overall_coeff))->
+ return (new mul(std::move(evaled_seqp), overall_coeff))->
setflag(status_flags::dynallocated);
}
@@ -702,7 +702,7 @@ ex mul::eval(int level) const
// handle infinity and handle exp(a)*exp(b) -> exp(a+b) and
unsigned exp_count = 0;
- for (epvector::const_iterator i = seq.begin(); i != seq.end(); i++) {
+ for (auto i = seq.begin(); i != seq.end(); i++) {
const numeric& coeff = ex_to<numeric>(i->coeff);
if (unlikely(is_exactly_a<infinity>(i->rest)))
return eval_infinity(i);
@@ -734,14 +734,14 @@ ex mul::eval(int level) const
ex_to<numeric>((*seq.begin()).coeff).is_equal(*_num1_p)) {
// *(+(x,y,...);c) -> +(*(x,c),*(y,c),...) (c numeric(), no powers of +())
const add & addref = ex_to<add>((*seq.begin()).rest);
- std::auto_ptr<epvector> distrseq(new epvector);
+ std::unique_ptr<epvector> distrseq(new epvector);
distrseq->reserve(addref.seq.size());
- epvector::const_iterator i = addref.seq.begin(), end = addref.seq.end();
+ auto i = addref.seq.begin(), end = addref.seq.end();
while (i != end) {
distrseq->push_back(addref.combine_pair_with_coeff_to_pair(*i, overall_coeff));
++i;
}
- return (new add(distrseq,
+ return (new add(std::move(distrseq),
ex_to<numeric>(addref.overall_coeff).
mul_dyn(ex_to<numeric>(overall_coeff)))
)->setflag(status_flags::dynallocated | status_flags::evaluated);
@@ -749,10 +749,10 @@ ex mul::eval(int level) const
// Strip the content and the unit part from each term. Thus
// things like (-x+a)*(3*x-3*a) automagically turn into - 3*(x-a)2
- epvector::const_iterator last = seq.end();
- epvector::const_iterator i = seq.begin();
- epvector::const_iterator j = seq.begin();
- std::auto_ptr<epvector> s(new epvector);
+ auto last = seq.end();
+ auto i = seq.begin();
+ auto j = seq.begin();
+ std::unique_ptr<epvector> s(new epvector);
numeric oc = *_num1_p;
bool something_changed = false;
while (i!=last) {
@@ -804,14 +804,13 @@ ex mul::eval(int level) const
// divide add by the number in place to save at least 2 .eval() calls
const add& addref = ex_to<add>(i->rest);
- add* primitive = new add(addref);
+ auto primitive = new add(addref);
primitive->setflag(status_flags::dynallocated);
primitive->clearflag(status_flags::hash_calculated);
primitive->overall_coeff = ex_to<numeric>(primitive->overall_coeff).div_dyn(c);
primitive->seq_sorted.resize(0);
- for (epvector::iterator ai = primitive->seq.begin();
- ai != primitive->seq.end(); ++ai)
- ai->coeff = ex_to<numeric>(ai->coeff).div_dyn(c);
+ for (auto & elem : primitive->seq)
+ elem.coeff = ex_to<numeric>(elem.coeff).div_dyn(c);
s->push_back(expair(*primitive, _ex1));
@@ -826,7 +825,7 @@ ex mul::eval(int level) const
if (s->empty()) {
return ex_to<numeric>(overall_coeff).mul_dyn(oc);
}
- return (new mul(s, ex_to<numeric>(overall_coeff).mul_dyn(oc))
+ return (new mul(std::move(s), ex_to<numeric>(overall_coeff).mul_dyn(oc))
)->setflag(status_flags::dynallocated);
}
}
@@ -840,10 +839,10 @@ ex mul::eval_exponentials() const
{
ex exp_arg = _ex0;
numeric oc = *_num1_p;
- std::auto_ptr<epvector> s(new epvector);
+ std::unique_ptr<epvector> s(new epvector);
s->reserve(seq.size());
- for (epvector::const_iterator i = seq.begin(); i != seq.end(); i++) {
+ for (auto i = seq.begin(); i != seq.end(); i++) {
const numeric & coeff = ex_to<numeric>(i->coeff);
const bool simplifyable_exp = is_ex_the_function(i->rest, exp) and coeff.is_integer();
if (likely(not simplifyable_exp))
@@ -858,7 +857,7 @@ ex mul::eval_exponentials() const
else
s->push_back(expair(new_exp, _ex1));
- mul * result = new mul(s, ex_to<numeric>(overall_coeff).mul_dyn(oc));
+ mul * result = new mul(std::move(s), ex_to<numeric>(overall_coeff).mul_dyn(oc));
return result->setflag(status_flags::dynallocated);
}
@@ -870,7 +869,7 @@ ex mul::eval_infinity(epvector::const_iterator infinity_iter) const
infinity result = ex_to<infinity>(recombine_pair_to_ex(*infinity_iter));
result *= overall_coeff;
- for (epvector::const_iterator i = seq.begin(); i != seq.end(); i++) {
+ for (auto i = seq.begin(); i != seq.end(); i++) {
if (i == infinity_iter) continue;
result *= recombine_pair_to_ex(*i);
}
@@ -886,25 +885,25 @@ ex mul::evalf(int level, PyObject* parent) const
if (level==-max_recursion_level)
throw(std::runtime_error("max recursion level reached"));
- std::auto_ptr<epvector> s(new epvector);
+ std::unique_ptr<epvector> s(new epvector);
s->reserve(seq.size());
--level;
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
s->push_back(combine_ex_with_coeff_to_pair(
i->rest.evalf(level, parent), i->coeff));
++i;
}
- return mul(s, overall_coeff.evalf(level, parent));
+ return mul(std::move(s), overall_coeff.evalf(level, parent));
}
void mul::find_real_imag(ex & rp, ex & ip) const
{
rp = overall_coeff.real_part();
ip = overall_coeff.imag_part();
- for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
- ex factor = recombine_pair_to_ex(*i);
+ for (const auto & elem : seq) {
+ ex factor = recombine_pair_to_ex(elem);
ex new_rp = factor.real_part();
ex new_ip = factor.imag_part();
if(new_ip.is_zero()) {
@@ -944,13 +943,13 @@ ex mul::evalm() const
// Evaluate children first, look whether there are any matrices at all
// (there can be either no matrices or one matrix; if there were more
// than one matrix, it would be a non-commutative product)
- std::auto_ptr<epvector> s(new epvector);
+ std::unique_ptr<epvector> s(new epvector);
s->reserve(seq.size());
bool have_matrix = false;
epvector::iterator the_matrix;
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
const ex &m = recombine_pair_to_ex(*i).evalm();
s->push_back(split_ex_to_pair(m));
@@ -967,11 +966,11 @@ ex mul::evalm() const
// into that matrix.
matrix m = ex_to<matrix>(the_matrix->rest);
s->erase(the_matrix);
- ex scalar = (new mul(s, overall_coeff))->setflag(status_flags::dynallocated);
+ ex scalar = (new mul(std::move(s), overall_coeff))->setflag(status_flags::dynallocated);
return m.mul_scalar(scalar);
} else
- return (new mul(s, overall_coeff))->setflag(status_flags::dynallocated);
+ return (new mul(std::move(s), overall_coeff))->setflag(status_flags::dynallocated);
}
ex mul::eval_ncmul(const exvector & v) const
@@ -980,7 +979,7 @@ ex mul::eval_ncmul(const exvector & v) const
return inherited::eval_ncmul(v);
// Find first noncommutative element and call its eval_ncmul()
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
if (i->rest.return_type() == return_types::noncommutative)
return i->rest.eval_ncmul(v);
@@ -1094,25 +1093,25 @@ ex mul::algebraic_subs_mul(const exmap & m, unsigned options) const
ex divide_by = 1;
ex multiply_by = 1;
- for (exmap::const_iterator it = m.begin(); it != m.end(); ++it) {
+ for (const auto & elem : m) {
- if (is_exactly_a<mul>(it->first)) {
+ if (is_exactly_a<mul>(elem.first)) {
retry1:
int nummatches = std::numeric_limits<int>::max();
std::vector<bool> currsubsed(nops(), false);
lst repls;
- if(!algebraic_match_mul_with_mul(*this, it->first, repls, 0, nummatches, subsed, currsubsed))
+ if(!algebraic_match_mul_with_mul(*this, elem.first, repls, 0, nummatches, subsed, currsubsed))
continue;
for (size_t j=0; j<subsed.size(); j++)
if (currsubsed[j])
subsed[j] = true;
ex subsed_pattern
- = it->first.subs(ex(repls), subs_options::no_pattern);
+ = elem.first.subs(ex(repls), subs_options::no_pattern);
divide_by *= power(subsed_pattern, nummatches);
ex subsed_result
- = it->second.subs(ex(repls), subs_options::no_pattern);
+ = elem.second.subs(ex(repls), subs_options::no_pattern);
multiply_by *= power(subsed_result, nummatches);
goto retry1;
@@ -1121,13 +1120,13 @@ retry1:
for (size_t j=0; j<this->nops(); j++) {
int nummatches = std::numeric_limits<int>::max();
lst repls;
- if (!subsed[j] && tryfactsubs(op(j), it->first, nummatches, repls)){
+ if (!subsed[j] && tryfactsubs(op(j), elem.first, nummatches, repls)){
subsed[j] = true;
ex subsed_pattern
- = it->first.subs(ex(repls), subs_options::no_pattern);
+ = elem.first.subs(ex(repls), subs_options::no_pattern);
divide_by *= power(subsed_pattern, nummatches);
ex subsed_result
- = it->second.subs(ex(repls), subs_options::no_pattern);
+ = elem.second.subs(ex(repls), subs_options::no_pattern);
multiply_by *= power(subsed_result, nummatches);
}
}
@@ -1135,8 +1134,8 @@ retry1:
}
bool subsfound = false;
- for (size_t i=0; i<subsed.size(); i++) {
- if (subsed[i]) {
+ for (size_t i=0; i<subsed.size(); i++) {
+ if (subsed[i]) {
subsfound = true;
break;
}
@@ -1151,8 +1150,8 @@ ex mul::conjugate() const
{
// The base class' method is wrong here because we have to be careful at
// branch cuts. power::conjugate takes care of that already, so use it.
- epvector *newepv = 0;
- for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
+ epvector *newepv = nullptr;
+ for (auto i=seq.begin(); i!=seq.end(); ++i) {
if (newepv) {
newepv->push_back(split_ex_to_pair(recombine_pair_to_ex(*i).conjugate()));
continue;
@@ -1164,7 +1163,7 @@ ex mul::conjugate() const
}
newepv = new epvector;
newepv->reserve(seq.size());
- for (epvector::const_iterator j=seq.begin(); j!=i; ++j) {
+ for (auto j=seq.begin(); j!=i; ++j) {
newepv->push_back(*j);
}
newepv->push_back(split_ex_to_pair(c));
@@ -1191,8 +1190,8 @@ ex mul::derivative(const symbol & s) const
// D(a*b*c) = D(a)*b*c + a*D(b)*c + a*b*D(c)
epvector mulseq = seq;
- epvector::const_iterator i = seq.begin(), end = seq.end();
- epvector::iterator i2 = mulseq.begin();
+ auto i = seq.begin(), end = seq.end();
+ auto i2 = mulseq.begin();
while (i != end) {
expair ep = split_ex_to_pair(power(i->rest, i->coeff - _ex1) *
i->rest.diff(s));
@@ -1236,7 +1235,7 @@ unsigned mul::return_type() const
bool all_commutative = true;
epvector::const_iterator noncommutative_element; // point to first found nc element
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
unsigned rt = i->rest.return_type();
if (rt == return_types::noncommutative_composite)
@@ -1265,7 +1264,7 @@ tinfo_t mul::return_type_tinfo() const
return this; // mul without factors: should not happen
// return type_info of first noncommutative element
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
if (i->rest.return_type() == return_types::noncommutative)
return i->rest.return_type_tinfo();
@@ -1280,9 +1279,9 @@ ex mul::thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming)
return (new mul(v, oc, do_index_renaming))->setflag(status_flags::dynallocated);
}
-ex mul::thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc, bool do_index_renaming) const
+ex mul::thisexpairseq(std::unique_ptr<epvector> vp, const ex & oc, bool do_index_renaming) const
{
- return (new mul(vp, oc, do_index_renaming))->setflag(status_flags::dynallocated);
+ return (new mul(std::move(vp), oc, do_index_renaming))->setflag(status_flags::dynallocated);
}
expair mul::split_ex_to_pair(const ex & e) const
@@ -1384,8 +1383,8 @@ bool mul::can_make_flat(const expair & p) const
bool mul::can_be_further_expanded(const ex & e)
{
if (is_exactly_a<mul>(e)) {
- for (epvector::const_iterator cit = ex_to<mul>(e).seq.begin(); cit != ex_to<mul>(e).seq.end(); ++cit) {
- if (is_exactly_a<add>(cit->rest) && cit->coeff.info(info_flags::posint))
+ for (const auto & elem : ex_to<mul>(e).seq) {
+ if (is_exactly_a<add>(elem.rest) && elem.coeff.info(info_flags::posint))
return true;
}
} else if (is_exactly_a<power>(e)) {
@@ -1399,7 +1398,7 @@ ex mul::expand(unsigned options) const
{
{
// trivial case: expanding the monomial (~ 30% of all calls)
- epvector::const_iterator i = seq.begin(), seq_end = seq.end();
+ auto i = seq.begin(), seq_end = seq.end();
while ((i != seq.end()) && is_a<symbol>(i->rest) && i->coeff.info(info_flags::integer))
++i;
if (i == seq_end) {
@@ -1416,7 +1415,7 @@ ex mul::expand(unsigned options) const
const bool skip_idx_rename = !(options & expand_options::expand_rename_idx);
// First, expand the children
- std::auto_ptr<epvector> expanded_seqp = expandchildren(options);
+ std::unique_ptr<epvector> expanded_seqp = expandchildren(options);
const epvector & expanded_seq = (expanded_seqp.get() ? *expanded_seqp : seq);
// Now, look for all the factors that are sums and multiply each one out
@@ -1427,20 +1426,20 @@ ex mul::expand(unsigned options) const
epvector non_adds;
non_adds.reserve(expanded_seq.size());
- for (epvector::const_iterator cit = expanded_seq.begin(); cit != expanded_seq.end(); ++cit) {
- if (is_exactly_a<add>(cit->rest) &&
- (cit->coeff.is_integer_one())) {
+ for (const auto & elem : expanded_seq) {
+ if (is_exactly_a<add>(elem.rest) &&
+ (elem.coeff.is_integer_one())) {
if (is_exactly_a<add>(last_expanded)) {
// Expand a product of two sums, aggressive version.
// Caring for the overall coefficients in separate loops can
// sometimes give a performance gain of up to 15%!
- const int sizedifference = ex_to<add>(last_expanded).seq.size()-ex_to<add>(cit->rest).seq.size();
+ const int sizedifference = ex_to<add>(last_expanded).seq.size()-ex_to<add>(elem.rest).seq.size();
// add2 is for the inner loop and should be the bigger of the two sums
// in the presence of asymptotically good sorting:
- const add& add1 = (sizedifference<0 ? ex_to<add>(last_expanded) : ex_to<add>(cit->rest));
- const add& add2 = (sizedifference<0 ? ex_to<add>(cit->rest) : ex_to<add>(last_expanded));
+ const add& add1 = (sizedifference<0 ? ex_to<add>(last_expanded) : ex_to<add>(elem.rest));
+ const add& add2 = (sizedifference<0 ? ex_to<add>(elem.rest) : ex_to<add>(last_expanded));
const epvector::const_iterator add1begin = add1.seq.begin();
const epvector::const_iterator add1end = add1.seq.end();
const epvector::const_iterator add2begin = add2.seq.begin();
@@ -1514,11 +1513,11 @@ ex mul::expand(unsigned options) const
} else {
if (!last_expanded.is_integer_one())
non_adds.push_back(split_ex_to_pair(last_expanded));
- last_expanded = cit->rest;
+ last_expanded = elem.rest;
}
} else {
- non_adds.push_back(*cit);
+ non_adds.push_back(elem);
}
}
@@ -1594,21 +1593,21 @@ const epvector & mul::get_sorted_seq() const
* @see mul::expand()
* @return pointer to epvector containing expanded representation or zero
* pointer, if sequence is unchanged. */
-std::auto_ptr<epvector> mul::expandchildren(unsigned options) const
+std::unique_ptr<epvector> mul::expandchildren(unsigned options) const
{
const epvector::const_iterator last = seq.end();
- epvector::const_iterator cit = seq.begin();
+ auto cit = seq.begin();
while (cit!=last) {
const ex & factor = recombine_pair_to_ex(*cit);
const ex & expanded_factor = factor.expand(options);
if (!are_ex_trivially_equal(factor,expanded_factor)) {
// something changed, copy seq, eval and return it
- std::auto_ptr<epvector> s(new epvector);
+ std::unique_ptr<epvector> s(new epvector);
s->reserve(seq.size());
// copy parts of seq which are known not to have changed
- epvector::const_iterator cit2 = seq.begin();
+ auto cit2 = seq.begin();
while (cit2!=cit) {
s->push_back(*cit2);
++cit2;
@@ -1623,12 +1622,12 @@ std::auto_ptr<epvector> mul::expandchildren(unsigned options) const
s->push_back(split_ex_to_pair(recombine_pair_to_ex(*cit2).expand(options)));
++cit2;
}
- return s;
+ return std::move(s);
}
++cit;
}
- return std::auto_ptr<epvector>(0); // nothing has changed
+ return std::unique_ptr<epvector>(nullptr); // nothing has changed
}
} // namespace GiNaC
diff --git a/ginac/mul.h b/ginac/mul.h
index a1639ad..962fed6 100644
--- a/ginac/mul.h
+++ b/ginac/mul.h
@@ -44,7 +44,7 @@ public:
mul(const exvector & v, bool hold=false);
mul(const epvector & v);
mul(const epvector & v, const ex & oc, bool do_index_renaming = false);
- mul(std::auto_ptr<epvector> vp, const ex & oc, bool do_index_renaming = false);
+ mul(std::unique_ptr<epvector> vp, const ex & oc, bool do_index_renaming = false);
mul(const ex & lh, const ex & mh, const ex & rh);
// functions overriding virtual functions from base classes
@@ -57,7 +57,7 @@ public:
ex coeff(const ex & s, int n = 1) const;
bool has(const ex & other, unsigned options = 0) const;
ex eval(int level=0) const;
- ex evalf(int level=0, PyObject* parent=NULL) const;
+ ex evalf(int level=0, PyObject* parent=nullptr) const;
ex real_part() const;
ex imag_part() const;
ex evalm() const;
@@ -74,7 +74,7 @@ protected:
unsigned return_type() const;
tinfo_t return_type_tinfo() const;
ex thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming = false) const;
- ex thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc, bool do_index_renaming = false) const;
+ ex thisexpairseq(std::unique_ptr<epvector> vp, const ex & oc, bool do_index_renaming = false) const;
expair split_ex_to_pair(const ex & e) const;
expair combine_ex_with_coeff_to_pair(const ex & e, const ex & c) const;
expair combine_pair_with_coeff_to_pair(const expair & p, const ex & c) const;
@@ -113,7 +113,7 @@ protected:
void do_print_csrc(const print_csrc & c, unsigned level) const;
void do_print_python_repr(const print_python_repr & c, unsigned level) const;
static bool can_be_further_expanded(const ex & e);
- std::auto_ptr<epvector> expandchildren(unsigned options) const;
+ std::unique_ptr<epvector> expandchildren(unsigned options) const;
mutable double tdegree;
};
diff --git a/ginac/ncmul.cpp b/ginac/ncmul.cpp
index db7d404..086b554 100644
--- a/ginac/ncmul.cpp
+++ b/ginac/ncmul.cpp
@@ -91,7 +91,7 @@ ncmul::ncmul(const exvector & v, bool discardable) : inherited(v,discardable)
tinfo_key = &ncmul::tinfo_static;
}
-ncmul::ncmul(std::auto_ptr<exvector> vp) : inherited(vp)
+ncmul::ncmul(std::unique_ptr<exvector> vp) : inherited(std::move(vp))
{
tinfo_key = &ncmul::tinfo_static;
}
@@ -129,7 +129,7 @@ typedef std::vector<int> intvector;
ex ncmul::expand(unsigned options) const
{
// First, expand the children
- std::auto_ptr<exvector> vp = expandchildren(options);
+ std::unique_ptr<exvector> vp = expandchildren(options);
const exvector &expanded_seq = vp.get() ? *vp : this->seq;
// Now, look for all the factors that are sums and remember their
@@ -141,8 +141,8 @@ ex ncmul::expand(unsigned options) const
size_t number_of_expanded_terms = 1;
size_t current_position = 0;
- exvector::const_iterator last = expanded_seq.end();
- for (exvector::const_iterator cit=expanded_seq.begin(); cit!=last; ++cit) {
+ auto last = expanded_seq.end();
+ for (auto cit=expanded_seq.begin(); cit!=last; ++cit) {
if (is_exactly_a<add>(*cit)) {
positions_of_adds[number_of_adds] = current_position;
size_t num_ops = cit->nops();
@@ -156,7 +156,7 @@ ex ncmul::expand(unsigned options) const
// If there are no sums, we are done
if (number_of_adds == 0) {
if (vp.get())
- return (new ncmul(vp))->
+ return (new ncmul(std::move(vp)))->
setflag(status_flags::dynallocated | (options == 0 ? status_flags::expanded : 0));
else
return *this;
@@ -213,7 +213,7 @@ int ncmul::degree(const ex & s) const
// Sum up degrees of factors
int deg_sum = 0;
- exvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
deg_sum += i->degree(s);
++i;
@@ -228,7 +228,7 @@ int ncmul::ldegree(const ex & s) const
// Sum up degrees of factors
int deg_sum = 0;
- exvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
deg_sum += i->degree(s);
++i;
@@ -247,7 +247,7 @@ ex ncmul::coeff(const ex & s, int n) const
if (n == 0) {
// product of individual coeffs
// if a non-zero power of s is found, the resulting product will be 0
- exvector::const_iterator it=seq.begin();
+ auto it=seq.begin();
while (it!=seq.end()) {
coeffseq.push_back((*it).coeff(s,n));
++it;
@@ -255,7 +255,7 @@ ex ncmul::coeff(const ex & s, int n) const
return (new ncmul(coeffseq,1))->setflag(status_flags::dynallocated);
}
- exvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
bool coeff_found = false;
while (i != end) {
ex c = i->coeff(s,n);
@@ -456,9 +456,9 @@ ex ncmul::eval(int level) const
ex ncmul::evalm() const
{
// Evaluate children first
- std::auto_ptr<exvector> s(new exvector);
+ std::unique_ptr<exvector> s(new exvector);
s->reserve(seq.size());
- exvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
while (it != itend) {
s->push_back(it->evalm());
it++;
@@ -479,7 +479,7 @@ ex ncmul::evalm() const
}
no_matrix:
- return (new ncmul(s))->setflag(status_flags::dynallocated);
+ return (new ncmul(std::move(s)))->setflag(status_flags::dynallocated);
}
ex ncmul::thiscontainer(const exvector & v) const
@@ -487,9 +487,9 @@ ex ncmul::thiscontainer(const exvector & v) const
return (new ncmul(v))->setflag(status_flags::dynallocated);
}
-ex ncmul::thiscontainer(std::auto_ptr<exvector> vp) const
+ex ncmul::thiscontainer(std::unique_ptr<exvector> vp) const
{
- return (new ncmul(vp))->setflag(status_flags::dynallocated);
+ return (new ncmul(std::move(vp)))->setflag(status_flags::dynallocated);
}
ex ncmul::conjugate() const
@@ -504,7 +504,7 @@ ex ncmul::conjugate() const
exvector ev;
ev.reserve(nops());
- for (const_iterator i=end(); i!=begin();) {
+ for (auto i=end(); i!=begin();) {
--i;
ev.push_back(i->conjugate());
}
@@ -556,7 +556,7 @@ unsigned ncmul::return_type() const
bool all_commutative = true;
exvector::const_iterator noncommutative_element; // point to first found nc element
- exvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
unsigned rt = i->return_type();
if (rt == return_types::noncommutative_composite)
@@ -584,7 +584,7 @@ tinfo_t ncmul::return_type_tinfo() const
return this;
// return type_info of first noncommutative element
- exvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
if (i->return_type() == return_types::noncommutative)
return i->return_type_tinfo();
@@ -605,15 +605,15 @@ tinfo_t ncmul::return_type_tinfo() const
// non-virtual functions in this class
//////////
-std::auto_ptr<exvector> ncmul::expandchildren(unsigned options) const
+std::unique_ptr<exvector> ncmul::expandchildren(unsigned options) const
{
- const_iterator cit = this->seq.begin(), end = this->seq.end();
+ auto cit = this->seq.begin(), end = this->seq.end();
while (cit != end) {
const ex & expanded_ex = cit->expand(options);
if (!are_ex_trivially_equal(*cit, expanded_ex)) {
// copy first part of seq which hasn't changed
- std::auto_ptr<exvector> s(new exvector(this->seq.begin(), cit));
+ std::unique_ptr<exvector> s(new exvector(this->seq.begin(), cit));
reserve(*s, this->seq.size());
// insert changed element
@@ -626,13 +626,13 @@ std::auto_ptr<exvector> ncmul::expandchildren(unsigned options) const
++cit;
}
- return s;
+ return std::move(s);
}
++cit;
}
- return std::auto_ptr<exvector>(0); // nothing has changed
+ return std::unique_ptr<exvector>(nullptr); // nothing has changed
}
const exvector & ncmul::get_factors() const
diff --git a/ginac/ncmul.h b/ginac/ncmul.h
index 7b21cf8..a3239c5 100644
--- a/ginac/ncmul.h
+++ b/ginac/ncmul.h
@@ -49,7 +49,7 @@ public:
ncmul(const ex & f1, const ex & f2, const ex & f3,
const ex & f4, const ex & f5, const ex & f6);
ncmul(const exvector & v, bool discardable=false);
- ncmul(std::auto_ptr<exvector> vp);
+ ncmul(std::unique_ptr<exvector> vp);
// functions overriding virtual functions from base classes
public:
@@ -63,7 +63,7 @@ public:
ex evalm() const;
exvector get_free_indices() const;
ex thiscontainer(const exvector & v) const;
- ex thiscontainer(std::auto_ptr<exvector> vp) const;
+ ex thiscontainer(std::unique_ptr<exvector> vp) const;
ex conjugate() const;
ex real_part() const;
ex imag_part() const;
@@ -82,7 +82,7 @@ protected:
void do_print_csrc(const print_context & c, unsigned level) const;
size_t count_factors(const ex & e) const;
void append_factors(exvector & v, const ex & e) const;
- std::auto_ptr<exvector> expandchildren(unsigned options) const;
+ std::unique_ptr<exvector> expandchildren(unsigned options) const;
public:
const exvector & get_factors() const;
};
diff --git a/ginac/normal.cpp b/ginac/normal.cpp
index 8cf0512..d195cf8 100644
--- a/ginac/normal.cpp
+++ b/ginac/normal.cpp
@@ -196,7 +196,7 @@ static void get_symbol_stats(const ex &a, const ex &b, sym_desc_vec &v)
{
collect_symbols(a.eval(), v); // eval() to expand assigned symbols
collect_symbols(b.eval(), v);
- sym_desc_vec::iterator it = v.begin(), itend = v.end();
+ auto it = v.begin(), itend = v.end();
while (it != itend) {
int deg_a = a.degree(it->sym);
int deg_b = b.degree(it->sym);
@@ -320,8 +320,8 @@ numeric numeric::integer_content() const
numeric add::integer_content() const
{
- epvector::const_iterator it = seq.begin();
- epvector::const_iterator itend = seq.end();
+ auto it = seq.begin();
+ auto itend = seq.end();
numeric c = *_num0_p, l = *_num1_p;
while (it != itend) {
GINAC_ASSERT(!is_exactly_a<numeric>(it->rest));
@@ -959,7 +959,7 @@ ex ex::content(const ex &x) const
return lcoeff * c / lcoeff.unit(x);
ex cont = _ex0;
for (int i=ldeg; i<=deg; i++)
- cont = gcd(r.coeff(x, i), cont, NULL, NULL, false);
+ cont = gcd(r.coeff(x, i), cont, nullptr, nullptr, false);
return cont * c;
}
@@ -1099,7 +1099,7 @@ static ex sr_gcd(const ex &a, const ex &b, sym_desc_vec::const_iterator var)
// Remove content from c and d, to be attached to GCD later
ex cont_c = c.content(x);
ex cont_d = d.content(x);
- ex gamma = gcd(cont_c, cont_d, NULL, NULL, false);
+ ex gamma = gcd(cont_c, cont_d, nullptr, nullptr, false);
if (ddeg == 0)
return gamma;
c = c.primpart(x, cont_c);
@@ -1163,8 +1163,8 @@ numeric numeric::max_coefficient() const
numeric add::max_coefficient() const
{
- epvector::const_iterator it = seq.begin();
- epvector::const_iterator itend = seq.end();
+ auto it = seq.begin();
+ auto itend = seq.end();
GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
numeric cur_max = abs(ex_to<numeric>(overall_coeff));
while (it != itend) {
@@ -1213,8 +1213,8 @@ ex add::smod(const numeric &xi) const
{
epvector newseq;
newseq.reserve(seq.size()+1);
- epvector::const_iterator it = seq.begin();
- epvector::const_iterator itend = seq.end();
+ auto it = seq.begin();
+ auto itend = seq.end();
while (it != itend) {
GINAC_ASSERT(!is_exactly_a<numeric>(it->rest));
numeric coeff = GiNaC::smod(ex_to<numeric>(it->coeff), xi);
@@ -1237,7 +1237,7 @@ ex mul::smod(const numeric &xi) const
it++;
}
#endif // def DO_GINAC_ASSERT
- mul * mulcopyp = new mul(*this);
+ auto mulcopyp = new mul(*this);
GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
mulcopyp->overall_coeff = GiNaC::smod(ex_to<numeric>(overall_coeff),xi);
mulcopyp->clearflag(status_flags::evaluated);
@@ -1615,7 +1615,7 @@ factored_b:
// The symbol with least degree which is contained in both polynomials
// is our main variable
- sym_desc_vec::iterator vari = sym_stats.begin();
+ auto vari = sym_stats.begin();
while ((vari != sym_stats.end()) &&
(((vari->ldeg_b == 0) && (vari->deg_b == 0)) ||
((vari->ldeg_a == 0) && (vari->deg_a == 0))))
@@ -1829,7 +1829,7 @@ ex sqrfree(const ex &a, const lst &l)
// recurse down the factors in remaining variables
if (newargs.nops()>0) {
- exvector::iterator i = factors.begin();
+ auto i = factors.begin();
while (i != factors.end()) {
*i = sqrfree(*i, newargs);
++i;
@@ -2120,7 +2120,7 @@ ex add::normal(exmap & repl, exmap & rev_lookup, int level) const
exvector nums, dens;
nums.reserve(seq.size()+1);
dens.reserve(seq.size()+1);
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
while (it != itend) {
ex n = ex_to<basic>(recombine_pair_to_ex(*it)).normal(repl, rev_lookup, level-1);
nums.push_back(n.op(0));
@@ -2179,7 +2179,7 @@ ex mul::normal(exmap & repl, exmap & rev_lookup, int level) const
exvector num; num.reserve(seq.size());
exvector den; den.reserve(seq.size());
ex n;
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
while (it != itend) {
n = ex_to<basic>(recombine_pair_to_ex(*it)).normal(repl, rev_lookup, level-1);
num.push_back(n.op(0));
@@ -2258,7 +2258,7 @@ ex power::normal(exmap & repl, exmap & rev_lookup, int level) const
ex pseries::normal(exmap & repl, exmap & rev_lookup, int level) const
{
epvector newseq;
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
ex restexp = i->rest.normal();
if (!restexp.is_zero())
@@ -2381,8 +2381,8 @@ ex ex::to_rational(lst & repl_lst) const
{
// Convert lst to exmap
exmap m;
- for (lst::const_iterator it = repl_lst.begin(); it != repl_lst.end(); ++it)
- m.insert(std::make_pair(it->op(0), it->op(1)));
+ for (const auto & elem : repl_lst)
+ m.insert(std::make_pair(elem.op(0), elem.op(1)));
ex ret = bp->to_rational(m);
@@ -2404,8 +2404,8 @@ ex ex::to_polynomial(lst & repl_lst) const
{
// Convert lst to exmap
exmap m;
- for (lst::const_iterator it = repl_lst.begin(); it != repl_lst.end(); ++it)
- m.insert(std::make_pair(it->op(0), it->op(1)));
+ for (const auto & elem : repl_lst)
+ m.insert(std::make_pair(elem.op(0), elem.op(1)));
ex ret = bp->to_polynomial(m);
@@ -2519,7 +2519,7 @@ ex expairseq::to_rational(exmap & repl) const
{
epvector s;
s.reserve(seq.size());
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
s.push_back(split_ex_to_pair(recombine_pair_to_ex(*i).to_rational(repl)));
++i;
@@ -2537,7 +2537,7 @@ ex expairseq::to_polynomial(exmap & repl) const
{
epvector s;
s.reserve(seq.size());
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
s.push_back(split_ex_to_pair(recombine_pair_to_ex(*i).to_polynomial(repl)));
++i;
diff --git a/ginac/normal.h b/ginac/normal.h
index 5f44427..8ea0e66 100644
--- a/ginac/normal.h
+++ b/ginac/normal.h
@@ -52,7 +52,7 @@ extern ex sprem(const ex &a, const ex &b, const ex &x, bool check_args = true);
extern bool divide(const ex &a, const ex &b, ex &q, bool check_args = true);
// Polynomial GCD in Z[X], cofactors are returned in ca and cb, if desired
-extern ex gcd(const ex &a, const ex &b, ex *ca = NULL, ex *cb = NULL, bool check_args = true);
+extern ex gcd(const ex &a, const ex &b, ex *ca = nullptr, ex *cb = nullptr, bool check_args = true);
// Polynomial LCM in Z[X]
extern ex lcm(const ex &a, const ex &b, bool check_args = true);
diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp
index 03f6314..28f79bd 100644
--- a/ginac/numeric.cpp
+++ b/ginac/numeric.cpp
@@ -207,7 +207,7 @@ inline bool Pynac_PyObj_RichCmp(PyObject *optr1, PyObject *optr2, int opid, cons
// than what we can do without those.
static bool initialized = false;
-static PyObject* pyfunc_Float = 0;
+static PyObject* pyfunc_Float = nullptr;
void ginac_pyinit_Float(PyObject* f) {
Py_INCREF(f);
@@ -220,7 +220,7 @@ void ginac_pyinit_I(PyObject* z) {
GiNaC::I = z; // I is a global constant defined below.
}
-static PyObject* pyfunc_Integer = 0;
+static PyObject* pyfunc_Integer = nullptr;
void ginac_pyinit_Integer(PyObject* f) {
Py_INCREF(f);
@@ -1465,7 +1465,7 @@ PyObject* numeric::to_pyobject() const {
default:
std::cout << t << std::endl;
stub("numeric::to_pyobject -- not able to do conversion to pyobject; everything else will be nonsense");
- return 0;
+ return nullptr;
}
}
diff --git a/ginac/numeric.h b/ginac/numeric.h
index 5ebcca2..c897ac6 100644
--- a/ginac/numeric.h
+++ b/ginac/numeric.h
@@ -122,7 +122,7 @@ public:
ex coeff(const ex & s, int n = 1) const;
bool has(const ex &other, unsigned options = 0) const;
ex eval(int level = 0) const;
- ex evalf(int level = 0, PyObject* parent = NULL) const;
+ ex evalf(int level = 0, PyObject* parent = nullptr) const;
ex subs(const exmap & m, unsigned options = 0) const
{
@@ -439,10 +439,10 @@ inline const numeric denom(const numeric &x)
// numeric evaluation functions for class constant objects:
-ex ConstantEvalf(unsigned serial, PyObject* parent = NULL);
-ex UnsignedInfinityEvalf(unsigned serial, PyObject* parent = NULL);
-ex InfinityEvalf(unsigned serial, PyObject* parent = NULL);
-ex NegInfinityEvalf(unsigned serial, PyObject* parent = NULL);
+ex ConstantEvalf(unsigned serial, PyObject* parent = nullptr);
+ex UnsignedInfinityEvalf(unsigned serial, PyObject* parent = nullptr);
+ex InfinityEvalf(unsigned serial, PyObject* parent = nullptr);
+ex NegInfinityEvalf(unsigned serial, PyObject* parent = nullptr);
} // namespace GiNaC
diff --git a/ginac/operators.cpp b/ginac/operators.cpp
index 87590f2..916332a 100644
--- a/ginac/operators.cpp
+++ b/ginac/operators.cpp
@@ -291,8 +291,8 @@ static void my_ios_callback(std::ios_base::event ev, std::ios_base & s, int i)
print_context *p = static_cast<print_context *>(s.pword(i));
if (ev == std::ios_base::erase_event) {
delete p;
- s.pword(i) = 0;
- } else if (ev == std::ios_base::copyfmt_event && p != 0)
+ s.pword(i) = nullptr;
+ } else if (ev == std::ios_base::copyfmt_event && p != nullptr)
s.pword(i) = p->duplicate();
}
@@ -335,7 +335,7 @@ static inline unsigned get_print_options(std::ios_base & s)
static void set_print_options(std::ostream & s, unsigned options)
{
print_context *p = get_print_context(s);
- if (p == 0)
+ if (p == nullptr)
set_print_context(s, print_dflt(s, options));
else
p->options = options;
@@ -344,7 +344,7 @@ static void set_print_options(std::ostream & s, unsigned options)
std::ostream & operator<<(std::ostream & os, const ex & e)
{
print_context *p = get_print_context(os);
- if (p == 0)
+ if (p == nullptr)
e.print(print_dflt(os));
else
e.print(*p);
@@ -354,8 +354,8 @@ std::ostream & operator<<(std::ostream & os, const ex & e)
std::ostream & operator<<(std::ostream & os, const exvector & e)
{
print_context *p = get_print_context(os);
- exvector::const_iterator i = e.begin();
- exvector::const_iterator vend = e.end();
+ auto i = e.begin();
+ auto vend = e.end();
if (i==vend) {
os << "[]";
@@ -364,7 +364,7 @@ std::ostream & operator<<(std::ostream & os, const exvector & e)
os << "[";
while (true) {
- if (p == 0)
+ if (p == nullptr)
i -> print(print_dflt(os));
else
i -> print(*p);
@@ -381,8 +381,8 @@ std::ostream & operator<<(std::ostream & os, const exvector & e)
std::ostream & operator<<(std::ostream & os, const exset & e)
{
print_context *p = get_print_context(os);
- exset::const_iterator i = e.begin();
- exset::const_iterator send = e.end();
+ auto i = e.begin();
+ auto send = e.end();
if (i==send) {
os << "<>";
@@ -391,7 +391,7 @@ std::ostream & operator<<(std::ostream & os, const exset & e)
os << "<";
while (true) {
- if (p == 0)
+ if (p == nullptr)
i->print(print_dflt(os));
else
i->print(*p);
@@ -408,8 +408,8 @@ std::ostream & operator<<(std::ostream & os, const exset & e)
std::ostream & operator<<(std::ostream & os, const exmap & e)
{
print_context *p = get_print_context(os);
- exmap::const_iterator i = e.begin();
- exmap::const_iterator mend = e.end();
+ auto i = e.begin();
+ auto mend = e.end();
if (i==mend) {
os << "{}";
@@ -418,12 +418,12 @@ std::ostream & operator<<(std::ostream & os, const exmap & e)
os << "{";
while (true) {
- if (p == 0)
+ if (p == nullptr)
i->first.print(print_dflt(os));
else
i->first.print(*p);
os << "==";
- if (p == 0)
+ if (p == nullptr)
i->second.print(print_dflt(os));
else
i->second.print(*p);
diff --git a/ginac/order.cpp b/ginac/order.cpp
index 1aa5ebf..399b767 100644
--- a/ginac/order.cpp
+++ b/ginac/order.cpp
@@ -376,10 +376,10 @@ int print_order::compare_same_type_mul(const mul &lh, const mul &rh) const
// compare each item in lh to corresponding element in rh
const epvector & sorted_seq1 = lh.get_sorted_seq();
const epvector & sorted_seq2 = rh.get_sorted_seq();
- epvector::const_reverse_iterator cit1 = sorted_seq1.rbegin();
- epvector::const_reverse_iterator cit2 = sorted_seq2.rbegin();
- epvector::const_reverse_iterator last1 = sorted_seq1.rend();
- epvector::const_reverse_iterator last2 = sorted_seq2.rend();
+ auto cit1 = sorted_seq1.rbegin();
+ auto cit2 = sorted_seq2.rbegin();
+ auto last1 = sorted_seq1.rend();
+ auto last2 = sorted_seq2.rend();
for (; (cit1!=last1)&&(cit2!=last2); ++cit1, ++cit2) {
// compare bases
@@ -502,10 +502,10 @@ int print_order::compare_same_type_add(const add &lh, const add &rh) const
const epvector & sorted_seq1 = lh.get_sorted_seq();
const epvector & sorted_seq2 = rh.get_sorted_seq();
- epvector::const_iterator cit1 = sorted_seq1.begin();
- epvector::const_iterator cit2 = sorted_seq2.begin();
- epvector::const_iterator last1 = sorted_seq1.end();
- epvector::const_iterator last2 = sorted_seq2.end();
+ auto cit1 = sorted_seq1.begin();
+ auto cit2 = sorted_seq2.begin();
+ auto last1 = sorted_seq1.end();
+ auto last2 = sorted_seq2.end();
for (; (cit1!=last1)&&(cit2!=last2); ++cit1, ++cit2) {
// compare bases
@@ -632,7 +632,7 @@ template <template <class T, class = std::allocator<T> > class C>
int print_order::compare_same_type_container(const container<C> &lh,
const container<C> &rh) const
{
- typename C<ex>::const_iterator it1 = lh.seq.begin(), it1end = lh.seq.end(),
+ auto it1 = lh.seq.begin(), it1end = lh.seq.end(),
it2 = rh.seq.begin(), it2end = rh.seq.end();
while (it1 != it1end && it2 != it2end) {
diff --git a/ginac/power.cpp b/ginac/power.cpp
index 7cd57d9..d13d43a 100644
--- a/ginac/power.cpp
+++ b/ginac/power.cpp
@@ -657,13 +657,13 @@ ex power::eval(int level) const
if (canonicalizable && (icont != *_num1_p)) {
const add& addref = ex_to<add>(ebasis);
- add* addp = new add(addref);
+ auto addp = new add(addref);
addp->setflag(status_flags::dynallocated);
addp->clearflag(status_flags::hash_calculated);
addp->overall_coeff = ex_to<numeric>(addp->overall_coeff).div_dyn(icont);
addp->seq_sorted.resize(0);
- for (epvector::iterator i = addp->seq.begin(); i != addp->seq.end(); ++i)
- i->coeff = ex_to<numeric>(i->coeff).div_dyn(icont);
+ for (auto & elem : addp->seq)
+ elem.coeff = ex_to<numeric>(elem.coeff).div_dyn(icont);
const numeric c = icont.power(*num_exponent);
if (likely(c != *_num1_p))
@@ -683,7 +683,7 @@ ex power::eval(int level) const
const numeric & num_coeff = ex_to<numeric>(mulref.overall_coeff);
if (num_coeff.is_real()) {
if (num_coeff.is_positive()) {
- mul *mulp = new mul(mulref);
+ auto mulp = new mul(mulref);
mulp->overall_coeff = _ex1;
mulp->setflag(status_flags::dynallocated);
mulp->clearflag(status_flags::evaluated);
@@ -694,7 +694,7 @@ ex power::eval(int level) const
} else {
GINAC_ASSERT(num_coeff.compare(*_num0_p)<0);
if (!num_coeff.is_equal(*_num_1_p)) {
- mul *mulp = new mul(mulref);
+ auto mulp = new mul(mulref);
mulp->overall_coeff = _ex_1;
mulp->setflag(status_flags::dynallocated);
mulp->clearflag(status_flags::evaluated);
@@ -796,7 +796,7 @@ ex power::subs(const exmap & m, unsigned options) const
if (!(options & subs_options::algebraic))
return subs_one_level(m, options);
- for (exmap::const_iterator it = m.begin(); it != m.end(); ++it) {
+ for (auto it = m.begin(); it != m.end(); ++it) {
int nummatches = std::numeric_limits<int>::max();
lst repls;
if (tryfactsubs(*this, it->first, nummatches, repls))
@@ -952,8 +952,8 @@ ex power::expand(unsigned options) const
epvector powseq;
prodseq.reserve(m.seq.size() + 1);
powseq.reserve(m.seq.size() + 1);
- epvector::const_iterator last = m.seq.end();
- epvector::const_iterator cit = m.seq.begin();
+ auto last = m.seq.end();
+ auto cit = m.seq.begin();
bool possign = true;
// search for positive/negative factors
@@ -997,8 +997,8 @@ ex power::expand(unsigned options) const
const add &a = ex_to<add>(expanded_exponent);
exvector distrseq;
distrseq.reserve(a.seq.size() + 1);
- epvector::const_iterator last = a.seq.end();
- epvector::const_iterator cit = a.seq.begin();
+ auto last = a.seq.end();
+ auto cit = a.seq.begin();
while (cit!=last) {
distrseq.push_back(power(expanded_basis, a.recombine_pair_to_ex(*cit)));
++cit;
@@ -1154,11 +1154,11 @@ ex power::expand_add_2(const add & a, unsigned options) const
epvector sum;
size_t a_nops = a.nops();
sum.reserve((a_nops*(a_nops+1))/2);
- epvector::const_iterator last = a.seq.end();
+ auto last = a.seq.end();
// power(+(x,...,z;c),2)=power(+(x,...,z;0),2)+2*c*+(x,...,z;0)+c*c
// first part: ignore overall_coeff and expand other terms
- for (epvector::const_iterator cit0=a.seq.begin(); cit0!=last; ++cit0) {
+ for (auto cit0=a.seq.begin(); cit0!=last; ++cit0) {
const ex & r = cit0->rest;
const ex & c = cit0->coeff;
@@ -1188,7 +1188,7 @@ ex power::expand_add_2(const add & a, unsigned options) const
}
}
- for (epvector::const_iterator cit1=cit0+1; cit1!=last; ++cit1) {
+ for (auto cit1=cit0+1; cit1!=last; ++cit1) {
const ex & r1 = cit1->rest;
const ex & c1 = cit1->coeff;
sum.push_back(a.combine_ex_with_coeff_to_pair((new mul(r,r1))->setflag(status_flags::dynallocated),
@@ -1200,7 +1200,7 @@ ex power::expand_add_2(const add & a, unsigned options) const
// second part: add terms coming from overall_factor (if != 0)
if (!a.overall_coeff.is_zero()) {
- epvector::const_iterator i = a.seq.begin(), end = a.seq.end();
+ auto i = a.seq.begin(), end = a.seq.end();
while (i != end) {
sum.push_back(a.combine_pair_with_coeff_to_pair(*i, ex_to<numeric>(a.overall_coeff).mul_dyn(*_num2_p)));
++i;
@@ -1243,8 +1243,8 @@ ex power::expand_mul(const mul & m, const numeric & n, unsigned options, bool fr
distrseq.reserve(m.seq.size());
bool need_reexpand = false;
- epvector::const_iterator last = m.seq.end();
- epvector::const_iterator cit = m.seq.begin();
+ auto last = m.seq.end();
+ auto cit = m.seq.begin();
while (cit!=last) {
expair p = m.combine_pair_with_coeff_to_pair(*cit, n);
if (from_expand && is_exactly_a<add>(cit->rest) && ex_to<numeric>(p.coeff).is_pos_integer()) {
diff --git a/ginac/power.h b/ginac/power.h
index 306a9db..20b0c65 100644
--- a/ginac/power.h
+++ b/ginac/power.h
@@ -48,8 +48,8 @@ class power : public basic
// other constructors
public:
- power(const ex & lh, const ex & rh) : inherited(&power::tinfo_static), basis(lh), exponent(rh) {}
- template<typename T> power(const ex & lh, const T & rh) : inherited(&power::tinfo_static), basis(lh), exponent(rh) {}
+ power(ex lh, ex rh) : inherited(&power::tinfo_static), basis(std::move(lh)), exponent(std::move(rh)) {}
+ template<typename T> power(ex lh, const T & rh) : inherited(&power::tinfo_static), basis(std::move(lh)), exponent(rh) {}
// functions overriding virtual functions from base classes
public:
@@ -63,7 +63,7 @@ public:
int ldegree(const ex & s) const;
ex coeff(const ex & s, int n = 1) const;
ex eval(int level=0) const;
- ex evalf(int level=0, PyObject* parent=NULL) const;
+ ex evalf(int level=0, PyObject* parent=nullptr) const;
ex evalm() const;
ex series(const relational & s, int order, unsigned options = 0) const;
ex subs(const exmap & m, unsigned options = 0) const;
diff --git a/ginac/print.h b/ginac/print.h
index e2ba250..1e30b4f 100644
--- a/ginac/print.h
+++ b/ginac/print.h
@@ -180,7 +180,7 @@ public:
/** Check if obj is a T, including base classes. */
template <class T>
inline bool is_a(const print_context & obj)
-{ return dynamic_cast<const T *>(&obj) != 0; }
+{ return dynamic_cast<const T *>(&obj) != nullptr; }
class basic;
@@ -239,9 +239,9 @@ private:
* implements the actual function call. */
class print_functor {
public:
- print_functor() : impl(0) {}
- print_functor(const print_functor & other) : impl(other.impl.get() ? other.impl->duplicate() : 0) {}
- print_functor(std::auto_ptr<print_functor_impl> impl_) : impl(impl_) {}
+ print_functor() : impl(nullptr) {}
+ print_functor(const print_functor & other) : impl(other.impl.get() ? other.impl->duplicate() : nullptr) {}
+ print_functor(std::unique_ptr<print_functor_impl> impl_) : impl(std::move(impl_)) {}
template <class T, class C>
print_functor(void f(const T &, const C &, unsigned)) : impl(new print_ptrfun_handler<T, C>(f)) {}
@@ -253,7 +253,7 @@ public:
{
if (this != &other) {
print_functor_impl *p = other.impl.get();
- impl.reset(p ? other.impl->duplicate() : 0);
+ impl.reset(p ? other.impl->duplicate() : nullptr);
}
return *this;
}
@@ -266,7 +266,7 @@ public:
bool is_valid() const { return impl.get(); }
private:
- std::auto_ptr<print_functor_impl> impl;
+ std::unique_ptr<print_functor_impl> impl;
};
diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp
index 868a106..fec80c1 100644
--- a/ginac/pseries.cpp
+++ b/ginac/pseries.cpp
@@ -68,7 +68,7 @@ pseries::pseries() : inherited(&pseries::tinfo_static) { }
* @param rel_ expansion variable and point (must hold a relational)
* @param ops_ vector of {coefficient, power} pairs (coefficient must not be zero)
* @return newly constructed pseries */
-pseries::pseries(const ex &rel_, const epvector &ops_) : basic(&pseries::tinfo_static), seq(ops_)
+pseries::pseries(const ex &rel_, epvector ops_) : basic(&pseries::tinfo_static), seq(std::move(ops_))
{
GINAC_ASSERT(is_a<relational>(rel_));
GINAC_ASSERT(is_a<symbol>(rel_.lhs()));
@@ -83,12 +83,12 @@ pseries::pseries(const ex &rel_, const epvector &ops_) : basic(&pseries::tinfo_s
pseries::pseries(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
{
- archive_node::archive_node_cit first = n.find_first("coeff");
- archive_node::archive_node_cit last = n.find_last("power");
+ auto first = n.find_first("coeff");
+ auto last = n.find_last("power");
++last;
seq.reserve((last-first)/2);
- for (archive_node::archive_node_cit loc = first; loc < last;) {
+ for (auto loc = first; loc < last;) {
ex rest;
ex coeff;
n.find_ex_by_loc(loc++, rest, sym_lst);
@@ -103,7 +103,7 @@ pseries::pseries(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
void pseries::archive(archive_node &n) const
{
inherited::archive(n);
- epvector::const_iterator i = seq.begin(), iend = seq.end();
+ auto i = seq.begin(), iend = seq.end();
while (i != iend) {
n.add_ex("coeff", i->rest);
n.add_ex("power", i->coeff);
@@ -129,7 +129,7 @@ void pseries::print_series(const print_context & c, const char *openbrace, const
if (seq.empty())
c.s << '0';
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
// print a sign, if needed
@@ -248,7 +248,7 @@ int pseries::compare_same_type(const basic & other) const
return cmpval;
// ...and if that failed the individual elements
- epvector::const_iterator it = seq.begin(), o_it = o.seq.begin();
+ auto it = seq.begin(), o_it = o.seq.begin();
while (it!=seq.end() && o_it!=o.seq.end()) {
cmpval = it->compare(*o_it);
if (cmpval)
@@ -290,7 +290,7 @@ int pseries::degree(const ex &s) const
else
return 0;
} else {
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
if (it == itend)
return 0;
int max_pow = std::numeric_limits<int>::min();
@@ -318,7 +318,7 @@ int pseries::ldegree(const ex &s) const
else
return 0;
} else {
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
if (it == itend)
return 0;
int min_pow = std::numeric_limits<int>::max();
@@ -388,7 +388,7 @@ ex pseries::eval(int level) const
// Construct a new series with evaluated coefficients
epvector new_seq;
new_seq.reserve(seq.size());
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
while (it != itend) {
new_seq.push_back(expair(it->rest.eval(level-1), it->coeff));
++it;
@@ -408,7 +408,7 @@ ex pseries::evalf(int level, PyObject* parent) const
// Construct a new series with evaluated coefficients
epvector new_seq;
new_seq.reserve(seq.size());
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
while (it != itend) {
new_seq.push_back(expair(it->rest.evalf(level-1, parent),
it->coeff));
@@ -444,8 +444,8 @@ ex pseries::real_part() const
epvector v;
v.reserve(seq.size());
- for(epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i)
- v.push_back(expair((i->rest).real_part(), i->coeff));
+ for(const auto & elem : seq)
+ v.push_back(expair((elem.rest).real_part(), elem.coeff));
return (new pseries(var==point, v))->setflag(status_flags::dynallocated);
}
@@ -459,15 +459,15 @@ ex pseries::imag_part() const
epvector v;
v.reserve(seq.size());
- for(epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i)
- v.push_back(expair((i->rest).imag_part(), i->coeff));
+ for(const auto & elem : seq)
+ v.push_back(expair((elem.rest).imag_part(), elem.coeff));
return (new pseries(var==point, v))->setflag(status_flags::dynallocated);
}
ex pseries::eval_integ() const
{
- epvector *newseq = NULL;
- for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
+ epvector *newseq = nullptr;
+ for (auto i=seq.begin(); i!=seq.end(); ++i) {
if (newseq) {
newseq->push_back(expair(i->rest.eval_integ(), i->coeff));
continue;
@@ -476,7 +476,7 @@ ex pseries::eval_integ() const
if (!are_ex_trivially_equal(newterm, i->rest)) {
newseq = new epvector;
newseq->reserve(seq.size());
- for (epvector::const_iterator j=seq.begin(); j!=i; ++j)
+ for (auto j=seq.begin(); j!=i; ++j)
newseq->push_back(*j);
newseq->push_back(expair(newterm, i->coeff));
}
@@ -494,7 +494,7 @@ ex pseries::evalm() const
// evalm each coefficient
epvector newseq;
bool something_changed = false;
- for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
+ for (auto i=seq.begin(); i!=seq.end(); ++i) {
if (something_changed) {
ex newcoeff = i->rest.evalm();
if (!newcoeff.is_zero())
@@ -529,7 +529,7 @@ ex pseries::subs(const exmap & m, unsigned options) const
// expansion point
epvector newseq;
newseq.reserve(seq.size());
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
while (it != itend) {
newseq.push_back(expair(it->rest.subs(m, options), it->coeff));
++it;
@@ -542,7 +542,7 @@ ex pseries::subs(const exmap & m, unsigned options) const
ex pseries::expand(unsigned options) const
{
epvector newseq;
- epvector::const_iterator i = seq.begin(), end = seq.end();
+ auto i = seq.begin(), end = seq.end();
while (i != end) {
ex restexp = i->rest.expand();
if (!restexp.is_zero())
@@ -558,7 +558,7 @@ ex pseries::expand(unsigned options) const
ex pseries::derivative(const symbol & s) const
{
epvector new_seq;
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
if (s == var) {
@@ -594,7 +594,7 @@ ex pseries::derivative(const symbol & s) const
ex pseries::convert_to_poly(bool no_order) const
{
ex e;
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
while (it != itend) {
if (is_order_function(it->rest)) {
@@ -714,10 +714,10 @@ ex pseries::add_series(const pseries &other) const
// Series addition
epvector new_seq;
- epvector::const_iterator a = seq.begin();
- epvector::const_iterator b = other.seq.begin();
- epvector::const_iterator a_end = seq.end();
- epvector::const_iterator b_end = other.seq.end();
+ auto a = seq.begin();
+ auto b = other.seq.begin();
+ auto a_end = seq.end();
+ auto b_end = other.seq.end();
int pow_a = std::numeric_limits<int>::max(), pow_b = std::numeric_limits<int>::max();
for (;;) {
// If a is empty, fill up with elements from b and stop
@@ -782,8 +782,8 @@ ex add::series(const relational & r, int order, unsigned options) const
acc = overall_coeff.series(r, order, options);
// Add remaining terms
- epvector::const_iterator it = seq.begin();
- epvector::const_iterator itend = seq.end();
+ auto it = seq.begin();
+ auto itend = seq.end();
for (; it!=itend; ++it) {
ex op;
if (is_exactly_a<pseries>(it->rest))
@@ -810,7 +810,7 @@ ex pseries::mul_const(const numeric &other) const
epvector new_seq;
new_seq.reserve(seq.size());
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
while (it != itend) {
if (!is_order_function(it->rest))
new_seq.push_back(expair(it->rest * other, it->coeff));
@@ -1089,7 +1089,7 @@ ex pseries::power_const(const numeric &p, int deg) const
pseries pseries::shift_exponents(int deg) const
{
epvector newseq = seq;
- epvector::iterator i = newseq.begin(), end = newseq.end();
+ auto i = newseq.begin(), end = newseq.end();
while (i != end) {
i->coeff += deg;
++i;
@@ -1209,7 +1209,7 @@ ex pseries::series(const relational & r, int order, unsigned options) const
return *this;
else {
epvector new_seq;
- epvector::const_iterator it = seq.begin(), itend = seq.end();
+ auto it = seq.begin(), itend = seq.end();
while (it != itend) {
int o = ex_to<numeric>(it->coeff).to_int();
if (o >= order) {
diff --git a/ginac/pseries.h b/ginac/pseries.h
index 6a843c4..7f94fa5 100644
--- a/ginac/pseries.h
+++ b/ginac/pseries.h
@@ -38,7 +38,7 @@ class pseries : public basic
// other constructors
public:
- pseries(const ex &rel_, const epvector &ops_);
+ pseries(const ex &rel_, epvector ops_);
// functions overriding virtual functions from base classes
public:
@@ -50,7 +50,7 @@ public:
ex coeff(const ex &s, int n = 1) const;
ex collect(const ex &s, bool distributed = false) const;
ex eval(int level=0) const;
- ex evalf(int level=0, PyObject* parent=NULL) const;
+ ex evalf(int level=0, PyObject* parent=nullptr) const;
ex series(const relational & r, int order, unsigned options = 0) const;
ex subs(const exmap & m, unsigned options = 0) const;
ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const;
diff --git a/ginac/py_funcs.h b/ginac/py_funcs.h
index ce8aae9..29beb98 100644
--- a/ginac/py_funcs.h
+++ b/ginac/py_funcs.h
@@ -7,7 +7,7 @@
#ifndef PY_FUNC_H_
# define PY_FUNC_H_
-#include <python/Python.h>
+#include <Python.h>
#include "basic.h"
#include "constant.h"
#include "ex.h"
@@ -117,7 +117,7 @@ namespace GiNaC {
PyObject* (*paramset_to_PyTuple)(const GiNaC::paramset &s);
PyObject* (*py_rational_power_parts)(PyObject* basis, PyObject* exp);
- };
+ };
extern py_funcs_struct py_funcs;
diff --git a/ginac/relational.cpp b/ginac/relational.cpp
index 023a735..549d050 100644
--- a/ginac/relational.cpp
+++ b/ginac/relational.cpp
@@ -51,7 +51,7 @@ relational::relational() : basic(&relational::tinfo_static) {}
// public
-relational::relational(const ex & lhs, const ex & rhs, operators oper) : basic(&relational::tinfo_static), lh(lhs), rh(rhs), o(oper) {}
+relational::relational(ex lhs, ex rhs, operators oper) : basic(&relational::tinfo_static), lh(std::move(lhs)), rh(std::move(rhs)), o(oper) {}
//////////
// archiving
@@ -373,7 +373,7 @@ relational::operators relational::the_operator() const
relational::safe_bool relational::make_safe_bool(bool cond) const
{
- return cond? &safe_bool_helper::nonnull : 0;
+ return cond? &safe_bool_helper::nonnull : nullptr;
}
/** Cast the relational into a boolean, mainly for evaluation within an
diff --git a/ginac/relational.h b/ginac/relational.h
index f0ceec8..014574f 100644
--- a/ginac/relational.h
+++ b/ginac/relational.h
@@ -47,7 +47,7 @@ public:
// other constructors
public:
- relational(const ex & lhs, const ex & rhs, operators oper=equal);
+ relational(ex lhs, ex rhs, operators oper=equal);
// functions overriding virtual functions from base classes
public:
diff --git a/ginac/remember.cpp b/ginac/remember.cpp
index 98591da..149afbf 100644
--- a/ginac/remember.cpp
+++ b/ginac/remember.cpp
@@ -33,8 +33,8 @@ namespace GiNaC {
// class remember_table_entry
//////////
-remember_table_entry::remember_table_entry(function const & f, ex const & r)
- : hashvalue(f.gethash()), seq(f.seq), result(r)
+remember_table_entry::remember_table_entry(function const & f, ex r)
+ : hashvalue(f.gethash()), seq(f.seq), result(std::move(r))
{
++last_access = access_counter;
successful_hits = 0;
@@ -81,8 +81,8 @@ void remember_table_list::add_entry(function const & f, ex const & result)
}
case remember_strategies::delete_lru: {
// delete least recently used entry
- iterator it = begin();
- iterator lowest_access_it = it;
+ auto it = begin();
+ auto lowest_access_it = it;
unsigned long lowest_access = (*it).get_last_access();
++it;
while (it!=end()) {
@@ -97,8 +97,8 @@ void remember_table_list::add_entry(function const & f, ex const & result)
}
case remember_strategies::delete_lfu: {
// delete least frequently used entry
- iterator it = begin();
- iterator lowest_hits_it = it;
+ auto it = begin();
+ auto lowest_hits_it = it;
unsigned lowest_hits = (*it).get_successful_hits();
++it;
while (it!=end()) {
@@ -121,7 +121,7 @@ void remember_table_list::add_entry(function const & f, ex const & result)
bool remember_table_list::lookup_entry(function const & f, ex & result) const
{
- const_iterator i = begin(), iend = end();
+ auto i = begin(), iend = end();
while (i != iend) {
if (i->is_equal(f)) {
result = i->get_result();
@@ -183,7 +183,7 @@ void remember_table::init_table()
std::vector<remember_table> & remember_table::remember_tables()
{
- static std::vector<remember_table> * rt = new std::vector<remember_table>;
+ static auto rt = new std::vector<remember_table>;
return *rt;
}
diff --git a/ginac/remember.h b/ginac/remember.h
index 9a32d17..d9afe44 100644
--- a/ginac/remember.h
+++ b/ginac/remember.h
@@ -39,7 +39,7 @@ class ex;
* 'is_equal'. */
class remember_table_entry {
public:
- remember_table_entry(function const & f, ex const & r);
+ remember_table_entry(function const & f, ex r);
bool is_equal(function const & f) const;
ex get_result() const { return result; }
unsigned long get_last_access() const { return last_access; }
diff --git a/ginac/structure.h b/ginac/structure.h
index e2520be..99ee4cc 100644
--- a/ginac/structure.h
+++ b/ginac/structure.h
@@ -131,7 +131,7 @@ public:
public:
// evaluation
ex eval(int level = 0) const { return hold(); }
- ex evalf(int level = 0, PyObject* parent=NULL) const {
+ ex evalf(int level = 0, PyObject* parent=nullptr) const {
return inherited::evalf(level, parent); }
ex evalm() const { return inherited::evalm(); }
protected:
diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp
index 9c821a4..1658aba 100644
--- a/ginac/symbol.cpp
+++ b/ginac/symbol.cpp
@@ -77,26 +77,26 @@ possymbol::possymbol()
// symbol
-symbol::symbol(const std::string & initname, unsigned domain)
- : inherited(&symbol::tinfo_static), serial(next_serial++), name(initname), TeX_name(default_TeX_name()), domain(domain), ret_type(return_types::commutative), ret_type_tinfo(&symbol::tinfo_static)
+symbol::symbol(std::string initname, unsigned domain)
+ : inherited(&symbol::tinfo_static), serial(next_serial++), name(std::move(initname)), TeX_name(default_TeX_name()), domain(domain), ret_type(return_types::commutative), ret_type_tinfo(&symbol::tinfo_static)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
-symbol::symbol(const std::string & initname, unsigned rt, tinfo_t rtt, unsigned domain)
- : inherited(&symbol::tinfo_static), serial(next_serial++), name(initname), TeX_name(default_TeX_name()), domain(domain), ret_type(rt), ret_type_tinfo(rtt)
+symbol::symbol(std::string initname, unsigned rt, tinfo_t rtt, unsigned domain)
+ : inherited(&symbol::tinfo_static), serial(next_serial++), name(std::move(initname)), TeX_name(default_TeX_name()), domain(domain), ret_type(rt), ret_type_tinfo(rtt)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
-symbol::symbol(const std::string & initname, const std::string & texname, unsigned domain)
- : inherited(&symbol::tinfo_static), serial(next_serial++), name(initname), TeX_name(texname), domain(domain), ret_type(return_types::commutative), ret_type_tinfo(&symbol::tinfo_static)
+symbol::symbol(std::string initname, std::string texname, unsigned domain)
+ : inherited(&symbol::tinfo_static), serial(next_serial++), name(std::move(initname)), TeX_name(std::move(texname)), domain(domain), ret_type(return_types::commutative), ret_type_tinfo(&symbol::tinfo_static)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
-symbol::symbol(const std::string & initname, const std::string & texname, unsigned rt, tinfo_t rtt, unsigned domain)
- : inherited(&symbol::tinfo_static), serial(next_serial++), name(initname), TeX_name(texname), domain(domain), ret_type(rt), ret_type_tinfo(rtt)
+symbol::symbol(std::string initname, std::string texname, unsigned rt, tinfo_t rtt, unsigned domain)
+ : inherited(&symbol::tinfo_static), serial(next_serial++), name(std::move(initname)), TeX_name(std::move(texname)), domain(domain), ret_type(rt), ret_type_tinfo(rtt)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
@@ -154,9 +154,9 @@ ex symbol::unarchive(const archive_node &n, lst &sym_lst)
ex s = (new symbol(n, sym_lst))->setflag(status_flags::dynallocated);
// If symbol is in sym_lst, return the existing symbol
- for (lst::const_iterator it = sym_lst.begin(); it != sym_lst.end(); ++it) {
- if (is_a<symbol>(*it) && (ex_to<symbol>(*it).name == ex_to<symbol>(s).name))
- return *it;
+ for (const auto & elem : sym_lst) {
+ if (is_a<symbol>(elem) && (ex_to<symbol>(elem).name == ex_to<symbol>(s).name))
+ return elem;
}
// Otherwise add new symbol to list and return it
@@ -387,7 +387,7 @@ unsigned symbol::next_serial = 0;
const symbol & get_symbol(const std::string & s)
{
static std::map<std::string, symbol> directory;
- std::map<std::string, symbol>::iterator i = directory.find(s);
+ auto i = directory.find(s);
if (i != directory.end()) {
return i->second;
}
diff --git a/ginac/symbol.h b/ginac/symbol.h
index 39f428e..99dcee4 100644
--- a/ginac/symbol.h
+++ b/ginac/symbol.h
@@ -51,11 +51,11 @@ class symbol : public basic
// other constructors
public:
- explicit symbol(const std::string & initname, unsigned domain = domain::complex);
- symbol(const std::string & initname, const std::string & texname, unsigned domain = domain::complex);
+ explicit symbol(std::string initname, unsigned domain = domain::complex);
+ symbol(std::string initname, std::string texname, unsigned domain = domain::complex);
symbol(const std::string & initname, const std::string & texname, unsigned rt, unsigned domain);
- symbol(const std::string & initname, unsigned rt, tinfo_t rtt, unsigned domain = domain::complex);
- symbol(const std::string & initname, const std::string & texname, unsigned rt, tinfo_t rtt, unsigned domain = domain::complex);
+ symbol(std::string initname, unsigned rt, tinfo_t rtt, unsigned domain = domain::complex);
+ symbol(std::string initname, std::string texname, unsigned rt, tinfo_t rtt, unsigned domain = domain::complex);
// functions overriding virtual functions from base classes
public:
diff --git a/ginac/symmetry.cpp b/ginac/symmetry.cpp
index 1ab495e..2160502 100644
--- a/ginac/symmetry.cpp
+++ b/ginac/symmetry.cpp
@@ -120,13 +120,13 @@ void symmetry::archive(archive_node &n) const
n.add_unsigned("type", type);
if (children.empty()) {
- std::set<unsigned>::const_iterator i = indices.begin(), iend = indices.end();
+ auto i = indices.begin(), iend = indices.end();
while (i != iend) {
n.add_unsigned("index", *i);
i++;
}
} else {
- exvector::const_iterator i = children.begin(), iend = children.end();
+ auto i = children.begin(), iend = children.end();
while (i != iend) {
n.add_ex("child", *i);
i++;
@@ -161,8 +161,8 @@ int symmetry::compare_same_type(const basic & other) const
if (this_size < that_size)
return -1;
typedef std::set<unsigned>::const_iterator set_it;
- set_it end = indices.end();
- for (set_it i=indices.begin(),j=othersymm.indices.begin(); i!=end; ++i,++j) {
+ auto end = indices.end();
+ for (auto i=indices.begin(),j=othersymm.indices.begin(); i!=end; ++i,++j) {
if(*i < *j)
return 1;
if(*i > *j)
@@ -193,10 +193,10 @@ unsigned symmetry::calchash() const
if (!indices.empty())
v ^= *(indices.begin());
} else {
- for (exvector::const_iterator i=children.begin(); i!=children.end(); ++i)
+ for (const auto & elem : children)
{
v = rotate_left(v);
- v ^= i->gethash();
+ v ^= elem.gethash();
}
}
@@ -250,7 +250,7 @@ void symmetry::do_print_tree(const print_tree & c, unsigned level) const
c.s << ", indices=(";
if (!indices.empty()) {
- std::set<unsigned>::const_iterator i = indices.begin(), end = indices.end();
+ auto i = indices.begin(), end = indices.end();
--end;
while (i != end)
c.s << *i++ << ",";
@@ -258,7 +258,7 @@ void symmetry::do_print_tree(const print_tree & c, unsigned level) const
}
c.s << ")\n";
- exvector::const_iterator i = children.begin(), end = children.end();
+ auto i = children.begin(), end = children.end();
while (i != end) {
i->print(c, level + c.delta_indent);
++i;
@@ -274,8 +274,8 @@ bool symmetry::has_nonsymmetric() const
if (type == antisymmetric || type == cyclic)
return true;
- for (exvector::const_iterator i=children.begin(); i!=children.end(); ++i)
- if (ex_to<symmetry>(*i).has_nonsymmetric())
+ for (const auto & elem : children)
+ if (ex_to<symmetry>(elem).has_nonsymmetric())
return true;
return false;
@@ -286,8 +286,8 @@ bool symmetry::has_cyclic() const
if (type == cyclic)
return true;
- for (exvector::const_iterator i=children.begin(); i!=children.end(); ++i)
- if (ex_to<symmetry>(*i).has_cyclic())
+ for (const auto & elem : children)
+ if (ex_to<symmetry>(elem).has_cyclic())
return true;
return false;
@@ -400,14 +400,14 @@ class sy_is_less : public std::binary_function<ex, ex, bool> {
exvector::iterator v;
public:
- sy_is_less(exvector::iterator v_) : v(v_) {}
+ sy_is_less(exvector::iterator v_) : v(std::move(v_)) {}
bool operator() (const ex &lh, const ex &rh) const
{
GINAC_ASSERT(is_exactly_a<symmetry>(lh));
GINAC_ASSERT(is_exactly_a<symmetry>(rh));
GINAC_ASSERT(ex_to<symmetry>(lh).indices.size() == ex_to<symmetry>(rh).indices.size());
- std::set<unsigned>::const_iterator ait = ex_to<symmetry>(lh).indices.begin(), aitend = ex_to<symmetry>(lh).indices.end(), bit = ex_to<symmetry>(rh).indices.begin();
+ auto ait = ex_to<symmetry>(lh).indices.begin(), aitend = ex_to<symmetry>(lh).indices.end(), bit = ex_to<symmetry>(rh).indices.begin();
while (ait != aitend) {
int cmpval = v[*ait].compare(v[*bit]);
if (cmpval < 0)
@@ -426,14 +426,14 @@ class sy_swap : public std::binary_function<ex, ex, void> {
public:
bool &swapped;
- sy_swap(exvector::iterator v_, bool &s) : v(v_), swapped(s) {}
+ sy_swap(exvector::iterator v_, bool &s) : v(std::move(v_)), swapped(s) {}
void operator() (const ex &lh, const ex &rh)
{
GINAC_ASSERT(is_exactly_a<symmetry>(lh));
GINAC_ASSERT(is_exactly_a<symmetry>(rh));
GINAC_ASSERT(ex_to<symmetry>(lh).indices.size() == ex_to<symmetry>(rh).indices.size());
- std::set<unsigned>::const_iterator ait = ex_to<symmetry>(lh).indices.begin(), aitend = ex_to<symmetry>(lh).indices.end(), bit = ex_to<symmetry>(rh).indices.begin();
+ auto ait = ex_to<symmetry>(lh).indices.begin(), aitend = ex_to<symmetry>(lh).indices.end(), bit = ex_to<symmetry>(rh).indices.begin();
while (ait != aitend) {
v[*ait].swap(v[*bit]);
++ait; ++bit;
@@ -451,7 +451,7 @@ int canonicalize(exvector::iterator v, const symmetry &symm)
// Canonicalize children first
bool something_changed = false;
int sign = 1;
- exvector::const_iterator first = symm.children.begin(), last = symm.children.end();
+ auto first = symm.children.begin(), last = symm.children.end();
while (first != last) {
GINAC_ASSERT(is_exactly_a<symmetry>(*first));
int child_sign = canonicalize(v, ex_to<symmetry>(*first));
@@ -503,7 +503,7 @@ static ex symm(const ex & e, exvector::const_iterator first, exvector::const_ite
unsigned *iv = new unsigned[num], *iv2;
for (unsigned i=0; i<num; i++)
iv[i] = i;
- iv2 = (asymmetric ? new unsigned[num] : NULL);
+ iv2 = (asymmetric ? new unsigned[num] : nullptr);
// Loop over all permutations (the first permutation, which is the
// identity, is unrolled)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pynac.git
More information about the debian-science-commits
mailing list