[GiNaC-list] Problem with scalar_products : Scalar product of two vectors in index notation

aravind b baravi2005 at gmail.com
Thu Nov 9 13:00:58 CET 2006


oh k. Guess i got to work my problem out differently. It would be nice if i
was able to do stuff like that because i am trying to write a very simple
code for doing tensor algebra in continuum mechanics.

Thanks a lot alexei for the prompt and clear clarification.

On 11/9/06, Sheplyakov Alexei <varg at theor.jinr.ru> wrote:
>
> Hello,
>
> On Thu, Nov 09, 2006 at 07:38:08AM +0530, aravind b wrote:
> > Please go through this code :
> >
> >
> > #include <iostream>
> > #include <ginac/ginac.h>
> > using namespace std;
> > using namespace GiNaC;
> >
> > int main()
> > {
> >    symbol i_sym("i"), j_sym("j"), e("e"), a("a"), b("b") ;
> >    idx i(i_sym, 3), j( j_sym, 3) ;          //defining indices i and j
> >
> >    scalar_products sp;
> >    sp.add( indexed(e, i), indexed(e, j), delta_tensor(i,j) );       //
> e.i*
> > e.j = delta_tensor.i.j
> >
> >    cout << (indexed(e,i)*indexed(e,j)).simplify_indexed(sp) <<endl ;
> >
> >    return 0;
> > }
> >
> > does NOT give delta.j.i instead just gives e.i * e.j - why?
>
> Quoting the manual:
> "* as a special case of dummy index summation, it can replace scalar
>    products   of two tensors with a user-defined value"
>
> Since e.i * e.j is not a scalar (it is a tensor of second rank), your
> code won't work.
>
> > Basically, i want to define an orthonormal basis vector set {e.i}.
>
> I think using `idx' object to enumerate the basis is a bad idea.
> In general, GiNaC `indexed', `idx' classes are well-suited for
> 'basis-less'
> calculations (see http://www.ginac.de/FAQ.html#matrix_indexed to find
> out why). They don't prevent anyone from doing calculation in scpecific
> basis, but don't help either.
>
> > If i have vector_a = indexed(a, i) * indexed(e, i) and
> > vector_b = indexed(b, j) * indexed(e, j) ,
>
> Indexed objects in GiNaC are treated as tensors, so such a vector_a
> is _not_ really a vector, but instead a scalar.
>
>
> Best regards,
> Alexei
>
> --
> All science is either physics or stamp collecting.
>
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (GNU/Linux)
>
> iQIVAwUBRVLV27L3rFoFceCwAQL3aw//SkchtQFAGdoQkKu+8u9FertudZO9fHFD
> 9KlKaOBOhnvMydZUHBojaEz3HyTXB9KLX6nmRI3F4PwIi8N0zOSX0kzYNP6c43yT
> 6V0C8v+kW+FRcCLp58iQ0MILNh54qMYmpD32i2dk0ErN7v9YyaOxPtGdIM/Gv/0R
> 89yn8FmlSg8Rf44Np44ZbR95arbeIXU+/YS640io6Mj6OppbugRkRnaI2ojHYWjk
> 01yV9CWH86vlSnPupD6+oUjtT/SUUSV3XT2XDqIyuExIu+sViUH6OSAE3MpfCIls
> siAhdMpQkv05ISSo5VJemUidHwN7ajaFQ7cQf/V82DZsm/KwVE/MjVa7qZOYcUpx
> sxQBDFrLIFQX9OiWyf4fhtd52UhU80Au3IlKR6PjO24BEOeXTpQt+qpNusaA+/Tb
> WgqWcqn8A6slBnNHuFtkZ1QbZFL+WxqJq4bbSWo3X5dLY0+cUw/MKMP7etRDbr0b
> /5VSk6pPy5Ee7VS+M8UnlHCzHOswoiKxdFuhKJy6sWpkva1STTwAnmdBgDPJoGPH
> SZ0MGkI8qV1SWwo/M8yVyr/RqWktbwNI2JO/tXbKmzk+PwTnXJAO/MMbeipS/rCP
> /5E3E2kOEdwxtrr3I48Z0QBSclJC6eoqnF0T7BTBkV94mVv0cUMxpf+IWSI2DffB
> jQaSWrzTkjQ=
> =VrMW
> -----END PGP SIGNATURE-----
>
>
> _______________________________________________
> GiNaC-list mailing list
> GiNaC-list at ginac.de
> https://www.cebix.net/mailman/listinfo/ginac-list
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.cebix.net/pipermail/ginac-list/attachments/20061109/6feed9ad/attachment.html


More information about the GiNaC-list mailing list