X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Florentzidx.cpp;h=584a5d0e2d169ae9004137e4e1b7d3efac5b3d75;hp=56b4358c4c86f4b10208d9234e471ba6d6b7f73a;hb=ae3044935ddf13dd325f6e11770357b99bbe6095;hpb=15d4b353c85f8815a95d97ab977c9ca48e155574 diff --git a/ginac/lorentzidx.cpp b/ginac/lorentzidx.cpp index 56b4358c..584a5d0e 100644 --- a/ginac/lorentzidx.cpp +++ b/ginac/lorentzidx.cpp @@ -23,12 +23,16 @@ #include #include "lorentzidx.h" +#include "lst.h" +#include "archive.h" #include "utils.h" #include "debugmsg.h" -#ifndef NO_GINAC_NAMESPACE +#ifndef NO_NAMESPACE_GINAC namespace GiNaC { -#endif // ndef NO_GINAC_NAMESPACE +#endif // ndef NO_NAMESPACE_GINAC + +GINAC_IMPLEMENT_REGISTERED_CLASS(lorentzidx, idx) ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -38,46 +42,46 @@ namespace GiNaC { lorentzidx::lorentzidx() : orthogonal_only(false), dim_parallel_space(0) { - debugmsg("lorentzidx default constructor",LOGLEVEL_CONSTRUCT); - // serial is incremented in idx::idx() - name="mu"+ToString(serial); - tinfo_key=TINFO_lorentzidx; + debugmsg("lorentzidx default constructor",LOGLEVEL_CONSTRUCT); + // serial is incremented in idx::idx() + name = "mu" + ToString(serial); + tinfo_key = TINFO_lorentzidx; } lorentzidx::~lorentzidx() { - debugmsg("lorentzidx destructor",LOGLEVEL_DESTRUCT); - destroy(0); + debugmsg("lorentzidx destructor",LOGLEVEL_DESTRUCT); + destroy(false); } -lorentzidx::lorentzidx(lorentzidx const & other) +lorentzidx::lorentzidx(const lorentzidx & other) { - debugmsg("lorentzidx copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); + debugmsg("lorentzidx copy constructor",LOGLEVEL_CONSTRUCT); + copy(other); } -lorentzidx const & lorentzidx::operator=(lorentzidx const & other) +const lorentzidx & lorentzidx::operator=(const lorentzidx & other) { - debugmsg("lorentzidx operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(1); - copy(other); - } - return *this; + debugmsg("lorentzidx operator=",LOGLEVEL_ASSIGNMENT); + if (this != &other) { + destroy(true); + copy(other); + } + return *this; } // protected -void lorentzidx::copy(lorentzidx const & other) +void lorentzidx::copy(const lorentzidx & other) { - idx::copy(other); - orthogonal_only=other.orthogonal_only; - dim_parallel_space=other.dim_parallel_space; + inherited::copy(other); + orthogonal_only=other.orthogonal_only; + dim_parallel_space=other.dim_parallel_space; } void lorentzidx::destroy(bool call_parent) { - if (call_parent) idx::destroy(call_parent); + if (call_parent) inherited::destroy(call_parent); } ////////// @@ -86,40 +90,77 @@ void lorentzidx::destroy(bool call_parent) // public -lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) : - idx(cov), orthogonal_only(oonly), dim_parallel_space(dimp) +lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) + : idx(cov), orthogonal_only(oonly), dim_parallel_space(dimp) +{ + debugmsg("lorentzidx constructor from bool",LOGLEVEL_CONSTRUCT); + // serial is incremented in idx::idx(bool) + if (oonly) { + name="muorth"+ToString(serial); + } else { + name="mu"+ToString(serial); + } + tinfo_key=TINFO_lorentzidx; +} + +lorentzidx::lorentzidx(const std::string & n, bool cov, bool oonly, unsigned dimp) + : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp) +{ + debugmsg("lorentzidx constructor from string,bool,bool,unsigned", + LOGLEVEL_CONSTRUCT); + tinfo_key=TINFO_lorentzidx; +} + +lorentzidx::lorentzidx(const char * n, bool cov, bool oonly, unsigned dimp) + : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp) { - debugmsg("lorentzidx constructor from bool",LOGLEVEL_CONSTRUCT); - // serial is incremented in idx::idx(bool) - if (oonly) { - name="muorth"+ToString(serial); - } else { - name="mu"+ToString(serial); - } - tinfo_key=TINFO_lorentzidx; + debugmsg("lorentzidx constructor from char*,bool,bool,unsigned", + LOGLEVEL_CONSTRUCT); + tinfo_key=TINFO_lorentzidx; } -lorentzidx::lorentzidx(string const & n, bool cov, bool oonly, unsigned dimp) - : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp) +lorentzidx::lorentzidx(unsigned v, bool cov) + : idx(v,cov), orthogonal_only(false), dim_parallel_space(0) +{ + debugmsg("lorentzidx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT); + tinfo_key=TINFO_lorentzidx; +} + +////////// +// archiving +////////// + +/** Construct object from archive_node. */ +lorentzidx::lorentzidx(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) { - debugmsg("lorentzidx constructor from string,bool,bool,unsigned", - LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_lorentzidx; + debugmsg("lorentzidx constructor from archive_node", LOGLEVEL_CONSTRUCT); + n.find_bool("orthogonal_only", orthogonal_only); + if (orthogonal_only) + n.find_unsigned("pdim", dim_parallel_space); } -lorentzidx::lorentzidx(char const * n, bool cov, bool oonly, unsigned dimp) - : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp) +/** Unarchive the object. */ +ex lorentzidx::unarchive(const archive_node &n, const lst &sym_lst) { - debugmsg("lorentzidx constructor from char*,bool,bool,unsigned", - LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_lorentzidx; + ex s = (new lorentzidx(n, sym_lst))->setflag(status_flags::dynallocated); + + if (ex_to_lorentzidx(s).symbolic) { + // If lorentzidx is in sym_lst, return the existing lorentzidx + for (unsigned i=0; i