#include "debugmsg.h"
#include "utils.h"
-#ifndef NO_GINAC_NAMESPACE
+#ifndef NO_NAMESPACE_GINAC
namespace GiNaC {
-#endif // ndef NO_GINAC_NAMESPACE
+#endif // ndef NO_NAMESPACE_GINAC
GINAC_IMPLEMENT_REGISTERED_CLASS(add, expairseq)
{
debugmsg("add constructor from ex,ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_add;
- overall_coeff=_ex0();
+ overall_coeff = _ex0();
construct_from_2_ex(lh,rh);
GINAC_ASSERT(is_canonical());
}
{
debugmsg("add constructor from exvector",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_add;
- overall_coeff=_ex0();
+ overall_coeff = _ex0();
construct_from_exvector(v);
GINAC_ASSERT(is_canonical());
}
{
debugmsg("add constructor from epvector",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_add;
- overall_coeff=_ex0();
+ overall_coeff = _ex0();
construct_from_epvector(v);
GINAC_ASSERT(is_canonical());
}
{
debugmsg("add constructor from epvector,ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_add;
- overall_coeff=oc;
+ overall_coeff = oc;
construct_from_epvector(v);
GINAC_ASSERT(is_canonical());
}
debugmsg("add constructor from epvector *,ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_add;
GINAC_ASSERT(vp!=0);
- overall_coeff=oc;
+ overall_coeff = oc;
construct_from_epvector(*vp);
delete vp;
GINAC_ASSERT(is_canonical());
int add::degree(const symbol & s) const
{
- int deg=INT_MIN;
+ int deg = INT_MIN;
if (!overall_coeff.is_equal(_ex0())) {
- deg=0;
+ deg = 0;
}
int cur_deg;
for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
int add::ldegree(const symbol & s) const
{
- int deg=INT_MAX;
+ int deg = INT_MAX;
if (!overall_coeff.is_equal(_ex0())) {
- deg=0;
+ deg = 0;
}
int cur_deg;
for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
- cur_deg=(*cit).rest.ldegree(s);
+ cur_deg = (*cit).rest.ldegree(s);
if (cur_deg<deg) deg=cur_deg;
}
return deg;
return (new add(evaled_seqp,overall_coeff))->
setflag(status_flags::dynallocated);
}
-
+
#ifdef DO_GINAC_ASSERT
for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
GINAC_ASSERT(!is_ex_exactly_of_type((*cit).rest,add));
GINAC_ASSERT(!is_ex_exactly_of_type((*cit).rest,numeric));
}
#endif // def DO_GINAC_ASSERT
-
+
if (flags & status_flags::evaluated) {
GINAC_ASSERT(seq.size()>0);
GINAC_ASSERT((seq.size()>1)||!overall_coeff.is_equal(_ex0()));
return *this;
}
-
+
int seq_size=seq.size();
if (seq_size==0) {
// +(;c) -> c
// protected
+/** Implementation of ex::diff() for a sum. It differentiates each term.
+ * @see ex::diff */
+ex add::derivative(const symbol & s) const
+{
+ // D(a+b+c)=D(a)+D(b)+D(c)
+ return (new add(diffchildren(s)))->setflag(status_flags::dynallocated);
+}
+
int add::compare_same_type(const basic & other) const
{
return inherited::compare_same_type(other);
ex add::expand(unsigned options) const
{
- epvector * vp=expandchildren(options);
+ if (flags & status_flags::expanded)
+ return *this;
+
+ epvector * vp = expandchildren(options);
if (vp==0) {
return *this;
}
- return (new add(vp,overall_coeff))->setflag(status_flags::expanded |
- status_flags::dynallocated );
+ return (new add(vp,overall_coeff))->
+ setflag(status_flags::expanded |
+ status_flags::dynallocated);
}
//////////
// protected
-unsigned add::precedence=40;
+unsigned add::precedence = 40;
//////////
// global constants
//////////
const add some_add;
-const type_info & typeid_add=typeid(some_add);
+const type_info & typeid_add = typeid(some_add);
-#ifndef NO_GINAC_NAMESPACE
+#ifndef NO_NAMESPACE_GINAC
} // namespace GiNaC
-#endif // ndef NO_GINAC_NAMESPACE
+#endif // ndef NO_NAMESPACE_GINAC