Dear Alejandro, On Thu, 27 Jul 2006, Alejandro Limache wrote:
For example, in the area of continuum mechanics, its very common to see inner products defined for 2nd order tensors (2 indices). In particular the "stress power P" is the inner product of the stress tensor T with the rate of deformation tensor D: P = T*D=T.i.j * D.i.j and measures the power produced by the inner (stress) forces.
Yes, such a thing could be useful. However....
1) By definition an inner product must be a scalar so all tensor indices should get contracted.
Yes, obviously.
2) One must be careful with the order of the indices. The inner product of a non zero tensor with itself must be positive, from this condition it follows that T.i.j * D.j.i is NOT an inner product
Yes, the old implementation that I deleted would do this. Looking at the old code again, I guess it would even do T.i.j.k.k*D.i.j -> P if the user were to define that the scalar product between T and D is P. *shrug* I can think of two problems with your solution (1) What if the indices are of different dimension? Should it be possible to specify a different dimension for every index postion? IMO, this would get a bit overly complicated. Maybe user-defined inner products should only be used if all dimensions of indices involved are the same. This, at least, seems to cover your case. (2) What if T happens to be symmetric and D is not? Then the product T.i.j*D.i.j might automatically evaluate into T.j.i*D.i.j and the contraction would no longer occur, depending on what the canonical ordering of i and j happens to be. Not good. Maybe looping over all posibilities for a symmetric tensor would need to be done. I'm not sure whether I will have time to implement this, though.
3) Covariant indices should contract with contravariant indices so T~a.mu*T~a~mu is not correct a should throw an exception or not get simplified, but T.a.mu*T~a~mu should get simplified.
Oh yes, of course I should have written T.a.mu*T.a~mu, where a was not a varidx but an ordinary idx. Never mind though, the problem was that if these indices a and mu were of incomparable dimension (in the sense of the function minimal_dim) an exception would be thrown. Best wishes, Chris