From 8ef6aee2104e15e87c5c15bdb639655d5d0a8ef5 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Tue, 6 Mar 2001 20:05:24 +0000 Subject: [PATCH] removed obsolete files --- check/exam_noncommut.cpp | 109 ---- ginac/clifford.cpp | 191 ------- ginac/clifford.h | 82 --- ginac/color.cpp | 1034 -------------------------------------- ginac/color.h | 166 ------ ginac/coloridx.cpp | 213 -------- ginac/coloridx.h | 78 --- ginac/isospin.cpp | 218 -------- ginac/isospin.h | 77 --- ginac/lorentzidx.cpp | 297 ----------- ginac/lorentzidx.h | 94 ---- ginac/lortensor.cpp | 575 --------------------- ginac/lortensor.h | 139 ----- ginac/simp_lor.cpp | 508 ------------------- ginac/simp_lor.h | 145 ------ 15 files changed, 3926 deletions(-) delete mode 100644 check/exam_noncommut.cpp delete mode 100644 ginac/clifford.cpp delete mode 100644 ginac/clifford.h delete mode 100644 ginac/color.cpp delete mode 100644 ginac/color.h delete mode 100644 ginac/coloridx.cpp delete mode 100644 ginac/coloridx.h delete mode 100644 ginac/isospin.cpp delete mode 100644 ginac/isospin.h delete mode 100644 ginac/lorentzidx.cpp delete mode 100644 ginac/lorentzidx.h delete mode 100644 ginac/lortensor.cpp delete mode 100644 ginac/lortensor.h delete mode 100644 ginac/simp_lor.cpp delete mode 100644 ginac/simp_lor.h diff --git a/check/exam_noncommut.cpp b/check/exam_noncommut.cpp deleted file mode 100644 index a6137aa0..00000000 --- a/check/exam_noncommut.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/** @file exam_noncommut.cpp - * - * Here we test manipulations on GiNaC's lortensors. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "exams.h" - -static unsigned lortensor_check1(void) -{ - // checks simple identities of the metric tensor! - - unsigned result = 0; - lorentzidx mu("mu"), nu("nu"); - ex e1, e2, e3, e4, e5, e6; - e1 = lortensor_g(mu,nu); - e2 = lortensor_g(nu,mu); - e3 = e1 - e2; // g(~mu,~nu) - g(~nu,~mu) = 0 ! - e4 = lortensor_g(mu,mu.toggle_covariant()); - e5 = lortensor_g(mu.toggle_covariant(),mu); - e6 = e4 - e5; // g(~mu,_mu) - g(_mu,~mu) = 0! - if (!e3.is_zero()) { - clog << e1 << "-" << e2 << " erroneously returned " - << e3 << " instead of 0" << endl; - ++result; - } - if (!e6.is_zero()) { - clog << e4 << "-" << e5 << " erroneously returned " - << e6 << " instead of 0" << endl; - ++result; - } - - return result; -} - -#if 0 // this will change -static unsigned lortensor_check2(void) -{ - // checks simple contraction properties of an arbitrary (symmetric!) rankn lortensor! - - unsigned result = 0; - lorentzidx mu("mu"), nu("nu"), rho("rho"); - ex e1, e2, e3, e4, e5, e6, e7, e8, e9, e10; - e1 = lortensor_g(mu,nu); - e2 = lortensor_g(nu,mu); - e3 = lortensor_rank1("p",mu.toggle_covariant()); - e4 = lortensor_rank1("p",nu); - e5 = e3 * e1 - e3 * e2; // p_mu g(~mu,~nu) - p_mu g(~nu,~mu) = 0! - e6 = simplify_lortensor(e3 * e1) - e4; // p~nu - p~nu = 0! - e7 = lortensor_g(nu,rho); - e8 = lortensor_rank2("F",mu.toggle_covariant(),nu.toggle_covariant()); - e9 = lortensor_rank2("F",mu.toggle_covariant(),rho); - e10 = simplify_lortensor(e8 * e7) - e9; // F(_mu,_nu) g(~nu,~rho) - F(_mu,~rho) = 0! - if (!e5.is_zero()) { - clog << e3 << "*" << e1 << "-" << e3 << "*" << e2 << " erroneously returned " - << e5 << " instead of 0" << endl; - ++result; - } - if (!e6.is_zero()) { - clog << " simplify_lortensor(e3 * e1)" << "-" << e4 << " erroneously returned" - << e6 << " instead of 0" << endl; - ++result; - } - if (!e10.is_zero()) { - clog << " simplify_lortensor(e8 * e7)" << "-" << e9 << " erroneously returned" - << e10 << " instead of 0" << endl; - ++result; - } - - return result; -} -#endif - -unsigned exam_noncommut(void) -{ - unsigned result = 0; - - cout << "examining behaviour of noncommutative objects" << flush; - clog << "----------behaviour of noncommutative objects:" << endl; - - result += lortensor_check1(); cout << '.' << flush; -#if 0 - result += lortensor_check2(); cout << '.' << flush; -#endif - if (!result) { - cout << " passed " << endl; - clog << "(no output)" << endl; - } else { - cout << " failed " << endl; - } - - return result; -} diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp deleted file mode 100644 index a3f26c96..00000000 --- a/ginac/clifford.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/** @file clifford.cpp - * - * Implementation of GiNaC's clifford objects. - * No real implementation yet, to be done. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#include "clifford.h" -#include "ex.h" -#include "ncmul.h" -#include "archive.h" -#include "utils.h" -#include "debugmsg.h" - -namespace GiNaC { - -GINAC_IMPLEMENT_REGISTERED_CLASS(clifford, lortensor) - -////////// -// default constructor, destructor, copy constructor assignment operator and helpers -////////// - -// public - -clifford::clifford() -{ - debugmsg("clifford default constructor",LOGLEVEL_CONSTRUCT); - tinfo_key = TINFO_clifford; -} - -// protected - -void clifford::copy(const clifford & other) -{ - inherited::copy(other); -} - -void clifford::destroy(bool call_parent) -{ - if (call_parent) inherited::destroy(call_parent); -} - -////////// -// other constructors -////////// - -// public - -clifford::clifford(const std::string & n, const ex & mu) : inherited(lortensor_symbolic, n, mu) -{ - debugmsg("clifford constructor from string,ex",LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_clifford; -} - -clifford::clifford(const std::string & n, const exvector & iv) : inherited(lortensor_symbolic, n, iv) -{ - debugmsg("clifford constructor from string,exvector", LOGLEVEL_CONSTRUCT); - GINAC_ASSERT(all_of_type_lorentzidx()); - tinfo_key=TINFO_clifford; -} - -clifford::clifford(const std::string & n, exvector *ivp) : inherited(lortensor_symbolic, n, *ivp) -{ - debugmsg("clifford constructor from string,exvector", LOGLEVEL_CONSTRUCT); - GINAC_ASSERT(all_of_type_lorentzidx()); - tinfo_key=TINFO_clifford; -} - -////////// -// archiving -////////// - -/** 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); -} - -/** Unarchive the object. */ -ex clifford::unarchive(const archive_node &n, const lst &sym_lst) -{ - return (new clifford(n, sym_lst))->setflag(status_flags::dynallocated); -} - -/** Archive the object. */ -void clifford::archive(archive_node &n) const -{ - inherited::archive(n); -} - -////////// -// functions overriding virtual functions from bases classes -////////// - -// public - -void clifford::printraw(std::ostream & os) const -{ - debugmsg("clifford printraw",LOGLEVEL_PRINT); - 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,' ') << " (clifford): " - << seq.size() << "indices="; - printtreeindices(os, indent); - os << ", hash=" << hashvalue - << " (0x" << std::hex << hashvalue << std::dec << ")" - << ", flags=" << flags << std::endl; -} - -void clifford::print(std::ostream & os, unsigned upper_precedence) const -{ - debugmsg("clifford print",LOGLEVEL_PRINT); - os << name; - printindices(os); -} - -bool clifford::info(unsigned inf) const -{ - return inherited::info(inf); -} - -// protected - -int clifford::compare_same_type(const basic & other) const -{ - GINAC_ASSERT(is_of_type(other,clifford)); - // only compare indices - return exprseq::compare_same_type(other); -} - -bool clifford::is_equal_same_type(const basic & other) const -{ - GINAC_ASSERT(is_of_type(other,clifford)); - // only compare indices - return exprseq::is_equal_same_type(other); -} - -ex clifford::thisexprseq(const exvector & v) const -{ - return clifford(name, v); -} - -ex clifford::thisexprseq(exvector *vp) const -{ - return clifford(name, vp); -} - -ex clifford::simplify_ncmul(const exvector & v) const -{ - return simplified_ncmul(v); -} - -////////// -// friend functions -////////// - -/** 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); -} - -} // namespace GiNaC diff --git a/ginac/clifford.h b/ginac/clifford.h deleted file mode 100644 index 86978e98..00000000 --- a/ginac/clifford.h +++ /dev/null @@ -1,82 +0,0 @@ -/** @file clifford.h - * - * Interface to GiNaC's clifford objects. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __GINAC_CLIFFORD_H__ -#define __GINAC_CLIFFORD_H__ - -#include -#include "lortensor.h" - -namespace GiNaC { - - -/** This class holds an object representing an element of the Clifford - * algebra (the Dirac gamma matrices). These objects only carry Lorentz - * indices. Spinor indices are always hidden in our implementation. */ -class clifford : public lortensor -{ - GINAC_DECLARE_REGISTERED_CLASS(clifford, lortensor) - -// friends - - friend clifford clifford_gamma(const ex & mu); - - // other constructors -public: - clifford(const std::string & n, const ex & mu); - clifford(const std::string & n, const exvector & iv); - clifford(const std::string & n, exvector * ivp); - - // functions overriding virtual functions from base classes -public: - void printraw(std::ostream & os) const; - void printtree(std::ostream & os, unsigned indent) const; - void print(std::ostream & os, unsigned upper_precedence=0) const; - bool info(unsigned inf) const; - // ex eval(int level=0) const; -protected: - bool is_equal_same_type(const basic & other) const; - ex simplify_ncmul(const exvector & v) const; - ex thisexprseq(const exvector & v) const; - ex thisexprseq(exvector * vp) const; - - // new virtual functions which can be overridden by derived classes - // none - - // non-virtual functions in this class - // none - - // member variables - // none -}; - -// global functions -inline const clifford &ex_to_clifford(const ex &e) -{ - return static_cast(*e.bp); -} - -clifford clifford_gamma(const ex & mu); - -} // namespace GiNaC - -#endif // ndef __GINAC_CLIFFORD_H__ diff --git a/ginac/color.cpp b/ginac/color.cpp deleted file mode 100644 index 9e355cb0..00000000 --- a/ginac/color.cpp +++ /dev/null @@ -1,1034 +0,0 @@ -/** @file color.cpp - * - * Implementation of GiNaC's color objects. - * No real implementation yet, to be done. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "color.h" -#include "ex.h" -#include "coloridx.h" -#include "ncmul.h" -#include "numeric.h" -#include "relational.h" -#include "archive.h" -#include "debugmsg.h" -#include "utils.h" - -namespace GiNaC { - -GINAC_IMPLEMENT_REGISTERED_CLASS(color, indexed) - -////////// -// default constructor, destructor, copy constructor assignment operator and helpers -////////// - -// public - -color::color() : inherited(TINFO_color), type(invalid), representation_label(0) -{ - debugmsg("color default constructor",LOGLEVEL_CONSTRUCT); -} - -// protected - -void color::copy(const color & other) -{ - inherited::copy(other); - type=other.type; - representation_label=other.representation_label; -} - -void color::destroy(bool call_parent) -{ - if (call_parent) { - inherited::destroy(call_parent); - } -} - -////////// -// other constructors -////////// - -// protected - -/** Construct object without any color index. This constructor is for internal - * use only. Use the color_ONE() function instead. - * @see color_ONE */ -color::color(color_types const t, unsigned rl) : type(t), representation_label(rl) -{ - debugmsg("color constructor from color_types,unsigned",LOGLEVEL_CONSTRUCT); - GINAC_ASSERT(representation_labelsetflag(status_flags::dynallocated); -} - -/** Archive the object. */ -void color::archive(archive_node &n) const -{ - inherited::archive(n); - n.add_unsigned("type", type); - n.add_unsigned("representation", representation_label); -} - -////////// -// functions overriding virtual functions from bases classes -////////// - -// public - -void color::printraw(std::ostream & os) const -{ - debugmsg("color printraw",LOGLEVEL_PRINT); - os << "color(type=" << (unsigned)type - << ",representation_label=" << representation_label - << ",indices="; - printrawindices(os); - os << ",hash=" << hashvalue << ",flags=" << flags << ")"; -} - -void color::printtree(std::ostream & os, unsigned indent) const -{ - debugmsg("color printtree",LOGLEVEL_PRINT); - os << std::string(indent,' ') << "color object: " - << "type=" << (unsigned)type - << ",representation_label=" << representation_label << ", "; - os << seq.size() << " indices" << std::endl; - printtreeindices(os,indent); - os << std::string(indent,' ') << "hash=" << hashvalue - << " (0x" << std::hex << hashvalue << std::dec << ")" - << ", flags=" << flags << std::endl; -} - -void color::print(std::ostream & os, unsigned upper_precedence) const -{ - debugmsg("color print",LOGLEVEL_PRINT); - switch (type) { - case color_T: - os << "T"; - if (representation_label!=0) { - os << "^(" << representation_label << ")"; - } - break; - case color_f: - os << "f"; - break; - case color_d: - os << "d"; - break; - case color_delta8: - os << "delta8"; - break; - case color_ONE: - os << "color_ONE"; - break; - case invalid: - default: - os << "INVALID_COLOR_OBJECT"; - break; - } - printindices(os); -} - -bool color::info(unsigned inf) const -{ - return inherited::info(inf); -} - -#define CMPINDICES(A,B,C) ((idx1.get_value()==(A))&&(idx2.get_value()==(B))&&(idx3.get_value()==(C))) - -ex color::eval(int level) const -{ - // canonicalize indices - - bool antisymmetric=false; - - switch (type) { - case color_f: - antisymmetric=true; // no break here! - case color_d: - case color_delta8: - { - exvector iv=seq; - int sig=canonicalize_indices(iv,antisymmetric); - if (sig!=INT_MAX) { - // something has changed while sorting indices, more evaluations later - if (sig==0) return _ex0(); - return ex(sig)*color(type,iv,representation_label); - } - } - break; - default: - // nothing to canonicalize - break; - } - - switch (type) { - case color_delta8: - { - GINAC_ASSERT(seq.size()==2); - const coloridx & idx1=ex_to_coloridx(seq[0]); - const coloridx & idx2=ex_to_coloridx(seq[1]); - - // check for delta8_{a,a} where a is a symbolic index, replace by 8 - if ((idx1.is_symbolic())&&(idx1.is_equal_same_type(idx2))) { - return ex(COLOR_EIGHT); - } - - // check for delta8_{a,b} where a and b are numeric indices, replace by 0 or 1 - if ((!idx1.is_symbolic())&&(!idx2.is_symbolic())) { - if ((idx1.get_value()!=idx2.get_value())) { - return _ex1(); - } else { - return _ex0(); - } - } - } - break; - case color_d: - // check for d_{a,a,c} (=0) when a is symbolic - { - GINAC_ASSERT(seq.size()==3); - const coloridx & idx1=ex_to_coloridx(seq[0]); - const coloridx & idx2=ex_to_coloridx(seq[1]); - const coloridx & idx3=ex_to_coloridx(seq[2]); - - if (idx1.is_equal_same_type(idx2) && idx1.is_symbolic()) { - return _ex0(); - } else if (idx2.is_equal_same_type(idx3) && idx2.is_symbolic()) { - return _ex0(); - } - - // check for three numeric indices - if (!(idx1.is_symbolic()||idx2.is_symbolic()||idx3.is_symbolic())) { - GINAC_ASSERT(idx1.get_value()<=idx2.get_value()); - GINAC_ASSERT(idx2.get_value()<=idx3.get_value()); - if (CMPINDICES(1,4,6)||CMPINDICES(1,5,7)||CMPINDICES(2,5,6)|| - CMPINDICES(3,4,4)||CMPINDICES(3,5,5)) { - return _ex1_2(); - } else if (CMPINDICES(2,4,7)||CMPINDICES(3,6,6)||CMPINDICES(3,7,7)) { - return -_ex1_2(); - } else if (CMPINDICES(1,1,8)||CMPINDICES(2,2,8)||CMPINDICES(3,3,8)) { - return 1/sqrt(numeric(3)); - } else if (CMPINDICES(8,8,8)) { - return -1/sqrt(numeric(3)); - } else if (CMPINDICES(4,4,8)||CMPINDICES(5,5,8)||CMPINDICES(6,6,8)||CMPINDICES(7,7,8)) { - return -1/(2*sqrt(numeric(3))); - } - return _ex0(); - } - } - break; - case color_f: - { - GINAC_ASSERT(seq.size()==3); - const coloridx & idx1=ex_to_coloridx(seq[0]); - const coloridx & idx2=ex_to_coloridx(seq[1]); - const coloridx & idx3=ex_to_coloridx(seq[2]); - - // check for three numeric indices - if (!(idx1.is_symbolic()||idx2.is_symbolic()||idx3.is_symbolic())) { - GINAC_ASSERT(idx1.get_value()<=idx2.get_value()); - GINAC_ASSERT(idx2.get_value()<=idx3.get_value()); - if (CMPINDICES(1,2,3)) { - return _ex1(); - } else if (CMPINDICES(1,4,7)||CMPINDICES(2,4,6)|| - CMPINDICES(2,5,7)||CMPINDICES(3,4,5)) { - return _ex1_2(); - } else if (CMPINDICES(1,5,6)||CMPINDICES(3,6,7)) { - return -_ex1_2(); - } else if (CMPINDICES(4,5,8)||CMPINDICES(6,7,8)) { - return sqrt(numeric(3))/2; - } else if (CMPINDICES(8,8,8)) { - return -1/sqrt(numeric(3)); - } else if (CMPINDICES(4,4,8)||CMPINDICES(5,5,8)||CMPINDICES(6,6,8)||CMPINDICES(7,7,8)) { - return -1/(2*sqrt(numeric(3))); - } - return _ex0(); - } - break; - } - default: - // nothing to evaluate - break; - } - - return this->hold(); -} - -// protected - -int color::compare_same_type(const basic & other) const -{ - GINAC_ASSERT(other.tinfo() == TINFO_color); - const color &o = static_cast(other); - - if (type != o.type) { - // different type - return type < o.type ? -1 : 1; - } - - if (representation_label != o.representation_label) { - // different representation label - return representation_label < o.representation_label ? -1 : 1; - } - - return inherited::compare_same_type(other); -} - -bool color::is_equal_same_type(const basic & other) const -{ - GINAC_ASSERT(other.tinfo() == TINFO_color); - const color &o = static_cast(other); - - if (type != o.type) return false; - if (representation_label != o.representation_label) return false; - return inherited::is_equal_same_type(other); -} - -#include - -ex color::simplify_ncmul(const exvector & v) const -{ - // simplifications: contract delta8_{a,b} where possible - // sort delta8,f,d,T(rl=0),T(rl=1),...,ONE(rl=0),ONE(rl=1),... - // remove superfluous ONEs - - // contract indices of delta8_{a,b} if they are different and symbolic - - exvector v_contracted=v; - unsigned replacements; - bool something_changed=false; - - exvector::iterator it=v_contracted.begin(); - while (it!=v_contracted.end()) { - // process only delta8 objects - if (is_ex_exactly_of_type(*it,color) && (ex_to_color(*it).type==color_delta8)) { - color & d8=ex_to_nonconst_color(*it); - GINAC_ASSERT(d8.seq.size()==2); - const coloridx & first_idx=ex_to_coloridx(d8.seq[0]); - const coloridx & second_idx=ex_to_coloridx(d8.seq[1]); - // delta8_{a,a} should have been contracted in color::eval() - GINAC_ASSERT((!first_idx.is_equal(second_idx))||(!first_idx.is_symbolic())); - ex saved_delta8=*it; // save to restore it later - - // try to contract first index - replacements=1; - if (first_idx.is_symbolic()) { - replacements = subs_index_in_exvector(v_contracted,first_idx,second_idx); - if (replacements==1) { - // not contracted except in itself, restore delta8 object - *it=saved_delta8; - } else { - // a contracted index should occur exactly twice - GINAC_ASSERT(replacements==2); - *it=_ex1(); - something_changed=true; - } - } - - // try second index only if first was not contracted - if ((replacements==1)&&(second_idx.is_symbolic())) { - // first index not contracted, *it is guaranteed to be the original delta8 object - replacements = subs_index_in_exvector(v_contracted,second_idx,first_idx); - if (replacements==1) { - // not contracted except in itself, restore delta8 object - *it=saved_delta8; - } else { - // a contracted index should occur exactly twice - GINAC_ASSERT(replacements==2); - *it=_ex1(); - something_changed=true; - } - } - } - ++it; - } - - if (something_changed) { - // do more simplifications later - return nonsimplified_ncmul(v_contracted); - } - - // there were no indices to contract - // sort delta8,f,d,T(rl=0),T(rl=1),...,ONE(rl=0),ONE(rl=1),...,unknown - // (if there is at least one unknown object, all Ts will be unknown to not change the order) - - exvector delta8vec; - exvector fvec; - exvector dvec; - exvectorvector Tvecs; - Tvecs.resize(MAX_REPRESENTATION_LABELS); - exvectorvector ONEvecs; - ONEvecs.resize(MAX_REPRESENTATION_LABELS); - exvector unknownvec; - - split_color_string_in_parts(v,delta8vec,fvec,dvec,Tvecs,ONEvecs,unknownvec); - - // d_{a,k,l} f_{b,k,l}=0 (includes case a=b) - if ((dvec.size()>=1)&&(fvec.size()>=1)) { - for (exvector::iterator it1=dvec.begin(); it1!=dvec.end(); ++it1) { - for (exvector::iterator it2=fvec.begin(); it2!=fvec.end(); ++it2) { - GINAC_ASSERT(is_ex_exactly_of_type(*it1,color)); - GINAC_ASSERT(is_ex_exactly_of_type(*it2,color)); - const color & col1=ex_to_color(*it1); - const color & col2=ex_to_color(*it2); - exvector iv_intersect=idx_intersect(col1.seq,col2.seq); - if (iv_intersect.size()>=2) return _ex0(); - } - } - } - - // d_{a,k,l} d_{b,k,l}=5/3 delta8_{a,b} (includes case a=b) - if (dvec.size()>=2) { - for (exvector::iterator it1=dvec.begin(); it1!=dvec.end()-1; ++it1) { - for (exvector::iterator it2=it1+1; it2!=dvec.end(); ++it2) { - GINAC_ASSERT(is_ex_exactly_of_type(*it1,color)); - GINAC_ASSERT(is_ex_exactly_of_type(*it2,color)); - const color & col1=ex_to_color(*it1); - const color & col2=ex_to_color(*it2); - exvector iv_intersect=idx_intersect(col1.seq,col2.seq); - if (iv_intersect.size()>=2) { - if (iv_intersect.size()==3) { - *it1=numeric(40)/numeric(3); - *it2=_ex1(); - } else { - int dummy; // sign unimportant, since symmetric - ex idx1=permute_free_index_to_front(col1.seq,iv_intersect,&dummy); - ex idx2=permute_free_index_to_front(col2.seq,iv_intersect,&dummy); - *it1=numeric(5)/numeric(3)*color(color_delta8,idx1,idx2); - *it2=_ex1(); - } - return nonsimplified_ncmul(recombine_color_string( - delta8vec,fvec,dvec,Tvecs,ONEvecs,unknownvec)); - } - } - } - } - - // f_{a,k,l} f_{b,k,l}=3 delta8_{a,b} (includes case a=b) - if (fvec.size()>=2) { - for (exvector::iterator it1=fvec.begin(); it1!=fvec.end()-1; ++it1) { - for (exvector::iterator it2=it1+1; it2!=fvec.end(); ++it2) { - GINAC_ASSERT(is_ex_exactly_of_type(*it1,color)); - GINAC_ASSERT(is_ex_exactly_of_type(*it2,color)); - const color & col1=ex_to_color(*it1); - const color & col2=ex_to_color(*it2); - exvector iv_intersect=idx_intersect(col1.seq,col2.seq); - if (iv_intersect.size()>=2) { - if (iv_intersect.size()==3) { - *it1=numeric(24); - *it2=_ex1(); - } else { - int sig1, sig2; - ex idx1=permute_free_index_to_front(col1.seq,iv_intersect,&sig1); - ex idx2=permute_free_index_to_front(col2.seq,iv_intersect,&sig2); - *it1=numeric(sig1*sig2*5)/numeric(3)*color(color_delta8,idx1,idx2); - *it2=_ex1(); - } - return nonsimplified_ncmul(recombine_color_string( - delta8vec,fvec,dvec,Tvecs,ONEvecs,unknownvec)); - } - } - } - } - - // d_{a,b,c} T_b T_c = 5/6 T_a - // f_{a,b,c} T_b T_c = 3/2 I T_a - for (unsigned rl=0; rl=2)&&((dvec.size()>=1)||(fvec.size()>=1))) { - for (exvector::iterator it1=Tvecs[rl].begin(); it1!=Tvecs[rl].end()-1; ++it1) { - exvector iv; - GINAC_ASSERT(is_ex_exactly_of_type(*it1,color)&&ex_to_color(*it1).type==color_T); - GINAC_ASSERT(is_ex_exactly_of_type(*(it1+1),color)&&ex_to_color(*(it1+1)).type==color_T); - iv.push_back(ex_to_color(*it1).seq[0]); - iv.push_back(ex_to_color(*(it1+1)).seq[0]); - - // d_{a,b,c} T_b T_c = 5/6 T_a - for (exvector::iterator it2=dvec.begin(); it2!=dvec.end(); ++it2) { - GINAC_ASSERT(is_ex_exactly_of_type(*it2,color)&&ex_to_color(*it2).type==color_d); - const color & dref=ex_to_color(*it2); - exvector iv_intersect=idx_intersect(dref.seq,iv); - if (iv_intersect.size()==2) { - int dummy; // sign unimportant, since symmetric - ex free_idx=permute_free_index_to_front(dref.seq,iv,&dummy); - *it1=color(color_T,free_idx,rl); - *(it1+1)=color(color_ONE,rl); - *it2=numeric(5)/numeric(6); - return nonsimplified_ncmul(recombine_color_string( - delta8vec,fvec,dvec,Tvecs,ONEvecs,unknownvec)); - } - } - - // f_{a,b,c} T_b T_c = 3/2 I T_a - for (exvector::iterator it2=fvec.begin(); it2!=fvec.end(); ++it2) { - GINAC_ASSERT(is_ex_exactly_of_type(*it2,color)&&ex_to_color(*it2).type==color_f); - const color & fref=ex_to_color(*it2); - exvector iv_intersect=idx_intersect(fref.seq,iv); - if (iv_intersect.size()==2) { - int sig; - ex free_idx=permute_free_index_to_front(fref.seq,iv,&sig); - *it1=color(color_T,free_idx,rl); - *(it1+1)=color(color_ONE,rl); - *it2=numeric(sig*3)/numeric(2)*I; - return nonsimplified_ncmul(recombine_color_string( - delta8vec,fvec,dvec,Tvecs,ONEvecs,unknownvec)); - } - } - } - } - } - - // clear all ONEs when there is at least one corresponding color_T - // in this representation, retain one ONE otherwise - for (unsigned rl=0; rl=2) { - for (unsigned i=0; i counter; - counter.resize(iv_double.size()); - int l; - for (l=0; unsigned(l)=0)&&((++counter[l])>(int)COLOR_EIGHT)) { - counter[l]=1; - l--; - } - if (l<2) { std::cout << counter[0] << counter[1] << std::endl; } - if (l<0) break; - } - - return sum; -} - -} // namespace GiNaC diff --git a/ginac/color.h b/ginac/color.h deleted file mode 100644 index 4d4169a7..00000000 --- a/ginac/color.h +++ /dev/null @@ -1,166 +0,0 @@ -/** @file color.h - * - * Interface to GiNaC's color objects. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __GINAC_COLOR_H__ -#define __GINAC_COLOR_H__ - -#include -#include -#include "indexed.h" -#include "ex.h" - -namespace GiNaC { - -const unsigned MAX_REPRESENTATION_LABELS = 4; -const unsigned COLOR_EIGHT = 8; // N*N-1 -const unsigned COLOR_THREE = 3; // N - -// Cint doesn't like vector<..,default_alloc> but malloc_alloc is -// unstandardized and not supported by newer GCCs. -#if defined(__GNUC__) && ((__GNUC__ == 2) && (__GNUC_MINOR__ < 97)) -typedef std::vector exvectorvector; -#else -typedef std::vector exvectorvector; -#endif - - -/** This class holds an object carrying color indices (of class coloridx). - * It can represent the generators T_a and structure constants f_abc/d_abc - * of SU(3), the unity element ONE of the Lie algebra of SU(3), or the - * unity matrix delta8. Together, these objects are used to implement the - * Lie algebra su(3), as required for calculations in quantum - * chromodynamics. A representation label (an unsigned integer) is used to - * distinguish elements from different Lie algebras (only objects with the - * same representation label "interact" with each other). */ -class color : public indexed -{ - GINAC_DECLARE_REGISTERED_CLASS(color, indexed) - -// friends - - friend color color_ONE(unsigned rl); - friend color color_T(const ex & a, unsigned rl); - friend color color_f(const ex & a, const ex & b, const ex & c); - friend color color_d(const ex & a, const ex & b, const ex & c); - friend ex color_h(const ex & a, const ex & b, const ex & c); - friend color color_delta8(const ex & a, const ex & b); - friend unsigned subs_index_in_exvector(exvector & v, const ex & is, const ex & ir); - friend void split_color_string_in_parts(const exvector & v, exvector & delta8vec, - exvector & fvec, exvector & dvec, - exvectorvector & Tvecs, - exvectorvector & ONEvecs, - exvector & unknownvec); - friend exvector recombine_color_string(exvector & delta8vec, exvector & fvec, - exvector & dvec, exvectorvector & Tvecs, - exvectorvector & ONEvecs, exvector & unknownvec); - friend ex color_trace_of_one_representation_label(const exvector & v); - friend ex color_trace(const exvector & v, unsigned rl); - friend ex simplify_pure_color_string(const ex & e); - friend ex simplify_color(const ex & e); - -// types - -public: - /** Type of object */ - typedef enum { - invalid, /**< not properly constructed */ - color_T, /**< one of the generators T_a of SU(3) (these are non-commutative) */ - color_f, /**< one of the antisymmetric structure constants f_abc of SU(3) */ - color_d, /**< one of the symmetric structure constants d_abc of SU(3) */ - color_delta8, /**< the unity matrix */ - color_ONE /**< the unity element of su(3) */ - } color_types; - -// member functions - - // other constructors -protected: - color(color_types const t, unsigned rl=0); - color(color_types const t, const ex & i1, unsigned rl=0); - color(color_types const t, const ex & i1, const ex & i2, unsigned rl=0); - color(color_types const t, const ex & i1, const ex & i2, const ex & i3, - unsigned rl=0); - color(color_types const t, const exvector & iv, unsigned rl=0); - color(color_types const t, exvector * ivp, unsigned rl=0); - - // functions overriding virtual functions from base classes -public: - void printraw(std::ostream & os) const; - void printtree(std::ostream & os, unsigned indent) const; - void print(std::ostream & os, unsigned upper_precedence=0) const; - bool info(unsigned inf) const; - ex eval(int level=0) const; -protected: - bool is_equal_same_type(const basic & other) const; - ex simplify_ncmul(const exvector & v) const; - ex thisexprseq(const exvector & v) const; - ex thisexprseq(exvector * vp) const; - - // new virtual functions which can be overridden by derived classes - // none - - // non-virtual functions in this class -protected: - bool all_of_type_coloridx(void) const; - -// member variables - -protected: - color_types type; /**< Type of object (generator, structure constant etc.) */ - unsigned representation_label; /**< Representation label to distiguish independent color matrices coming from separated fermion lines */ -}; - -// global functions -inline const color &ex_to_color(const ex &e) -{ - return static_cast(*e.bp); -} - -inline color &ex_to_nonconst_color(const ex &e) -{ - return static_cast(*e.bp); -} - -color color_ONE(unsigned rl=0); -color color_T(const ex & a, unsigned rl=0); -color color_f(const ex & a, const ex & b, const ex & c); -color color_d(const ex & a, const ex & b, const ex & c); -ex color_h(const ex & a, const ex & b, const ex & c); -color color_delta8(const ex & a, const ex & b); -void split_color_string_in_parts(const exvector & v, exvector & delta8vec, - exvector & fvec, exvector & dvec, - exvectorvector & Tvecs, - exvectorvector & ONEvecs, - exvector & unknownvec); -exvector recombine_color_string(exvector & delta8vec, exvector & fvec, - exvector & dvec, exvectorvector & Tvecs, - exvectorvector & ONEvecs, exvector & unknownvec); -ex color_trace_of_one_representation_label(const exvector & v); -ex color_trace(const exvector & v, unsigned rl=0); -ex simplify_pure_color_string(const ex & e); -ex simplify_color(const ex & e); - -ex brute_force_sum_color_indices(const ex & e); - -} // namespace GiNaC - -#endif // ndef __GINAC_COLOR_H__ diff --git a/ginac/coloridx.cpp b/ginac/coloridx.cpp deleted file mode 100644 index cb8b629e..00000000 --- a/ginac/coloridx.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/** @file coloridx.cpp - * - * Implementation of GiNaC's color indices. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#include "coloridx.h" -#include "archive.h" -#include "utils.h" -#include "debugmsg.h" - -namespace GiNaC { - -GINAC_IMPLEMENT_REGISTERED_CLASS(coloridx, idx) - -////////// -// default constructor, destructor, copy constructor assignment operator and helpers -////////// - -// public - -coloridx::coloridx() -{ - debugmsg("coloridx default constructor",LOGLEVEL_CONSTRUCT); - // serial is incremented in idx::idx() - name="color"+ToString(serial); - tinfo_key=TINFO_coloridx; -} - -// protected - -void coloridx::copy(const coloridx & other) -{ - inherited::copy(other); -} - -void coloridx::destroy(bool call_parent) -{ - if (call_parent) inherited::destroy(call_parent); -} - -////////// -// other constructors -////////// - -// public - -/** Construct symbolic color index, using an automatically generated unique name. - * - * @param cov Index is covariant (contravariant otherwise) - * @return newly constructed index */ -coloridx::coloridx(bool cov) : idx(cov) -{ - debugmsg("coloridx constructor from bool",LOGLEVEL_CONSTRUCT); - // serial is incremented in idx::idx(bool) - name="color"+ToString(serial); - tinfo_key=TINFO_coloridx; -} - -/** Construct symbolic color index with specified name. - * - * @param n Symbolic index name - * @param cov Index is covariant (contravariant otherwise) - * @return newly constructed index */ -coloridx::coloridx(const std::string & n, bool cov) : idx(n,cov) -{ - debugmsg("coloridx constructor from string,bool",LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_coloridx; -} - -/** Construct symbolic color index with specified name. - * - * @param n Symbolic index name - * @param cov Index is covariant (contravariant otherwise) - * @return newly constructed index */ -coloridx::coloridx(const char * n, bool cov) : idx(n,cov) -{ - debugmsg("coloridx constructor from char*,bool",LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_coloridx; -} - -/** Construct numeric color index with specified value. - * - * @param v Numeric index value - * @param cov Index is covariant (contravariant otherwise) - * @return newly constructed index */ -coloridx::coloridx(unsigned v, bool cov) : idx(v,cov) -{ - debugmsg("coloridx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_coloridx; -} - -////////// -// archiving -////////// - -/** Construct object from archive_node. */ -coloridx::coloridx(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) -{ - debugmsg("coloridx constructor from archive_node", LOGLEVEL_CONSTRUCT); -} - -/** Unarchive the object. */ -ex coloridx::unarchive(const archive_node &n, const lst &sym_lst) -{ - return (new coloridx(n, sym_lst))->setflag(status_flags::dynallocated); -} - -/** Archive the object. */ -void coloridx::archive(archive_node &n) const -{ - inherited::archive(n); -} - -////////// -// functions overriding virtual functions from bases classes -////////// - -// public - -void coloridx::printraw(std::ostream & os) const -{ - debugmsg("coloridx printraw",LOGLEVEL_PRINT); - - os << "coloridx("; - - if (symbolic) { - os << "symbolic,name=" << name; - } else { - os << "non symbolic,value=" << value; - } - - if (covariant) { - os << ",covariant"; - } else { - os << ",contravariant"; - } - - os << ",serial=" << serial; - os << ",hash=" << hashvalue << ",flags=" << flags; - os << ")"; -} - -void coloridx::printtree(std::ostream & os, unsigned indent) const -{ - debugmsg("coloridx printtree",LOGLEVEL_PRINT); - - os << std::string(indent,' ') << "coloridx: "; - - if (symbolic) { - os << "symbolic,name=" << name; - } else { - os << "non symbolic,value=" << value; - } - - if (covariant) { - os << ",covariant"; - } else { - os << ",contravariant"; - } - - os << ", serial=" << serial - << ", hash=" << hashvalue - << " (0x" << std::hex << hashvalue << std::dec << ")" - << ", flags=" << flags << std::endl; -} - -void coloridx::print(std::ostream & os, unsigned upper_precedence) const -{ - debugmsg("coloridx print",LOGLEVEL_PRINT); - - if (covariant) { - os << "_"; - } else { - os << "~"; - } - if (symbolic) { - os << name; - } else { - os << value; - } -} - -bool coloridx::info(unsigned inf) const -{ - if (inf==info_flags::coloridx) return true; - return idx::info(inf); -} - -int coloridx::compare_same_type(const basic & other) const -{ - return inherited::compare_same_type(other); -} - -} // namespace GiNaC diff --git a/ginac/coloridx.h b/ginac/coloridx.h deleted file mode 100644 index ab78abb3..00000000 --- a/ginac/coloridx.h +++ /dev/null @@ -1,78 +0,0 @@ -/** @file coloridx.h - * - * Interface to GiNaC's color indices. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __GINAC_COLORIDX_H__ -#define __GINAC_COLORIDX_H__ - -#include -#include -#include "idx.h" -#include "ex.h" - -namespace GiNaC { - - -/** Class of indices for color algebra objects, to tell them apart from - * other index families like Lorentz indices. The color indices are the - * indices of the SU(3) generators T_a, so they lie in the range of 0 to 7. - * Note that this kind of index is different from the indices carried by - * elements of a specific matrix representation of su(3). Such indices are - * always hidden in our implementation and we are not concerned with them. */ -class coloridx : public idx -{ - GINAC_DECLARE_REGISTERED_CLASS(coloridx, idx) - - friend class color; - - // other constructors -public: - explicit coloridx(bool cov); - explicit coloridx(const std::string & n, bool cov=false); - explicit coloridx(const char * n, bool cov=false); - explicit coloridx(unsigned v, bool cov=false); - - // functions overriding virtual functions from bases classes -public: - void printraw(std::ostream & os) const; - void printtree(std::ostream & os, unsigned indent) const; - void print(std::ostream & os, unsigned upper_precedence=0) const; - bool info(unsigned inf) const; - - // new virtual functions which can be overridden by derived classes - // none - - // non-virtual functions in this class - // none - - // member variables - // none -}; - -// utility functions -inline const coloridx &ex_to_coloridx(const ex &e) -{ - return static_cast(*e.bp); -} - -} // namespace GiNaC - -#endif // ndef __GINAC_COLORIDX_H__ diff --git a/ginac/isospin.cpp b/ginac/isospin.cpp deleted file mode 100644 index 2a2a254d..00000000 --- a/ginac/isospin.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/** @file isospin.cpp - * - * Implementation of GiNaC's isospin objects. - * No real implementation yet, to be done. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#include "isospin.h" -#include "ex.h" -#include "ncmul.h" -#include "lst.h" -#include "archive.h" -#include "utils.h" -#include "debugmsg.h" - -namespace GiNaC { - -GINAC_IMPLEMENT_REGISTERED_CLASS(isospin, indexed) - -////////// -// default constructor, destructor, copy constructor assignment operator and helpers -////////// - -// public - -isospin::isospin() -{ - debugmsg("isospin default constructor",LOGLEVEL_CONSTRUCT); - serial=next_serial++; - name=autoname_prefix()+ToString(serial); - tinfo_key=TINFO_isospin; -} - -// protected - -void isospin::copy(const isospin & other) -{ - inherited::copy(other); - name=other.name; - serial=other.serial; -} - -void isospin::destroy(bool call_parent) -{ - if (call_parent) { - inherited::destroy(call_parent); - } -} - -////////// -// other constructors -////////// - -// public - -isospin::isospin(const std::string & initname) -{ - debugmsg("isospin constructor from string",LOGLEVEL_CONSTRUCT); - name=initname; - serial=next_serial++; - tinfo_key=TINFO_isospin; -} - -////////// -// archiving -////////// - -/** Construct object from archive_node. */ -isospin::isospin(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) -{ - debugmsg("isospin constructor from archive_node", LOGLEVEL_CONSTRUCT); - serial = next_serial++; - if (!(n.find_string("name", name))) - name = autoname_prefix() + ToString(serial); - tinfo_key = TINFO_isospin; -} - -/** Unarchive the object. */ -ex isospin::unarchive(const archive_node &n, const lst &sym_lst) -{ - ex s = (new isospin(n, sym_lst))->setflag(status_flags::dynallocated); - - // If isospin is in sym_lst, return the existing isospin - for (unsigned i=0; i(&other); - if (serial==o->serial) { - return inherited::compare_same_type(other); - } - return serial < o->serial ? -1 : 1; -} - -ex isospin::simplify_ncmul(const exvector & v) const -{ - return simplified_ncmul(v); -} - -unsigned isospin::calchash(void) const -{ - hashvalue = golden_ratio_hash(golden_ratio_hash(0x55555556U ^ - golden_ratio_hash(tinfo_key) ^ serial)); - setflag(status_flags::hash_calculated); - return hashvalue; -} - -////////// -// virtual functions which can be overridden by derived classes -////////// - -// none - -////////// -// non-virtual functions in this class -////////// - -void isospin::setname(const std::string & n) -{ - name = n; -} - -// private - -std::string & isospin::autoname_prefix(void) -{ - static std::string * s = new std::string("isospin"); - return *s; -} - -////////// -// static member variables -////////// - -// private - -unsigned isospin::next_serial = 0; - -} // namespace GiNaC - diff --git a/ginac/isospin.h b/ginac/isospin.h deleted file mode 100644 index 925ef63b..00000000 --- a/ginac/isospin.h +++ /dev/null @@ -1,77 +0,0 @@ -/** @file isospin.h - * - * Interface to GiNaC's isospin objects. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __GINAC_ISOSPIN_H__ -#define __GINAC_ISOSPIN_H__ - -#include -#include "indexed.h" - -namespace GiNaC { - -/** Base class for isospin object */ -class isospin : public indexed -{ - GINAC_DECLARE_REGISTERED_CLASS(isospin, indexed) - - // other constructors -public: - explicit isospin(const std::string & initname); - - // functions overriding virtual functions from base classes -public: - void printraw(std::ostream & os) const; - void printtree(std::ostream & os, unsigned indent) const; - void print(std::ostream & os, unsigned upper_precedence=0) const; - void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; - bool info(unsigned inf) const; -protected: - ex simplify_ncmul(const exvector & v) const; - unsigned calchash(void) const; - - // new virtual functions which can be overridden by derived classes - // none - - // non-virtual functions in this class -public: - void setname(const std::string & n); -private: - std::string & autoname_prefix(void); - -// member variables - -protected: - std::string name; - unsigned serial; // unique serial number for comparision -private: - static unsigned next_serial; -}; - -// utility functions -inline const isospin &ex_to_isospin(const ex &e) -{ - return static_cast(*e.bp); -} - -} // namespace GiNaC - -#endif // ndef __GINAC_ISOSPIN_H__ diff --git a/ginac/lorentzidx.cpp b/ginac/lorentzidx.cpp deleted file mode 100644 index 783316c4..00000000 --- a/ginac/lorentzidx.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/** @file lorentzidx.cpp - * - * Implementation of GiNaC's Lorentz indices. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#include "lorentzidx.h" -#include "lst.h" -#include "symbol.h" -#include "archive.h" -#include "utils.h" -#include "debugmsg.h" - -namespace GiNaC { - -GINAC_IMPLEMENT_REGISTERED_CLASS(lorentzidx, idx) - -////////// -// default constructor, destructor, copy constructor assignment operator and helpers -////////// - -// public - -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; -} - -// protected - -void lorentzidx::copy(const lorentzidx & 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) inherited::destroy(call_parent); -} - -////////// -// other constructors -////////// - -// public - -/** Construct symbolic Lorentz index, using an automatically generated unique name. - * - * @param cov Index is covariant (contravariant otherwise) - * @param oonly Index only lives in orthogonal space - * @param dimp Dimension of parallel space - * @return newly constructed index */ -lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) - : idx(cov), orthogonal_only(oonly), dim_parallel_space(dimp) -{ - debugmsg("lorentzidx constructor from bool,bool,unsigned",LOGLEVEL_CONSTRUCT); - // serial is incremented in idx::idx(bool) - if (oonly) { - name="muorth"+ToString(serial); - } else { - name="mu"+ToString(serial); - } - tinfo_key=TINFO_lorentzidx; -} - -/** Construct symbolic Lorentz index with specified name. - * - * @param n Symbolic index name - * @param cov Index is covariant (contravariant otherwise) - * @param oonly Index only lives in orthogonal space - * @param dimp Dimension of parallel space - * @return newly constructed index */ -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; -} - -/** Construct symbolic Lorentz index with specified name. - * - * @param n Symbolic index name - * @param cov Index is covariant (contravariant otherwise) - * @param oonly Index only lives in orthogonal space - * @param dimp Dimension of parallel space - * @return newly constructed index */ -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", - LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_lorentzidx; -} - -/** Construct numeric Lorentz index with specified value. - * - * @param v Numeric index value - * @param cov Index is covariant (contravariant otherwise) - * @return newly constructed index */ -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); - 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(other); - - if (orthogonal_only != o.orthogonal_only) - return orthogonal_only ? -1 : 1; - if (dim_parallel_space != o.dim_parallel_space) - return dim_parallel_space < o.dim_parallel_space ? -1 : 1; - return inherited::compare_same_type(other); -} - -////////// -// non-virtual functions in this class -////////// - -// public - -/** Create anonymous contravariant copy of a symbolic Lorentz index. */ -lorentzidx lorentzidx::create_anonymous_representative(void) const -{ - GINAC_ASSERT(is_symbolic()); - lorentzidx i_copy(*this); - i_copy.serial=0; - i_copy.name="anonymous_representative"; - i_copy.covariant=false; - i_copy.clearflag(status_flags::dynallocated | - status_flags::hash_calculated); - return i_copy; -} - -////////// -// global functions -////////// - -/** Return the global symbol that represents the dimension D of spacetime. */ -ex Dim(void) -{ - static symbol *d = new symbol("dim"); - return *d; -} - -} // namespace GiNaC diff --git a/ginac/lorentzidx.h b/ginac/lorentzidx.h deleted file mode 100644 index d4226e1b..00000000 --- a/ginac/lorentzidx.h +++ /dev/null @@ -1,94 +0,0 @@ -/** @file lorentzidx.h - * - * Interface to GiNaC's Lorentz indices. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __GINAC_LORENTZIDX_H__ -#define __GINAC_LORENTZIDX_H__ - -#include -#include -#include "idx.h" - -namespace GiNaC { - - -/** Class of indices for Lorentz tensors, to tell them apart from other - * index families like color indices. The indices of this class also - * support the case of P-O-decomposed D-dimensional spacetime, where the - * parallel space is a Minkowski space with integral dimension P and the - * orthogonal space is a Euclidean space with (possibly complex) dimension - * D-P. The dimension D of spacetime is represented by the global symbol - * that is returned by the Dim() function. */ -class lorentzidx : public idx -{ - GINAC_DECLARE_REGISTERED_CLASS(lorentzidx, idx) - - friend class simp_lor; - friend class scalar_products; - -// member functions - - // other constructors -public: - explicit lorentzidx(bool cov, bool oonly=false, unsigned dimp=0); - explicit lorentzidx(const std::string & n, bool cov=false, - bool oonly=false, unsigned dimp=0); - explicit lorentzidx(const char * n, bool cov=false, - bool oonly=false, unsigned dimp=0); - explicit lorentzidx(unsigned v, bool cov=false); - - // functions overriding virtual functions from bases classes -public: - void printraw(std::ostream & os) const; - void printtree(std::ostream & os, unsigned indent) const; - void print(std::ostream & os, unsigned upper_precedence=0) const; - bool info(unsigned inf) const; - - // new virtual functions which can be overridden by derived classes - // none - - // non-virtual functions in this class -public: - /** Check whether index only lives in orthogonal space. */ - bool is_orthogonal_only(void) const {return orthogonal_only;} - - /** Return dimension of parallel space. */ - unsigned get_dim_parallel_space(void) const {return dim_parallel_space;} - - lorentzidx create_anonymous_representative(void) const; - - // member variables -protected: - bool orthogonal_only; /**< Symbolic index only lives in orthogonal space? */ - unsigned dim_parallel_space; /**< Dimension of parallel space */ -}; - -// utility functions -inline const lorentzidx &ex_to_lorentzidx(const ex &e) -{ - return static_cast(*e.bp); -} - -ex Dim(void); - -} // namespace GiNaC - -#endif // ndef __GINAC_LORENTZIDX_H__ diff --git a/ginac/lortensor.cpp b/ginac/lortensor.cpp deleted file mode 100644 index 1dae91a6..00000000 --- a/ginac/lortensor.cpp +++ /dev/null @@ -1,575 +0,0 @@ -/** @file lortensor.cpp - * - * Implementation of GiNaC's Lorentz tensors. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include - -#include "basic.h" -#include "add.h" -#include "mul.h" -#include "debugmsg.h" -#include "lst.h" -#include "lortensor.h" -#include "operators.h" -#include "tinfos.h" -#include "power.h" -#include "archive.h" -#include "utils.h" -#include "config.h" - -namespace GiNaC { - -GINAC_IMPLEMENT_REGISTERED_CLASS(lortensor, indexed) - -////////// -// default constructor, destructor, copy constructor assignment operator and helpers -////////// - -// public - -lortensor::lortensor() : inherited(TINFO_lortensor), type(invalid) -{ - debugmsg("lortensor default constructor",LOGLEVEL_CONSTRUCT); - serial=next_serial++; - name=autoname_prefix()+ToString(serial); -} - -//protected - -void lortensor::copy(const lortensor & other) -{ - inherited::copy(other); - type=other.type; - name=other.name; - serial=other.serial; -} - -void lortensor::destroy(bool call_parent) -{ - if (call_parent) inherited::destroy(call_parent); -} - -////////// -// other constructors -////////// - -// protected - -/** Construct object without any Lorentz index. This constructor is for - * internal use only. */ -lortensor::lortensor(lortensor_types const lt, const std::string & n) : type(lt), name(n) -{ - debugmsg("lortensor constructor from lortensor_types,string",LOGLEVEL_CONSTRUCT); - if (lt == lortensor_symbolic) - serial = next_serial++; - else - serial = 0; - tinfo_key = TINFO_lortensor; -} - -/** Construct object with one Lorentz index. This constructor is for - * internal use only. Use the lortensor_vector() or lortensor_symbolic() - * functions instead. - * @see lortensor_vector - * @see lortensor_symbolic */ -lortensor::lortensor(lortensor_types const lt, const std::string & n, const ex & mu) : inherited(mu), type(lt), name(n) -{ - debugmsg("lortensor constructor from lortensor_types,string,ex",LOGLEVEL_CONSTRUCT); - GINAC_ASSERT(all_of_type_lorentzidx()); - if (lt == lortensor_symbolic) - serial = next_serial++; - else - serial = 0; - tinfo_key=TINFO_lortensor; -} - -/** Construct object with two Lorentz indices. This constructor is for - * internal use only. Use the lortensor_g(), lortensor_delta() or - * lortensor_symbolic() functions instead. - * @see lortensor_g - * @see lortensor_delta - * @see lortensor_symbolic */ -lortensor::lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu) : inherited(mu,nu), type(lt), name(n) -{ - debugmsg("lortensor constructor from lortensor_types,string,ex,ex",LOGLEVEL_CONSTRUCT); - GINAC_ASSERT(all_of_type_lorentzidx()); - if (lt == lortensor_symbolic) - serial = next_serial++; - else - serial = 0; - tinfo_key=TINFO_lortensor; -} - -/** Construct object with three Lorentz indices. This constructor is for - * internal use only. Use the lortensor_symbolic() function instead. - * @see lortensor_symbolic */ -lortensor::lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho) : inherited(mu,nu,rho), type(lt), name(n) -{ - debugmsg("lortensor constructor from lortensor_types,string,ex,ex,ex",LOGLEVEL_CONSTRUCT); - GINAC_ASSERT(all_of_type_lorentzidx()); - if (lt == lortensor_symbolic) - serial = next_serial++; - else - serial = 0; - tinfo_key=TINFO_lortensor; -} - -/** Construct object with four Lorentz indices. This constructor is for - * internal use only. Use the lortensor_epsilon() or lortensor_symbolic() - * functions instead. - * @see lortensor_epsilon - * @see lortensor_symbolic */ -lortensor::lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho, const ex & sigma) : inherited(mu,nu,rho,sigma), type(lt), name(n) -{ - debugmsg("lortensor constructor from lortensor_types,string,ex,ex,ex,ex",LOGLEVEL_CONSTRUCT); - GINAC_ASSERT(all_of_type_lorentzidx()); - if (lt == lortensor_symbolic) - serial = next_serial++; - else - serial = 0; - tinfo_key=TINFO_lortensor; -} - -/** Construct object with arbitrary number of Lorentz indices. This - * constructor is for internal use only. Use the lortensor_symbolic() - * function instead. - * - * @see lortensor_symbolic */ -lortensor::lortensor(lortensor_types const lt, const std::string & n, const exvector & iv) : inherited(iv), type(lt), name(n) -{ - debugmsg("lortensor constructor from lortensor_types,string,exvector",LOGLEVEL_CONSTRUCT); - GINAC_ASSERT(all_of_type_lorentzidx()); - if (lt == lortensor_symbolic) - serial = next_serial++; - else - serial = 0; - tinfo_key=TINFO_lortensor; -} - -lortensor::lortensor(lortensor_types const lt, const std::string & n, unsigned s, const exvector & iv) : indexed(iv), type(lt), name(n), serial(s) -{ - debugmsg("lortensor constructor from lortensor_types,string,unsigned,exvector",LOGLEVEL_CONSTRUCT); - GINAC_ASSERT(all_of_type_lorentzidx()); - tinfo_key=TINFO_lortensor; -} - -lortensor::lortensor(lortensor_types const lt, const std::string & n, unsigned s, exvector *ivp) : indexed(ivp), type(lt), name(n), serial(s) -{ - debugmsg("lortensor constructor from lortensor_types,string,unsigned,exvector",LOGLEVEL_CONSTRUCT); - GINAC_ASSERT(all_of_type_lorentzidx()); - tinfo_key=TINFO_lortensor; -} - - -////////// -// archiving -////////// - -/** Construct object from archive_node. */ -lortensor::lortensor(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) -{ - debugmsg("lortensor constructor from archive_node", LOGLEVEL_CONSTRUCT); - unsigned int ty; - if (!(n.find_unsigned("type", ty))) - throw (std::runtime_error("unknown lortensor type in archive")); - type = (lortensor_types)ty; - if (type == lortensor_symbolic) { - serial = next_serial++; - if (!(n.find_string("name", name))) - name = autoname_prefix() + ToString(serial); - } else - serial = 0; -} - -/** Unarchive the object. */ -ex lortensor::unarchive(const archive_node &n, const lst &sym_lst) -{ - ex s = (new lortensor(n, sym_lst))->setflag(status_flags::dynallocated); - - if (ex_to_lortensor(s).type == lortensor_symbolic) { - // If lortensor is in sym_lst, return the existing lortensor - for (unsigned i=0; i hold(); -} - -//protected - -int lortensor::compare_same_type(const basic & other) const -{ - GINAC_ASSERT(is_of_type(other,lortensor)); - const lortensor &o = static_cast(other); - - if (type!=o.type) { - // different type - return type < o.type ? -1 : 1; - } - - if (type == lortensor_symbolic) { - // symbolic, compare serials - if (serial != o.serial) { - return serial < o.serial ? -1 : 1; - } - } - - return inherited::compare_same_type(other); -} - -bool lortensor::is_equal_same_type(const basic & other) const -{ - GINAC_ASSERT(is_of_type(other,lortensor)); - const lortensor &o = static_cast(other); - - if (type != o.type) return false; - if (type == lortensor_symbolic && serial != o.serial) return false; - return inherited::is_equal_same_type(other); -} - -unsigned lortensor::return_type(void) const -{ - return return_types::commutative; -} - -unsigned lortensor::return_type_tinfo(void) const -{ - return tinfo_key; -} - -ex lortensor::thisexprseq(const exvector & v) const -{ - return lortensor(type,name,serial,v); -} - -ex lortensor::thisexprseq(exvector *vp) const -{ - return lortensor(type,name,serial,vp); -} - -////////// -// non-virtual functions in this class -////////// - -// protected - -/** Check whether all indices are of class lorentzidx or a subclass. This - * function is used internally to make sure that all constructed Lorentz - * tensors really carry Lorentz indices and not some other classes. */ -bool lortensor::all_of_type_lorentzidx(void) const -{ - for (exvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++ cit) { - if (!is_ex_of_type(*cit,lorentzidx)) return false; - } - return true; -} - -// private - -std::string & lortensor::autoname_prefix(void) -{ - static std::string * s = new std::string("lortensor"); - return *s; -} - -////////// -// static member variables -////////// - -// private - -unsigned lortensor::next_serial=0; - -////////// -// friend functions -////////// - -/** Construct an object representing the metric tensor g. The indices must - * be of class lorentzidx. - * - * @param mu First index - * @param nu Second index - * @return newly constructed object */ -lortensor lortensor_g(const ex & mu, const ex & nu) -{ - return lortensor(lortensor::lortensor_g,"",mu,nu); -} - -/** Construct an object representing the unity matrix delta. The indices - * must be of class lorentzidx. - * - * @param mu First index - * @param nu Second index - * @return newly constructed object */ -lortensor lortensor_delta(const ex & mu, const ex & nu) -{ - return lortensor(lortensor::lortensor_delta,"",mu,nu); -} - -/** Construct an object representing the four-dimensional totally - * antisymmetric tensor epsilon. The indices must be of class lorentzidx. - * - * @param mu First index - * @param nu Second index - * @param rho Third index - * @param sigma Fourth index - * @return newly constructed object */ -lortensor lortensor_epsilon(const ex & mu, const ex & nu, const ex & rho, const ex & sigma) -{ - return lortensor(lortensor::lortensor_epsilon,"",mu,nu,rho,sigma); -} - -/** Construct an object representing a symbolic Lorentz vector. The index - * must be of class lorentzidx. - * - * @param n Symbolic name - * @param mu Index - * @return newly constructed object */ -lortensor lortensor_vector(const std::string & n, const ex & mu) -{ - return lortensor(lortensor::lortensor_symbolic,n,mu); -} - -/** Construct an object representing a symbolic Lorentz tensor of arbitrary - * rank. The indices must be of class lorentzidx. - * - * @param n Symbolic name - * @param iv Vector of indices - * @return newly constructed object */ -lortensor lortensor_symbolic(const std::string & n, const exvector & iv) -{ - return lortensor(lortensor::lortensor_symbolic,n,iv); -} - -ex simplify_lortensor_mul(const ex & m) -{ - GINAC_ASSERT(is_ex_exactly_of_type(m,mul)); - exvector v_contracted; - - // collect factors in an exvector, store squares twice - int n=m.nops(); - v_contracted.reserve(2*n); - for (int i=0; i -#include -#include -#include "indexed.h" -#include "lorentzidx.h" - -namespace GiNaC { - - -/** This class holds an object carrying Lorentz indices (of class - * lorentzidx). It can represent a general (symbolic) tensor of type - * (p,q), or one of the constant tensors g (the metric), delta (unity - * matrix) or epsilon (4-dimensional totally antisymmetric tensor). */ -class lortensor : public indexed -{ - GINAC_DECLARE_REGISTERED_CLASS(lortensor, indexed) - -// friends - - friend lortensor lortensor_g(const ex & mu, const ex & nu); - friend lortensor lortensor_delta(const ex & mu, const ex & nu); - friend lortensor lortensor_epsilon(const ex & mu, const ex & nu, - const ex & rho, const ex & sigma); - friend lortensor lortensor_vector(const std::string & n, const ex & mu); - friend lortensor lortensor_symbolic(const std::string & name, const exvector & iv); - - friend ex simplify_lortensor_mul(const ex & m); - friend ex simplify_lortensor(const ex & e); - -// types - -public: - typedef enum { - invalid, /**< not properly constructed */ - lortensor_g, /**< metric tensor */ - lortensor_delta, /**< unity matrix */ - lortensor_epsilon, /**< four-dimensional totally antisymmetric tensor */ - lortensor_symbolic /**< general symbolic Lorentz tensor */ - } lortensor_types; - -// member functions - - // other constructors -protected: - lortensor(lortensor_types const lt, const std::string & n); - lortensor(lortensor_types const lt, const std::string & n, const ex & mu); - lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu); - lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho); - lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho, const ex & sigma); - lortensor(lortensor_types const lt, const std::string & n, const exvector & iv); - lortensor(lortensor_types const lt, const std::string & n, unsigned s, const exvector & iv); - lortensor(lortensor_types const lt, const std::string & n, unsigned s, exvector * ivp); - - //functions overriding virtual functions from base classes -public: - void printraw(std::ostream & os) const; - void printtree(std::ostream & os, unsigned indent) const; - void print(std::ostream & os, unsigned upper_precedence=0) const; - bool info(unsigned inf) const; - ex eval(int level=0) const; -protected: - bool is_equal_same_type(const basic & other) const; - unsigned return_type(void) const; - unsigned return_type_tinfo(void) const; - ex thisexprseq(const exvector & v) const; - ex thisexprseq(exvector * vp) const; - - // new virtual functions which can be overridden by derived classes - // none - - //non virtual functions in this class -public: - void setname(const std::string & n) {name = n;} - std::string getname(void) const {return name;} -protected: - bool all_of_type_lorentzidx(void) const; -private: - std::string & autoname_prefix(void); - - //member variables - -protected: - lortensor_types type; /**< Type of object */ - std::string name; /**< Name of symbolic tensor */ - unsigned serial; /**< Unique serial number for comparing symbolic tensors */ -private: - static unsigned next_serial; -}; - -// utility functions - -inline const lortensor & ex_to_lortensor(const ex &e) -{ - return static_cast(*e.bp); -} - -inline lortensor &ex_to_nonconst_lortensor(const ex &e) -{ - return static_cast(*e.bp); -} - -lortensor lortensor_g(const ex & mu, const ex & nu); -lortensor lortensor_delta(const ex & mu, const ex & nu); -lortensor lortensor_epsilon(const ex & mu, const ex & nu, - const ex & rho, const ex & sigma); -lortensor lortensor_vector(const std::string & n, const ex & mu); -lortensor lortensor_symbolic(const std::string & name, const exvector & iv); - -ex simplify_lortensor_mul(const ex & m); -ex simplify_lortensor(const ex & e); - -} // namespace GiNaC - -#endif // ndef __GINAC_LORTENSOR_H__ diff --git a/ginac/simp_lor.cpp b/ginac/simp_lor.cpp deleted file mode 100644 index 0734439e..00000000 --- a/ginac/simp_lor.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/** @file simp_lor.cpp - * - * Implementation of GiNaC's simp_lor objects. - * No real implementation yet, to be done. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include - -#include "simp_lor.h" -#include "ex.h" -#include "mul.h" -#include "archive.h" -#include "debugmsg.h" -#include "utils.h" - -namespace GiNaC { - -GINAC_IMPLEMENT_REGISTERED_CLASS(simp_lor, indexed) - -////////// -// default constructor, destructor, copy constructor assignment operator and helpers -////////// - -// public - -simp_lor::simp_lor() : type(invalid) -{ - debugmsg("simp_lor default constructor",LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_simp_lor; -} - -// protected - -void simp_lor::copy(const simp_lor & other) -{ - indexed::copy(other); - type=other.type; - name=other.name; -} - -void simp_lor::destroy(bool call_parent) -{ - if (call_parent) { - indexed::destroy(call_parent); - } -} - -////////// -// other constructors -////////// - -// protected - -simp_lor::simp_lor(simp_lor_types const t) : type(t) -{ - debugmsg("simp_lor constructor from simp_lor_types",LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_simp_lor; -} - -simp_lor::simp_lor(simp_lor_types const t, const ex & i1, const ex & i2) - : indexed(i1,i2), type(t) -{ - debugmsg("simp_lor constructor from simp_lor_types,ex,ex",LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_simp_lor; - GINAC_ASSERT(all_of_type_lorentzidx()); -} - -simp_lor::simp_lor(simp_lor_types const t, const std::string & n, const ex & i1) - : indexed(i1), type(t), name(n) -{ - debugmsg("simp_lor constructor from simp_lor_types,string,ex",LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_simp_lor; - GINAC_ASSERT(all_of_type_lorentzidx()); -} - -simp_lor::simp_lor(simp_lor_types const t, const std::string & n, const exvector & iv) - : indexed(iv), type(t), name(n) -{ - debugmsg("simp_lor constructor from simp_lor_types,string,exvector",LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_simp_lor; - GINAC_ASSERT(all_of_type_lorentzidx()); -} - -simp_lor::simp_lor(simp_lor_types const t, const std::string & n, exvector * ivp) - : indexed(ivp), type(t), name(n) -{ - debugmsg("simp_lor constructor from simp_lor_types,string,exvector*",LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_simp_lor; - GINAC_ASSERT(all_of_type_lorentzidx()); -} - -////////// -// archiving -////////// - -/** Construct object from archive_node. */ -simp_lor::simp_lor(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) -{ - debugmsg("simp_lor constructor from archive_node", LOGLEVEL_CONSTRUCT); - unsigned int ty; - if (!(n.find_unsigned("type", ty))) - throw (std::runtime_error("unknown simp_lor type in archive")); - type = (simp_lor_types)ty; - n.find_string("name", name); -} - -/** Unarchive the object. */ -ex simp_lor::unarchive(const archive_node &n, const lst &sym_lst) -{ - return (new simp_lor(n, sym_lst))->setflag(status_flags::dynallocated); -} - -/** Archive the object. */ -void simp_lor::archive(archive_node &n) const -{ - inherited::archive(n); - n.add_unsigned("type", type); - n.add_string("name", name); -} - - -////////// -// functions overriding virtual functions from bases classes -////////// - -// public - -void simp_lor::printraw(std::ostream & os) const -{ - debugmsg("simp_lor printraw",LOGLEVEL_PRINT); - os << "simp_lor(type=" << (unsigned)type - << ",name=" << name << ",indices="; - printrawindices(os); - os << ",hash=" << hashvalue << ",flags=" << flags << ")"; -} - -void simp_lor::printtree(std::ostream & os, unsigned indent) const -{ - debugmsg("simp_lor printtree",LOGLEVEL_PRINT); - os << std::string(indent,' ') << "simp_lor object: " - << "type=" << (unsigned)type - << ", name=" << name << ", "; - os << seq.size() << " indices" << std::endl; - printtreeindices(os,indent); - os << std::string(indent,' ') << "hash=" << hashvalue - << " (0x" << std::hex << hashvalue << std::dec << ")" - << ", flags=" << flags << std::endl; -} - -void simp_lor::print(std::ostream & os, unsigned upper_precedence) const -{ - debugmsg("simp_lor print",LOGLEVEL_PRINT); - switch (type) { - case simp_lor_g: - os << "g"; - break; - case simp_lor_vec: - os << name; - break; - case invalid: - default: - os << "INVALID_SIMP_LOR_OBJECT"; - break; - } - printindices(os); -} - -void simp_lor::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const -{ - debugmsg("simp_lor print csrc",LOGLEVEL_PRINT); - print(os,upper_precedence); -} - -bool simp_lor::info(unsigned inf) const -{ - return indexed::info(inf); -} - -ex simp_lor::eval(int level) const -{ - if (type==simp_lor_g) { - // canonicalize indices - exvector iv=seq; - int sig=canonicalize_indices(iv,false); // symmetric - if (sig!=INT_MAX) { - // something has changed while sorting indices, more evaluations later - if (sig==0) return _ex0(); - return ex(sig)*simp_lor(type,name,iv); - } - const lorentzidx & idx1=ex_to_lorentzidx(seq[0]); - const lorentzidx & idx2=ex_to_lorentzidx(seq[1]); - if ((!idx1.is_symbolic())&&(!idx2.is_symbolic())) { - // both indices are numeric - if ((idx1.get_value()==idx2.get_value())) { - // both on diagonal - if (idx1.get_value()==0) { - // (0,0) - return _ex1(); - } else { - if (idx1.is_covariant()!=idx2.is_covariant()) { - // (_i,~i) or (~i,_i), i=1..3 - return _ex1(); - } else { - // (_i,_i) or (~i,~i), i=1..3 - return _ex_1(); - } - } - } else { - // at least one off-diagonal - return _ex0(); - } - } else if (idx1.is_symbolic() && idx1.is_co_contra_pair(idx2)) { - if (idx1.is_orthogonal_only()) - return Dim() - idx1.get_dim_parallel_space(); - else - return Dim(); - } - } - - return this->hold(); -} - -// protected - -int simp_lor::compare_same_type(const basic & other) const -{ - GINAC_ASSERT(other.tinfo() == TINFO_simp_lor); - const simp_lor *o = static_cast(&other); - if (type==o->type) { - if (name==o->name) { - return indexed::compare_same_type(other); - } - return name.compare(o->name); - } - return type < o->type ? -1 : 1; -} - -bool simp_lor::is_equal_same_type(const basic & other) const -{ - GINAC_ASSERT(other.tinfo() == TINFO_simp_lor); - const simp_lor *o = static_cast(&other); - if (type!=o->type) return false; - if (name!=o->name) return false; - return indexed::is_equal_same_type(other); -} - -unsigned simp_lor::return_type(void) const -{ - return return_types::commutative; -} - -unsigned simp_lor::return_type_tinfo(void) const -{ - return tinfo_key; -} - -ex simp_lor::thisexprseq(const exvector & v) const -{ - return simp_lor(type,name,v); -} - -ex simp_lor::thisexprseq(exvector * vp) const -{ - return simp_lor(type,name,vp); -} - -////////// -// virtual functions which can be overridden by derived classes -////////// - -// none - -////////// -// non-virtual functions in this class -////////// - -// protected - -bool simp_lor::all_of_type_lorentzidx(void) const -{ - // used only inside of ASSERTs - for (exvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) { - if (!is_ex_of_type(*cit,lorentzidx)) return false; - } - return true; -} - -////////// -// static member variables -////////// - -// none - -////////// -// friend functions -////////// - -simp_lor lor_g(const ex & mu, const ex & nu) -{ - return simp_lor(simp_lor::simp_lor_g,mu,nu); -} - -simp_lor lor_vec(const std::string & n, const ex & mu) -{ - return simp_lor(simp_lor::simp_lor_vec,n,mu); -} - -ex simplify_simp_lor_mul(const ex & m, const scalar_products & sp) -{ - GINAC_ASSERT(is_ex_exactly_of_type(m,mul)); - exvector v_contracted; - - // collect factors in an exvector, store squares twice - unsigned n=m.nops(); - v_contracted.reserve(2*n); - for (unsigned i=0; i0) { - reg(v2,v1,sp); - return; - } - spm[make_key(v1,v2)]=sp; -} - -bool scalar_products::is_defined(const simp_lor & v1, const simp_lor & v2) const -{ - if (v1.compare_same_type(v2)>0) { - return is_defined(v2,v1); - } - return spm.find(make_key(v1,v2))!=spm.end(); -} - -ex scalar_products::evaluate(const simp_lor & v1, const simp_lor & v2) const -{ - if (v1.compare_same_type(v2)>0) - return evaluate(v2, v1); - - return (*spm.find(make_key(v1,v2))).second; -} - -void scalar_products::debugprint(void) const -{ - std::cerr << "map size=" << spm.size() << std::endl; - for (spmap::const_iterator cit=spm.begin(); cit!=spm.end(); ++cit) { - const spmapkey & k=(*cit).first; - std::cerr << "item key=((" << k.first.first - << "," << k.first.second << "),"; - k.second.printraw(std::cerr); - std::cerr << ") value=" << (*cit).second << std::endl; - } -} - -spmapkey scalar_products::make_key(const simp_lor & v1, const simp_lor & v2) -{ - GINAC_ASSERT(v1.type==simp_lor::simp_lor_vec); - GINAC_ASSERT(v2.type==simp_lor::simp_lor_vec); - lorentzidx anon=ex_to_lorentzidx(v1.seq[0]).create_anonymous_representative(); - GINAC_ASSERT(anon.is_equal_same_type(ex_to_lorentzidx(v2.seq[0]).create_anonymous_representative())); - return spmapkey(strstrpair(v1.name,v2.name),anon); -} - -} // namespace GiNaC diff --git a/ginac/simp_lor.h b/ginac/simp_lor.h deleted file mode 100644 index 1fcf84fc..00000000 --- a/ginac/simp_lor.h +++ /dev/null @@ -1,145 +0,0 @@ -/** @file simp_lor.h - * - * Interface to GiNaC's simp_lor objects. */ - -/* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _SIMP__GINAC_LOR_H__ -#define _SIMP__GINAC_LOR_H__ - -#include -#include -#include -#include -#include -#include "indexed.h" -#include "lorentzidx.h" - -namespace GiNaC { - -typedef std::pair strstrpair; -typedef std::pair spmapkey; - -class spmapkey_is_less -{ -public: - bool operator()(const spmapkey & lh, const spmapkey & rh) const - { - bool res = lh.first spmap; - -class simp_lor; - -/** helper class for scalar products */ -class scalar_products -{ -public: - void reg(const simp_lor & v1, const simp_lor & v2, const ex & sp); - bool is_defined(const simp_lor & v1, const simp_lor & v2) const; - ex evaluate(const simp_lor & v1, const simp_lor & v2) const; - void debugprint(void) const; -protected: - static spmapkey make_key(const simp_lor & v1, const simp_lor & v2); -protected: - spmap spm; -}; - -/** Base class for simp_lor object */ -class simp_lor : public indexed -{ - GINAC_DECLARE_REGISTERED_CLASS(simp_lor, indexed) - -// friends - - friend class scalar_products; - friend simp_lor lor_g(const ex & mu, const ex & nu); - friend simp_lor lor_vec(const std::string & n, const ex & mu); - friend ex simplify_simp_lor_mul(const ex & m, const scalar_products & sp); - friend ex simplify_simp_lor(const ex & e, const scalar_products & sp); - -// types - -public: - typedef enum { - invalid, // not properly constructed by one of the friend functions - simp_lor_g, - simp_lor_vec - } simp_lor_types; - - // other constructors -protected: - simp_lor(simp_lor_types const t); - simp_lor(simp_lor_types const t, const ex & i1, const ex & i2); - simp_lor(simp_lor_types const t, const std::string & n, const ex & i1); - simp_lor(simp_lor_types const t, const std::string & n, const exvector & iv); - simp_lor(simp_lor_types const t, const std::string & n, exvector * ivp); - - // functions overriding virtual functions from base classes -public: - void printraw(std::ostream & os) const; - void printtree(std::ostream & os, unsigned indent) const; - void print(std::ostream & os, unsigned upper_precedence=0) const; - void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; - bool info(unsigned inf) const; - ex eval(int level=0) const; -protected: - bool is_equal_same_type(const basic & other) const; - unsigned return_type(void) const; - unsigned return_type_tinfo(void) const; - ex thisexprseq(const exvector & v) const; - ex thisexprseq(exvector * vp) const; - - // new virtual functions which can be overridden by derived classes - // none - - // non-virtual functions in this class -protected: - bool all_of_type_lorentzidx(void) const; - -// member variables - -protected: - simp_lor_types type; - std::string name; -}; - -// utility functions -inline const simp_lor &ex_to_simp_lor(const ex &e) -{ - return static_cast(*e.bp); -} - -inline simp_lor &ex_to_nonconst_simp_lor(const ex &e) -{ - return static_cast(*e.bp); -} - -simp_lor lor_g(const ex & mu, const ex & nu); -simp_lor lor_vec(const std::string & n, const ex & mu); -ex simplify_simp_lor_mul(const ex & m, const scalar_products & sp); -ex simplify_simp_lor(const ex & e, const scalar_products & sp=scalar_products()); - -} // namespace GiNaC - -#endif // ndef _SIMP__GINAC_LOR_H__ -- 2.44.0