MathGroup Archive 2008

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

Search the Archive

Re: Performance of Array Addition

  • To: mathgroup at
  • Subject: [mg91022] Re: [mg90952] Performance of Array Addition
  • From: Carl Woll <carlw at>
  • Date: Mon, 4 Aug 2008 03:21:10 -0400 (EDT)
  • References: <>

Jeremy wrote:

>Let there be, for example, an array of reals with dimensions
>I have noticed that the command
>array[[All,All,1]] + array[[All,All,2]] + array[[All,All,3]];
>is much faster than
>Map[Total, array, {2}];
>even though they return the same answer.
>The advantage of Map[Total, array, {2}] is that it allows arrays of
>dimension {d1,d2,d3}, with d3 arbitrary.
>Is there a way to get closer to the speed advantages of hand-coding
>the addition of the final dimension, while
>allowing the number of elements in the final dimension to be
>Thanks, Jeremy
Why not

Total[array, {3}]


Carl Woll
Wolfram Research

  • Prev by Date: Incoherent value for partial derivative
  • Next by Date: Re: Using \[Breve] as a substitute for underscore
  • Previous by thread: Re: Performance of Array Addition
  • Next by thread: Fisher scoring algorithm