Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Algorithm Analysis Course: Should I use Mathematica for projects? //oops, typos

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127288] Re: Algorithm Analysis Course: Should I use Mathematica for projects? //oops, typos
  • From: Richard Fateman <fateman at cs.berkeley.edu>
  • Date: Sat, 14 Jul 2012 01:29:28 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

On 7/12/2012 11:57 PM, Richard Fateman wrote:

Sorry, some errors crept into my demo examples as I tried
to simplify them for inclusion in the email...


>
> An example.
>
> Create 3 arrays.
>
> A=Table[i,{i,0,100}];
> B=Table[i,{i,0,1000}];
> Q=Table[i,{i,0,10000}];
>
> Try updating the 50th element of each of these items, which look like
> arrays in Mathematica.
>
> Timing [A[[50]],{i,0,100000}]

Should be Timing[Do[A[[50]]++, {i, 0, 100000}]].  My computer reports 
0.281 sec
>
> Timing [B[[50]],{i,0,100000}]
Should be B[[5]]=j; Timing[Do[B[[50]]++, {i, 0, 100000}]].  My computer 
reports 1.266 sec
>
> Timing [Q[[50]],{i,0,100000}]

Should be Timing[Do[Q[[50]]++, {i, 0, 100000}]].  My computer reports 
0.421 sec
>

Apologies for sowing confusion unnecessarily.
RJF




  • Prev by Date: Re: Algorithm Analysis Course: Should I use Mathematica for projects?
  • Next by Date: Re: Replace, ReplaceAll and If time performace comparition
  • Previous by thread: estimated variance on parameter fit
  • Next by thread: Re: Embedded HTML CDF rendered as grey box.