[Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??

Henning Thielemann lemming at henning-thielemann.de
Sun Jan 23 21:17:41 CET 2011


On Sun, 23 Jan 2011, Claude Heiland-Allen wrote:

> essentially, it creates a matrix of 1d splines, but now I see that this isn't 
> what you wanted...
>
> for interpolated 2d matrix lookup, something like this, perhaps:

Interpolated matrix or vector lookup can of course be written as 
interpolation of sub-matrices or sub-vectors. For lazy matrices and 
vectors this would be almost as efficient.

interp i v =
    vectorIndex (floor i) $
    interpolateVectorSpace (fraction i)
       (Vector.take (n-3) $ Vector.drop 0 v)
       (Vector.take (n-3) $ Vector.drop 1 v)
       (Vector.take (n-3) $ Vector.drop 2 v)
       (Vector.take (n-3) $ Vector.drop 3 v)

(Sorry for the many fictional functions.)



More information about the Haskell-Cafe mailing list