]> www.ginac.de Git - ginac.git/blobdiff - ginac/add.cpp
#ifndef around namespace GiNaC { }
[ginac.git] / ginac / add.cpp
index 9d054379aa5c24781ad5697fac9d72171bb1bdd7..553b8272c4861b910e784ac6fe465512f09d9770 100644 (file)
@@ -1,7 +1,8 @@
 /** @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
@@ -83,7 +89,7 @@ add::add(ex const & lh, ex const & rh)
     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)
@@ -92,7 +98,7 @@ add::add(exvector const & v)
     tinfo_key = TINFO_add;
     overall_coeff=exZERO();
     construct_from_exvector(v);
-    ASSERT(is_canonical());
+    GINAC_ASSERT(is_canonical());
 }
 
 /*
@@ -108,7 +114,7 @@ add::add(epvector const & v, bool do_not_canonicalize)
     } else {
         construct_from_epvector(v);
     }
-    ASSERT(is_canonical());
+    GINAC_ASSERT(is_canonical());
 }
 */
 
@@ -118,7 +124,7 @@ add::add(epvector const & v)
     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)
@@ -127,18 +133,18 @@ 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());
 }
 
 //////////
@@ -272,13 +278,13 @@ ex add::eval(int level) const
     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;
     }
 
@@ -292,13 +298,13 @@ ex add::eval(int level) const
         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;
@@ -390,19 +396,19 @@ ex add::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,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;
     }
 
@@ -419,9 +425,9 @@ ex add::eval(int level) const
 
 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();
     }
@@ -479,7 +485,7 @@ expair add::split_ex_to_pair(ex const & e) const
 {
     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) &&
@@ -524,10 +530,10 @@ expair add::split_ex_to_pair(ex const & e) const
 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) &&
@@ -562,7 +568,7 @@ expair add::combine_ex_with_coeff_to_pair(ex const & e,
 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;
@@ -590,11 +596,11 @@ expair add::combine_ex_with_coeff_to_pair(ex const & e,
 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());
     }
 
@@ -649,5 +655,6 @@ unsigned add::precedence=40;
 const add some_add;
 type_info const & typeid_add=typeid(some_add);
 
-
-
+#ifndef NO_GINAC_NAMESPACE
+} // namespace GiNaC
+#endif // ndef NO_GINAC_NAMESPACE