]> www.ginac.de Git - ginac.git/blobdiff - ginac/idx.cpp
Transform abs(x)^n => x^n if x is real and n is even.
[ginac.git] / ginac / idx.cpp
index 427dfe99345f0f724d5d973934a0a82c9177db06..a3f0b843f153fefc8da3be335e5510e9f2d23c1b 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's indices. */
 
 /*
- *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2011 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
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <iostream>
-#include <sstream>
-#include <stdexcept>
-
 #include "idx.h"
 #include "symbol.h"
 #include "lst.h"
 #include "operators.h"
 #include "archive.h"
 #include "utils.h"
+#include "hash_seed.h"
+
+#include <iostream>
+#include <sstream>
+#include <stdexcept>
 
 namespace GiNaC {
 
@@ -87,21 +88,27 @@ spinidx::spinidx(const ex & v, const ex & d, bool cov, bool dot) : inherited(v,
 // archiving
 //////////
 
-idx::idx(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
+void idx::read_archive(const archive_node& n, lst& sym_lst) 
 {
+       inherited::read_archive(n, sym_lst);
        n.find_ex("value", value, sym_lst);
        n.find_ex("dim", dim, sym_lst);
 }
+GINAC_BIND_UNARCHIVER(idx);
 
-varidx::varidx(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
+void varidx::read_archive(const archive_node& n, lst& sym_lst)
 {
+       inherited::read_archive(n, sym_lst);
        n.find_bool("covariant", covariant);
 }
+GINAC_BIND_UNARCHIVER(varidx);
 
-spinidx::spinidx(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
+void spinidx::read_archive(const archive_node& n, lst& sym_lst)
 {
+       inherited::read_archive(n, sym_lst);
        n.find_bool("dotted", dotted);
 }
+GINAC_BIND_UNARCHIVER(spinidx);
 
 void idx::archive(archive_node &n) const
 {
@@ -122,10 +129,6 @@ void spinidx::archive(archive_node &n) const
        n.add_bool("dotted", dotted);
 }
 
-DEFAULT_UNARCHIVE(idx)
-DEFAULT_UNARCHIVE(varidx)
-DEFAULT_UNARCHIVE(spinidx)
-
 //////////
 // functions overriding virtual functions from base classes
 //////////
@@ -348,8 +351,7 @@ unsigned idx::calchash() const
        // hash keys. That is, the hash values must not depend on the index
        // dimensions or other attributes (variance etc.).
        // The compare_same_type() methods will take care of the rest.
-       const void* this_tinfo = (const void*)(typeid(*this).name());
-       unsigned v = golden_ratio_hash((p_int)this_tinfo);
+       unsigned v = make_hash_seed(typeid(*this));
        v = rotate_left(v);
        v ^= value.gethash();