MathGroup Archive 2009

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

Search the Archive

Compute once question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105627] Compute once question
  • From: Michael Greene <mgreene at csumb.edu>
  • Date: Sat, 12 Dec 2009 06:55:32 -0500 (EST)

I'm having trouble getting Mathematica not to repeatedly compute values in a
Manipulate Window. I'm not sure if it's a bug in my code or if it's a
fundamental disconnect between what I think is going on and what Mathematica
is actually doing.

What my code is doing is slicing a circle into segments, rotating the slices
and then translating them. When  the process first starts out, I'm dealing
with a small number of slices so the response is immediate. The process
eventually works up to around 20 slices and the user begins to see a slight
delay between manipulating the controller and seeing the result. At 100
slices, we're talking about a 3 or 4 second lag which isn't OK.

When I first started the process, I was allowing the user to directly
manipulate the slice count. When I saw the lags starting to kick in, I
thought I'd just let the user control a step counter instead and based on
which step the user was on, compute the graphic, store the graphic and reuse
the stored graphic as we moved further into the process. That is:

If[Step<=8, <do intensive computation and store graphic in G>];
Graphics[G];

So when Step gets to 9, I expect G to pop up on the screen right away but it
doesn't. The program still takes several seconds as if it's recomputing G.
Am I wrong to expect Mathematica to only compute G when Step is less than 9?
I'd post the actual code but it's rather hoary. Hopefully my question still
makes sense sans code.

 What I'd really like to be able to do is timeslice G's computation in the
earlier steps when the user is spending time assimilating the earlier
information so by the time he/she gets to the computationally expensive
step, the work is done and G just pops onto the screen as if it's no big
deal. But first things first...

Thanks,
Michael



  • Prev by Date: Re: Re: Play Command Error
  • Next by Date: Re: Import from web addresses fails
  • Previous by thread: Re: Having problems finding skeleton of a binary image
  • Next by thread: Re: Compute once question