MathGroup Archive 2003

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

Search the Archive

RE: Speed Tips

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39738] RE: Speed Tips
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Mon, 3 Mar 2003 23:51:56 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

My note on 25 Feb, 2003  included:  
In general one should always use the form that requires the minimum work for
the kernel.  So for example:

Don't use   Table[expr,{i,imax}]  when  Table[expr,{imax}]  will work.
Don't use   Do[expr,{i,imax}]      when  Do[expr,{imax}]  will work.

-------------
Borut replied:

I think the two iterator specifications {i,imax} and {imax} are two
different things, are they not.
For example Table[Random[], {10}]  versus  Table[Random[]+i, {i,imax}]
------------

I was saying that (for example) one shouldn't use  
   Table[ Random[], {i, 100000}]  
but instead use   
   Table[ Random, {100000}]  
because the later form gives the same result in less time.  In summary don't
specify a variable for an iterator, if it isn't used.  When you specify a
variable for an iterator, the kernel has to do extra work to maintain the
variable.  

--------
Regards,
  Ted Ersek



  • Prev by Date: Re: Is it doable in Mathematica? How?
  • Next by Date: Is Sort stable?
  • Previous by thread: check this one also
  • Next by thread: Is Sort stable?