Home My Page Projects Code Snippets Project Openings diderot

# SCM Repository

[diderot] Diff of /trunk/src/compiler/IL/kernel.sml
 [diderot] / trunk / src / compiler / IL / kernel.sml # Diff of /trunk/src/compiler/IL/kernel.sml

revision 127, Tue Jun 29 20:08:28 2010 UTC revision 135, Fri Jul 2 21:57:47 2010 UTC
# Line 16  Line 16
16      type polynomial = coefficient list      type polynomial = coefficient list
17
18      type kernel = {      type kernel = {
19            name : string,
20          support : int,          (* number of samples to left/right *)          support : int,          (* number of samples to left/right *)
21          segs : polynomial list, (* piece-wise polynomial that defines the kernel.  Since *)          segs : polynomial list  (* piece-wise polynomial that defines the kernel.  Since *)
22                                  (* a kernel is symmetric, we only store the positive *)                                  (* a kernel is symmetric, we only store the positive *)
23                                  (* segments, with segs[i] covering the domain [i,i+1) *)                                  (* segments, with segs[i] covering the domain [i,i+1) *)
24        }        }
# Line 41  Line 42
42      type polynomial = coefficient list      type polynomial = coefficient list
43
44      type kernel = {      type kernel = {
45            name : string,
46          support : int,          (* number of samples to left/right *)          support : int,          (* number of samples to left/right *)
47          segs : polynomial list, (* piece-wise polynomial that defines the *)          segs : polynomial list  (* piece-wise polynomial that defines the *)
48                                  (* kernel; there are 2*support segments *)                                  (* kernel; there are 2*support segments *)
49        }        }
50
# Line 50  Line 52
52        | differentiate [_] = [zero]        | differentiate [_] = [zero]
53        | differentiate (_::coeffs) = let        | differentiate (_::coeffs) = let
54            fun lp (_, []) = []            fun lp (_, []) = []
55              | lp (i, c::r) = R.mul(F.fromInt i, c) :: lp(i+1, r)              | lp (i, c::r) = R.mul(R.fromInt i, c) :: lp(i+1, r)
56            in            in
57              lp (1, coeffs)              lp (1, coeffs)
58            end            end
# Line 59  Line 61
61      fun evaluate (poly, x) = let      fun evaluate (poly, x) = let
62            val x = F.fromInt x            val x = F.fromInt x
63            fun eval (sum, [], xn) = sum            fun eval (sum, [], xn) = sum
64              | eval (sum, c::r, xn) = eval(F.add(sum, R.mul(c, xn)), r, R.mul(x, xn))              | eval (sum, c::r, xn) = eval(R.add(sum, R.mul(c, xn)), r, R.mul(x, xn))
65            in            in
66              eval (zero, poly, one)              eval (zero, poly, one)
67            end            end
# Line 70  Line 72
72        fun r i = R.fromInt i        fun r i = R.fromInt i
73      in      in
74      val tent : kernel = {       (* linear interpolation *)      val tent : kernel = {       (* linear interpolation *)
75                name = "tent",
76              support = 1,              support = 1,
77              segs = [[r 1, r ~1]]              segs = [[r 1, r ~1]]
78            }            }
79      val ctmr : kernel = {       (* Catmull-Rom interpolation *)      val ctmr : kernel = {       (* Catmull-Rom interpolation *)
80                name = "ctmr",
81              support = 2,              support = 2,
82              segs = [              segs = [
83                  [r 1, r 0, ~5/2, 3/2],                  [r 1, r 0, ~5/2, 3/2],
# Line 81  Line 85
85                ]                ]
86            }            }
87      val bspl3 : kernel = {      (* cubic bspline reconstruction, doesn't interpolate *)      val bspl3 : kernel = {      (* cubic bspline reconstruction, doesn't interpolate *)
88                name = "bspl3",
89              support = 2,              support = 2,
90              segs = [              segs = [
91                  [ 2/3, r 0, r ~1, 1/2 ],                  [ 2/3, r 0, r ~1, 1/2 ],
92                  [ 4/3, r ~2, r 1, ~1/6 ]'                  [ 4/3, r ~2, r 1, ~1/6 ]
93                ]                ]
94            }            }
95      val bspl5 : kernel = {      (* quintic bspline reconstruction, doesn't interpolate *)      val bspl5 : kernel = {      (* quintic bspline reconstruction, doesn't interpolate *)
96                name = "bspl5",
97              support = 3,              support = 3,
98              segs = [              segs = [
99                  [ 11/20, r 0, ~1/2, r 0, 1/4, ~1/12 ],                  [ 11/20, r 0, ~1/2, r 0, 1/4, ~1/12 ],

Legend:
 Removed from v.127 changed lines Added in v.135