]> www.ginac.de Git - ginac.git/blobdiff - ginac/basic.cpp
- changed behaviour of numeric::is_rational() and added numeric::is_cinteger()
[ginac.git] / ginac / basic.cpp
index 097ec5749196d599a04e2d55eadbd5aa7b6f2333..c2b4ce156cf3dbde1d2a5a53ee17ab986d651124 100644 (file)
 #include "lst.h"
 #include "ncmul.h"
 #include "utils.h"
+#include "debugmsg.h"
+
+#ifndef NO_GINAC_NAMESPACE
+namespace GiNaC {
+#endif // ndef NO_GINAC_NAMESPACE
 
 //////////
 // default constructor, destructor, copy constructor assignment operator and helpers
@@ -50,7 +55,7 @@ basic::~basic()
 {
     debugmsg("basic destructor",LOGLEVEL_DESTRUCT);
     destroy(0);
-    ASSERT((!(flags & status_flags::dynallocated))||(refcount==0));
+    GINAC_ASSERT((!(flags & status_flags::dynallocated))||(refcount==0));
 }
 
 basic::basic(basic const & other) : flags(0), refcount(0), tinfo_key(TINFO_BASIC)
@@ -146,7 +151,7 @@ ex basic::operator[](int const i) const
 
 bool basic::has(ex const & other) const
 {
-    ASSERT(other.bp!=0);
+    GINAC_ASSERT(other.bp!=0);
     if (is_equal(*other.bp)) return true;
     if (nops()>0) {
         for (int i=0; i<nops(); i++) {
@@ -289,28 +294,9 @@ ex basic::subs(ex const & e) const
     return subs(ls,lr);
 }
 
-// compare functions to sort expressions canonically
-// all compare functions return: -1 for *this less than other, 0 equal, 1 greater
-
-/*
-int basic::compare(basic const & other) const
-{
-    const type_info & typeid_this = typeid(*this);
-    const type_info & typeid_other = typeid(other);
-
-    if (typeid_this==typeid_other) {
-        return compare_same_type(other);
-    }
-
-    // special rule: sort numeric() to end
-    if (typeid_this==typeid_numeric) return 1;
-    if (typeid_other==typeid_numeric) return -1;
-
-    // otherwise: sort according to type_info order (arbitrary, but well defined)
-    return typeid_this.before(typeid_other) ? -1 : 1;
-}
-*/
-
+/** Compare objects to establish canonical order.
+ *  All compare functions return: -1 for *this less than other, 0 equal,
+ *  1 greater. */
 int basic::compare(basic const & other) const
 {
     unsigned hash_this = gethash();
@@ -345,7 +331,7 @@ int basic::compare(basic const & other) const
         return 1;
     }
 
-    ASSERT(typeid(*this)==typeid(other));
+    GINAC_ASSERT(typeid(*this)==typeid(other));
 
     int cmpval=compare_same_type(other);
     if ((cmpval!=0)&&(hash_this<0x80000000U)) {
@@ -373,7 +359,7 @@ bool basic::is_equal(basic const & other) const
 
     if (typeid_this!=typeid_other) return false;
 
-    ASSERT(typeid(*this)==typeid(other));
+    GINAC_ASSERT(typeid(*this)==typeid(other));
 
     return is_equal_same_type(other);
 }
@@ -413,3 +399,7 @@ type_info const & typeid_basic=typeid(some_basic);
 //////////
 
 int max_recursion_level=1024;
+
+#ifndef NO_GINAC_NAMESPACE
+} // namespace GiNaC
+#endif // ndef NO_GINAC_NAMESPACE