[Haskell-cafe] Memoization of functions
Michael Orlitzky
michael at orlitzky.com
Tue Sep 6 21:16:09 CEST 2011
I'm working on a program where I need to compute a gajillion (171442176)
polynomials and evaluate them more than once. This is the definition of
the polynomial, and it is expensive to compute:
> polynomial :: Tetrahedron -> (RealFunction Point)
> polynomial t =
> sum [ (c t i j k l) `cmult` (beta t i j k l) | i <- [0..3],
> j <- [0..3],
> k <- [0..3],
> l <- [0..3],
> i + j + k + l == 3]
Currently, I'm storing the polynomials in an array, which is quickly
devoured by the OOM killer. This makes me wonder: how much memory can I
expect to use storing a function in an array? Is it possible to save
some space through strictness? Does that question even make sense?
More information about the Haskell-Cafe
mailing list