* Implementation of GiNaC's non-commutative products 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
GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(ncmul, exprseq,
print_func<print_context>(&ncmul::do_print).
- print_func<print_tree>(&basic::do_print_tree).
+ print_func<print_tree>(&ncmul::do_print_tree).
print_func<print_csrc>(&ncmul::do_print_csrc).
print_func<print_python_repr>(&ncmul::do_print_csrc))
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);
}
+ex ncmul::conjugate() const
+{
+ if (return_type() != return_types::noncommutative) {
+ return exprseq::conjugate();
+ }
+
+ if (return_type_tinfo() & 0xffffff00U != TINFO_clifford) {
+ return exprseq::conjugate();
+ }
+
+ exvector ev;
+ ev.reserve(nops());
+ for (const_iterator i=end(); i!=begin();) {
+ --i;
+ ev.push_back(i->conjugate());
+ }
+ return (new ncmul(ev, true))->setflag(status_flags::dynallocated).eval();
+}
+
// protected
/** Implementation of ex::diff() for a non-commutative product. It applies