* Implementation of GiNaC's sums 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
tinfo_key = TINFO_add;
}
-add::~add()
-{
- debugmsg("add destructor",LOGLEVEL_DESTRUCT);
- destroy(false);
-}
-
-add::add(const add & other)
-{
- debugmsg("add copy constructor",LOGLEVEL_CONSTRUCT);
- copy(other);
-}
-
-const add & add::operator=(const add & other)
-{
- debugmsg("add operator=",LOGLEVEL_ASSIGNMENT);
- if (this != &other) {
- destroy(true);
- copy(other);
- }
- return *this;
-}
-
// protected
void add::copy(const add & other)
// public
-basic * add::duplicate() const
-{
- debugmsg("add duplicate",LOGLEVEL_DUPLICATE);
- return new add(*this);
-}
-
void add::print(std::ostream & os, unsigned upper_precedence) const
{
debugmsg("add print",LOGLEVEL_PRINT);
}
os << '*';
}
- os << cit->rest;
+ cit->rest.print(os, precedence);
}
if (precedence<=upper_precedence) os << ")";
}
expair add::split_ex_to_pair(const ex & e) const
{
if (is_ex_exactly_of_type(e,mul)) {
- const mul & mulref=ex_to_mul(e);
- ex numfactor=mulref.overall_coeff;
- // mul * mulcopyp=static_cast<mul *>(mulref.duplicate());
- mul * mulcopyp=new mul(mulref);
- mulcopyp->overall_coeff=_ex1();
+ const mul & mulref = ex_to_mul(e);
+ ex numfactor = mulref.overall_coeff;
+ // mul * mulcopyp = static_cast<mul *>(mulref.duplicate());
+ mul * mulcopyp = new mul(mulref);
+ mulcopyp->overall_coeff = _ex1();
mulcopyp->clearflag(status_flags::evaluated);
mulcopyp->clearflag(status_flags::hash_calculated);
return expair(mulcopyp->setflag(status_flags::dynallocated),numfactor);
const ex & c) const
{
GINAC_ASSERT(is_ex_exactly_of_type(c, numeric));
- ex one = _ex1();
if (is_ex_exactly_of_type(e, mul)) {
const mul &mulref = ex_to_mul(e);
ex numfactor = mulref.overall_coeff;
mul *mulcopyp = new mul(mulref);
- mulcopyp->overall_coeff = one;
+ mulcopyp->overall_coeff = _ex1();
mulcopyp->clearflag(status_flags::evaluated);
mulcopyp->clearflag(status_flags::hash_calculated);
mulcopyp->setflag(status_flags::dynallocated);
- if (are_ex_trivially_equal(c, one)) {
+ if (are_ex_trivially_equal(c, _ex1())) {
return expair(*mulcopyp, numfactor);
- } else if (are_ex_trivially_equal(numfactor, one)) {
+ } else if (are_ex_trivially_equal(numfactor, _ex1())) {
return expair(*mulcopyp, c);
}
return expair(*mulcopyp, ex_to_numeric(numfactor).mul_dyn(ex_to_numeric(c)));
} else if (is_ex_exactly_of_type(e, numeric)) {
- if (are_ex_trivially_equal(c, one)) {
- return expair(e, one);
- }
- return expair(ex_to_numeric(e).mul_dyn(ex_to_numeric(c)), one);
+ if (are_ex_trivially_equal(c, _ex1()))
+ return expair(e, _ex1());
+ return expair(ex_to_numeric(e).mul_dyn(ex_to_numeric(c)), _ex1());
}
return expair(e, c);
}
return (new add(vp,overall_coeff))->setflag(status_flags::expanded | status_flags::dynallocated);
}
-//////////
-// new virtual functions which can be overridden by derived classes
-//////////
-
-// none
-
-//////////
-// non-virtual functions in this class
-//////////
-
-// none
-
//////////
// static member variables
//////////
unsigned add::precedence = 40;
-//////////
-// global constants
-//////////
-
-const add some_add;
-const std::type_info & typeid_add = typeid(some_add);
-
#ifndef NO_NAMESPACE_GINAC
} // namespace GiNaC
#endif // ndef NO_NAMESPACE_GINAC