
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?

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

On Sat, 22 Jan 2011, Grigory Sarnitskiy wrote:
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.
Incidentally I am currently working on a function representation based on Gaussians. It supports exact Fourier transform, convolution, but not division and composition. http://code.haskell.org/numericprelude/src/MathObj/Gaussian/Polynomial.hs http://users.informatik.uni-halle.de/~thielema/Research/fourieralgebra.pdf
Is there some libraries which allow me to work with functions as if their type was (Double -> Double), but indeed it was something faster?
No, you have to use a special type for the particular function representation and use an 'apply' function, that converts your representation to a real function: apply :: FunctionRepresentation a b -> a -> b You can also define an infix operator ($$) :: FunctionRepresentation a b -> a -> b and then write f $$ x where you would have written (f x) if 'f' would be a function and not a function representation.

On Sat, 22 Jan 2011, Henning Thielemann wrote:
http://code.haskell.org/numericprelude/src/MathObj/Gaussian/Polynomial.hs
a hyphen was missing: http://code.haskell.org/numeric-prelude/src/MathObj/Gaussian/Polynomial.hs
participants (3)
-
Gershom Bazerman
-
Grigory Sarnitskiy
-
Henning Thielemann