[Haskell-cafe] Effective function representation.
Gershom Bazerman
gershomb at gmail.com
Sat Jan 22 15:53:49 CET 2011
> Hello!
>
> I need to deal with functions of type (Double -> Double). I need Fourier transform, integration, + - * / operations, value of a function in a point, probably composition.
>
> However it is not very effective to use straightforwardly this type. Since functions in question are rather smooth (if not analytical), the best option would be to use some kind of pointwise representation (e.g. lists, arrays). But in this case the code wouldn't be so easy to understand and implement, compact and so on.
>
> Is there some libraries which allow me to work with functions as if their type was (Double -> Double), but indeed it was something faster?
Lazy polynomial splines: http://hackage.haskell.org/package/lazysplines
Lazy polynomial splines are potentially infinite sequences of segments represented by polynomials. They're a very straightforward abstraction for functions which can be treated as piecewise analytic. They provide efficient addition, subtraction integration and differentiation. Multiplication and composition can be more expensive, and division by a non-scalar can, if one is not careful, be somewhat disastrous. The package was intended as much as a proof-of-concept as for production. But the concept is simple enough that you should be able to tune it to your needs.
Cheers,
Gershom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110122/1d9062d5/attachment.htm>
More information about the Haskell-Cafe
mailing list