MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Embed extra info?

  • To: mathgroup at
  • Subject: [mg113654] Re: Embed extra info?
  • From: David Bailey <dave at>
  • Date: Sat, 6 Nov 2010 05:00:06 -0500 (EST)
  • References: <iatt2m$egl$>

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

  • Prev by Date: Re: When is Exp[z]==Exp[w]??
  • Next by Date: Mysterious Apply troubles (a bug?)
  • Previous by thread: Embed extra info?
  • Next by thread: Re: Embed extra info?