]> www.ginac.de Git - ginac.git/blobdiff - ginac/normal.cpp
- Introduced exception do_taylor to signal Taylor expansion is ok for series
[ginac.git] / ginac / normal.cpp
index 70447acfc5cb94c793c579af7b39abb5e0913d01..3549dfee1f54df61d4c1889119651231f38be47b 100644 (file)
@@ -46,7 +46,9 @@
 #include "series.h"
 #include "symbol.h"
 
+#ifndef NO_GINAC_NAMESPACE
 namespace GiNaC {
+#endif // ndef NO_GINAC_NAMESPACE
 
 // If comparing expressions (ex::compare()) is fast, you can set this to 1.
 // Some routines like quo(), rem() and gcd() will then return a quick answer
@@ -220,7 +222,7 @@ static numeric lcm_of_coefficients_denominators(const ex &e)
 
 numeric ex::integer_content(void) const
 {
-    ASSERT(bp!=0);
+    GINAC_ASSERT(bp!=0);
     return bp->integer_content();
 }
 
@@ -240,27 +242,27 @@ numeric add::integer_content(void) const
     epvector::const_iterator itend = seq.end();
     numeric c = numZERO();
     while (it != itend) {
-        ASSERT(!is_ex_exactly_of_type(it->rest,numeric));
-        ASSERT(is_ex_exactly_of_type(it->coeff,numeric));
+        GINAC_ASSERT(!is_ex_exactly_of_type(it->rest,numeric));
+        GINAC_ASSERT(is_ex_exactly_of_type(it->coeff,numeric));
         c = gcd(ex_to_numeric(it->coeff), c);
         it++;
     }
-    ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+    GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
     c = gcd(ex_to_numeric(overall_coeff),c);
     return c;
 }
 
 numeric mul::integer_content(void) const
 {
-#ifdef DOASSERT
+#ifdef DO_GINAC_ASSERT
     epvector::const_iterator it = seq.begin();
     epvector::const_iterator itend = seq.end();
     while (it != itend) {
-        ASSERT(!is_ex_exactly_of_type(recombine_pair_to_ex(*it),numeric));
+        GINAC_ASSERT(!is_ex_exactly_of_type(recombine_pair_to_ex(*it),numeric));
         ++it;
     }
-#endif // def DOASSERT
-    ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+#endif // def DO_GINAC_ASSERT
+    GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
     return abs(ex_to_numeric(overall_coeff));
 }
 
@@ -841,7 +843,7 @@ static ex sr_gcd(const ex &a, const ex &b, const symbol *x)
 
 numeric ex::max_coefficient(void) const
 {
-    ASSERT(bp!=0);
+    GINAC_ASSERT(bp!=0);
     return bp->max_coefficient();
 }
 
