Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Cost of Composition vs Pure Function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg93681] Re: [mg93646] Cost of Composition vs Pure Function
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Fri, 21 Nov 2008 05:35:16 -0500 (EST)
  • References: <200811200956.EAA20593@smc.vnet.net>

On Nov 20, 2008, at 4:56 AM, Raffy wrote:

> The speed difference between these two evaluations seems odd,
> considering they are effectively the same thing:
>
> m = RandomReal[{0, 1}, {10, 1000, 1000}];
>
> Total[Total[#]]& /@ m; // Timing => 0.14 sec
>
> Composition[Total, Total] /@ m; // Timing => 0.983 sec
>
> Other than the Identity and Inverse Function transformation, where is
> this overhead coming from?

I think it's from Composition, due to order of operations the  
composition is being done for each row of m as the pure function is  
mapped, not before the mapping.

Regards,

Sseziwa


  • Prev by Date: Re: Cost of Composition vs Pure Function
  • Next by Date: Re: Cost of Composition vs Pure Function
  • Previous by thread: Cost of Composition vs Pure Function
  • Next by thread: Re: Cost of Composition vs Pure Function