* 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))
//////////
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);
GINAC_ASSERT(is_canonical());
return (new add(s, overall_coeff))->setflag(status_flags::dynallocated);
}
+ex add::conjugate() const
+{
+ exvector *v = 0;
+ for (int i=0; i<nops(); ++i) {
+ if (v) {
+ v->push_back(op(i).conjugate());
+ continue;
+ }
+ ex term = op(i);
+ ex ccterm = term.conjugate();
+ if (are_ex_trivially_equal(term, ccterm))
+ continue;
+ v = new exvector;
+ v->reserve(nops());
+ for (int j=0; j<i; ++j)
+ v->push_back(op(j));
+ v->push_back(ccterm);
+ }
+ if (v) {
+ ex result = add(*v);
+ delete v;
+ return result;
+ }
+ return *this;
+}
+
ex add::eval_ncmul(const exvector & v) const
{
if (seq.empty())