[GiNaC-list] Mixed index simmetry (its long..)

mdias at ift.unesp.br mdias at ift.unesp.br
Mon Feb 21 21:00:07 CET 2005


Thanks Christian, I make this

Looking symmetrize.cpp I define:

class symmetrize_pair : public map_function{
  lst w;
public:
  symmetrize_pair(lst & var_) : w(var_){} 
  ex operator()(const ex & e);
};
ex symmetrize_pair :: operator()(const ex & e)
  { 
    if(is_a<add>(e))
      return e.map(*this);
    else{
  lst l; 
  lst orig_lst=w;
unsigned num=w.nops();
 unsigned *iv= new unsigned[num];
 for(unsigned i=0;i<num;i++)
   iv[i]=i;
ex sum=e;
while(std::next_permutation(iv,iv+num))
       {
  lst new_lst;
  for(unsigned i=0;i<num;i++)
    new_lst.append(orig_lst.op(iv[i]));
    l.remove_all();
    for(unsigned j=0;j<num;j++)
   
l.append(orig_lst.op(j).op(0)==new_lst.op(j).op(0)).append(orig_lst.op(j).op(1)==new_lst.op(j).op(1));
     ex term=e.subs(l);
     sum+=term;
        }
delete[] iv;

 return sum;
  }  
  }
int main ()
{
varidx mu(symbol("mu"),4),
nu(symbol("nu"),4),gamma(symbol("gamma"),4),delta(symbol("delta"),4),alpha(symbol("alpha"),4),beta(symbol("beta"),4),sigma(symbol("sigma"),4);
  idx a(symbol("a"),8), b(symbol("b"),8), c(symbol("c"),8), d(symbol("d"),8),
e(symbol("e"),8), f(symbol("f"),8),g(symbol("g"),8), r(symbol("r"),8),
s(symbol("s"),8);
  ex four =
delta_tensor(a,e)*delta_tensor(b,f)*delta_tensor(c,r)*delta_tensor(d,s)*metric_tensor(alpha,gamma)*metric_tensor(beta,delta);
    lst u(a,alpha);
    lst v(b,beta);
    lst z(c,gamma);
    lst x(d,delta);
    lst w(u,v,z,x);
    symmetrize_pair make_symm(w);
    ex fourv = make_symm(four);
}


Ginac is really great !!!!!!

Marco


Quoting Christian Bauer <Christian.Bauer at uni-mainz.de>:

> Hi!
> 
> On Wed, Feb 16, 2005 at 12:13:47PM -0200, mdias at ift.unesp.br wrote:
> > I can make somethink like
> > four.symmetrize((sigma,l),(mu,m),(nu,n),(rho,o))?
> 
> No, it can't do that (but it would be a nice feature to have, actually...).
> You have to do the symmetrization by hand.
> 
> Bye,
> Christian
> 
> -- 
>   / Physics is an algorithm
> \/ http://www.uni-mainz.de/~bauec002/
> 
> _______________________________________________
> GiNaC-list mailing list
> GiNaC-list at ginac.de
> http://thep.physik.uni-mainz.de/mailman/listinfo/ginac-list
> 




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/




More information about the GiNaC-list mailing list