#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
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()?"));
exvector term;
term=expanded_seq;
for (l=0; l<number_of_adds; l++) {
- ASSERT(is_ex_exactly_of_type(expanded_seq[positions_of_adds[l]],add));
+ GINAC_ASSERT(is_ex_exactly_of_type(expanded_seq[positions_of_adds[l]],add));
add const & addref=ex_to_add(expanded_seq[positions_of_adds[l]]);
term[positions_of_adds[l]]=addref.recombine_pair_to_ex(addref.seq[k[l]]);
}
if (coeff_found) return (new ncmul(coeffseq,1))->setflag(status_flags::dynallocated);
- return exZERO();
+ return _ex0();
}
unsigned ncmul::count_factors(ex const & e) 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;
}
++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)
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;
}
}
-#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<evv.size(); ++i) {
s += evv[i].size();
}
- ASSERT(s==assocseq.size());
-#endif // def DOASSERT
+ GINAC_ASSERT(s==assocseq.size());
+#endif // def DO_GINAC_ASSERT
// if all elements are of same type, simplify the string
if (evv.size()==1) {
}
}
// all factors checked
- ASSERT(!all_commutative); // not all factors should commute, because this is a ncmul();
+ GINAC_ASSERT(!all_commutative); // not all factors should commute, because this is a ncmul();
return all_commutative ? return_types::commutative : return_types::noncommutative;
}
ex simplified_ncmul(exvector const & v)
{
if (v.size()==0) {
- return exONE();
+ return _ex1();
} else if (v.size()==1) {
return v[0];
}
status_flags::evaluated);
}
-
+#ifndef NO_GINAC_NAMESPACE
+} // namespace GiNaC
+#endif // ndef NO_GINAC_NAMESPACE