]> www.ginac.de Git - ginac.git/blobdiff - ginac/idx.cpp
- changed mul::print() to behave similar to add::print()
[ginac.git] / ginac / idx.cpp
index c24846833989386f5c78d87961dd59a6719d5414..f57a5ae4bdc6ac71067d888d37c1ddead3ca59f4 100644 (file)
@@ -1,7 +1,8 @@
 /** @file idx.cpp
  *
- *  Implementation of GiNaC's indices.
- *
+ *  Implementation of GiNaC's indices. */
+
+/*
  *  GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -26,6 +27,9 @@
 #include "lst.h"
 #include "relational.h"
 #include "utils.h"
+#include "debugmsg.h"
+
+namespace GiNaC {
 
 //////////
 // default constructor, destructor, copy constructor assignment operator and helpers
@@ -196,13 +200,13 @@ bool idx::info(unsigned inf) const
 
 ex idx::subs(lst const & ls, lst const & lr) const
 {
-    ASSERT(ls.nops()==lr.nops());
-#ifdef DOASSERT
+    GINAC_ASSERT(ls.nops()==lr.nops());
+#ifdef DO_GINAC_ASSERT
     for (int i=0; i<ls.nops(); i++) {
-        ASSERT(is_ex_exactly_of_type(ls.op(i),symbol)||
+        GINAC_ASSERT(is_ex_exactly_of_type(ls.op(i),symbol)||
                is_ex_of_type(ls.op(i),idx));
     }
-#endif // def DOASSERT
+#endif // def DO_GINAC_ASSERT
 
     for (int i=0; i<ls.nops(); i++) {
         if (is_equal(*(ls.op(i)).bp)) {
@@ -216,7 +220,7 @@ ex idx::subs(lst const & ls, lst const & lr) const
 
 int idx::compare_same_type(basic const & other) const
 {
-    ASSERT(is_of_type(other,idx));
+    GINAC_ASSERT(is_of_type(other,idx));
     idx const & o=static_cast<idx const &>
                              (const_cast<basic &>(other));
 
@@ -244,7 +248,7 @@ int idx::compare_same_type(basic const & other) const
 
 bool idx::is_equal_same_type(basic const & other) const
 {
-    ASSERT(is_of_type(other,idx));
+    GINAC_ASSERT(is_of_type(other,idx));
     idx const & o=static_cast<idx const &>
                              (const_cast<basic &>(other));
 
@@ -270,7 +274,7 @@ unsigned idx::calchash(void) const
 bool idx::is_co_contra_pair(basic const & other) const
 {
     // like is_equal_same_type(), but tests for different covariant status
-    ASSERT(is_of_type(other,idx));
+    GINAC_ASSERT(is_of_type(other,idx));
     idx const & o=static_cast<idx const &>
                              (const_cast<basic &>(other));
 
@@ -362,10 +366,10 @@ exvector idx_intersect(exvector const & iv1, exvector const & iv2)
     // assumes (but does not test) that each index occurs at most twice
     exvector iv_intersect;
     for (exvector::const_iterator cit1=iv1.begin(); cit1!=iv1.end(); ++cit1) {
-        ASSERT(is_ex_of_type(*cit1,idx));
+        GINAC_ASSERT(is_ex_of_type(*cit1,idx));
         if (ex_to_idx(*cit1).is_symbolic()) {
             for (exvector::const_iterator cit2=iv2.begin(); cit2!=iv2.end(); ++cit2) {
-                ASSERT(is_ex_of_type(*cit2,idx));
+                GINAC_ASSERT(is_ex_of_type(*cit2,idx));
                 if ((*cit1).is_equal(*cit2)) {
                     iv_intersect.push_back(*cit1);
                     break;
@@ -388,8 +392,8 @@ ex permute_free_index_to_front(exvector const & iv3, exvector const & iv2,
     // match (return value,iv2) to iv3 by permuting indices
     // iv3 is always cyclic
 
-    ASSERT(iv3.size()==3);
-    ASSERT(iv2.size()==2);
+    GINAC_ASSERT(iv3.size()==3);
+    GINAC_ASSERT(iv2.size()==2);
 
     *sig=1;
     
@@ -408,8 +412,8 @@ unsigned subs_index_in_exvector(exvector & v, ex const & is, ex const & ir)
     unsigned replacements=0;
     unsigned current_replacements;
 
-    ASSERT(is_ex_of_type(is,idx));
-    ASSERT(is_ex_of_type(ir,idx));
+    GINAC_ASSERT(is_ex_of_type(is,idx));
+    GINAC_ASSERT(is_ex_of_type(ir,idx));
    
     for (it=v.begin(); it!=v.end(); ++it) {
         current_replacements=count_index(*it,is);
@@ -434,7 +438,7 @@ unsigned count_index(ex const & e, ex const & i)
 ex subs_indices(ex const & e, exvector const & idxv_subs,
                 exvector const & idxv_repl)
 {
-    ASSERT(idxv_subs.size()==idxv_repl.size());
+    GINAC_ASSERT(idxv_subs.size()==idxv_repl.size());
     ex res=e;
     for (unsigned i=0; i<idxv_subs.size(); ++i) {
         res=res.subs(idxv_subs[i]==idxv_repl[i]);
@@ -442,6 +446,4 @@ ex subs_indices(ex const & e, exvector const & idxv_subs,
     return res;
 }
 
-
-
-
+} // namespace GiNaC