]> gitweb.michael.orlitzky.com - spline3.git/blob - src/Tests/Grid.hs
Move all of the trilinear coefficient tests into the Tests.Grid module.
[spline3.git] / src / Tests / Grid.hs
1 module Tests.Grid
2 where
3
4 import Data.Maybe (fromJust)
5 import Test.HUnit
6 import Test.QuickCheck
7
8 import Assertions
9 import Comparisons
10 import Cube
11 import Grid
12 import Misc
13 import Point
14 import Tetrahedron
15
16
17 instance Arbitrary Grid where
18 arbitrary = do
19 (Positive h') <- arbitrary :: Gen (Positive Double)
20 fv <- arbitrary :: Gen [[[Double]]]
21 return (make_grid h' fv)
22
23
24 -- | Values of the function f(x,y,z) = 1 + x + xy + xyz taken at nine
25 -- points (hi, hj, jk) with h = 1. From example one in the paper.
26 -- Used in the next bunch of tests.
27 trilinear :: [[[Double]]]
28 trilinear = [ [ [ 1, 2, 3 ],
29 [ 1, 3, 5 ],
30 [ 1, 4, 7 ] ],
31 [ [ 1, 2, 3 ],
32 [ 1, 4, 7 ],
33 [ 1, 6, 11 ] ],
34 [ [ 1, 2, 3 ],
35 [ 1, 5, 9 ],
36 [ 1, 8, 15 ]]]
37
38 -- | Check the value of c0030 for tetrahedron0 belonging to the
39 -- cube centered on (1,1,1) with a grid constructed from the
40 -- trilinear values. See example one in the paper.
41 test_trilinear_c0030 :: Test
42 test_trilinear_c0030 =
43 TestCase $ assertAlmostEqual "c0030 is correct" (c t 0 0 3 0) (17/8)
44 where
45 g = make_grid 1 trilinear
46 cube = fromJust $ cube_at g 1 1 1
47 t = tetrahedron0 cube
48
49
50 -- | Check the value of c0003 for tetrahedron0 belonging to the
51 -- cube centered on (1,1,1) with a grid constructed from the
52 -- trilinear values. See example one in the paper.
53 test_trilinear_c0003 :: Test
54 test_trilinear_c0003 =
55 TestCase $ assertAlmostEqual "c0003 is correct" (c t 0 0 0 3) (27/8)
56 where
57 g = make_grid 1 trilinear
58 cube = fromJust $ cube_at g 1 1 1
59 t = tetrahedron0 cube
60
61
62 -- | Check the value of c0021 for tetrahedron0 belonging to the
63 -- cube centered on (1,1,1) with a grid constructed from the
64 -- trilinear values. See example one in the paper.
65 test_trilinear_c0021 :: Test
66 test_trilinear_c0021 =
67 TestCase $ assertAlmostEqual "c0021 is correct" (c t 0 0 2 1) (61/24)
68 where
69 g = make_grid 1 trilinear
70 cube = fromJust $ cube_at g 1 1 1
71 t = tetrahedron0 cube
72
73
74 -- | Check the value of c0012 for tetrahedron0 belonging to the
75 -- cube centered on (1,1,1) with a grid constructed from the
76 -- trilinear values. See example one in the paper.
77 test_trilinear_c0012 :: Test
78 test_trilinear_c0012 =
79 TestCase $ assertAlmostEqual "c0012 is correct" (c t 0 0 1 2) (71/24)
80 where
81 g = make_grid 1 trilinear
82 cube = fromJust $ cube_at g 1 1 1
83 t = tetrahedron0 cube
84
85
86 -- | Check the value of c0120 for tetrahedron0 belonging to the
87 -- cube centered on (1,1,1) with a grid constructed from the
88 -- trilinear values. See example one in the paper.
89 test_trilinear_c0120 :: Test
90 test_trilinear_c0120 =
91 TestCase $ assertAlmostEqual "c0120 is correct" (c t 0 1 2 0) (55/24)
92 where
93 g = make_grid 1 trilinear
94 cube = fromJust $ cube_at g 1 1 1
95 t = tetrahedron0 cube
96
97
98 -- | Check the value of c0102 for tetrahedron0 belonging to the
99 -- cube centered on (1,1,1) with a grid constructed from the
100 -- trilinear values. See example one in the paper.
101 test_trilinear_c0102 :: Test
102 test_trilinear_c0102 =
103 TestCase $ assertAlmostEqual "c0102 is correct" (c t 0 1 0 2) (73/24)
104 where
105 g = make_grid 1 trilinear
106 cube = fromJust $ cube_at g 1 1 1
107 t = tetrahedron0 cube
108
109
110 -- | Check the value of c0111 for tetrahedron0 belonging to the
111 -- cube centered on (1,1,1) with a grid constructed from the
112 -- trilinear values. See example one in the paper.
113 test_trilinear_c0111 :: Test
114 test_trilinear_c0111 =
115 TestCase $ assertAlmostEqual "c0111 is correct" (c t 0 1 1 1) (8/3)
116 where
117 g = make_grid 1 trilinear
118 cube = fromJust $ cube_at g 1 1 1
119 t = tetrahedron0 cube
120
121
122 -- | Check the value of c0210 for tetrahedron0 belonging to the
123 -- cube centered on (1,1,1) with a grid constructed from the
124 -- trilinear values. See example one in the paper.
125 test_trilinear_c0210 :: Test
126 test_trilinear_c0210 =
127 TestCase $ assertAlmostEqual "c0210 is correct" (c t 0 2 1 0) (29/12)
128 where
129 g = make_grid 1 trilinear
130 cube = fromJust $ cube_at g 1 1 1
131 t = tetrahedron0 cube
132
133
134 -- | Check the value of c0201 for tetrahedron0 belonging to the
135 -- cube centered on (1,1,1) with a grid constructed from the
136 -- trilinear values. See example one in the paper.
137 test_trilinear_c0201 :: Test
138 test_trilinear_c0201 =
139 TestCase $ assertAlmostEqual "c0201 is correct" (c t 0 2 0 1) (11/4)
140 where
141 g = make_grid 1 trilinear
142 cube = fromJust $ cube_at g 1 1 1
143 t = tetrahedron0 cube
144
145
146 -- | Check the value of c0300 for tetrahedron0 belonging to the
147 -- cube centered on (1,1,1) with a grid constructed from the
148 -- trilinear values. See example one in the paper.
149 test_trilinear_c0300 :: Test
150 test_trilinear_c0300 =
151 TestCase $ assertAlmostEqual "c0300 is correct" (c t 0 3 0 0) (5/2)
152 where
153 g = make_grid 1 trilinear
154 cube = fromJust $ cube_at g 1 1 1
155 t = tetrahedron0 cube
156
157
158 -- | Check the value of c1020 for tetrahedron0 belonging to the
159 -- cube centered on (1,1,1) with a grid constructed from the
160 -- trilinear values. See example one in the paper.
161 test_trilinear_c1020 :: Test
162 test_trilinear_c1020 =
163 TestCase $ assertAlmostEqual "c1020 is correct" (c t 1 0 2 0) (8/3)
164 where
165 g = make_grid 1 trilinear
166 cube = fromJust $ cube_at g 1 1 1
167 t = tetrahedron0 cube
168
169
170 -- | Check the value of c1002 for tetrahedron0 belonging to the
171 -- cube centered on (1,1,1) with a grid constructed from the
172 -- trilinear values. See example one in the paper.
173 test_trilinear_c1002 :: Test
174 test_trilinear_c1002 =
175 TestCase $ assertAlmostEqual "c1002 is correct" (c t 1 0 0 2) (23/6)
176 where
177 g = make_grid 1 trilinear
178 cube = fromJust $ cube_at g 1 1 1
179 t = tetrahedron0 cube
180
181
182 -- | Check the value of c1011 for tetrahedron0 belonging to the
183 -- cube centered on (1,1,1) with a grid constructed from the
184 -- trilinear values. See example one in the paper.
185 test_trilinear_c1011 :: Test
186 test_trilinear_c1011 =
187 TestCase $ assertAlmostEqual "c1011 is correct" (c t 1 0 1 1) (13/4)
188 where
189 g = make_grid 1 trilinear
190 cube = fromJust $ cube_at g 1 1 1
191 t = tetrahedron0 cube
192
193
194 -- | Check the value of c1110 for tetrahedron0 belonging to the
195 -- cube centered on (1,1,1) with a grid constructed from the
196 -- trilinear values. See example one in the paper.
197 test_trilinear_c1110 :: Test
198 test_trilinear_c1110 =
199 TestCase $ assertAlmostEqual "c1110 is correct" (c t 1 1 1 0) (23/8)
200 where
201 g = make_grid 1 trilinear
202 cube = fromJust $ cube_at g 1 1 1
203 t = tetrahedron0 cube
204
205
206 -- | Check the value of c1101 for tetrahedron0 belonging to the
207 -- cube centered on (1,1,1) with a grid constructed from the
208 -- trilinear values. See example one in the paper.
209 test_trilinear_c1101 :: Test
210 test_trilinear_c1101 =
211 TestCase $ assertAlmostEqual "c1101 is correct" (c t 1 1 0 1) (27/8)
212 where
213 g = make_grid 1 trilinear
214 cube = fromJust $ cube_at g 1 1 1
215 t = tetrahedron0 cube
216
217
218 -- | Check the value of c1200 for tetrahedron0 belonging to the
219 -- cube centered on (1,1,1) with a grid constructed from the
220 -- trilinear values. See example one in the paper.
221 test_trilinear_c1200 :: Test
222 test_trilinear_c1200 =
223 TestCase $ assertAlmostEqual "c1200 is correct" (c t 1 2 0 0) 3
224 where
225 g = make_grid 1 trilinear
226 cube = fromJust $ cube_at g 1 1 1
227 t = tetrahedron0 cube
228
229
230 -- | Check the value of c2010 for tetrahedron0 belonging to the
231 -- cube centered on (1,1,1) with a grid constructed from the
232 -- trilinear values. See example one in the paper.
233 test_trilinear_c2010 :: Test
234 test_trilinear_c2010 =
235 TestCase $ assertAlmostEqual "c2010 is correct" (c t 2 0 1 0) (10/3)
236 where
237 g = make_grid 1 trilinear
238 cube = fromJust $ cube_at g 1 1 1
239 t = tetrahedron0 cube
240
241
242 -- | Check the value of c2001 for tetrahedron0 belonging to the
243 -- cube centered on (1,1,1) with a grid constructed from the
244 -- trilinear values. See example one in the paper.
245 test_trilinear_c2001 :: Test
246 test_trilinear_c2001 =
247 TestCase $ assertAlmostEqual "c2001 is correct" (c t 2 0 0 1) 4
248 where
249 g = make_grid 1 trilinear
250 cube = fromJust $ cube_at g 1 1 1
251 t = tetrahedron0 cube
252
253
254 -- | Check the value of c2100 for tetrahedron0 belonging to the
255 -- cube centered on (1,1,1) with a grid constructed from the
256 -- trilinear values. See example one in the paper.
257 test_trilinear_c2100 :: Test
258 test_trilinear_c2100 =
259 TestCase $ assertAlmostEqual "c2100 is correct" (c t 2 1 0 0) (7/2)
260 where
261 g = make_grid 1 trilinear
262 cube = fromJust $ cube_at g 1 1 1
263 t = tetrahedron0 cube
264
265
266 -- | Check the value of c3000 for tetrahedron0 belonging to the
267 -- cube centered on (1,1,1) with a grid constructed from the
268 -- trilinear values. See example one in the paper.
269 test_trilinear_c3000 :: Test
270 test_trilinear_c3000 =
271 TestCase $ assertAlmostEqual "c3000 is correct" (c t 3 0 0 0) 4
272 where
273 g = make_grid 1 trilinear
274 cube = fromJust $ cube_at g 1 1 1
275 t = tetrahedron0 cube
276
277
278 -- | A list of all HUnit tests defined in this module.
279 grid_tests :: [Test]
280 grid_tests =
281 [test_trilinear_c0030,
282 test_trilinear_c0003,
283 test_trilinear_c0021,
284 test_trilinear_c0012,
285 test_trilinear_c0120,
286 test_trilinear_c0102,
287 test_trilinear_c0111,
288 test_trilinear_c0210,
289 test_trilinear_c0201,
290 test_trilinear_c0300,
291 test_trilinear_c1020,
292 test_trilinear_c1002,
293 test_trilinear_c1011,
294 test_trilinear_c1110,
295 test_trilinear_c1101,
296 test_trilinear_c1200,
297 test_trilinear_c2010,
298 test_trilinear_c2001,
299 test_trilinear_c2100,
300 test_trilinear_c3000]