[GiNaC-list] setting and getting numeric values from indexed expressions

Chris Dams Chris.Dams at mi.infn.it
Fri Jul 28 23:54:47 CEST 2006


Dear Alejandro,

On Fri, 28 Jul 2006, Alejandro Limache wrote:

> >ex expand_dummy_sum(const ex & e, bool subs_idx).

> Yes that is what I wanted to do. I did an example to do just that
> in the simple code below however instead of getting:
> A.i*B.i -> A.0*B.0 + A.1*B.1
> I am getting:
> A.i*B.i -> A.0*B.i + A.1*B.i
> so why is it not working?.

Yes, this function is broken. The commentary in indexed.h states that it
was intended to be used for all indices but actually it only works for
varidxes. I will fix this. In a few days the CVS should have code that
does work as expected. If you don't want to use CVS-code or are in a
hurry, I suggest you write your own function to do this.

> >Not directly. The closest that you can get to that is keeping an exmap m
> >and say m[A(2,0,4)] = 3.5 and then do .subs(m) in an expression where you
> >have unrolled the dummy indices.
> I tried to do this in the simple code below where I have the expanded
> expression: A.0*B.i + A.1*B.i I tried to replace A.1 by 7.5. It worked
> ok but I noticed that in order for this to work I needed to use an
> expression of the form: indexed(A,idx(1,)) in .subs Is there any
> alternative where I can just put some kind of string str "A.1" inside
> .subs and still work?

That is not possible. You will have to use indexed(A,idx(1,2)).

Best wishes,
Chris



More information about the GiNaC-list mailing list