Tensors in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg37510] Tensors in Mathematica
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Sat, 2 Nov 2002 03:30:39 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Liquo.Song at vanderbilt.edu posted a message with the vague subject "[mg37469] Is Mathematica capable of doing this?" In that post the author want to know if he/she can define a new object, Tensor, which will act like Complex. The he/she could implement a sort of multiplication of tensors. ---------------- Yes this can be done, except in Mathematica we don't have "objects". Below I define TensorQ[expr] which returns True if expr is a tensor and otherwise returns False. In[1]:= TensorQ[expr_]:=MatchQ[expr,_List?(Length[Dimensions[#]]===Depth[#]-1&)] You don't explain how tensors are multiplied, and I know very little about tensors. Hence I won't implement tensor multiplication, but in the next line I define a function that is only defined when it's two arguments are tensors. This function indicates if the two tensors have the same dimensions. In[2]:= SameDimensionsQ[t1_?TensorQ, t2_?TensorQ]:= (Dimensions[t1]===Dimensions[t2]) ------------ It certainly is possible to implement super/sub-scripts to represent indices for a tensor. However, I won't try to implement it because I know very little about tensors. You can find some stuff about tensors and Mathematica at: http://mathworld.wolfram.com/Tensor.html Also did you check the tensor package at: http://home.earthlink.net/~djmp/Mathematica.html ---------- Regards, Ted Ersek Download my latest Mathematica Tips, Tricks from http://www.verbeia.com/mathematica/tips/Tricks.html or from http://www.mathsource.com/Content/General/Tutorials/0212-331