* Implementation of GiNaC's non-commutative products of expressions. */
/*
- * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2001 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
#include "debugmsg.h"
#include "utils.h"
-#ifndef NO_NAMESPACE_GINAC
namespace GiNaC {
-#endif // ndef NO_NAMESPACE_GINAC
GINAC_IMPLEMENT_REGISTERED_CLASS(ncmul, exprseq)
tinfo_key = TINFO_ncmul;
}
-ncmul::~ncmul()
-{
- debugmsg("ncmul destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
-}
-
-ncmul::ncmul(const ncmul & other)
-{
- debugmsg("ncmul copy constructor",LOGLEVEL_CONSTRUCT);
- copy(other);
-}
-
-const ncmul & ncmul::operator=(const ncmul & other)
-{
- debugmsg("ncmul operator=",LOGLEVEL_ASSIGNMENT);
- if (this != &other) {
- destroy(1);
- copy(other);
- }
- return *this;
-}
-
// protected
void ncmul::copy(const ncmul & other)
// public
-ncmul::ncmul(const ex & lh, const ex & rh) :
- inherited(lh,rh)
+ncmul::ncmul(const ex & lh, const ex & rh) : inherited(lh,rh)
{
debugmsg("ncmul constructor from ex,ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_ncmul;
}
-ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3) :
- inherited(f1,f2,f3)
+ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3) : inherited(f1,f2,f3)
{
debugmsg("ncmul constructor from 3 ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_ncmul;
}
ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3,
- const ex & f4) : inherited(f1,f2,f3,f4)
+ const ex & f4) : inherited(f1,f2,f3,f4)
{
debugmsg("ncmul constructor from 4 ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_ncmul;
}
ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3,
- const ex & f4, const ex & f5) : inherited(f1,f2,f3,f4,f5)
+ const ex & f4, const ex & f5) : inherited(f1,f2,f3,f4,f5)
{
debugmsg("ncmul constructor from 5 ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_ncmul;
}
ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3,
- const ex & f4, const ex & f5, const ex & f6) :
- inherited(f1,f2,f3,f4,f5,f6)
+ const ex & f4, const ex & f5, const ex & f6) : inherited(f1,f2,f3,f4,f5,f6)
{
debugmsg("ncmul constructor from 6 ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_ncmul;
// public
-basic * ncmul::duplicate() const
-{
- debugmsg("ncmul duplicate",LOGLEVEL_ASSIGNMENT);
- return new ncmul(*this);
-}
-
void ncmul::print(std::ostream & os, unsigned upper_precedence) const
{
debugmsg("ncmul print",LOGLEVEL_PRINT);
void ncmul::printraw(std::ostream & os) const
{
debugmsg("ncmul printraw",LOGLEVEL_PRINT);
-
os << "%(";
for (exvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
(*it).bp->printraw(os);
os << ")";
}
-void ncmul::printcsrc(std::ostream & os, unsigned upper_precedence) const
+void ncmul::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const
{
debugmsg("ncmul print csrc",LOGLEVEL_PRINT);
exvector::const_iterator it;
// ncmul(...,x1,x2,...,x3,x4,...) (associativity)
// ncmul(x) -> x
// ncmul() -> 1
- // ncmul(...,c1,...,c2,...) ->
+ // ncmul(...,c1,...,c2,...)
// *(c1,c2,ncmul(...)) (pull out commutative elements)
// ncmul(x1,y1,x2,y2) -> *(ncmul(x1,x2),ncmul(y1,y2))
// (collect elements of same type)
noncommutativeseq.push_back(assocseq[i]);
}
}
- commutativeseq.push_back((new ncmul(noncommutativeseq,1))->
- setflag(status_flags::dynallocated));
+ commutativeseq.push_back((new ncmul(noncommutativeseq,1))->setflag(status_flags::dynallocated));
return (new mul(commutativeseq))->setflag(status_flags::dynallocated);
}
exvector splitseq;
splitseq.reserve(evv.size());
for (i=0; i<evv.size(); ++i) {
- splitseq.push_back((new ncmul(evv[i]))->
- setflag(status_flags::dynallocated));
+ splitseq.push_back((new ncmul(evv[i]))->setflag(status_flags::dynallocated));
}
return (new mul(splitseq))->setflag(status_flags::dynallocated);
status_flags::evaluated);
}
-exvector ncmul::get_indices(void) const
-{
- // return union of indices of factors
- exvector iv;
- for (exvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
- exvector subiv=(*cit).get_indices();
- iv.reserve(iv.size()+subiv.size());
- for (exvector::const_iterator cit2=subiv.begin(); cit2!=subiv.end(); ++cit2) {
- iv.push_back(*cit2);
- }
- }
- return iv;
-}
-
ex ncmul::subs(const lst & ls, const lst & lr) const
{
return ncmul(subschildren(ls, lr));
all_commutative=0;
}
if ((rt==return_types::noncommutative)&&(!all_commutative)) {
- // another nc element found, compare type_infos
+ // another nc element found, compare type_infos
if ((*cit_noncommutative_element).return_type_tinfo()!=(*cit).return_type_tinfo()) {
- // diffent types -> mul is ncc
- return return_types::noncommutative_composite;
+ // diffent types -> mul is ncc
+ return return_types::noncommutative_composite;
}
}
}
// protected
-unsigned ncmul::precedence=50;
-
-
-//////////
-// global constants
-//////////
-
-const ncmul some_ncmul;
-const type_info & typeid_ncmul=typeid(some_ncmul);
+unsigned ncmul::precedence = 50;
//////////
// friend functions
return v[0];
}
return (new ncmul(v))->setflag(status_flags::dynallocated |
- status_flags::evaluated);
+ status_flags::evaluated);
}
-#ifndef NO_NAMESPACE_GINAC
} // namespace GiNaC
-#endif // ndef NO_NAMESPACE_GINAC