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

Claude Heiland-Allen claude at goto10.org
Sun Jan 23 17:52:56 CET 2011


Hi Phil,

On 22/01/11 23:13, gutti wrote:
> - are  t a b c d points or curve parameters ?

a b c d are points, t is the interpolation coefficient (between 0 and 1)

> - how does lifting to matrix create a 1d spline to a 2d spline ? -- I don't
> see how it works

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:


-- using the cubic interpolator from earlier in the thread
m @@>+ (x, y) =
   let (i, j) = (floor x, floor y)
       (s, t) = (x - fromIntegral i, y - fromIntegral j)
       cx j' = cubic s (m@@>(i-1,j')) (m@@>(i,j')) (m@@>(i+1,j')) 
(m@@>(i+2,j'))
   in  cubic t (cx (j-1)) (cx j) (cx (j+1)) (cx (j+2))

test =
   let m = (16><16) [0 ..]
       n = 36
       r = 5
       (x0, y0) = (8, 8)
   in  [ m @@>+ (x, y)
       | a <- [0 .. n - 1]
       , let a' = 2 * pi * fromIntegral a / fromIntegral n
       , let x = x0 + r * cos a'
       , let y = y0 + r * sin a'
       ]


Claude
-- 
http://claudiusmaximus.goto10.org



More information about the Haskell-Cafe mailing list