GINAC_ASSERT(is_canonical());
}
-add::add(epvector * vp, const ex & oc)
+add::add(std::auto_ptr<epvector> vp, const ex & oc)
{
tinfo_key = TINFO_add;
GINAC_ASSERT(vp!=0);
overall_coeff = oc;
construct_from_epvector(*vp);
- delete vp;
GINAC_ASSERT(is_canonical());
}
ex add::coeff(const ex & s, int n) const
{
- epvector *coeffseq = new epvector();
+ std::auto_ptr<epvector> coeffseq(new epvector);
// Calculate sum of coefficients in each term
epvector::const_iterator i = seq.begin(), end = seq.end();
* @param level cut-off in recursive evaluation */
ex add::eval(int level) const
{
- epvector *evaled_seqp = evalchildren(level);
- if (evaled_seqp) {
+ std::auto_ptr<epvector> evaled_seqp = evalchildren(level);
+ if (evaled_seqp.get()) {
// do more evaluation later
return (new add(evaled_seqp, overall_coeff))->
setflag(status_flags::dynallocated);
{
// Evaluate children first and add up all matrices. Stop if there's one
// term that is not a matrix.
- epvector *s = new epvector;
+ std::auto_ptr<epvector> s(new epvector);
s->reserve(seq.size());
bool all_matrices = true;
++it;
}
- if (all_matrices) {
- delete s;
+ if (all_matrices)
return sum + overall_coeff;
- } else
+ else
return (new add(s, overall_coeff))->setflag(status_flags::dynallocated);
}
* @see ex::diff */
ex add::derivative(const symbol & y) const
{
- epvector *s = new epvector();
+ std::auto_ptr<epvector> s(new epvector);
s->reserve(seq.size());
// Only differentiate the "rest" parts of the expairs. This is faster
return (new add(v,oc))->setflag(status_flags::dynallocated);
}
-ex add::thisexpairseq(epvector * vp, const ex & oc) const
+ex add::thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc) const
{
return (new add(vp,oc))->setflag(status_flags::dynallocated);
}
ex add::expand(unsigned options) const
{
- epvector *vp = expandchildren(options);
- if (vp == NULL) {
+ std::auto_ptr<epvector> vp = expandchildren(options);
+ if (vp.get() == 0) {
// the terms have not changed, so it is safe to declare this expanded
return (options == 0) ? setflag(status_flags::expanded) : *this;
}
add(const exvector & v);
add(const epvector & v);
add(const epvector & v, const ex & oc);
- add(epvector * vp, const ex & oc);
+ add(std::auto_ptr<epvector> vp, const ex & oc);
// functions overriding virtual functions from base classes
public:
unsigned return_type() const;
unsigned return_type_tinfo() const;
ex thisexpairseq(const epvector & v, const ex & oc) const;
- ex thisexpairseq(epvector * vp, const ex & oc) const;
+ ex thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc) const;
expair split_ex_to_pair(const ex & e) const;
expair combine_ex_with_coeff_to_pair(const ex & e,
const ex & c) const;
tinfo_key = TINFO_clifford;
}
-clifford::clifford(unsigned char rl, exvector * vp) : inherited(sy_none(), vp), representation_label(rl)
+clifford::clifford(unsigned char rl, std::auto_ptr<exvector> vp) : inherited(sy_none(), vp), representation_label(rl)
{
tinfo_key = TINFO_clifford;
}
return clifford(representation_label, v);
}
-ex clifford::thiscontainer(exvector * vp) const
+ex clifford::thiscontainer(std::auto_ptr<exvector> vp) const
{
return clifford(representation_label, vp);
}
// internal constructors
clifford(unsigned char rl, const exvector & v, bool discardable = false);
- clifford(unsigned char rl, exvector * vp); // vp will be deleted
+ clifford(unsigned char rl, std::auto_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(exvector * vp) const;
+ ex thiscontainer(std::auto_ptr<exvector> vp) const;
unsigned return_type() const { return return_types::noncommutative; }
unsigned return_type_tinfo() const { return TINFO_clifford + representation_label; }
tinfo_key = TINFO_color;
}
-color::color(unsigned char rl, exvector * vp) : inherited(sy_none(), vp), representation_label(rl)
+color::color(unsigned char rl, std::auto_ptr<exvector> vp) : inherited(sy_none(), vp), representation_label(rl)
{
tinfo_key = TINFO_color;
}
return color(representation_label, v);
}
-ex color::thiscontainer(exvector * vp) const
+ex color::thiscontainer(std::auto_ptr<exvector> vp) const
{
return color(representation_label, vp);
}
// internal constructors
color(unsigned char rl, const exvector & v, bool discardable = false);
- color(unsigned char rl, exvector * vp); // vp will be deleted
+ color(unsigned char rl, std::auto_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(exvector * vp) const;
+ ex thiscontainer(std::auto_ptr<exvector> vp) const;
unsigned return_type() const { return return_types::noncommutative; }
unsigned return_type_tinfo() const { return TINFO_color + representation_label; }
#include <algorithm>
#include <vector>
#include <list>
+#include <memory>
#include "ex.h"
#include "print.h"
this->seq = s;
}
- explicit container(STLT * vp) : inherited(get_tinfo())
+ explicit container(std::auto_ptr<STLT> vp) : inherited(get_tinfo())
{
- if (vp == 0) {
- // lst(0) ends up here
- this->seq.push_back(0);
- } else {
- this->seq.swap(*vp);
- delete vp;
- }
+ this->seq.swap(*vp);
}
container(exvector::const_iterator b, exvector::const_iterator e)
/** Similar to duplicate(), but with a preset sequence (which gets
* deleted). Must be overridden by derived classes. */
- virtual ex thiscontainer(STLT * vp) const { return container(vp); }
+ virtual ex thiscontainer(std::auto_ptr<STLT> vp) const { return container(vp); }
virtual void printseq(const print_context & c, char openbracket, char delim,
char closebracket, unsigned this_precedence,
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;
- STLT *subschildren(const exmap & m, unsigned options = 0) const;
+ std::auto_ptr<STLT> subschildren(const exmap & m, unsigned options = 0) const;
};
/** Default constructor */
template <template <class> class C>
ex container<C>::subs(const exmap & m, unsigned options) const
{
- STLT *vp = subschildren(m, options);
- if (vp)
+ std::auto_ptr<STLT> vp = subschildren(m, options);
+ if (vp.get())
return ex_to<basic>(thiscontainer(vp)).subs_one_level(m, options);
else
return subs_one_level(m, options);
}
template <template <class> class C>
-typename container<C>::STLT *container<C>::subschildren(const exmap & m, unsigned options) const
+std::auto_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 epvector otherwise
- // (which has to be deleted somewhere else)
+ // (and relinquishes responsibility for the epvector)
const_iterator cit = this->seq.begin(), end = this->seq.end();
while (cit != end) {
if (!are_ex_trivially_equal(*cit, subsed_ex)) {
// copy first part of seq which hasn't changed
- STLT *s = new STLT(this->seq.begin(), cit);
+ std::auto_ptr<STLT> s(new STLT(this->seq.begin(), cit));
reserve(*s, this->seq.size());
// insert changed element
++cit;
}
- return 0; // nothing has changed
+ return std::auto_ptr<STLT>(0); // nothing has changed
}
} // namespace GiNaC
GINAC_ASSERT(is_canonical());
}
-expairseq::expairseq(epvector *vp, const ex &oc)
+expairseq::expairseq(std::auto_ptr<epvector> vp, const ex &oc)
: inherited(TINFO_expairseq), overall_coeff(oc)
{
GINAC_ASSERT(vp!=0);
GINAC_ASSERT(is_a<numeric>(oc));
construct_from_epvector(*vp);
- delete vp;
GINAC_ASSERT(is_canonical());
}
ex expairseq::map(map_function &f) const
{
- epvector *v = new epvector;
+ std::auto_ptr<epvector> v(new epvector);
v->reserve(seq.size());
epvector::const_iterator cit = seq.begin(), last = seq.end();
if ((level==1) && (flags &status_flags::evaluated))
return *this;
- epvector *vp = evalchildren(level);
- if (vp==0)
+ std::auto_ptr<epvector> vp = evalchildren(level);
+ if (vp.get() == 0)
return this->hold();
- return (new expairseq(vp,overall_coeff))->setflag(status_flags::dynallocated | status_flags::evaluated);
+ return (new expairseq(vp, overall_coeff))->setflag(status_flags::dynallocated | status_flags::evaluated);
}
bool expairseq::match(const ex & pattern, lst & repl_lst) const
// it has already been matched before, in which case the matches
// must be equal)
size_t num = ops.size();
- epvector *vp = new epvector();
+ std::auto_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 expairseq::subs(const exmap & m, unsigned options) const
{
- epvector *vp = subschildren(m, options);
- if (vp)
+ std::auto_ptr<epvector> vp = subschildren(m, options);
+ if (vp.get())
return ex_to<basic>(thisexpairseq(vp, overall_coeff));
else if ((options & subs_options::algebraic) && is_exactly_a<mul>(*this))
return static_cast<const mul *>(this)->algebraic_subs_mul(m, options);
ex expairseq::expand(unsigned options) const
{
- epvector *vp = expandchildren(options);
- if (vp == NULL) {
+ std::auto_ptr<epvector> vp = expandchildren(options);
+ if (vp.get())
+ return thisexpairseq(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;
- } else
- return thisexpairseq(vp, overall_coeff);
+ }
}
//////////
* definition. */
ex expairseq::thisexpairseq(const epvector &v, const ex &oc) const
{
- return expairseq(v,oc);
+ return expairseq(v, oc);
}
-ex expairseq::thisexpairseq(epvector *vp, const ex &oc) const
+ex expairseq::thisexpairseq(std::auto_ptr<epvector> vp, const ex &oc) const
{
- return expairseq(vp,oc);
+ return expairseq(vp, oc);
}
void expairseq::printpair(const print_context & c, const expair & p, unsigned upper_precedence) const
* @see expairseq::expand()
* @return pointer to epvector containing expanded pairs or zero pointer,
* if no members were changed. */
-epvector * expairseq::expandchildren(unsigned options) const
+std::auto_ptr<epvector> expairseq::expandchildren(unsigned options) const
{
const epvector::const_iterator last = seq.end();
epvector::const_iterator cit = seq.begin();
if (!are_ex_trivially_equal(cit->rest,expanded_ex)) {
// something changed, copy seq, eval and return it
- epvector *s = new epvector;
+ std::auto_ptr<epvector> s(new epvector);
s->reserve(seq.size());
// copy parts of seq which are known not to have changed
s->push_back(*cit2);
++cit2;
}
+
// copy first changed element
s->push_back(combine_ex_with_coeff_to_pair(expanded_ex,
cit2->coeff));
++cit2;
+
// copy rest
while (cit2!=last) {
s->push_back(combine_ex_with_coeff_to_pair(cit2->rest.expand(options),
++cit;
}
- return 0; // signalling nothing has changed
+ return std::auto_ptr<epvector>(0); // signalling nothing has changed
}
* @see expairseq::eval()
* @return pointer to epvector containing evaluated pairs or zero pointer,
* if no members were changed. */
-epvector * expairseq::evalchildren(int level) const
+std::auto_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 0;
+ return std::auto_ptr<epvector>(0);
if (level == -max_recursion_level)
throw(std::runtime_error("max recursion level reached"));
if (!are_ex_trivially_equal(cit->rest,evaled_ex)) {
// something changed, copy seq, eval and return it
- epvector *s = new epvector;
+ std::auto_ptr<epvector> s(new epvector);
s->reserve(seq.size());
// copy parts of seq which are known not to have changed
s->push_back(*cit2);
++cit2;
}
+
// copy first changed element
s->push_back(combine_ex_with_coeff_to_pair(evaled_ex,
cit2->coeff));
++cit2;
+
// copy rest
while (cit2!=last) {
s->push_back(combine_ex_with_coeff_to_pair(cit2->rest.eval(level),
++cit;
}
- return 0; // signalling nothing has changed
+ return std::auto_ptr<epvector>(0); // signalling nothing has changed
}
* @see expairseq::subs()
* @return pointer to epvector containing pairs after application of subs,
* or NULL pointer if no members were changed. */
-epvector * expairseq::subschildren(const exmap & m, unsigned options) const
+std::auto_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
if (!are_ex_trivially_equal(orig_ex, subsed_ex)) {
// Something changed, copy seq, subs and return it
- epvector *s = new epvector;
+ std::auto_ptr<epvector> s(new epvector);
s->reserve(seq.size());
// Copy parts of seq which are known not to have changed
if (!are_ex_trivially_equal(cit->rest, subsed_ex)) {
// Something changed, copy seq, subs and return it
- epvector *s = new epvector;
+ std::auto_ptr<epvector> s(new epvector);
s->reserve(seq.size());
// Copy parts of seq which are known not to have changed
}
// Nothing has changed
- return NULL;
+ return std::auto_ptr<epvector>(0);
}
//////////
#include <vector>
#include <list>
+#include <memory>
// CINT needs <algorithm> to work properly with <vector> and <list>
#include <algorithm>
expairseq(const ex & lh, const ex & rh);
expairseq(const exvector & v);
expairseq(const epvector & v, const ex & oc);
- expairseq(epvector * vp, const ex & oc); // vp will be deleted
+ expairseq(std::auto_ptr<epvector>, const ex & oc);
// functions overriding virtual functions from base classes
public:
// new virtual functions which can be overridden by derived classes
protected:
virtual ex thisexpairseq(const epvector & v, const ex & oc) const;
- virtual ex thisexpairseq(epvector * vp, const ex & oc) const;
+ virtual ex thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc) const;
virtual void printseq(const print_context & c, char delim,
unsigned this_precedence,
unsigned upper_precedence) const;
epvector::const_iterator last_non_zero);
#endif // EXPAIRSEQ_USE_HASHTAB
bool is_canonical() const;
- epvector * expandchildren(unsigned options) const;
- epvector * evalchildren(int level) const;
- epvector * subschildren(const exmap & m, unsigned options = 0) 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;
// member variables
tinfo_key = TINFO_fderivative;
}
-fderivative::fderivative(unsigned ser, const paramset & params, exvector * vp) : function(ser, vp), parameter_set(params)
+fderivative::fderivative(unsigned ser, const paramset & params, std::auto_ptr<exvector> vp) : function(ser, vp), parameter_set(params)
{
tinfo_key = TINFO_fderivative;
}
return fderivative(serial, parameter_set, v);
}
-ex fderivative::thiscontainer(exvector * vp) const
+ex fderivative::thiscontainer(std::auto_ptr<exvector> vp) const
{
return fderivative(serial, parameter_set, vp);
}
fderivative(unsigned ser, const paramset & params, const exvector & args);
// internal constructors
- fderivative(unsigned ser, const paramset & params, exvector * vp); // vp will be deleted
+ fderivative(unsigned ser, const paramset & params, std::auto_ptr<exvector> vp);
// functions overriding virtual functions from base classes
public:
ex evalf(int level = 0) const;
ex series(const relational & r, int order, unsigned options = 0) const;
ex thiscontainer(const exvector & v) const;
- ex thiscontainer(exvector * vp) const;
+ ex thiscontainer(std::auto_ptr<exvector> vp) const;
protected:
ex derivative(const symbol & s) const;
bool is_equal_same_type(const basic & other) const;
// end of generated lines
function(unsigned ser, const exprseq & es);
function(unsigned ser, const exvector & v, bool discardable = false);
- function(unsigned ser, exvector * vp); // vp will be deleted
+ function(unsigned ser, std::auto_ptr<exvector> vp);
// functions overriding virtual functions from base classes
public:
unsigned calchash() const;
ex series(const relational & r, int order, unsigned options = 0) const;
ex thiscontainer(const exvector & v) const;
- ex thiscontainer(exvector * vp) const;
+ ex thiscontainer(std::auto_ptr<exvector> vp) const;
protected:
ex derivative(const symbol & s) const;
bool is_equal_same_type(const basic & other) const;
tinfo_key = TINFO_function;
}
-function::function(unsigned ser, exvector * vp)
+function::function(unsigned ser, std::auto_ptr<exvector> vp)
: exprseq(vp), serial(ser)
{
tinfo_key = TINFO_function;
ex function::thiscontainer(const exvector & v) const
{
- return function(serial,v);
+ return function(serial, v);
}
-ex function::thiscontainer(exvector * vp) const
+ex function::thiscontainer(std::auto_ptr<exvector> vp) const
{
- return function(serial,vp);
+ return function(serial, vp);
}
/** Implementation of ex::series for functions.
tinfo_key = TINFO_indexed;
}
-indexed::indexed(const symmetry & symm, exvector * vp) : inherited(vp), symtree(symm)
+indexed::indexed(const symmetry & symm, std::auto_ptr<exvector> vp) : inherited(vp), symtree(symm)
{
tinfo_key = TINFO_indexed;
}
return indexed(ex_to<symmetry>(symtree), v);
}
-ex indexed::thiscontainer(exvector * vp) const
+ex indexed::thiscontainer(std::auto_ptr<exvector> vp) const
{
return indexed(ex_to<symmetry>(symtree), vp);
}
// internal constructors
indexed(const symmetry & symm, const exprseq & es);
indexed(const symmetry & symm, const exvector & v, bool discardable = false);
- indexed(const symmetry & symm, exvector * vp); // vp will be deleted
+ indexed(const symmetry & symm, std::auto_ptr<exvector> vp);
// functions overriding virtual functions from base classes
public:
protected:
ex derivative(const symbol & s) const;
ex thiscontainer(const exvector & v) const;
- ex thiscontainer(exvector * vp) const;
+ ex thiscontainer(std::auto_ptr<exvector> vp) const;
unsigned return_type() const { return return_types::commutative; }
ex expand(unsigned options = 0) const;
GINAC_ASSERT(is_canonical());
}
-mul::mul(epvector * vp, const ex & oc)
+mul::mul(std::auto_ptr<epvector> vp, const ex & oc)
{
tinfo_key = TINFO_mul;
GINAC_ASSERT(vp!=0);
overall_coeff = oc;
construct_from_epvector(*vp);
- delete vp;
GINAC_ASSERT(is_canonical());
}
* @param level cut-off in recursive evaluation */
ex mul::eval(int level) const
{
- epvector *evaled_seqp = evalchildren(level);
- if (evaled_seqp) {
+ std::auto_ptr<epvector> evaled_seqp = evalchildren(level);
+ if (evaled_seqp.get()) {
// do more evaluation later
- return (new mul(evaled_seqp,overall_coeff))->
+ return (new mul(evaled_seqp, overall_coeff))->
setflag(status_flags::dynallocated);
}
ex_to<numeric>((*seq.begin()).coeff).is_equal(_num1)) {
// *(+(x,y,...);c) -> +(*(x,c),*(y,c),...) (c numeric(), no powers of +())
const add & addref = ex_to<add>((*seq.begin()).rest);
- epvector *distrseq = new epvector();
+ std::auto_ptr<epvector> distrseq(new epvector);
distrseq->reserve(addref.seq.size());
epvector::const_iterator i = addref.seq.begin(), end = addref.seq.end();
while (i != end) {
if (level==-max_recursion_level)
throw(std::runtime_error("max recursion level reached"));
- epvector *s = new epvector();
+ std::auto_ptr<epvector> s(new epvector);
s->reserve(seq.size());
--level;
// 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)
- epvector *s = new epvector;
+ std::auto_ptr<epvector> s(new epvector);
s->reserve(seq.size());
bool have_matrix = false;
return (new mul(v, oc))->setflag(status_flags::dynallocated);
}
-ex mul::thisexpairseq(epvector * vp, const ex & oc) const
+ex mul::thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc) const
{
return (new mul(vp, oc))->setflag(status_flags::dynallocated);
}
ex mul::expand(unsigned options) const
{
// First, expand the children
- epvector * expanded_seqp = expandchildren(options);
- const epvector & expanded_seq = (expanded_seqp == NULL) ? seq : *expanded_seqp;
+ std::auto_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
// with the next one that is found while collecting the factors which are
}
++cit;
}
- if (expanded_seqp)
- delete expanded_seqp;
// Now the only remaining thing to do is to multiply the factors which
// were not sums into the "last_expanded" sum
* @see mul::expand()
* @return pointer to epvector containing expanded representation or zero
* pointer, if sequence is unchanged. */
-epvector * mul::expandchildren(unsigned options) const
+std::auto_ptr<epvector> mul::expandchildren(unsigned options) const
{
const epvector::const_iterator last = seq.end();
epvector::const_iterator cit = seq.begin();
if (!are_ex_trivially_equal(factor,expanded_factor)) {
// something changed, copy seq, eval and return it
- epvector *s = new epvector;
+ std::auto_ptr<epvector> s(new epvector);
s->reserve(seq.size());
// copy parts of seq which are known not to have changed
s->push_back(*cit2);
++cit2;
}
+
// copy first changed element
s->push_back(split_ex_to_pair(expanded_factor));
++cit2;
+
// copy rest
while (cit2!=last) {
s->push_back(split_ex_to_pair(recombine_pair_to_ex(*cit2).expand(options)));
++cit;
}
- return 0; // nothing has changed
+ return std::auto_ptr<epvector>(0); // nothing has changed
}
} // namespace GiNaC
mul(const exvector & v);
mul(const epvector & v);
mul(const epvector & v, const ex & oc);
- mul(epvector * vp, const ex & oc);
+ mul(std::auto_ptr<epvector> vp, const ex & oc);
mul(const ex & lh, const ex & mh, const ex & rh);
// functions overriding virtual functions from base classes
unsigned return_type() const;
unsigned return_type_tinfo() const;
ex thisexpairseq(const epvector & v, const ex & oc) const;
- ex thisexpairseq(epvector * vp, const ex & oc) const;
+ ex thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc) 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;
void do_print_latex(const print_latex & c, unsigned level) const;
void do_print_csrc(const print_csrc & c, unsigned level) const;
void do_print_python_repr(const print_python_repr & c, unsigned level) const;
- epvector * expandchildren(unsigned options) const;
+ std::auto_ptr<epvector> expandchildren(unsigned options) const;
};
// utility functions
tinfo_key = TINFO_ncmul;
}
-ncmul::ncmul(exvector * vp) : inherited(vp)
+ncmul::ncmul(std::auto_ptr<exvector> vp) : inherited(vp)
{
tinfo_key = TINFO_ncmul;
}
ex ncmul::evalm() const
{
// Evaluate children first
- exvector *s = new exvector;
+ std::auto_ptr<exvector> s(new exvector);
s->reserve(seq.size());
exvector::const_iterator it = seq.begin(), itend = seq.end();
while (it != itend) {
prod = prod.mul(ex_to<matrix>(*it));
it++;
}
- delete s;
return prod;
}
return (new ncmul(v))->setflag(status_flags::dynallocated);
}
-ex ncmul::thiscontainer(exvector * vp) const
+ex ncmul::thiscontainer(std::auto_ptr<exvector> vp) const
{
return (new ncmul(vp))->setflag(status_flags::dynallocated);
}
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(exvector * vp); // vp will be deleted
+ ncmul(std::auto_ptr<exvector> vp);
// functions overriding virtual functions from base classes
public:
ex evalm() const;
exvector get_free_indices() const;
ex thiscontainer(const exvector & v) const;
- ex thiscontainer(exvector * vp) const;
+ ex thiscontainer(std::auto_ptr<exvector> vp) const;
protected:
ex derivative(const symbol & s) const;