Re: Tensors in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg37539] Re: [mg37510] Tensors in Mathematica
- From: Liguo Song <liguo.song at vanderbilt.edu>
- Date: Mon, 4 Nov 2002 02:44:01 -0500 (EST)
- Reply-to: Liguo Song <liguo.song at vanderbilt.edu>
- Sender: owner-wri-mathgroup at wolfram.com
Ted, Thanks for you input. First of all, sorry for the vague subject. I will try to be make the subject more clear next time. I have been playing with this Tensor idea for a couple weeks before I sent the question to the List. So, I did have a lot of things figured out except those in my initial post. For example, the TensorQ you provided, except my implementation is a really ugly newbie's stuff. Another solution that I learned is to use Head, which I wrongly used object, as from Object Oriented Programming. I can define A=Tensor[x], then I can use F[T_Tensor] to check whether it is a Tensor. This is more closer to the behavior of Complex, I think. Tensor multiplication is a more complicated issue. I got some ideas, but haven't straight them out. As Mr. Christensen pointed out in his email to me, which is very nice of him, that it is much more than a simple task to make a fully functional tensor package. Also, thanks for the links. I will check them out. At last but not the least, big thanks for the nice Tips and Tricks. I have gone through most part of it, and learned a lot. In fact, I got the idea of TensorQ thing from your Tips and Tricks. Wonderful job. With my best wishes, Liguo On Sat, 2 Nov 2002, Ersek, Ted R wrote: > 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 > > >