[Haskell-cafe] Effective function representation.
Henning Thielemann
lemming at henning-thielemann.de
Sat Jan 22 21:12:28 CET 2011
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.
More information about the Haskell-Cafe
mailing list