* No real implementation yet, to be done. */
/*
- * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2001 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
#include "clifford.h"
#include "ex.h"
#include "ncmul.h"
+#include "archive.h"
#include "utils.h"
#include "debugmsg.h"
-#ifndef NO_NAMESPACE_GINAC
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()
+// protected
+
+void clifford::copy(const clifford & other)
{
- debugmsg("clifford destructor",LOGLEVEL_DESTRUCT);
- destroy(false);
+ inherited::copy(other);
}
-clifford::clifford(const clifford & other)
+void clifford::destroy(bool call_parent)
{
- debugmsg("clifford copy constructor",LOGLEVEL_CONSTRUCT);
- copy (other);
+ if (call_parent) inherited::destroy(call_parent);
}
-const clifford & clifford::operator=(const clifford & other)
+//////////
+// other constructors
+//////////
+
+// public
+
+clifford::clifford(const std::string & n, const ex & mu) : inherited(lortensor_symbolic, n, mu)
{
- debugmsg("clifford operator=",LOGLEVEL_ASSIGNMENT);
- if (this != &other) {
- destroy(true);
- copy(other);
- }
- return *this;
+ debugmsg("clifford constructor from string,ex",LOGLEVEL_CONSTRUCT);
+ tinfo_key=TINFO_clifford;
}
-// protected
-
-void clifford::copy(const clifford & other)
+clifford::clifford(const std::string & n, const exvector & iv) : inherited(lortensor_symbolic, n, iv)
{
- indexed::copy(other);
- name=other.name;
- serial=other.serial;
+ debugmsg("clifford constructor from string,exvector", LOGLEVEL_CONSTRUCT);
+ GINAC_ASSERT(all_of_type_lorentzidx());
+ tinfo_key=TINFO_clifford;
}
-void clifford::destroy(bool call_parent)
+clifford::clifford(const std::string & n, exvector *ivp) : inherited(lortensor_symbolic, n, *ivp)
{
- if (call_parent) {
- indexed::destroy(call_parent);
- }
+ debugmsg("clifford constructor from string,exvector", LOGLEVEL_CONSTRUCT);
+ GINAC_ASSERT(all_of_type_lorentzidx());
+ tinfo_key=TINFO_clifford;
}
//////////
-// other constructors
+// archiving
//////////
-// public
+/** Construct object from archive_node. */
+clifford::clifford(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+{
+ debugmsg("clifford constructor from archive_node", LOGLEVEL_CONSTRUCT);
+}
-clifford::clifford(const std::string & initname)
+/** Unarchive the object. */
+ex clifford::unarchive(const archive_node &n, const lst &sym_lst)
{
- debugmsg("clifford constructor from string",LOGLEVEL_CONSTRUCT);
- name=initname;
- serial=next_serial++;
- tinfo_key=TINFO_clifford;
+ return (new clifford(n, sym_lst))->setflag(status_flags::dynallocated);
+}
+
+/** Archive the object. */
+void clifford::archive(archive_node &n) const
+{
+ inherited::archive(n);
}
//////////
// public
-basic * clifford::duplicate() const
-{
- debugmsg("clifford duplicate",LOGLEVEL_DUPLICATE);
- return new clifford(*this);
-}
-
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::thisexprseq(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 clifford(name, v);
}
-//////////
-// virtual functions which can be overridden by derived classes
-//////////
-
-// none
-
-//////////
-// non-virtual functions in this class
-//////////
-
-void clifford::setname(const std::string & n)
+ex clifford::thisexprseq(exvector *vp) const
{
- name = n;
+ return clifford(name, vp);
}
-// private
-
-std::string & clifford::autoname_prefix(void)
+ex clifford::simplify_ncmul(const exvector & v) const
{
- static std::string * s = new std::string("clifford");
- return *s;
+ return simplified_ncmul(v);
}
//////////
-// static member variables
+// friend functions
//////////
-// private
-
-unsigned clifford::next_serial=0;
-
-//////////
-// global constants
-//////////
-
-const clifford some_clifford;
-const std::type_info & typeid_clifford = typeid(some_clifford);
+/** 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);
+}
-#ifndef NO_NAMESPACE_GINAC
} // namespace GiNaC
-#endif // ndef NO_NAMESPACE_GINAC