X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Florentzidx.cpp;h=9a0aa7bd34a854e6886a2323f840fd7568cbfa26;hb=d8452c110d6f725c569b8b151d3c78f6e8834536;hp=e8dacf73ae1827649d327b7658bee2ac42a7937b;hpb=2565309dd7c38635c191eacf2a4af9b23fc0d310;p=ginac.git diff --git a/ginac/lorentzidx.cpp b/ginac/lorentzidx.cpp index e8dacf73..9a0aa7bd 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 @@ -70,14 +74,14 @@ const lorentzidx & lorentzidx::operator=(const lorentzidx & other) void lorentzidx::copy(const lorentzidx & other) { - idx::copy(other); + 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); } ////////// @@ -99,7 +103,7 @@ lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) : tinfo_key=TINFO_lorentzidx; } -lorentzidx::lorentzidx(const string & n, bool cov, bool oonly, unsigned dimp) +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", @@ -122,6 +126,43 @@ lorentzidx::lorentzidx(unsigned v, bool cov) : idx(v,cov), 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 archive_node", LOGLEVEL_CONSTRUCT); + n.find_bool("orthogonal_only", orthogonal_only); + if (orthogonal_only) + n.find_unsigned("pdim", dim_parallel_space); +} + +/** Unarchive the object. */ +ex lorentzidx::unarchive(const archive_node &n, const lst &sym_lst) +{ + 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