MathGroup Archive 2008

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

Search the Archive

Re: Re: Product

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87639] Re: [mg87592] Re: Product
  • From: "Szabolcs HorvÃt" <szhorvat at gmail.com>
  • Date: Tue, 15 Apr 2008 05:47:00 -0400 (EDT)
  • References: <200804110542.BAA04653@smc.vnet.net>

On Mon, Apr 14, 2008 at 3:13 PM, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote:
>
> > But of course in principle there is nothing that would make it
> > impossible to introduce a special case for functions like Times and
> > Plus, and make them work with packed arrays.  So this alone does not
> > make it necessary to introduce a new syntax/new function, like Total[].
> >
>
>  Well, I never claimed that it did.

I didn't mean that you did :-)

> It seems to me that WRI wanted to add
> new functionality to Mathematica and modifying Plus would break too many
> things. For example, Total, in version 6 accepts level specifications, so:
>
>  Total[{{a, b}, {c, d}}, {2}]
>  {a + b, c + d}
>
>  while
>
>  Apply[Plus, {{a, b}, {c, d}}, {2}]
>  {{a, b}, {c, d}}
>
>  The key thing, in my opinion, is that Total[list] is just a spacial case of
> Total (=Total[list,1]) and the general case of Total would be quite hard or
> impossible to define using Apply and Plus.
>

Actually one just needs to shift the level specification by 1, so

Total[{{a, b}, {c, d}}, {2}] is equivalent to Apply[Plus, {{a, b}, {c, d}}, {1}]

Generally,

Total[expression, {n}]  is equivalent to  Apply[Plus, expression, {n-1}]

and

Total[expression, n]  is equivalent to  Apply[Plus, expression, {0, n-1}]

Szabolcs Horvát


  • References:
    • Product
      • From: "Steven" <steven_504@telenet.be>
  • Prev by Date: A kernel, multiple notebooks, and Global?
  • Next by Date: Re: Re: Product
  • Previous by thread: Re: Re: Product
  • Next by thread: Re: Re: Product