]> gitweb.michael.orlitzky.com - spline3.git/blob - src/Examples.hs
spline3.cabal: update to v1.0.1.
[spline3.git] / src / Examples.hs
1 module Examples (
2 naturals,
3 naturals_1d,
4 trilinear,
5 trilinear_zoom_2,
6 trilinear9x9x9,
7 zeros )
8 where
9
10 import Data.Array.Repa (
11 (:.)( (:.) ),
12 DIM3,
13 Z( Z ),
14 fromListUnboxed )
15 import Misc ( flatten, transpose_xz )
16 import Values ( Values3D )
17
18
19 -- | Values of the function f(x,y,z) = 1 + x + xy + xyz taken at nine
20 -- points (hi, hj, jk) with h = 1. From example one in the paper.
21 -- Used in the next bunch of tests.
22 --
23 trilinear_list :: [[[Double]]]
24 trilinear_list = [ [ [ 1, 2, 3 ],
25 [ 1, 3, 5 ],
26 [ 1, 4, 7 ] ],
27 [ [ 1, 2, 3 ],
28 [ 1, 4, 7 ],
29 [ 1, 6, 11 ] ],
30 [ [ 1, 2, 3 ],
31 [ 1, 5, 9 ],
32 [ 1, 8, 15 ]]]
33
34
35 n_cube :: Int -> DIM3
36 n_cube n = (Z :. n :. n :. n)
37
38 trilinear :: Values3D
39 trilinear = fromListUnboxed (n_cube 3) $
40 flatten $
41 transpose_xz
42 trilinear_list
43
44
45 -- | Values of the function f(x,y,z) = 1 + x + xy + xyz taken at 5^3
46 -- points (hi, hj, jk) with h = 0.5. We should be able to reproduce
47 -- this from splines based on the 3x3x3 trilinear.
48 trilinear_zoom_2_list :: [[[Double]]]
49 trilinear_zoom_2_list = [[[1, 3/2, 2, 5/2, 3], [1, 7/4, 5/2, 13/4, 4], [1, 2, 3, 4, 5], [1, 9/4, 7/2, 19/4, 6], [1, 5/2, 4, 11/2, 7]], [[1, 3/2, 2, 5/2, 3], [1, 15/8, 11/4, 29/8, 9/2], [1, 9/4, 7/2, 19/4, 6], [1, 21/8, 17/4, 47/8, 15/2], [1, 3, 5, 7, 9]], [[1, 3/2, 2, 5/2, 3], [1, 2, 3, 4, 5], [1, 5/2, 4, 11/2, 7], [1, 3, 5, 7, 9], [1, 7/2, 6, 17/2, 11]], [[1, 3/2, 2, 5/2, 3], [1, 17/8, 13/4, 35/8, 11/2], [1, 11/4, 9/2, 25/4, 8], [1, 27/8, 23/4, 65/8, 21/2], [1, 4, 7, 10, 13]], [[1, 3/2, 2, 5/2, 3], [1, 9/4, 7/2, 19/4, 6], [1, 3, 5, 7, 9], [1, 15/4, 13/2, 37/4, 12], [1, 9/2, 8, 23/2, 15]]]
50
51 trilinear_zoom_2 :: Values3D
52 trilinear_zoom_2 = fromListUnboxed (n_cube 6) $
53 flatten $
54 transpose_xz
55 trilinear_zoom_2_list
56
57
58 -- | Values of the function f(x,y,z) = 1 + x + xy + xyz taken at nine^3
59 -- points (hi, hj, jk) with h = 0.5. We should be able to reproduce
60 -- this from splines based on the 3x3x3 trilinear.
61 trilinear9x9x9_list :: [[[Double]]]
62 trilinear9x9x9_list = [[[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 1.75, 2.5, 3.25, 4, 4.75, 5.5, 6.25, 7], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2.25, 3.5, 4.75, 6, 7.25, 8.5, 9.75, 11], [1, 2.5, 4, 5.5, 7, 8.5, 10, 11.5, 13], [1, 2.75, 4.5, 6.25, 8, 9.75, 11.5, 13.25, 15], [1, 3, 5, 7, 9, 11, 13, 15, 17], [1, 3.25, 5.5, 7.75, 10, 12.25, 14.5, 16.75, 19], [1, 3.5, 6, 8.5, 11, 13.5, 16, 18.5, 21]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 1.875, 2.75, 3.625, 4.5, 5.375, 6.25, 7.125, 8], [1, 2.25, 3.5, 4.75, 6, 7.25, 8.5, 9.75, 11], [1, 2.625, 4.25, 5.875, 7.5, 9.125, 10.75, 12.375, 14], [1, 3, 5, 7, 9, 11, 13, 15, 17], [1, 3.375, 5.75, 8.125, 10.5, 12.875, 15.25, 17.625, 20], [1, 3.75, 6.5, 9.25, 12, 14.75, 17.5, 20.25, 23], [1, 4.125, 7.25, 10.375, 13.5, 16.625, 19.75, 22.875, 26], [1, 4.5, 8, 11.5, 15, 18.5, 22, 25.5, 29]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2.5, 4, 5.5, 7, 8.5, 10, 11.5, 13], [1, 3, 5, 7, 9, 11, 13, 15, 17], [1, 3.5, 6, 8.5, 11, 13.5, 16, 18.5, 21], [1, 4, 7, 10, 13, 16, 19, 22, 25], [1, 4.5, 8, 11.5, 15, 18.5, 22, 25.5, 29], [1, 5, 9, 13, 17, 21, 25, 29, 33], [1, 5.5, 10, 14.5, 19, 23.5, 28, 32.5, 37]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2.125, 3.25, 4.375, 5.5, 6.625, 7.75, 8.875, 10], [1, 2.75, 4.5, 6.25, 8, 9.75, 11.5, 13.25, 15], [1, 3.375, 5.75, 8.125, 10.5, 12.875, 15.25, 17.625, 20], [1, 4, 7, 10, 13, 16, 19, 22, 25], [1, 4.625, 8.25, 11.875, 15.5, 19.125, 22.75, 26.375, 30], [1, 5.25, 9.5, 13.75, 18, 22.25, 26.5, 30.75, 35], [1, 5.875, 10.75, 15.625, 20.5, 25.375, 30.25, 35.125, 40], [1, 6.5, 12, 17.5, 23, 28.5, 34, 39.5, 45]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2.25, 3.5, 4.75, 6, 7.25, 8.5, 9.75, 11], [1, 3, 5, 7, 9, 11, 13, 15, 17], [1, 3.75, 6.5, 9.25, 12, 14.75, 17.5, 20.25, 23], [1, 4.5, 8, 11.5, 15, 18.5, 22, 25.5, 29], [1, 5.25, 9.5, 13.75, 18, 22.25, 26.5, 30.75, 35], [1, 6, 11, 16, 21, 26, 31, 36, 41], [1, 6.75, 12.5, 18.25, 24, 29.75, 35.5, 41.25, 47], [1, 7.5, 14, 20.5, 27, 33.5, 40, 46.5, 53]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2.375, 3.75, 5.125, 6.5, 7.875, 9.25, 10.625, 12], [1, 3.25, 5.5, 7.75, 10, 12.25, 14.5, 16.75, 19], [1, 4.125, 7.25, 10.375, 13.5, 16.625, 19.75, 22.875, 26], [1, 5, 9, 13, 17, 21, 25, 29, 33], [1, 5.875, 10.75, 15.625, 20.5, 25.375, 30.25, 35.125, 40], [1, 6.75, 12.5, 18.25, 24, 29.75, 35.5, 41.25, 47], [1, 7.625, 14.25, 20.875, 27.5, 34.125, 40.75, 47.375, 54], [1, 8.5, 16, 23.5, 31, 38.5, 46, 53.5, 61]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2.5, 4, 5.5, 7, 8.5, 10, 11.5, 13], [1, 3.5, 6, 8.5, 11, 13.5, 16, 18.5, 21], [1, 4.5, 8, 11.5, 15, 18.5, 22, 25.5, 29], [1, 5.5, 10, 14.5, 19, 23.5, 28, 32.5, 37], [1, 6.5, 12, 17.5, 23, 28.5, 34, 39.5, 45], [1, 7.5, 14, 20.5, 27, 33.5, 40, 46.5, 53], [1, 8.5, 16, 23.5, 31, 38.5, 46, 53.5, 61], [1, 9.5, 18, 26.5, 35, 43.5, 52, 60.5, 69]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2.625, 4.25, 5.875, 7.5, 9.125, 10.75, 12.375, 14], [1, 3.75, 6.5, 9.25, 12, 14.75, 17.5, 20.25, 23], [1, 4.875, 8.75, 12.625, 16.5, 20.375, 24.25, 28.125, 32], [1, 6, 11, 16, 21, 26, 31, 36, 41], [1, 7.125, 13.25, 19.375, 25.5, 31.625, 37.75, 43.875, 50], [1, 8.25, 15.5, 22.75, 30, 37.25, 44.5, 51.75, 59], [1, 9.375, 17.75, 26.125, 34.5, 42.875, 51.25, 59.625, 68], [1, 10.5, 20, 29.5, 39, 48.5, 58, 67.5, 77]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2.75, 4.5, 6.25, 8, 9.75, 11.5, 13.25, 15], [1, 4, 7, 10, 13, 16, 19, 22, 25], [1, 5.25, 9.5, 13.75, 18, 22.25, 26.5, 30.75, 35], [1, 6.5, 12, 17.5, 23, 28.5, 34, 39.5, 45], [1, 7.75, 14.5, 21.25, 28, 34.75, 41.5, 48.25, 55], [1, 9, 17, 25, 33, 41, 49, 57, 65], [1, 10.25, 19.5, 28.75, 38, 47.25, 56.5, 65.75, 75], [1, 11.5, 22, 32.5, 43, 53.5, 64, 74.5, 85]]]
63
64
65 trilinear9x9x9 :: Values3D
66 trilinear9x9x9 = fromListUnboxed (n_cube 9) $
67 flatten $
68 transpose_xz
69 trilinear9x9x9_list
70
71
72 -- | A 3x3x3 array of zeros.
73 zeros_list :: [[[Double]]]
74 zeros_list = [ [ [ 0, 0, 0 ],
75 [ 0, 0, 0 ],
76 [ 0, 0, 0 ] ],
77
78 [ [ 0, 0, 0 ],
79 [ 0, 0, 0 ],
80 [ 0, 0, 0 ] ],
81
82 [ [ 0, 0, 0 ],
83 [ 0, 0, 0 ],
84 [ 0, 0, 0 ]]]
85
86
87 -- No need to transpose_xz this one.
88 zeros :: Values3D
89 zeros = fromListUnboxed (n_cube 3) $ flatten zeros_list
90
91
92 -- | A 3x3x3 array of numbers, starting at (0,0,0) == 0 and counting
93 -- up to (2,2,2) == 26 in x,y,z order.
94 naturals_list :: [[[Double]]]
95 naturals_list = [ [ [ 0, 1, 2 ],
96 [ 3, 4, 5 ],
97 [ 6, 7, 8 ] ],
98
99 [ [ 9, 10, 11 ],
100 [ 12, 13, 14 ],
101 [ 15, 16, 17 ] ],
102
103 [ [ 18, 19, 20 ],
104 [ 21, 22, 23 ],
105 [ 24, 25, 26 ]]]
106
107 naturals :: Values3D
108 naturals = fromListUnboxed (n_cube 3) $
109 flatten $
110 transpose_xz
111 naturals_list
112
113
114
115 naturals_1d_list :: [[[Double]]]
116 naturals_1d_list =[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
117 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]]
118
119
120 twenty_vector :: DIM3
121 twenty_vector = (Z :. 1 :. 20 :. 1)
122
123 -- | Used in at least one test where we need a 1x20x1 array.
124 naturals_1d :: Values3D
125 naturals_1d = fromListUnboxed twenty_vector (flatten naturals_1d_list)