lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi:

On Thu, Oct 31, 2013 at 3:41 PM, Fidelis Assis <fidelis.assis@gmail.com> wrote:
>> > Isn't that procedure the same as in tables of logarithms and
>> > trigonometric
>> > functions?
>> Whow, I did USE those, although they were dissapearing.
> Me too, and slide rules in an *advanced* stage :) - I still keep my old
> Aristo Hiperlog as a precious antique. But I think you're talking about
> implementation details like if one buys or constructs their tables,
> pre-computes all or does it on the fly, etc. That doesn't change the ideia,
> IMHO.

The buy or precompute is just a detail, just stated it as the
logarithm table was a book I bought, idea will be the same if you had
the resources to precompute them. The point is tables are computed for
the whole domain of function input parameters, while memoization is a
kind of cache used only for the things you do need. Something like the
disk cache is a kind of memoization, you only have the used sectors in
ram, if it where a lookup table you would have to preload your whole
disk before starting ( and have a lot of ram ). Full tables, if
attainable, are normally a lot more efficient to use than memoization
tables. Say, in a .01 radians sin table you can use an 629 element
array with a very simple multiply, int, index lookup, and you'll build
it in a nice thight loop at start, memoizing sin will need to use
something like a dictionary table ( of course, for something as simple
as sin and with a so small result you could use an array prepopulated
to 2 for the uninitialized values instead of a hash table or a tree ).

Francisco Olarte.