]> www.ginac.de Git - ginac.git/blobdiff - ginac/idx.cpp
#ifndef around namespace GiNaC { }
[ginac.git] / ginac / idx.cpp
index 9829b876b025b8c5c2f850b698e789ac9d23f16f..94616ce62ba7c4ba4335996b25a288f06e310b0b 100644 (file)
@@ -2,10 +2,36 @@
  *
  *  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
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
 #include <stdexcept>
 
-#include "ginac.h"
+#include "idx.h"
+#include "ex.h"
+#include "lst.h"
+#include "relational.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
@@ -13,7 +39,7 @@
 
 // public
 
-idx::idx() : basic(TINFO_IDX), symbolic(true), covariant(false)
+idx::idx() : basic(TINFO_idx), symbolic(true), covariant(false)
 {
     debugmsg("idx default constructor",LOGLEVEL_CONSTRUCT);
     serial=next_serial++;
@@ -65,28 +91,28 @@ void idx::destroy(bool call_parent)
 
 // public
 
-idx::idx(bool cov) : basic(TINFO_IDX), symbolic(true), covariant(cov)
+idx::idx(bool cov) : basic(TINFO_idx), symbolic(true), covariant(cov)
 {
     debugmsg("idx constructor from bool",LOGLEVEL_CONSTRUCT);
     serial=next_serial++;
     name="index"+ToString(serial);
 }
 
-idx::idx(string const & n, bool cov) : basic(TINFO_IDX),  
+idx::idx(string const & n, bool cov) : basic(TINFO_idx),  
     symbolic(true), name(n), covariant(cov)
 {
     debugmsg("idx constructor from string,bool",LOGLEVEL_CONSTRUCT);
     serial=next_serial++;
 }
 
-idx::idx(char const * n, bool cov) : basic(TINFO_IDX),  
+idx::idx(char const * n, bool cov) : basic(TINFO_idx),  
     symbolic(true), name(n), covariant(cov)
 {
     debugmsg("idx constructor from char*,bool",LOGLEVEL_CONSTRUCT);
     serial=next_serial++;
 }
 
-idx::idx(unsigned const v, bool cov) : basic(TINFO_IDX),
+idx::idx(unsigned const v, bool cov) : basic(TINFO_idx),
     symbolic(false), value(v), covariant(cov)
 {
     debugmsg("idx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT);
@@ -176,13 +202,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)) {
@@ -196,7 +222,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));
 
@@ -224,7 +250,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));
 
@@ -250,7 +276,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));
 
@@ -342,10 +368,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;
@@ -368,8 +394,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;
     
@@ -388,8 +414,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);
@@ -414,7 +440,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]);
@@ -422,6 +448,6 @@ ex subs_indices(ex const & e, exvector const & idxv_subs,
     return res;
 }
 
-
-
-
+#ifndef NO_GINAC_NAMESPACE
+} // namespace GiNaC
+#endif // ndef NO_GINAC_NAMESPACE