numeric-tools-0.2.0.1: Collection of numerical tools for integration, differentiation etc.

Portability portable experimental Aleksey Khudyakov None

Numeric.Tools.Interpolation

Description

Function interpolation.

Sine interpolation using cubic splines:

````>>> ````let tbl = cubicSpline \$ tabulateFun (uniformMesh (0,10) 100) sin
````>>> ````tbl `at` 1.786
```0.9769239849844867
```

Synopsis

# Type class

class (IndexVal (interp mesh) ~ (Double, Double), Indexable (interp mesh), IndexVal mesh ~ Double, Mesh mesh) => Interpolation interp mesh whereSource

Type class for Interpolation algorithms. Since some algorithms require some particular mesh type it's present as type class parameter. Every algorithms should be instance of `Indexable` as well. Indexing should return pair `(x,y)` for u'th mesh node.

Methods

at :: interp mesh -> Double -> DoubleSource

Interpolate function at some point. Function should not fail outside of mesh however it may and most likely will give nonsensical results

unsafeTabulate :: Vector v Double => mesh -> v Double -> interp meshSource

Use table of already evaluated function and mesh. Sizes of mesh and table must coincide but it's not checked. Do not use this function use `tabulate` instead.

interpolationMesh :: interp mesh -> meshSource

Get mesh.

interpolationTable :: interp mesh -> Vector DoubleSource

Get table of function values

Instances

 (Mesh mesh, ~ * (IndexVal mesh) Double) => Interpolation CubicSpline mesh (Mesh mesh, ~ * (IndexVal mesh) Double) => Interpolation LinearInterp mesh

tabulate :: (Interpolation i m, Vector v Double) => m -> v Double -> i mSource

Use table of already evaluated function and mesh. Sizes of mesh and table must coincide.

tabulateFun :: Interpolation i m => m -> (Double -> Double) -> i mSource

Tabulate function.

# Linear interpolation

data LinearInterp mesh Source

Data for linear interpolation

Instances

 Typeable1 LinearInterp (Mesh mesh, ~ * (IndexVal mesh) Double) => Interpolation LinearInterp mesh Eq mesh => Eq (LinearInterp mesh) Data mesh => Data (LinearInterp mesh) Show mesh => Show (LinearInterp mesh) (Mesh mesh, ~ * (IndexVal mesh) Double) => Indexable (LinearInterp mesh)

linearInterp :: LinearInterp mesh -> LinearInterp meshSource

Function used to fix types

# Cubic splines

data CubicSpline a Source

Natural cubic splines

Instances

 Typeable1 CubicSpline (Mesh mesh, ~ * (IndexVal mesh) Double) => Interpolation CubicSpline mesh Eq a => Eq (CubicSpline a) Data a => Data (CubicSpline a) Show a => Show (CubicSpline a) (Mesh mesh, ~ * (IndexVal mesh) Double) => Indexable (CubicSpline mesh)

Function used to fix types

# Default methods

defaultInterpSize :: Interpolation i m => i m -> IntSource

Default implementation of `size` for interpolation algorithms.

defaultInterpIndex :: Interpolation i m => i m -> Int -> (Double, Double)Source

Default implementation of `unsafeIndex` for interpolation algorithms.