PDA

View Full Version : Memoization (extended) in ThinBasic



RobbeK
17-03-2014, 11:49
Hi all,

While memoization in principle remembers one result, stores it in case to be used again (avoided calculations) it is easely extended into a table.
I wrote this first in Lisp (where the list (array) is built anyway).
At first sight it looks very memory consuming , however a table can be built storing every tenth result or so. Most functions can be interpolated (Lin/parabolic etc...) with accurate results.

(maybe JITtable is the more correct word here ;-)

IMHO an aspect of dynamic programming that's very interesting !

best Rob

It does the sum of the Harmonic series - it crawls very slow to infinity (the sum of 1/p where p is prime also does so - even slower )

ErosOlmi
17-03-2014, 19:02
Hi Rob,

if you need this function I can add it in Math module.
If compiled in module it will be very fast in script.

Let me know and if yes, just give me the name of the function you would like and a few description or a reference on the web

Ciao
Eros

RobbeK
17-03-2014, 21:28
Hi Eros,

That's very kind !
... it's only a demonstration of recycling results of previous calculations , giving upto 1000x speed increases during further calculations ...
Don't need the function (but of course tante grazie !! -- !! )

Rob