MathGroup Archive 2003

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

Search the Archive

Re: Caching of values and delayed sets

  • To: mathgroup at
  • Subject: [mg39705] Re: Caching of values and delayed sets
  • From: Nafod40 <may106 at>
  • Date: Mon, 3 Mar 2003 04:25:05 -0500 (EST)
  • Organization: Penn State University, Center for Academic Computing
  • References: <b3pgdu$7hr$> <b3rt4q$dnr$>
  • Sender: owner-wri-mathgroup at

Thanks for the answers, guys. Let me make it a little more complicated. Between
two evaluations of A the value for slow[ ] might change. It won't change during
an evaluation of A, but it will change between one evaluation and another.

What I do now, that works for my problem fine is to say...

eval = Block[{C = slow[ ]}, A];

This does what I need for the trivial problem I posed, but I might have a whole
slew of slow computations that get repeated in a single evaluation of A. I'd like
to have each of them run once and cache, but I'd like to not have to go through
the trouble of identifying them. Currently I have large expressions for a
variable like A that call functions like C:= slow[ ] repeatedly, and it is
slowing down the calculating of A something firece.

I don't think it can be done simply, but figured it would not hurt to ask.

Orestis Vantzos wrote:

> C:=(C=slow[...])
> should work...
> Orestis
> may106 at (Nafod40) wrote in message news:<b3pgdu$7hr$1 at>...
> > Hola Amigos,
> >
> > I have a variable A that depends via a delayed set on variables B1
> > through B1000 that each depend via delayed set on variable C and other
> > a mixture of the other B's, which delayed set depends on some slow to
> > calculate function C:= slow[ ]. If you explode out the tree view of A
> > symbolically, the variable C might appear 5000 times in a messy
> > acyclic dependency graph.
> >
> > How do I inject some smarts, so that, when asking for the value of A,
> > I only evaluate C:=slow[ ] once, and cache it and use the cached value
> > for every other time that I need C?

  • Prev by Date: How to evaluate a NIntegrate expression properly
  • Next by Date: RE: Incrementing a "For" loop - "For loop.nb" 5893 Bytes yEnc
  • Previous by thread: Re: Caching of values and delayed sets
  • Next by thread: Re: Caching of values and delayed sets