Re: Setting and Unsetting values, memory usage problems.
- To: mathgroup at smc.vnet.net
- Subject: [mg79682] Re: Setting and Unsetting values, memory usage problems.
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Wed, 1 Aug 2007 05:16:06 -0400 (EDT)
- Organization: Uni Leipzig
- References: <f8n1sl$k1d$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
Hi,
what mean "store the last 4-5", because I have no idea in what order
you address the arguments.
The code to remove *all* the stored values would be
ClearDynamicDefinitions[
f_Symbol] := (DownValues[f] =
Complement[DownValues[f],
Select[DownValues[f], FreeQ[First[#], Pattern] &]])
It may be, that it is easyer to remove all stored values after
50 or 60 calls of the function f ..
Regards
Jens
Lyle Gordon wrote:
> I have a function defined like this
>
> f[a_, b_] := f[a,b] = the function f (returns an interpolating
> function)
>
> f2[a_, b_, c_] := f[a,b] /.t -> c
>
> I use this to store each solution of the function f[a,b] so that I can
> then evaluate it at each time point (f2[a,b,c]) for the specific a & b
> without re-evaluating the entire thing (f[a,b]) for each time point.
> The problem is that each interpolating function is very large in
> memory and the function gets called for many different pairs of a & b
> and eventually I run out of memory before the code completes (I have
> 4gigs). The thing is I don't need to store more than the few most
> recent values of f[a,b], however not storing any makes the code too
> slow to be usable as f has to be evaluated for everytime point (8000
> points). I was wondering if there is a way to code the function to
> only store the last 4-5 values of f[a,b] or even just the most recent
> one.
>
> Hopefully this makes sense and someone can help.
>
> Thanks,
> Lyle Gordon
>
>