2 ;;; File: interpolation.cl
3 ;;; Description: interpolation for the clem matrix package
4 ;;; Author: Cyrus Harmon
10 (defmacro bilinear-interpolate
12 (ch-util::once-only
(g00 g01 g10 g11 a b
)
16 (* ,a
,b
(- (+ ,g00
,g11
)
19 (defmacro quadratic-kernel
(s type
)
20 (let ((minus-half (coerce -
0.5 `,type
))
21 (half (coerce 0.5 `,type
))
22 (minus-one-point-five (coerce -
1.5 `,type
))
23 (one-point-five (coerce 1.5 `,type
))
24 (five (coerce 5 `,type
))
25 (minus-two (coerce -
2 `,type
))
26 (two (coerce 2 `,type
))
27 (one (coerce 1 `,type
))
28 (zero (coerce 0 `,type
)))
29 `(cond ((<= ,minus-half
,s
,half
)
30 (+ (* ,minus-two
(* ,s
,s
)) ,one
))
31 ((<= ,minus-one-point-five
,s
,one-point-five
)
32 (+ (* ,s
,s
) (- (/ (* ,five
(abs ,s
)) ,two
)) ,one-point-five
))
35 (defmacro quadratic-interpolate
40 `(let ((a0 (quadratic-kernel (- -
1, a
) ,type
))
41 (a1 (quadratic-kernel (- ,a
) ,type
))
42 (a2 (quadratic-kernel (- 1 ,a
) ,type
))
43 (b0 (quadratic-kernel (- -
1 ,b
) ,type
))
44 (b1 (quadratic-kernel (- ,b
) ,type
))
45 (b2 (quadratic-kernel (- 1 ,b
) ,type
)))
46 (+ (* a0
(+ (* b0
,g00
)