X-Git-Url: https://ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Flortensor.cpp;h=2b2215fdb14a41a1306fbfd9c003f18611140937;hb=55d35dcf72dc411c8265628fcad2bd67d320a8c9;hp=7cbd2f43ede41c115b7d4b71d1ce163d3318eb9d;hpb=b5e7e31e6d33bbae4d635c27637c7e114b043735;p=ginac.git diff --git a/ginac/lortensor.cpp b/ginac/lortensor.cpp index 7cbd2f43..2b2215fd 100644 --- a/ginac/lortensor.cpp +++ b/ginac/lortensor.cpp @@ -4,7 +4,7 @@ * No real implementation yet, do be done. */ /* - * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany + * 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 @@ -35,15 +35,16 @@ #include "flags.h" #include "lst.h" #include "lortensor.h" -#include "utils.h" #include "operators.h" #include "tinfos.h" #include "power.h" #include "symbol.h" +#include "utils.h" +#include "config.h" -#ifndef NO_GINAC_NAMESPACE +#ifndef NO_NAMESPACE_GINAC namespace GiNaC { -#endif // ndef NO_GINAC_NAMESPACE +#endif // ndef NO_NAMESPACE_GINAC ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -65,13 +66,13 @@ lortensor::~lortensor() destroy(0); } -lortensor::lortensor(lortensor const & other) +lortensor::lortensor(const lortensor & other) { debugmsg("lortensor copy constructor",LOGLEVEL_CONSTRUCT); copy (other); } -lortensor const & lortensor::operator=(lortensor const & other) +const lortensor & lortensor::operator=(const lortensor & other) { debugmsg("lortensor operator=",LOGLEVEL_ASSIGNMENT); if (this != & other) { @@ -83,7 +84,7 @@ lortensor const & lortensor::operator=(lortensor const & other) //protected -void lortensor::copy(lortensor const & other) +void lortensor::copy(const lortensor & other) { indexed::copy(other); type=other.type; @@ -104,14 +105,14 @@ void lortensor::destroy(bool call_parent) // protected -lortensor::lortensor(lortensor_types const lt, string const & n) : type(lt), name(n) +lortensor::lortensor(lortensor_types const lt, const std::string & n) : type(lt), name(n) { debugmsg("lortensor constructor from lortensor_types,string",LOGLEVEL_CONSTRUCT); serial=next_serial++; tinfo_key=TINFO_lortensor; } -lortensor::lortensor(lortensor_types const lt, string const & n, ex const & mu) : indexed(mu), type(lt), name(n) +lortensor::lortensor(lortensor_types const lt, const std::string & n, const ex & mu) : indexed(mu), type(lt), name(n) { debugmsg("lortensor constructor from lortensor_types,string,ex",LOGLEVEL_CONSTRUCT); serial=next_serial++; @@ -119,7 +120,7 @@ lortensor::lortensor(lortensor_types const lt, string const & n, ex const & mu) tinfo_key=TINFO_lortensor; } -lortensor::lortensor(lortensor_types const lt, string const & n, ex const & mu, ex const & nu) : indexed(mu,nu), type(lt), name(n) +lortensor::lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu) : indexed(mu,nu), type(lt), name(n) { debugmsg("lortensor constructor from lortensor_types,string,ex,ex",LOGLEVEL_CONSTRUCT); serial=next_serial++; @@ -127,7 +128,7 @@ lortensor::lortensor(lortensor_types const lt, string const & n, ex const & mu, tinfo_key=TINFO_lortensor; } -lortensor::lortensor(lortensor_types const lt, string const & n, ex const & mu, ex const & nu, ex const & rho) : indexed(mu,nu,rho), type(lt), name(n) +lortensor::lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho) : indexed(mu,nu,rho), type(lt), name(n) { debugmsg("lortensor constructor from lortensor_types,string,ex,ex,ex",LOGLEVEL_CONSTRUCT); serial=next_serial++; @@ -135,7 +136,7 @@ lortensor::lortensor(lortensor_types const lt, string const & n, ex const & mu, tinfo_key=TINFO_lortensor; } -lortensor::lortensor(lortensor_types const lt, string const & n, ex const & mu, ex const & nu, ex const & rho, ex const & sigma) : indexed(mu,nu,rho,sigma), type(lt), name(n) +lortensor::lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho, const ex & sigma) : indexed(mu,nu,rho,sigma), type(lt), name(n) { debugmsg("lortensor constructor from lortensor_types,string,ex,ex,ex,ex",LOGLEVEL_CONSTRUCT); serial=next_serial++; @@ -143,7 +144,7 @@ lortensor::lortensor(lortensor_types const lt, string const & n, ex const & mu, tinfo_key=TINFO_lortensor; } -lortensor::lortensor(lortensor_types const lt, string const & n, exvector const & iv) : indexed(iv), type(lt), name(n) +lortensor::lortensor(lortensor_types const lt, const std::string & n, const exvector & iv) : indexed(iv), type(lt), name(n) { debugmsg("lortensor constructor from lortensor_types,string,exvector",LOGLEVEL_CONSTRUCT); serial=next_serial++; @@ -151,14 +152,14 @@ lortensor::lortensor(lortensor_types const lt, string const & n, exvector const tinfo_key=TINFO_lortensor; } -lortensor::lortensor(lortensor_types const lt, string const & n, unsigned s, exvector const & iv) : indexed(iv), type(lt), name(n), serial(s) +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, string const & n, unsigned s, exvector *ivp) : indexed(ivp), type(lt), name(n), serial(s) +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()); @@ -177,7 +178,7 @@ basic * lortensor::duplicate() const return new lortensor(*this); } -void lortensor::printraw(ostream & os) const +void lortensor::printraw(std::ostream & os) const { debugmsg("lortensor printraw",LOGLEVEL_PRINT); os << "lortensor(type=" << (unsigned)type @@ -186,19 +187,19 @@ void lortensor::printraw(ostream & os) const os << ",hash=" << hashvalue << ",flags=" << flags << ")"; } -void lortensor::printtree(ostream & os, unsigned indent) const +void lortensor::printtree(std::ostream & os, unsigned indent) const { debugmsg("lortensor printtree",LOGLEVEL_PRINT); - os << string(indent,' ') <<"lortensor object: " + os << std::string(indent,' ') <<"lortensor object: " << "type=" << (unsigned)type << "," - << seq.size() << " indices" << endl; + << seq.size() << " indices" << std::endl; printtreeindices(os,indent); - os << string(indent,' ') << "hash=" << hashvalue - << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + os << std::string(indent,' ') << "hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void lortensor::print(ostream & os, unsigned upper_precedence) const +void lortensor::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("lortensor print",LOGLEVEL_PRINT); switch (type) { @@ -225,7 +226,7 @@ void lortensor::print(ostream & os, unsigned upper_precedence) const printindices(os); } -void lortensor::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void lortensor::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("lortensor print csrc",LOGLEVEL_PRINT); print(os,upper_precedence); @@ -246,27 +247,27 @@ ex lortensor::eval(int level) const //something has changed while sorting indices, more evaluations later return ex(sig) *lortensor(type,name,iv); } - lorentzidx const & idx1=ex_to_lorentzidx(seq[0]); - lorentzidx const & idx2=ex_to_lorentzidx(seq[1]); + 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 exONE(); + return _ex1(); } else { if (idx1.is_covariant() != idx2.is_covariant()) { // (_i,~i) or (~i,_i), i = 1...3 - return exONE(); + return _ex1(); } else { // (_i,_i) or (~i,~i), i= 1...3 - return exMINUSONE(); + return _ex_1(); } } } else { // at least one off-diagonal - return exZERO(); + return _ex0(); } } else if (idx1.is_symbolic() && idx1.is_co_contra_pair(idx2)) { return Dim()-idx1.get_dim_parallel_space(); @@ -277,7 +278,7 @@ ex lortensor::eval(int level) const //protected -int lortensor::compare_same_type(basic const & other) const +int lortensor::compare_same_type(const basic & other) const { GINAC_ASSERT(is_of_type(other,lortensor)); const lortensor *o = static_cast (&other); @@ -292,7 +293,7 @@ int lortensor::compare_same_type(basic const & other) const return type < o->type ? -1 : 1; } -bool lortensor::is_equal_same_type(basic const & other) const +bool lortensor::is_equal_same_type(const basic & other) const { GINAC_ASSERT(is_of_type(other,lortensor)); const lortensor *o=static_cast (&other); @@ -311,7 +312,7 @@ unsigned lortensor::return_type_tinfo(void) const { return tinfo_key; } -ex lortensor::thisexprseq(exvector const & v) const +ex lortensor::thisexprseq(const exvector & v) const { return lortensor(type,name,serial,v); } @@ -326,9 +327,9 @@ ex lortensor::thisexprseq(exvector *vp) const // protected -void lortensor::setname(string const & n) +void lortensor::setname(const std::string & n) { - name=n; + name = n; } bool lortensor::all_of_type_lorentzidx(void) const @@ -343,9 +344,9 @@ bool lortensor::all_of_type_lorentzidx(void) const // private -string & lortensor::autoname_prefix(void) +std::string & lortensor::autoname_prefix(void) { - static string * s=new string("lortensor"); + static std::string * s = new std::string("lortensor"); return *s; } @@ -361,27 +362,27 @@ unsigned lortensor::next_serial=0; // friend functions ////////// -lortensor lortensor_g(ex const & mu, ex const & nu) +lortensor lortensor_g(const ex & mu, const ex & nu) { return lortensor(lortensor::lortensor_g,"",mu,nu); } -lortensor lortensor_epsilon(ex const & mu, ex const & nu, ex const & rho, ex const & sigma) +lortensor lortensor_epsilon(const ex & mu, const ex & nu, const ex & rho, const ex & sigma) { return lortensor(lortensor::lortensor_epsilon,"",mu,nu,rho,sigma); } -lortensor lortensor_rank1(string const & n, ex const & mu) +lortensor lortensor_rank1(const std::string & n, const ex & mu) { return lortensor(lortensor::lortensor_rank1,n,mu); } -lortensor lortensor_rank2(string const & n, ex const & mu, ex const & nu) +lortensor lortensor_rank2(const std::string & n, const ex & mu, const ex & nu) { return lortensor(lortensor::lortensor_rank2,n,mu,nu); } -ex simplify_lortensor_mul(ex const & m) +ex simplify_lortensor_mul(const ex & m) { GINAC_ASSERT(is_ex_exactly_of_type(m,mul)); exvector v_contracted; @@ -391,12 +392,12 @@ ex simplify_lortensor_mul(ex const & m) v_contracted.reserve(2*n); for (int i=0; i