MathGroup Archive 2006

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

Search the Archive

Re: Speed: Inner MUCH slower than dot product??


Hi,
From my experience, any Mathematica function that is limited to a single
operation such as dot, Total Cross,Transpose, etc, are faster
Functions that are general, such as, Inner, Outer, Thread etc, where you can
define arbitrary functions to play with within the function, are much
slower.
This is reasonable since since a function that is limited to a specific
operation  can be coded more efficiently.
Compare Transpose against Thread for large matrices.
Thread can transpose a matrix, but can do much more than that.
Transpose can only transpose and will be faster.
yehuda

On 4/6/06, Lee Newman <leenewm at umich.edu> wrote:
>
> Dear Group,
>
> In the process of performance tweaking some code, I came upon the
> following result:  using Inner is MUCH slower (orders of magnitude) than
> using Dot product (see code below).  Why is this?
>
> m = Table[Random[], {25*25}, {50}];
> mt = Transpose@m;
> v = Table[Random[], {50}];
>
> Do[v.mt, {10^3}] // Timing
> Do[Dot[v, mt], {10^3}] // Timing
> Do[Inner[Times, v, mt, Plus], {10^3}] // Timing
>
> {0.047 Second, Null}
> {0.046 Second, Null}
> {22.047 Second, Null}
>
> Lee
>
>


  • Prev by Date: Re: Speed: Inner MUCH slower than dot product??
  • Next by Date: Re: HoldFirst confusion
  • Previous by thread: Re: Speed: Inner MUCH slower than dot product??
  • Next by thread: Accessing Mathematica on a remote server from java