X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fncmul.cpp;h=5dce23f41fe5df2a27834798e33024f1c08a9fcd;hp=6d87597f8cc7d8bb1ee1cfbd27cd1773aee59c39;hb=955cb185a85535ab328ffedbfccdc508ce80fa91;hpb=66c0f31c678e6c1938d637636b230ea376c157c1 diff --git a/ginac/ncmul.cpp b/ginac/ncmul.cpp index 6d87597f..5dce23f4 100644 --- a/ginac/ncmul.cpp +++ b/ginac/ncmul.cpp @@ -1,7 +1,8 @@ /** @file ncmul.cpp * - * Implementation of GiNaC's non-commutative products of expressions. - * + * Implementation of GiNaC's non-commutative products of expressions. */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -27,6 +28,12 @@ #include "ex.h" #include "add.h" #include "mul.h" +#include "debugmsg.h" +#include "utils.h" + +#ifndef NO_GINAC_NAMESPACE +namespace GiNaC { +#endif // ndef NO_GINAC_NAMESPACE ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -140,6 +147,39 @@ basic * ncmul::duplicate() const return new ncmul(*this); } +void ncmul::print(ostream & os, unsigned upper_precedence) const +{ + debugmsg("ncmul print",LOGLEVEL_PRINT); + printseq(os,'(','%',')',precedence,upper_precedence); +} + +void ncmul::printraw(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 << ","; + } + os << ",hash=" << hashvalue << ",flags=" << flags; + os << ")"; +} + +void ncmul::printcsrc(ostream & os, unsigned upper_precedence) const +{ + debugmsg("ncmul print csrc",LOGLEVEL_PRINT); + exvector::const_iterator it; + exvector::const_iterator itend = seq.end()-1; + os << "ncmul("; + for (it=seq.begin(); it!=itend; ++it) { + (*it).bp->printcsrc(os,precedence); + os << ","; + } + (*it).bp->printcsrc(os,precedence); + os << ")"; +} + bool ncmul::info(unsigned inf) const { throw(std::logic_error("which flags have to be implemented in ncmul::info()?")); @@ -194,7 +234,7 @@ ex ncmul::expand(unsigned options) const exvector term; term=expanded_seq; for (l=0; lsetflag(status_flags::dynallocated); - return exZERO(); + return _ex0(); } unsigned ncmul::count_factors(ex const & e) const @@ -335,7 +375,7 @@ ex ncmul::eval(int level) const if (assocseq.size()==1) return *(seq.begin()); // ncmul() -> 1 - if (assocseq.size()==0) return exONE(); + if (assocseq.size()==0) return _ex1(); // determine return types unsignedvector rettypes; @@ -360,7 +400,7 @@ ex ncmul::eval(int level) const } ++i; } - ASSERT(count_commutative+count_noncommutative+count_noncommutative_composite==assocseq.size()); + GINAC_ASSERT(count_commutative+count_noncommutative+count_noncommutative_composite==assocseq.size()); // ncmul(...,c1,...,c2,...) -> // *(c1,c2,ncmul(...)) (pull out commutative elements) @@ -387,7 +427,7 @@ ex ncmul::eval(int level) const if (count_noncommutative_composite==0) { // there are neither commutative nor noncommutative_composite // elements in assocseq - ASSERT(count_commutative==0); + GINAC_ASSERT(count_commutative==0); exvectorvector evv; unsignedvector rttinfos; @@ -412,15 +452,15 @@ ex ncmul::eval(int level) const } } -#ifdef DOASSERT - ASSERT(evv.size()==rttinfos.size()); - ASSERT(evv.size()>0); +#ifdef DO_GINAC_ASSERT + GINAC_ASSERT(evv.size()==rttinfos.size()); + GINAC_ASSERT(evv.size()>0); unsigned s=0; for (i=0; i