* 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
#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"
#ifndef NO_GINAC_NAMESPACE
namespace GiNaC {
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) {
//protected
-void lortensor::copy(lortensor const & other)
+void lortensor::copy(const lortensor & other)
{
indexed::copy(other);
type=other.type;
// protected
-lortensor::lortensor(lortensor_types const lt, string const & n) : type(lt), name(n)
+lortensor::lortensor(lortensor_types const lt, const 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 string & n, const ex & mu) : indexed(mu), type(lt), name(n)
{
debugmsg("lortensor constructor from lortensor_types,string,ex",LOGLEVEL_CONSTRUCT);
serial=next_serial++;
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 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++;
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 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++;
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 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++;
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 string & n, const exvector & iv) : indexed(iv), type(lt), name(n)
{
debugmsg("lortensor constructor from lortensor_types,string,exvector",LOGLEVEL_CONSTRUCT);
serial=next_serial++;
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 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 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());
//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();
//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 <const lortensor *> (&other);
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<const lortensor *> (&other);
{
return tinfo_key;
}
-ex lortensor::thisexprseq(exvector const & v) const
+ex lortensor::thisexprseq(const exvector & v) const
{
return lortensor(type,name,serial,v);
}
// protected
-void lortensor::setname(string const & n)
+void lortensor::setname(const string & n)
{
name=n;
}
// 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 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 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;
v_contracted.reserve(2*n);
for (int i=0; i<n; ++i) {
ex f=m.op(i);
- if (is_ex_exactly_of_type(f,power)&&f.op(1).is_equal(exTWO())) {
+ if (is_ex_exactly_of_type(f,power)&&f.op(1).is_equal(_ex2())) {
v_contracted.push_back(f.op(0));
v_contracted.push_back(f.op(0));
} else {
v_contracted.push_back(f);
- }
+ }
}
unsigned replacements;
// process only lor_g objects
if (is_ex_exactly_of_type(*it,lortensor) &&
(ex_to_lortensor(*it).type==lortensor::lortensor_g)) {
- lortensor const & g=ex_to_lortensor(*it);
+ const lortensor & g=ex_to_lortensor(*it);
GINAC_ASSERT(g.seq.size()==2);
- idx const & first_idx=ex_to_lorentzidx(g.seq[0]);
- idx const & second_idx=ex_to_lorentzidx(g.seq[1]);
+ const idx & first_idx=ex_to_lorentzidx(g.seq[0]);
+ const idx & second_idx=ex_to_lorentzidx(g.seq[1]);
// g_{mu,mu} should have been contracted in lortensor::eval()
GINAC_ASSERT(!first_idx.is_equal(second_idx));
ex saved_g=*it; // save to restore it later
} else {
// a contracted index should occur exactly once
GINAC_ASSERT(replacements==1);
- *it=exONE();
+ *it=_ex1();
something_changed=true;
}
}
} else {
// a contracted index should occur exactly once
GINAC_ASSERT(replacements==1);
- *it=exONE();
+ *it=_ex1();
something_changed=true;
}
}
return m;
}
-ex simplify_lortensor(ex const & e)
+ex simplify_lortensor(const ex & e)
{
// all simplification is done on expanded objects
ex e_expanded=e.expand();
// simplification of sum=sum of simplifications
if (is_ex_exactly_of_type(e_expanded,add)) {
- ex sum=exZERO();
+ ex sum=_ex0();
for (int i=0; i<e_expanded.nops(); ++i) {
sum += simplify_lortensor(e_expanded.op(i));
}