namespace GiNaC {
#endif // ndef NO_NAMESPACE_GINAC
+GINAC_IMPLEMENT_REGISTERED_CLASS(clifford, lortensor)
+
//////////
// default constructor, destructor, copy constructor assignment operator and helpers
//////////
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()
clifford::clifford(const clifford & other)
{
debugmsg("clifford copy constructor",LOGLEVEL_CONSTRUCT);
- copy (other);
+ copy(other);
}
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);
}
//////////
// 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;
}
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 << ")";
}
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
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);
}
//////////
// 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