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

Alejandro Limache alejandrolimache at hotmail.com
Fri Jul 28 03:02:36 CEST 2006

```Hello people,
I have the following question.
Is there a way to SET and GET numeric values from indexed expressions?

Consider the 2 following cases:

1) For matrices. In the tutorial Section 4.13 one sees that is possible to
do:
matrix A(2, 2), B(2, 2), C(2, 2);
A =  1, 2,
3, 4;
B = -1, 0,
2, 1;
C =  8, 4,
2, 1;
e = indexed(A, i, k) * indexed(B, k, j) - 2 * indexed(C, i, j);
So:
cout << e.simplify_indexed() << endl;
// -> [[-13,-6],[1,2]].i.j
Is there a way to get the numeric values of each of the components of e?
I would like to be able to do something like
double d;
d = e(0,0);
to get:
d=-13

2) Can something similar be done for indexed expression not defined as
matrices?
For example given something like
symbol  A("A")....
idx i(.., 3), j(.., 3), k(..,10);
ex e = indexed(A,i,j,k)
could I set for example: i=2, j=0, k=4 and set A(2,0,4)=3.5 ?
could I then somehow get the value "3.5" back?