X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fmul.cpp;h=78f2bd9eb0a3e7e8f12df27243117ff4ce22689c;hp=021433a82d64e548d9e248f99dbaafdc63ffa491;hb=5cca67f43bc5d81e770ed299e35f30ecd2c1b4d4;hpb=66c0f31c678e6c1938d637636b230ea376c157c1 diff --git a/ginac/mul.cpp b/ginac/mul.cpp index 021433a8..78f2bd9e 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -1,7 +1,8 @@ /** @file mul.cpp * - * Implementation of GiNaC's products of expressions. - * + * Implementation of GiNaC's products of expressions. */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -25,6 +26,9 @@ #include "mul.h" #include "add.h" #include "power.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -84,7 +88,7 @@ mul::mul(ex const & lh, ex const & rh) tinfo_key = TINFO_mul; overall_coeff=exONE(); construct_from_2_ex(lh,rh); - ASSERT(is_canonical()); + GINAC_ASSERT(is_canonical()); } mul::mul(exvector const & v) @@ -93,7 +97,7 @@ mul::mul(exvector const & v) tinfo_key = TINFO_mul; overall_coeff=exONE(); construct_from_exvector(v); - ASSERT(is_canonical()); + GINAC_ASSERT(is_canonical()); } /* @@ -109,7 +113,7 @@ mul::mul(epvector const & v, bool do_not_canonicalize) } else { construct_from_epvector(v); } - ASSERT(is_canonical()); + GINAC_ASSERT(is_canonical()); } */ @@ -119,7 +123,7 @@ mul::mul(epvector const & v) tinfo_key = TINFO_mul; overall_coeff=exONE(); construct_from_epvector(v); - ASSERT(is_canonical()); + GINAC_ASSERT(is_canonical()); } mul::mul(epvector const & v, ex const & oc) @@ -128,18 +132,18 @@ mul::mul(epvector const & v, ex const & oc) tinfo_key = TINFO_mul; overall_coeff=oc; construct_from_epvector(v); - ASSERT(is_canonical()); + GINAC_ASSERT(is_canonical()); } mul::mul(epvector * vp, ex const & oc) { debugmsg("mul constructor from epvector *,ex",LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_mul; - ASSERT(vp!=0); + GINAC_ASSERT(vp!=0); overall_coeff=oc; construct_from_epvector(*vp); delete vp; - ASSERT(is_canonical()); + GINAC_ASSERT(is_canonical()); } mul::mul(ex const & lh, ex const & mh, ex const & rh) @@ -153,7 +157,7 @@ mul::mul(ex const & lh, ex const & mh, ex const & rh) factors.push_back(rh); overall_coeff=exONE(); construct_from_exvector(factors); - ASSERT(is_canonical()); + GINAC_ASSERT(is_canonical()); } ////////// @@ -253,9 +257,9 @@ ex mul::eval(int level) const debugmsg("mul 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,mul))|| + GINAC_ASSERT((!is_ex_exactly_of_type((*cit).rest,mul))|| (!(ex_to_numeric((*cit).coeff).is_integer()))); } @@ -268,9 +272,9 @@ ex mul::eval(int level) const do { cit--; if (is_ex_exactly_of_type((*cit).rest,numeric)) { - ASSERT(all_numeric); + GINAC_ASSERT(all_numeric); if ((*cit).coeff.is_equal(exONE())) { - ASSERT(all_coeff_1); + GINAC_ASSERT(all_coeff_1); } else { all_coeff_1=false; } @@ -279,7 +283,7 @@ ex mul::eval(int level) const } } while (cit!=seq.begin()); } -#endif // def DOASSERT +#endif // def DO_GINAC_ASSERT return *this; } @@ -317,9 +321,9 @@ ex mul::eval(int level) const } -#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,mul))|| + GINAC_ASSERT((!is_ex_exactly_of_type((*cit).rest,mul))|| (!(ex_to_numeric((*cit).coeff).is_integer()))); } @@ -332,9 +336,9 @@ ex mul::eval(int level) const do { cit--; if (is_ex_exactly_of_type((*cit).rest,numeric)) { - ASSERT(all_numeric); + GINAC_ASSERT(all_numeric); if ((*cit).coeff.is_equal(exONE())) { - ASSERT(all_coeff_1); + GINAC_ASSERT(all_coeff_1); } else { all_coeff_1=false; } @@ -343,7 +347,7 @@ ex mul::eval(int level) const } } while (cit!=seq.begin()); } -#endif // def DOASSERT +#endif // def DO_GINAC_ASSERT if (flags & status_flags::evaluated) { return *this; @@ -477,26 +481,26 @@ ex mul::eval(int level) const 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,mul))|| + GINAC_ASSERT((!is_ex_exactly_of_type((*cit).rest,mul))|| (!(ex_to_numeric((*cit).coeff).is_integer()))); - ASSERT(!((*cit).is_numeric_with_coeff_1())); + GINAC_ASSERT(!((*cit).is_numeric_with_coeff_1())); if (is_ex_exactly_of_type(recombine_pair_to_ex(*cit),numeric)) { printtree(cerr,0); } - ASSERT(!is_ex_exactly_of_type(recombine_pair_to_ex(*cit),numeric)); + GINAC_ASSERT(!is_ex_exactly_of_type(recombine_pair_to_ex(*cit),numeric)); /* for paranoia */ expair p=split_ex_to_pair(recombine_pair_to_ex(*cit)); - ASSERT(p.rest.is_equal((*cit).rest)); - ASSERT(p.coeff.is_equal((*cit).coeff)); + GINAC_ASSERT(p.rest.is_equal((*cit).rest)); + GINAC_ASSERT(p.coeff.is_equal((*cit).coeff)); /* end paranoia */ } -#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(exONE())); + GINAC_ASSERT(seq.size()>0); + GINAC_ASSERT((seq.size()>1)||!overall_coeff.is_equal(exONE())); return *this; } @@ -769,23 +773,23 @@ ex mul::default_overall_coeff(void) const void mul::combine_overall_coeff(ex const & c) { - ASSERT(is_ex_exactly_of_type(overall_coeff,numeric)); - ASSERT(is_ex_exactly_of_type(c,numeric)); + GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric)); + GINAC_ASSERT(is_ex_exactly_of_type(c,numeric)); overall_coeff = ex_to_numeric(overall_coeff).mul_dyn(ex_to_numeric(c)); } void mul::combine_overall_coeff(ex const & c1, ex const & c2) { - ASSERT(is_ex_exactly_of_type(overall_coeff,numeric)); - ASSERT(is_ex_exactly_of_type(c1,numeric)); - ASSERT(is_ex_exactly_of_type(c2,numeric)); + GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric)); + GINAC_ASSERT(is_ex_exactly_of_type(c1,numeric)); + GINAC_ASSERT(is_ex_exactly_of_type(c2,numeric)); overall_coeff = ex_to_numeric(overall_coeff). mul_dyn(ex_to_numeric(c1).power(ex_to_numeric(c2))); } bool mul::can_make_flat(expair const & p) const { - ASSERT(is_ex_exactly_of_type(p.coeff,numeric)); + GINAC_ASSERT(is_ex_exactly_of_type(p.coeff,numeric)); // this assertion will probably fail somewhere // it would require a more careful make_flat, obeying the power laws // probably should return true only if p.coeff is integer @@ -848,7 +852,7 @@ ex mul::expand(unsigned options) const term=expanded_seq; for (l=0; l