[GiNaC-list] setting and getting numeric values from indexed
expressions
Alejandro Limache
alejandrolimache at hotmail.com
Fri Jul 28 22:06:08 CEST 2006
Chris,
Thank you for helping me to get a grasp on GINAC.
>Do you mean the writing out of contractions as in A.i*B.i -> A.1*B.1 + ...
>+ A.3*B.3. That can be done using the function
>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?. Does it has something to do with the flag: bool
subs_idx
I just put a "1" in there. What is the purpose of that flag?
>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?
Alejandro
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#include <iostream>
#include <ginac/ginac.h>
#include <ginac/flags.h>
using namespace std;
using namespace GiNaC;
int main (void)
{
symbol i_sym("i");
idx i(i_sym, 2);
symbol A("A"),B("B");
ex exA = indexed(A,i);
ex exB = indexed(B,i);
ex exAB = exA*exB;
cout << exAB << endl;
ex exABexp = expand_dummy_sum(exAB,1);
cout << exABexp << endl;
// replacing numeric values for component A.1
ex exA1 = indexed(A,idx(1,2));
cout << exABexp.subs(exA1 == 7.5) << endl;
return 0;
}
More information about the GiNaC-list
mailing list