]> gitweb.michael.orlitzky.com - spline3.git/blob - src/Examples.hs
0e805a49d7a33c8128cb53f0f774deb27d24323f
[spline3.git] / src / Examples.hs
1 module Examples (
2 naturals,
3 naturals_1d,
4 trilinear,
5 trilinear_zoom_2,
6 trilinear9x9x9,
7 zeros
8 )
9 where
10
11 import qualified Data.Array.Repa as Repa
12
13 import Misc (flatten, transpose_xz)
14 import Values (Values3D)
15
16
17 -- | Values of the function f(x,y,z) = 1 + x + xy + xyz taken at nine
18 -- points (hi, hj, jk) with h = 1. From example one in the paper.
19 -- Used in the next bunch of tests.
20 trilinear_list :: [[[Double]]]
21 trilinear_list = [ [ [ 1, 2, 3 ],
22 [ 1, 3, 5 ],
23 [ 1, 4, 7 ] ],
24 [ [ 1, 2, 3 ],
25 [ 1, 4, 7 ],
26 [ 1, 6, 11 ] ],
27 [ [ 1, 2, 3 ],
28 [ 1, 5, 9 ],
29 [ 1, 8, 15 ]]]
30
31
32 n_cube :: Int -> Repa.DIM3
33 n_cube n = (Repa.Z Repa.:. n Repa.:. n Repa.:. n)
34
35 trilinear :: Values3D
36 trilinear = Repa.fromListUnboxed (n_cube 3) $
37 flatten $
38 transpose_xz
39 trilinear_list
40
41
42 -- | Values of the function f(x,y,z) = 1 + x + xy + xyz taken at 5^3
43 -- points (hi, hj, jk) with h = 0.5. We should be able to reproduce
44 -- this from splines based on the 3x3x3 trilinear.
45 trilinear_zoom_2_list :: [[[Double]]]
46 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]]]
47
48 trilinear_zoom_2 :: Values3D
49 trilinear_zoom_2 = Repa.fromListUnboxed (n_cube 6) $
50 flatten $
51 transpose_xz
52 trilinear_zoom_2_list
53
54
55 -- | Values of the function f(x,y,z) = 1 + x + xy + xyz taken at nine^3
56 -- points (hi, hj, jk) with h = 0.5. We should be able to reproduce
57 -- this from splines based on the 3x3x3 trilinear.
58 trilinear9x9x9_list :: [[[Double]]]
59 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]]]
60
61
62 trilinear9x9x9 :: Values3D
63 trilinear9x9x9 = Repa.fromListUnboxed (n_cube 9) $
64 flatten $
65 transpose_xz
66 trilinear9x9x9_list
67
68
69 -- | A 3x3x3 array of zeros.
70 zeros_list :: [[[Double]]]
71 zeros_list = [ [ [ 0, 0, 0 ],
72 [ 0, 0, 0 ],
73 [ 0, 0, 0 ] ],
74
75 [ [ 0, 0, 0 ],
76 [ 0, 0, 0 ],
77 [ 0, 0, 0 ] ],
78
79 [ [ 0, 0, 0 ],
80 [ 0, 0, 0 ],
81 [ 0, 0, 0 ]]]
82
83
84 -- No need to transpose_xz this one.
85 zeros :: Values3D
86 zeros = Repa.fromListUnboxed (n_cube 3) $ flatten zeros_list
87
88
89 -- | A 3x3x3 array of numbers, starting at (0,0,0) == 0 and counting
90 -- up to (2,2,2) == 26 in x,y,z order.
91 naturals_list :: [[[Double]]]
92 naturals_list = [ [ [ 0, 1, 2 ],
93 [ 3, 4, 5 ],
94 [ 6, 7, 8 ] ],
95
96 [ [ 9, 10, 11 ],
97 [ 12, 13, 14 ],
98 [ 15, 16, 17 ] ],
99
100 [ [ 18, 19, 20 ],
101 [ 21, 22, 23 ],
102 [ 24, 25, 26 ]]]
103
104 naturals :: Values3D
105 naturals = Repa.fromListUnboxed (n_cube 3) $
106 flatten $
107 transpose_xz
108 naturals_list
109
110
111
112 naturals_1d_list :: [[[Double]]]
113 naturals_1d_list =[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
114 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]]
115
116
117 twenty_vector :: Repa.DIM3
118 twenty_vector = (Repa.Z Repa.:. 1 Repa.:. 20 Repa.:. 1)
119
120 -- | Used in at least one test where we need a 1x20x1 array.
121 naturals_1d :: Values3D
122 naturals_1d = Repa.fromListUnboxed twenty_vector (flatten naturals_1d_list)