X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Florentzidx.cpp;h=52487dde554c66b2a727bc06c6139a4c2818e4b1;hb=a5083046b0f69afb57bec50a8658f6464bb7ee8a;hp=02611668313b23a7ad7ed733b18c19dc9eda2701;hpb=66c0f31c678e6c1938d637636b230ea376c157c1;p=ginac.git diff --git a/ginac/lorentzidx.cpp b/ginac/lorentzidx.cpp index 02611668..52487dde 100644 --- a/ginac/lorentzidx.cpp +++ b/ginac/lorentzidx.cpp @@ -1,8 +1,9 @@ /** @file lorentzidx.cpp * - * Implementation of GiNaC's lorentz indices. - * - * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany + * Implementation of GiNaC's lorentz indices. */ + +/* + * GiNaC Copyright (C) 1999-2000 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 @@ -22,7 +23,16 @@ #include #include "lorentzidx.h" +#include "lst.h" +#include "archive.h" #include "utils.h" +#include "debugmsg.h" + +#ifndef NO_GINAC_NAMESPACE +namespace GiNaC { +#endif // ndef NO_GINAC_NAMESPACE + +GINAC_IMPLEMENT_REGISTERED_CLASS(lorentzidx, idx) ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -44,13 +54,13 @@ lorentzidx::~lorentzidx() destroy(0); } -lorentzidx::lorentzidx(lorentzidx const & other) +lorentzidx::lorentzidx(const lorentzidx & 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) { @@ -62,16 +72,16 @@ lorentzidx const & lorentzidx::operator=(lorentzidx const & other) // protected -void lorentzidx::copy(lorentzidx const & 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); } ////////// @@ -93,7 +103,7 @@ lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) : tinfo_key=TINFO_lorentzidx; } -lorentzidx::lorentzidx(string const & n, bool cov, bool oonly, unsigned dimp) +lorentzidx::lorentzidx(const 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", @@ -101,7 +111,7 @@ lorentzidx::lorentzidx(string const & n, bool cov, bool oonly, unsigned dimp) tinfo_key=TINFO_lorentzidx; } -lorentzidx::lorentzidx(char const * n, bool cov, bool oonly, unsigned dimp) +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 char*,bool,bool,unsigned", @@ -109,13 +119,50 @@ lorentzidx::lorentzidx(char const * n, bool cov, bool oonly, unsigned dimp) tinfo_key=TINFO_lorentzidx; } -lorentzidx::lorentzidx(unsigned const v, bool cov) : idx(v,cov), +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 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 (int i=0; i