]> www.ginac.de Git - ginac.git/blobdiff - ginac/clifford.cpp
- added documentation to the indexed, color, lortensor and clifford classes
[ginac.git] / ginac / clifford.cpp
index fec22857c89410efb95a7b006244bbdec956e189..ce2088916bff33c928445da31413a974305fb79e 100644 (file)
@@ -33,6 +33,8 @@
 namespace GiNaC {
 #endif // ndef NO_NAMESPACE_GINAC
 
+GINAC_IMPLEMENT_REGISTERED_CLASS(clifford, lortensor)
+
 //////////
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
@@ -42,9 +44,7 @@ namespace GiNaC {
 clifford::clifford()
 {
        debugmsg("clifford default constructor",LOGLEVEL_CONSTRUCT);
-       serial=next_serial++;
-       name=autoname_prefix()+ToString(serial);
-       tinfo_key=TINFO_clifford;
+       tinfo_key = TINFO_clifford;
 }
 
 clifford::~clifford()
@@ -56,7 +56,7 @@ clifford::~clifford()
 clifford::clifford(const clifford & other)
 {
        debugmsg("clifford copy constructor",LOGLEVEL_CONSTRUCT);
-       copy (other);
+       copy(other);
 }
 
 const clifford & clifford::operator=(const clifford & other)
@@ -73,16 +73,12 @@ const clifford & clifford::operator=(const clifford & other)
 
 void clifford::copy(const clifford & other)
 {
-       indexed::copy(other);
-       name=other.name;
-       serial=other.serial;
+       inherited::copy(other);
 }
 
 void clifford::destroy(bool call_parent)
 {
-       if (call_parent) {
-               indexed::destroy(call_parent);
-       }
+       if (call_parent) inherited::destroy(call_parent);
 }
 
 //////////
@@ -91,11 +87,9 @@ void clifford::destroy(bool call_parent)
 
 // public
 
-clifford::clifford(const std::string & initname)
+clifford::clifford(const std::string & n, const ex & mu) : inherited(lortensor_symbolic, n, mu)
 {
-       debugmsg("clifford constructor from string",LOGLEVEL_CONSTRUCT);
-       name=initname;
-       serial=next_serial++;
+       debugmsg("clifford constructor from string,ex",LOGLEVEL_CONSTRUCT);
        tinfo_key=TINFO_clifford;
 }
 
@@ -114,8 +108,7 @@ basic * clifford::duplicate() const
 void clifford::printraw(std::ostream & os) const
 {
        debugmsg("clifford printraw",LOGLEVEL_PRINT);
-       os << "clifford(" << "name=" << name << ",serial=" << serial
-          << ",indices=";
+       os << "clifford(" << "indices=";
        printrawindices(os);
        os << ",hash=" << hashvalue << ",flags=" << flags << ")";
 }
@@ -123,8 +116,7 @@ void clifford::printraw(std::ostream & os) const
 void clifford::printtree(std::ostream & os, unsigned indent) const
 {
        debugmsg("clifford printtree",LOGLEVEL_PRINT);
-       os << std::string(indent,' ') << name << " (clifford): "
-          << "serial=" << serial << ","
+       os << std::string(indent,' ') << " (clifford): "
           << seq.size() << "indices=";
        printtreeindices(os, indent);
        os << ", hash=" << hashvalue
@@ -139,41 +131,30 @@ void clifford::print(std::ostream & os, unsigned upper_precedence) const
        printindices(os);
 }
 
-void clifford::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const
-{
-       debugmsg("clifford print csrc",LOGLEVEL_PRINT);
-       print(os,upper_precedence);
-}
-
 bool clifford::info(unsigned inf) const
 {
-       return indexed::info(inf);
+       return inherited::info(inf);
 }
 
 // protected
 
 int clifford::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(other.tinfo() == TINFO_clifford);
-       const clifford *o = static_cast<const clifford *>(&other);
-       if (serial==o->serial) {
-               return indexed::compare_same_type(other);
-       }
-       return serial < o->serial ? -1 : 1;
+       GINAC_ASSERT(is_of_type(other,clifford));
+       // only compare indices
+       return exprseq::compare_same_type(other);
 }
 
-ex clifford::simplify_ncmul(const exvector & v) const
+bool clifford::is_equal_same_type(const basic & other) const
 {
-       return simplified_ncmul(v);
+       GINAC_ASSERT(is_of_type(other,clifford));
+       // only compare indices
+       return exprseq::is_equal_same_type(other);
 }
 
-unsigned clifford::calchash(void) const
+ex clifford::simplify_ncmul(const exvector & v) const
 {
-       hashvalue=golden_ratio_hash(golden_ratio_hash(0x55555556U ^
-                                                                                                 golden_ratio_hash(tinfo_key) ^
-                                                                                                 serial));
-       setflag(status_flags::hash_calculated);
-       return hashvalue;
+       return simplified_ncmul(v);
 }
 
 //////////
@@ -186,26 +167,27 @@ unsigned clifford::calchash(void) const
 // non-virtual functions in this class
 //////////
 
-void clifford::setname(const std::string & n)
-{
-       name = n;
-}
-
-// private
-
-std::string & clifford::autoname_prefix(void)
-{
-       static std::string * s = new std::string("clifford");
-       return *s;
-}
+// none
 
 //////////
 // static member variables
 //////////
 
-// private
+// none
+
+//////////
+// friend functions
+//////////
 
-unsigned clifford::next_serial=0;
+/** Construct an object representing a Dirac gamma matrix. The index must
+ *  be of class lorentzidx.
+ *
+ *  @param mu Index
+ *  @return newly constructed object */
+clifford clifford_gamma(const ex & mu)
+{
+       return clifford("gamma", mu);
+}
 
 //////////
 // global constants