MathGroup Archive 2008

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

Search the Archive

Built-in Cross is slow

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89865] Built-in Cross is slow
  • From: Frank Hu <frank1998 at gmail.com>
  • Date: Mon, 23 Jun 2008 02:47:23 -0400 (EDT)

Hi,

Does anyone know why the built-in Cross function is so slow?  Compare  
the following version

cross = Compile[{{a, _Real, 1}, {b, _Real, 1}}, {-a[[3]] b[[2]] +
      a[[2]] b[[3]],
     a[[3]] b[[1]] - a[[1]] b[[3]],
     -a[[2]] b[[1]] + a[[1]] b[[2]]}];

to the built-in

a = RandomReal[1, {10000, 3}];
ca = Cross[#, {1.1, 2.2, 3.3}] & /@ a; // Timing
{1.17115,Null}
cb = cross[#, {1.1, 2.2, 3.3}] & /@ a; // Timing
{0.054181, Null}

That's 20 times difference.

Frank


  • Prev by Date: Happy Birthday Mathematica!
  • Next by Date: Two FindRoot questions
  • Previous by thread: Re: Re: Re: Happy Birthday Mathematica!
  • Next by thread: Two FindRoot questions