# [GiNaC-list] indexed objects are NOT arrays [Was: multi index storage of expressions]

Alexei Sheplyakov varg at theor.jinr.ru
Sun Feb 18 18:19:14 CET 2007

```Hello,

On Sun, Feb 18, 2007 at 12:02:25AM -0300, Charlls Quarra wrote:
> I wanted to define a simple matrix of derivatives
> (i.e: a Jacobian) first as an indexed object:

The only array-like class in GiNaC is the `matrix' class (2-dimensional
array). Indexed objects are NOT arrays. They are tensors, so things like
delta_tensor(0, i) are really meaningless. Mixing matrices (arrays) with
indexed objects (tensors) is a BAD idea. GiNaC does not prevent one from
doing so, but does not help either.

N.B. It is possible to mix matrices and indexed expressions in a
meaningful way as described in the manual (chapter "Basic concepts",
section "Matrices" and section "Indexed objects", paragraph "Linear
algebra"), but I think this is just a confusing misfeature.

>  ex f = a*x + b*y + c*x*y + ...
>  ex g = u*pow(x,2) + v*pow(y,2) + w*x,y + ....
>
>  idx i(symbol("is") , 2) , j(symbol("js") , 2);
>  ex Jacobian = diff( f*delta_tensor(i , 0) +
> g*delta_tensor(i,1) , x )*delta_tensor( 0 , j ) +
> diff( f*delta_tensor(i , 0) + g*delta_tensor(i,1) , y
> )*delta_tensor( 1 , j );
>
> but then this failed on me (because 0 and 1 are not
> acceptable arguments where an idx should be expected)
>
> Why am i trying to do this as an indexed object and
> not with a matrix?
>
> well, because later, i would also want to make
> computations with an object like
>
>  D( f_{i} ) / dx_{j} dx_{k}

What about using vector (std::vector) of matrices (or GiNaC::lst
of thereof)?

>  but afaik there isnt a "three indexed" matrix object

Once again: indexed object are NOT matrices (and vice a versa).

> in ginac, or how they are usually called, cubic
> arrays. correct?

You are right, there are no 3-dimensional arrays in GiNaC.

Best regards,
Alexei

--
All science is either physics or stamp collecting.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/ginac-list/attachments/20070218/42443f20/attachment.pgp
```