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

Sheplyakov Alexei varg at theor.jinr.ru
Thu Nov 9 08:16:44 CET 2006


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,

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/20061109/654eb505/attachment.pgp

More information about the GiNaC-list mailing list