Re: Embed extra info?
- To: mathgroup at smc.vnet.net
- Subject: [mg113669] Re: Embed extra info?
- From: Sam Takoy <sam.takoy at yahoo.com>
- Date: Sun, 7 Nov 2010 05:10:13 -0500 (EST)
- References: <iatt2m$egl$1@smc.vnet.net> <ib38va$f43$1@smc.vnet.net>
On 11/6/2010 6:00 AM, David Bailey wrote: > On 04/11/10 09:06, Sam Takoy wrote: >> Hi, >> >> I'm writing code that implements tensor calculus. I'm sure it's been >> done beautifully in MathTensor and other Mathematica packages, but I >> would like to do it for myself to learn things along the way... >> >> Nontensorially speaking, a tensor is a multidimensional array but each >> dimension is tagged as either upper or lower and certain operations on >> the array are performed differently depending on the flavor. Is there a >> way to embed extra info in a List of Lists so that if one does regular >> things with the List, such as displaying it, the information does not >> show up, but other operations can extract the extra info and use it? >> >> Many thanks in advance! >> >> Sam >> > > The best way to do this, is to wrap the matrix in an extra layer > together with the other information: > > myTensor[{{1,2},{3,4}},index info, etc....] > > Then overload an operator \[CircleTimes] to represent multiplication > (you can't use Times because you need a non-commutative operator) and > overload Times to represent scalar multiplication. > > To improve the appearance of the output, you can add MakeBoxes > expressions to make myTensor objects display in whatever way you want. > > David Bailey > http://www.dbaileyconsultancy.co.uk > Thank you very much for your great response!