module Numeric.Interpolation.Piecewise (
interpolate,
interpolateConstantExt,
) where
import qualified Numeric.Interpolation.NodeList as Nodes
import qualified Numeric.Interpolation.Type as Type
interpolate :: (Ord x) => Type.T x y ny -> Nodes.T x ny -> x -> y
interpolate typ ns x =
case Nodes.lookup ns x of
(Just p0, Just p1) -> Type.interpolatePiece typ p0 p1 x
_ -> error "interpolate: argument outside range"
interpolateConstantExt ::
(Ord x) => Type.T x y ny -> Nodes.T x ny -> x -> y
interpolateConstantExt typ ns x =
case Nodes.lookup ns x of
(Just p0, Just p1) -> Type.interpolatePiece typ p0 p1 x
(Just p, Nothing) -> Type.valueFromNode typ $ snd p
(Nothing, Just p) -> Type.valueFromNode typ $ snd p
(Nothing, Nothing) -> error "interpolateConstantExt: empty node list"