* Implementation of GiNaC's sums of expressions. */
/*
- * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2004 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
print_func<print_context>(&add::do_print).
print_func<print_latex>(&add::do_print_latex).
print_func<print_csrc>(&add::do_print_csrc).
- print_func<print_tree>(&inherited::do_print_tree).
+ print_func<print_tree>(&add::do_print_tree).
print_func<print_python_repr>(&add::do_print_python_repr))
//////////
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);
+ GINAC_ASSERT(vp.get()!=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;
}