/** @file add.cpp
*
- * Implementation of GiNaC's sums of expressions.
- *
+ * Implementation of GiNaC's sums of expressions. */
+
+/*
* GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
#include "add.h"
#include "mul.h"
+#include "debugmsg.h"
+
+#ifndef NO_GINAC_NAMESPACE
+namespace GiNaC {
+#endif // ndef NO_GINAC_NAMESPACE
//////////
// default constructor, destructor, copy constructor assignment operator and helpers
tinfo_key = TINFO_add;
overall_coeff=exZERO();
construct_from_2_ex(lh,rh);
- ASSERT(is_canonical());
+ GINAC_ASSERT(is_canonical());
}
add::add(exvector const & v)
tinfo_key = TINFO_add;
overall_coeff=exZERO();
construct_from_exvector(v);
- ASSERT(is_canonical());
+ GINAC_ASSERT(is_canonical());
}
/*
} else {
construct_from_epvector(v);
}
- ASSERT(is_canonical());
+ GINAC_ASSERT(is_canonical());
}
*/
tinfo_key = TINFO_add;
overall_coeff=exZERO();
construct_from_epvector(v);
- ASSERT(is_canonical());
+ GINAC_ASSERT(is_canonical());
}
add::add(epvector const & v, ex const & oc)
tinfo_key = TINFO_add;
overall_coeff=oc;
construct_from_epvector(v);
- ASSERT(is_canonical());
+ GINAC_ASSERT(is_canonical());
}
add::add(epvector * vp, ex const & oc)
{
debugmsg("add constructor from epvector *,ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_add;
- ASSERT(vp!=0);
+ GINAC_ASSERT(vp!=0);
overall_coeff=oc;
construct_from_epvector(*vp);
delete vp;
- ASSERT(is_canonical());
+ GINAC_ASSERT(is_canonical());
}
//////////
debugmsg("add eval",LOGLEVEL_MEMBER_FUNCTION);
if ((level==1)&&(flags & status_flags::evaluated)) {
-#ifdef DOASSERT
+#ifdef DO_GINAC_ASSERT
for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
- ASSERT(!is_ex_exactly_of_type((*cit).rest,add));
- ASSERT(!(is_ex_exactly_of_type((*cit).rest,numeric)&&
+ GINAC_ASSERT(!is_ex_exactly_of_type((*cit).rest,add));
+ GINAC_ASSERT(!(is_ex_exactly_of_type((*cit).rest,numeric)&&
(ex_to_numeric((*cit).coeff).compare(numONE())!=0)));
}
-#endif // def DOASSERT
+#endif // def DO_GINAC_ASSERT
return *this;
}
return (new add(evaled_seqp))->setflag(status_flags::dynallocated);
}
-#ifdef DOASSERT
+#ifdef DO_GINAC_ASSERT
for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
- ASSERT(!is_ex_exactly_of_type((*cit).rest,add));
- ASSERT(!(is_ex_exactly_of_type((*cit).rest,numeric)&&
+ GINAC_ASSERT(!is_ex_exactly_of_type((*cit).rest,add));
+ GINAC_ASSERT(!(is_ex_exactly_of_type((*cit).rest,numeric)&&
(ex_to_numeric((*cit).coeff).compare(numONE())!=0)));
}
-#endif // def DOASSERT
+#endif // def DO_GINAC_ASSERT
if (flags & status_flags::evaluated) {
return *this;
setflag(status_flags::dynallocated);
}
-#ifdef DOASSERT
+#ifdef DO_GINAC_ASSERT
for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
- ASSERT(!is_ex_exactly_of_type((*cit).rest,add));
+ GINAC_ASSERT(!is_ex_exactly_of_type((*cit).rest,add));
if (is_ex_exactly_of_type((*cit).rest,numeric)) {
dbgprint();
}
- ASSERT(!is_ex_exactly_of_type((*cit).rest,numeric));
+ GINAC_ASSERT(!is_ex_exactly_of_type((*cit).rest,numeric));
}
-#endif // def DOASSERT
+#endif // def DO_GINAC_ASSERT
if (flags & status_flags::evaluated) {
- ASSERT(seq.size()>0);
- ASSERT((seq.size()>1)||!overall_coeff.is_equal(exZERO()));
+ GINAC_ASSERT(seq.size()>0);
+ GINAC_ASSERT((seq.size()>1)||!overall_coeff.is_equal(exZERO()));
return *this;
}
exvector add::get_indices(void) const
{
- // all terms in the sum should have the same indices (compatible tensors)
- // however this is not checked, since there is no function yet which
- // compares indices (idxvector can be unsorted) !!!!!!!!!!!
+ // FIXME: all terms in the sum should have the same indices (compatible
+ // tensors) however this is not checked, since there is no function yet
+ // which compares indices (idxvector can be unsorted)
if (seq.size()==0) {
return exvector();
}
{
if (is_ex_exactly_of_type(e,mul)) {
mul const & mulref=ex_to_mul(e);
- ASSERT(mulref.seq.size()>1);
+ GINAC_ASSERT(mulref.seq.size()>1);
ex const & lastfactor_rest=(*(mulref.seq.end()-1)).rest;
ex const & lastfactor_coeff=(*(mulref.seq.end()-1)).coeff;
if (is_ex_exactly_of_type(lastfactor_rest,numeric) &&
expair add::combine_ex_with_coeff_to_pair(ex const & e,
ex const & c) const
{
- ASSERT(is_ex_exactly_of_type(c,numeric));
+ GINAC_ASSERT(is_ex_exactly_of_type(c,numeric));
if (is_ex_exactly_of_type(e,mul)) {
mul const & mulref=ex_to_mul(e);
- ASSERT(mulref.seq.size()>1);
+ GINAC_ASSERT(mulref.seq.size()>1);
ex const & lastfactor_rest=(*(mulref.seq.end()-1)).rest;
ex const & lastfactor_coeff=(*(mulref.seq.end()-1)).coeff;
if (is_ex_exactly_of_type(lastfactor_rest,numeric) &&
expair add::combine_ex_with_coeff_to_pair(ex const & e,
ex const & c) const
{
- ASSERT(is_ex_exactly_of_type(c,numeric));
+ GINAC_ASSERT(is_ex_exactly_of_type(c,numeric));
if (is_ex_exactly_of_type(e,mul)) {
mul const & mulref=ex_to_mul(e);
ex numfactor=mulref.overall_coeff;
expair add::combine_pair_with_coeff_to_pair(expair const & p,
ex const & c) const
{
- ASSERT(is_ex_exactly_of_type(p.coeff,numeric));
- ASSERT(is_ex_exactly_of_type(c,numeric));
+ GINAC_ASSERT(is_ex_exactly_of_type(p.coeff,numeric));
+ GINAC_ASSERT(is_ex_exactly_of_type(c,numeric));
if (is_ex_exactly_of_type(p.rest,numeric)) {
- ASSERT(ex_to_numeric(p.coeff).is_equal(numONE())); // should be normalized
+ GINAC_ASSERT(ex_to_numeric(p.coeff).is_equal(numONE())); // should be normalized
return expair(ex_to_numeric(p.rest).mul_dyn(ex_to_numeric(c)),exONE());
}
const add some_add;
type_info const & typeid_add=typeid(some_add);
-
-
+#ifndef NO_GINAC_NAMESPACE
+} // namespace GiNaC
+#endif // ndef NO_GINAC_NAMESPACE