@@ -859,11 +861,11 @@ numeric add::max_coefficient(void) const
 {
     epvector::const_iterator it = seq.begin();
     epvector::const_iterator itend = seq.end();
-    ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+    GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
     numeric cur_max = abs(ex_to_numeric(overall_coeff));
     while (it != itend) {
         numeric a;
-        ASSERT(!is_ex_exactly_of_type(it->rest,numeric));
+        GINAC_ASSERT(!is_ex_exactly_of_type(it->rest,numeric));
         a = abs(ex_to_numeric(it->coeff));
         if (a > cur_max)
             cur_max = a;
@@ -874,15 +876,15 @@ numeric add::max_coefficient(void) const
 
 numeric mul::max_coefficient(void) const
 {
-#ifdef DOASSERT
+#ifdef DO_GINAC_ASSERT
     epvector::const_iterator it = seq.begin();
     epvector::const_iterator itend = seq.end();
     while (it != itend) {
-        ASSERT(!is_ex_exactly_of_type(recombine_pair_to_ex(*it),numeric));
+        GINAC_ASSERT(!is_ex_exactly_of_type(recombine_pair_to_ex(*it),numeric));
         it++;
     }
-#endif // def DOASSERT
-    ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+#endif // def DO_GINAC_ASSERT
+    GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
     return abs(ex_to_numeric(overall_coeff));
 }
 
@@ -897,7 +899,7 @@ numeric mul::max_coefficient(void) const
 
 ex ex::smod(const numeric &xi) const
 {
-    ASSERT(bp!=0);
+    GINAC_ASSERT(bp!=0);
     return bp->smod(xi);
 }
 
@@ -908,7 +910,11 @@ ex basic::smod(const numeric &xi) const
 
 ex numeric::smod(const numeric &xi) const
 {
+#ifndef NO_GINAC_NAMESPACE
     return GiNaC::smod(*this, xi);
+#else // ndef NO_GINAC_NAMESPACE
+    return ::smod(*this, xi);
+#endif // ndef NO_GINAC_NAMESPACE
 }
 
 ex add::smod(const numeric &xi) const
@@ -918,37 +924,49 @@ ex add::smod(const numeric &xi) const
     epvector::const_iterator it = seq.begin();
     epvector::const_iterator itend = seq.end();
     while (it != itend) {
-        ASSERT(!is_ex_exactly_of_type(it->rest,numeric));
+        GINAC_ASSERT(!is_ex_exactly_of_type(it->rest,numeric));
+#ifndef NO_GINAC_NAMESPACE
         numeric coeff = GiNaC::smod(ex_to_numeric(it->coeff), xi);
+#else // ndef NO_GINAC_NAMESPACE
+        numeric coeff = ::smod(ex_to_numeric(it->coeff), xi);
+#endif // ndef NO_GINAC_NAMESPACE
         if (!coeff.is_zero())
             newseq.push_back(expair(it->rest, coeff));
         it++;
     }
-    ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+    GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+#ifndef NO_GINAC_NAMESPACE
     numeric coeff = GiNaC::smod(ex_to_numeric(overall_coeff), xi);
+#else // ndef NO_GINAC_NAMESPACE
+    numeric coeff = ::smod(ex_to_numeric(overall_coeff), xi);
+#endif // ndef NO_GINAC_NAMESPACE
     return (new add(newseq,coeff))->setflag(status_flags::dynallocated);
 }
 
 ex mul::smod(const numeric &xi) const
 {
-#ifdef DOASSERT
+#ifdef DO_GINAC_ASSERT
     epvector::const_iterator it = seq.begin();
     epvector::const_iterator itend = seq.end();
     while (it != itend) {
-        ASSERT(!is_ex_exactly_of_type(recombine_pair_to_ex(*it),numeric));
+        GINAC_ASSERT(!is_ex_exactly_of_type(recombine_pair_to_ex(*it),numeric));
         it++;
     }
-#endif // def DOASSERT
+#endif // def DO_GINAC_ASSERT
     mul * mulcopyp=new mul(*this);
-    ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+    GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+#ifndef NO_GINAC_NAMESPACE
     mulcopyp->overall_coeff = GiNaC::smod(ex_to_numeric(overall_coeff),xi);
+#else // ndef NO_GINAC_NAMESPACE
+    mulcopyp->overall_coeff = ::smod(ex_to_numeric(overall_coeff),xi);
+#endif // ndef NO_GINAC_NAMESPACE
     mulcopyp->clearflag(status_flags::evaluated);
     mulcopyp->clearflag(status_flags::hash_calculated);
     return mulcopyp->setflag(status_flags::dynallocated);
 }
 
 
-/** Exception thrown by heur_gcd() to signal failure */
+/** Exception thrown by heur_gcd() to signal failure. */
 class gcdheu_failed {};
 
 /** Compute GCD of multivariate polynomials using the heuristic GCD algorithm.
@@ -1484,4 +1502,6 @@ ex ex::normal(int level) const
         return e;
 }
 
+#ifndef NO_GINAC_NAMESPACE
 } // namespace GiNaC
+#endif // ndef NO_GINAC_NAMESPACE