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: [mg105984] Re: Best way to do contractions (arbitrary Tables with a Sum)?
  • From: Erik Max Francis <max at alcyone.com>
  • Date: Tue, 29 Dec 2009 01:19:10 -0500 (EST)
  • References: <200912270724.CAA21087@smc.vnet.net> <hh9vhf$1tl$1@smc.vnet.net>

Leonid Shifrin wrote:
> I expect <contract> to be reasonably fast since it avoids explcit looping
> and uses efficient operaqtions such as Transpose, Map and Tr, on an entire
> structure at once. I did not do any timing comparisons or benchmarks
> however.

Thanks to Leonid and everyone else who responded.  I was indeed unaware 
of the extra functionality available in Transpose and Tr, which is 
exactly what I needed.  (I figured there was something lurking 
somewhere, but wasn't sure where.)  I use the approach of transposing 
the two relevant indices to the beginning of the array, then using 
Tr[..., Plus, 2].  Works just fine.

For raising and lowering indices, I'll just do a tensor (outer) product 
with the metric (or its inverse), do the contraction trick, and then 
transpose the results back to the original place.  For covariant 
derivatives, I'll, uh, figure something out :-).  Then I should be ready 
do add some documentation and a few examples and post it to see what 
people think of my first shot at a package.

Weird way to spend a vacation, I know ... :-).

-- 
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
   I have not yet begun to right!
    -- John Paul Jones


  • Prev by Date: Re: Re[] function
  • Next by Date: Re: Replace and ReplaceAll -- simple application
  • Previous by thread: Re: Best way to do contractions (arbitrary Tables with a
  • Next by thread: Re: Best way to do contractions (arbitrary Tables with a Sum)?