The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Speed of dot product in Mathematica
Replies: 1   Last Post: Nov 13, 1996 1:38 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Carlos A. Felippa

Posts: 63
Registered: 12/7/04
Speed of dot product in Mathematica
Posted: Nov 12, 1996 1:19 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

The speed of dot products in Mathematica 2.2 depends
significantly on implementation. For example, timing

n=10000; a=Table[1.,{n}]; b=a;
Print[Timing[s=0;For[i=0,i<=n,i++,s+=a[[i]]*b[[i]] ]]];

on a Mac 8500 gives

{0.0666667 Second, 10000.}
{1.48333 Second, 10000.}
{2.38333 Second, Null}
{3.95 Second, Null}

Is there a way to speed up the Sum form, for example using Compile, so that
it achieves a performance similar to that of the built-in dot operator?

This is important in matrix routines where the dot product involves only
portions of rows or columns, or where the stride is not unity.

BTW, several of the LinearAlgebra Package functions (e.g. lufactor)
use the For-loop implementation. As shown above, that has the worst
performance, being 60 times slower than the built-in operator.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.