MathGroup Archive 2009

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

Search the Archive

Re: Best way to do contractions (arbitrary Tables with a Sum)?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105958] Re: [mg105937] Best way to do contractions (arbitrary Tables with a Sum)?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Mon, 28 Dec 2009 04:55:45 -0500 (EST)
  • References: <200912270724.CAA21087@smc.vnet.net>

Read the documentation for Transpose and Inner. Essentially you can 
perform arbitrary contractions by first transposing the pair of indices 
you wish to contract into the first and last position, then applying 
Inner and then Transposing again back to the original position.

Andrzej Kozlowski

On 27 Dec 2009, at 16:24, Erik Max Francis wrote:

> I'm trying to do arbitrary contractions with tensors, which basically
> amounts to taking an (arbitrarily) large multi-dimensional array,
> iterating over the uncontracted indices, and then summing over the two
> (and only two) indices to be contracted.  If I were dealing with a
> specific case, I'd use Table with Sum:
>
> 	Table[
> 	    Sum[
> 	        a[[i1]][[i2]]...[[j]]...[[j]]...[[im]]],
> 	    {j, n}],
> 	{i1, n}, {i2, n}, ... {im, n}]
>
> That is, iterating over the indices i1, i2, through im (all taking on
> values 1 through n) and summing over two of the indices (as j).  I'm
> trying to figure out the most elegant way to do this in Mathematica and
> I'm only coming up with ugly solutions which are basically arbitrary
> reimplementations of Table-like functionality.
>
> I figure there's probably some more elegant way to approach this.
> Anyone have any ideas?
>
> --
> Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
>  San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
>   Without love, benevolence becomes egotism.
>    -- Dr. Martin Luther King, Jr.
>



  • Prev by Date: Re: Best way to do contractions (arbitrary Tables with a Sum)?
  • Next by Date: Re: 3D Animations
  • Previous by thread: Best way to do contractions (arbitrary Tables with a Sum)?
  • Next by thread: Re: Best way to do contractions (arbitrary Tables with a