]> gitweb.michael.orlitzky.com - spline3.git/blob - src/Tests/Grid.hs
55ca31e4a1455137f42835fdbbaf16e532f686ea
[spline3.git] / src / Tests / Grid.hs
1 module Tests.Grid
2 where
3
4 import Data.Maybe (fromJust)
5 import Test.HUnit
6
7 import Assertions
8 import Comparisons
9 import Cube hiding (i, j, k)
10 import Examples
11 import FunctionValues (value_at)
12 import Grid
13 import Tetrahedron
14
15
16 -- | Check the value of c0030 for tetrahedron0 belonging to the
17 -- cube centered on (1,1,1) with a grid constructed from the
18 -- trilinear values. See example one in the paper.
19 test_trilinear_c0030 :: Assertion
20 test_trilinear_c0030 =
21 assertAlmostEqual "c0030 is correct" (c t 0 0 3 0) (17/8)
22 where
23 g = make_grid 1 trilinear
24 cube = fromJust $ cube_at g 1 1 1
25 t = tetrahedron0 cube
26
27
28 -- | Check the value of c0003 for tetrahedron0 belonging to the
29 -- cube centered on (1,1,1) with a grid constructed from the
30 -- trilinear values. See example one in the paper.
31 test_trilinear_c0003 :: Assertion
32 test_trilinear_c0003 =
33 assertAlmostEqual "c0003 is correct" (c t 0 0 0 3) (27/8)
34 where
35 g = make_grid 1 trilinear
36 cube = fromJust $ cube_at g 1 1 1
37 t = tetrahedron0 cube
38
39
40 -- | Check the value of c0021 for tetrahedron0 belonging to the
41 -- cube centered on (1,1,1) with a grid constructed from the
42 -- trilinear values. See example one in the paper.
43 test_trilinear_c0021 :: Assertion
44 test_trilinear_c0021 =
45 assertAlmostEqual "c0021 is correct" (c t 0 0 2 1) (61/24)
46 where
47 g = make_grid 1 trilinear
48 cube = fromJust $ cube_at g 1 1 1
49 t = tetrahedron0 cube
50
51
52 -- | Check the value of c0012 for tetrahedron0 belonging to the
53 -- cube centered on (1,1,1) with a grid constructed from the
54 -- trilinear values. See example one in the paper.
55 test_trilinear_c0012 :: Assertion
56 test_trilinear_c0012 =
57 assertAlmostEqual "c0012 is correct" (c t 0 0 1 2) (71/24)
58 where
59 g = make_grid 1 trilinear
60 cube = fromJust $ cube_at g 1 1 1
61 t = tetrahedron0 cube
62
63
64 -- | Check the value of c0120 for tetrahedron0 belonging to the
65 -- cube centered on (1,1,1) with a grid constructed from the
66 -- trilinear values. See example one in the paper.
67 test_trilinear_c0120 :: Assertion
68 test_trilinear_c0120 =
69 assertAlmostEqual "c0120 is correct" (c t 0 1 2 0) (55/24)
70 where
71 g = make_grid 1 trilinear
72 cube = fromJust $ cube_at g 1 1 1
73 t = tetrahedron0 cube
74
75
76 -- | Check the value of c0102 for tetrahedron0 belonging to the
77 -- cube centered on (1,1,1) with a grid constructed from the
78 -- trilinear values. See example one in the paper.
79 test_trilinear_c0102 :: Assertion
80 test_trilinear_c0102 =
81 assertAlmostEqual "c0102 is correct" (c t 0 1 0 2) (73/24)
82 where
83 g = make_grid 1 trilinear
84 cube = fromJust $ cube_at g 1 1 1
85 t = tetrahedron0 cube
86
87
88 -- | Check the value of c0111 for tetrahedron0 belonging to the
89 -- cube centered on (1,1,1) with a grid constructed from the
90 -- trilinear values. See example one in the paper.
91 test_trilinear_c0111 :: Assertion
92 test_trilinear_c0111 =
93 assertAlmostEqual "c0111 is correct" (c t 0 1 1 1) (8/3)
94 where
95 g = make_grid 1 trilinear
96 cube = fromJust $ cube_at g 1 1 1
97 t = tetrahedron0 cube
98
99
100 -- | Check the value of c0210 for tetrahedron0 belonging to the
101 -- cube centered on (1,1,1) with a grid constructed from the
102 -- trilinear values. See example one in the paper.
103 test_trilinear_c0210 :: Assertion
104 test_trilinear_c0210 =
105 assertAlmostEqual "c0210 is correct" (c t 0 2 1 0) (29/12)
106 where
107 g = make_grid 1 trilinear
108 cube = fromJust $ cube_at g 1 1 1
109 t = tetrahedron0 cube
110
111
112 -- | Check the value of c0201 for tetrahedron0 belonging to the
113 -- cube centered on (1,1,1) with a grid constructed from the
114 -- trilinear values. See example one in the paper.
115 test_trilinear_c0201 :: Assertion
116 test_trilinear_c0201 =
117 assertAlmostEqual "c0201 is correct" (c t 0 2 0 1) (11/4)
118 where
119 g = make_grid 1 trilinear
120 cube = fromJust $ cube_at g 1 1 1
121 t = tetrahedron0 cube
122
123
124 -- | Check the value of c0300 for tetrahedron0 belonging to the
125 -- cube centered on (1,1,1) with a grid constructed from the
126 -- trilinear values. See example one in the paper.
127 test_trilinear_c0300 :: Assertion
128 test_trilinear_c0300 =
129 assertAlmostEqual "c0300 is correct" (c t 0 3 0 0) (5/2)
130 where
131 g = make_grid 1 trilinear
132 cube = fromJust $ cube_at g 1 1 1
133 t = tetrahedron0 cube
134
135
136 -- | Check the value of c1020 for tetrahedron0 belonging to the
137 -- cube centered on (1,1,1) with a grid constructed from the
138 -- trilinear values. See example one in the paper.
139 test_trilinear_c1020 :: Assertion
140 test_trilinear_c1020 =
141 assertAlmostEqual "c1020 is correct" (c t 1 0 2 0) (8/3)
142 where
143 g = make_grid 1 trilinear
144 cube = fromJust $ cube_at g 1 1 1
145 t = tetrahedron0 cube
146
147
148 -- | Check the value of c1002 for tetrahedron0 belonging to the
149 -- cube centered on (1,1,1) with a grid constructed from the
150 -- trilinear values. See example one in the paper.
151 test_trilinear_c1002 :: Assertion
152 test_trilinear_c1002 =
153 assertAlmostEqual "c1002 is correct" (c t 1 0 0 2) (23/6)
154 where
155 g = make_grid 1 trilinear
156 cube = fromJust $ cube_at g 1 1 1
157 t = tetrahedron0 cube
158
159
160 -- | Check the value of c1011 for tetrahedron0 belonging to the
161 -- cube centered on (1,1,1) with a grid constructed from the
162 -- trilinear values. See example one in the paper.
163 test_trilinear_c1011 :: Assertion
164 test_trilinear_c1011 =
165 assertAlmostEqual "c1011 is correct" (c t 1 0 1 1) (13/4)
166 where
167 g = make_grid 1 trilinear
168 cube = fromJust $ cube_at g 1 1 1
169 t = tetrahedron0 cube
170
171
172 -- | Check the value of c1110 for tetrahedron0 belonging to the
173 -- cube centered on (1,1,1) with a grid constructed from the
174 -- trilinear values. See example one in the paper.
175 test_trilinear_c1110 :: Assertion
176 test_trilinear_c1110 =
177 assertAlmostEqual "c1110 is correct" (c t 1 1 1 0) (23/8)
178 where
179 g = make_grid 1 trilinear
180 cube = fromJust $ cube_at g 1 1 1
181 t = tetrahedron0 cube
182
183
184 -- | Check the value of c1101 for tetrahedron0 belonging to the
185 -- cube centered on (1,1,1) with a grid constructed from the
186 -- trilinear values. See example one in the paper.
187 test_trilinear_c1101 :: Assertion
188 test_trilinear_c1101 =
189 assertAlmostEqual "c1101 is correct" (c t 1 1 0 1) (27/8)
190 where
191 g = make_grid 1 trilinear
192 cube = fromJust $ cube_at g 1 1 1
193 t = tetrahedron0 cube
194
195
196 -- | Check the value of c1200 for tetrahedron0 belonging to the
197 -- cube centered on (1,1,1) with a grid constructed from the
198 -- trilinear values. See example one in the paper.
199 test_trilinear_c1200 :: Assertion
200 test_trilinear_c1200 =
201 assertAlmostEqual "c1200 is correct" (c t 1 2 0 0) 3
202 where
203 g = make_grid 1 trilinear
204 cube = fromJust $ cube_at g 1 1 1
205 t = tetrahedron0 cube
206
207
208 -- | Check the value of c2010 for tetrahedron0 belonging to the
209 -- cube centered on (1,1,1) with a grid constructed from the
210 -- trilinear values. See example one in the paper.
211 test_trilinear_c2010 :: Assertion
212 test_trilinear_c2010 =
213 assertAlmostEqual "c2010 is correct" (c t 2 0 1 0) (10/3)
214 where
215 g = make_grid 1 trilinear
216 cube = fromJust $ cube_at g 1 1 1
217 t = tetrahedron0 cube
218
219
220 -- | Check the value of c2001 for tetrahedron0 belonging to the
221 -- cube centered on (1,1,1) with a grid constructed from the
222 -- trilinear values. See example one in the paper.
223 test_trilinear_c2001 :: Assertion
224 test_trilinear_c2001 =
225 assertAlmostEqual "c2001 is correct" (c t 2 0 0 1) 4
226 where
227 g = make_grid 1 trilinear
228 cube = fromJust $ cube_at g 1 1 1
229 t = tetrahedron0 cube
230
231
232 -- | Check the value of c2100 for tetrahedron0 belonging to the
233 -- cube centered on (1,1,1) with a grid constructed from the
234 -- trilinear values. See example one in the paper.
235 test_trilinear_c2100 :: Assertion
236 test_trilinear_c2100 =
237 assertAlmostEqual "c2100 is correct" (c t 2 1 0 0) (7/2)
238 where
239 g = make_grid 1 trilinear
240 cube = fromJust $ cube_at g 1 1 1
241 t = tetrahedron0 cube
242
243
244 -- | Check the value of c3000 for tetrahedron0 belonging to the
245 -- cube centered on (1,1,1) with a grid constructed from the
246 -- trilinear values. See example one in the paper.
247 test_trilinear_c3000 :: Assertion
248 test_trilinear_c3000 =
249 assertAlmostEqual "c3000 is correct" (c t 3 0 0 0) 4
250 where
251 g = make_grid 1 trilinear
252 cube = fromJust $ cube_at g 1 1 1
253 t = tetrahedron0 cube
254
255
256 -- | Make sure that v0 of tetrahedron0 belonging to the cube centered
257 -- on (1,1,1) with a grid constructed from the trilinear values
258 -- winds up in the right place. See example one in the paper.
259 test_trilinear_f0_t0_v0 :: Assertion
260 test_trilinear_f0_t0_v0 =
261 assertEqual "v0 is correct" (v0 t) (1, 1, 1)
262 where
263 g = make_grid 1 trilinear
264 cube = fromJust $ cube_at g 1 1 1
265 t = tetrahedron0 cube
266
267
268 -- | Make sure that v1 of tetrahedron0 belonging to the cube centered
269 -- on (1,1,1) with a grid constructed from the trilinear values
270 -- winds up in the right place. See example one in the paper.
271 test_trilinear_f0_t0_v1 :: Assertion
272 test_trilinear_f0_t0_v1 =
273 assertEqual "v1 is correct" (v1 t) (0.5, 1, 1)
274 where
275 g = make_grid 1 trilinear
276 cube = fromJust $ cube_at g 1 1 1
277 t = tetrahedron0 cube
278
279
280 -- | Make sure that v2 of tetrahedron0 belonging to the cube centered
281 -- on (1,1,1) with a grid constructed from the trilinear values
282 -- winds up in the right place. See example one in the paper.
283 test_trilinear_f0_t0_v2 :: Assertion
284 test_trilinear_f0_t0_v2 =
285 assertEqual "v2 is correct" (v2 t) (0.5, 0.5, 1.5)
286 where
287 g = make_grid 1 trilinear
288 cube = fromJust $ cube_at g 1 1 1
289 t = tetrahedron0 cube
290
291
292 -- | Make sure that v3 of tetrahedron0 belonging to the cube centered
293 -- on (1,1,1) with a grid constructed from the trilinear values
294 -- winds up in the right place. See example one in the paper.
295 test_trilinear_f0_t0_v3 :: Assertion
296 test_trilinear_f0_t0_v3 =
297 assertClose "v3 is correct" (v3 t) (0.5, 1.5, 1.5)
298 where
299 g = make_grid 1 trilinear
300 cube = fromJust $ cube_at g 1 1 1
301 t = tetrahedron0 cube
302
303
304 test_trilinear_reproduced_t0 :: Assertion
305 test_trilinear_reproduced_t0 =
306 assertTrue "trilinears are reproduced correctly" $
307 and [p (i', j', k') ~= value_at trilinear i j k
308 | i <- [0..2],
309 j <- [0..2],
310 k <- [0..2],
311 let i' = fromIntegral i,
312 let j' = fromIntegral j,
313 let k' = fromIntegral k]
314 where
315 g = make_grid 1 trilinear
316 c0 = fromJust $ cube_at g 1 1 1
317 t0 = tetrahedron0 c0
318 p = polynomial t0
319
320 test_trilinear_reproduced_t1 :: Assertion
321 test_trilinear_reproduced_t1 =
322 assertTrue "trilinears are reproduced correctly" $
323 and [p (i', j', k') ~= value_at trilinear i j k
324 | i <- [0..2],
325 j <- [0..2],
326 k <- [0..2],
327 let i' = fromIntegral i,
328 let j' = fromIntegral j,
329 let k' = fromIntegral k]
330 where
331 g = make_grid 1 trilinear
332 c0 = fromJust $ cube_at g 1 1 1
333 t1 = tetrahedron1 c0
334 p = polynomial t1
335
336 test_trilinear_reproduced_t2 :: Assertion
337 test_trilinear_reproduced_t2 =
338 assertTrue "trilinears are reproduced correctly" $
339 and [p (i', j', k') ~= value_at trilinear i j k
340 | i <- [0..2],
341 j <- [0..2],
342 k <- [0..2],
343 let i' = fromIntegral i,
344 let j' = fromIntegral j,
345 let k' = fromIntegral k]
346 where
347 g = make_grid 1 trilinear
348 c0 = fromJust $ cube_at g 1 1 1
349 t2 = tetrahedron2 c0
350 p = polynomial t2
351
352 test_trilinear_reproduced_t3 :: Assertion
353 test_trilinear_reproduced_t3 =
354 assertTrue "trilinears are reproduced correctly" $
355 and [p (i', j', k') ~= value_at trilinear i j k
356 | i <- [0..2],
357 j <- [0..2],
358 k <- [0..2],
359 let i' = fromIntegral i,
360 let j' = fromIntegral j,
361 let k' = fromIntegral k]
362 where
363 g = make_grid 1 trilinear
364 c0 = fromJust $ cube_at g 1 1 1
365 t3 = tetrahedron3 c0
366 p = polynomial t3
367
368 test_trilinear_reproduced_t4 :: Assertion
369 test_trilinear_reproduced_t4 =
370 assertTrue "trilinears are reproduced correctly" $
371 and [p (i', j', k') ~= value_at trilinear i j k
372 | i <- [0..2],
373 j <- [0..2],
374 k <- [0..2],
375 let i' = fromIntegral i,
376 let j' = fromIntegral j,
377 let k' = fromIntegral k]
378 where
379 g = make_grid 1 trilinear
380 c0 = fromJust $ cube_at g 1 1 1
381 t4 = tetrahedron4 c0
382 p = polynomial t4
383
384 test_trilinear_reproduced_t5 :: Assertion
385 test_trilinear_reproduced_t5 =
386 assertTrue "trilinears are reproduced correctly" $
387 and [p (i', j', k') ~= value_at trilinear i j k
388 | i <- [0..2],
389 j <- [0..2],
390 k <- [0..2],
391 let i' = fromIntegral i,
392 let j' = fromIntegral j,
393 let k' = fromIntegral k]
394 where
395 g = make_grid 1 trilinear
396 c0 = fromJust $ cube_at g 1 1 1
397 t5 = tetrahedron5 c0
398 p = polynomial t5
399
400 test_trilinear_reproduced_t6 :: Assertion
401 test_trilinear_reproduced_t6 =
402 assertTrue "trilinears are reproduced correctly" $
403 and [p (i', j', k') ~= value_at trilinear i j k
404 | i <- [0..2],
405 j <- [0..2],
406 k <- [0..2],
407 let i' = fromIntegral i,
408 let j' = fromIntegral j,
409 let k' = fromIntegral k]
410 where
411 g = make_grid 1 trilinear
412 c0 = fromJust $ cube_at g 1 1 1
413 t6 = tetrahedron6 c0
414 p = polynomial t6
415
416 test_trilinear_reproduced_t7 :: Assertion
417 test_trilinear_reproduced_t7 =
418 assertTrue "trilinears are reproduced correctly" $
419 and [p (i', j', k') ~= value_at trilinear i j k
420 | i <- [0..2],
421 j <- [0..2],
422 k <- [0..2],
423 let i' = fromIntegral i,
424 let j' = fromIntegral j,
425 let k' = fromIntegral k]
426 where
427 g = make_grid 1 trilinear
428 c0 = fromJust $ cube_at g 1 1 1
429 t7 = tetrahedron7 c0
430 p = polynomial t7
431
432 test_trilinear_reproduced_t8 :: Assertion
433 test_trilinear_reproduced_t8 =
434 assertTrue "trilinears are reproduced correctly" $
435 and [p (i', j', k') ~= value_at trilinear i j k
436 | i <- [0..2],
437 j <- [0..2],
438 k <- [0..2],
439 let i' = fromIntegral i,
440 let j' = fromIntegral j,
441 let k' = fromIntegral k]
442 where
443 g = make_grid 1 trilinear
444 c0 = fromJust $ cube_at g 1 1 1
445 t8 = tetrahedron8 c0
446 p = polynomial t8
447
448 test_trilinear_reproduced_t9 :: Assertion
449 test_trilinear_reproduced_t9 =
450 assertTrue "trilinears are reproduced correctly" $
451 and [p (i', j', k') ~= value_at trilinear i j k
452 | i <- [0..2],
453 j <- [0..2],
454 k <- [0..2],
455 let i' = fromIntegral i,
456 let j' = fromIntegral j,
457 let k' = fromIntegral k]
458 where
459 g = make_grid 1 trilinear
460 c0 = fromJust $ cube_at g 1 1 1
461 t9 = tetrahedron9 c0
462 p = polynomial t9
463
464 test_trilinear_reproduced_t10 :: Assertion
465 test_trilinear_reproduced_t10 =
466 assertTrue "trilinears are reproduced correctly" $
467 and [p (i', j', k') ~= value_at trilinear i j k
468 | i <- [0..2],
469 j <- [0..2],
470 k <- [0..2],
471 let i' = fromIntegral i,
472 let j' = fromIntegral j,
473 let k' = fromIntegral k]
474 where
475 g = make_grid 1 trilinear
476 c0 = fromJust $ cube_at g 1 1 1
477 t10 = tetrahedron10 c0
478 p = polynomial t10
479
480 test_trilinear_reproduced_t11 :: Assertion
481 test_trilinear_reproduced_t11 =
482 assertTrue "trilinears are reproduced correctly" $
483 and [p (i', j', k') ~= value_at trilinear i j k
484 | i <- [0..2],
485 j <- [0..2],
486 k <- [0..2],
487 let i' = fromIntegral i,
488 let j' = fromIntegral j,
489 let k' = fromIntegral k]
490 where
491 g = make_grid 1 trilinear
492 c0 = fromJust $ cube_at g 1 1 1
493 t11 = tetrahedron11 c0
494 p = polynomial t11
495
496 test_trilinear_reproduced_t12 :: Assertion
497 test_trilinear_reproduced_t12 =
498 assertTrue "trilinears are reproduced correctly" $
499 and [p (i', j', k') ~= value_at trilinear i j k
500 | i <- [0..2],
501 j <- [0..2],
502 k <- [0..2],
503 let i' = fromIntegral i,
504 let j' = fromIntegral j,
505 let k' = fromIntegral k]
506 where
507 g = make_grid 1 trilinear
508 c0 = fromJust $ cube_at g 1 1 1
509 t12 = tetrahedron12 c0
510 p = polynomial t12
511
512 test_trilinear_reproduced_t13 :: Assertion
513 test_trilinear_reproduced_t13 =
514 assertTrue "trilinears are reproduced correctly" $
515 and [p (i', j', k') ~= value_at trilinear i j k
516 | i <- [0..2],
517 j <- [0..2],
518 k <- [0..2],
519 let i' = fromIntegral i,
520 let j' = fromIntegral j,
521 let k' = fromIntegral k]
522 where
523 g = make_grid 1 trilinear
524 c0 = fromJust $ cube_at g 1 1 1
525 t13 = tetrahedron13 c0
526 p = polynomial t13
527
528
529 test_trilinear_reproduced_t14 :: Assertion
530 test_trilinear_reproduced_t14 =
531 assertTrue "trilinears are reproduced correctly" $
532 and [p (i', j', k') ~= value_at trilinear i j k
533 | i <- [0..2],
534 j <- [0..2],
535 k <- [0..2],
536 let i' = fromIntegral i,
537 let j' = fromIntegral j,
538 let k' = fromIntegral k]
539 where
540 g = make_grid 1 trilinear
541 c0 = fromJust $ cube_at g 1 1 1
542 t14 = tetrahedron14 c0
543 p = polynomial t14
544
545 test_trilinear_reproduced_t15 :: Assertion
546 test_trilinear_reproduced_t15 =
547 assertTrue "trilinears are reproduced correctly" $
548 and [p (i', j', k') ~= value_at trilinear i j k
549 | i <- [0..2],
550 j <- [0..2],
551 k <- [0..2],
552 let i' = fromIntegral i,
553 let j' = fromIntegral j,
554 let k' = fromIntegral k]
555 where
556 g = make_grid 1 trilinear
557 c0 = fromJust $ cube_at g 1 1 1
558 t15 = tetrahedron15 c0
559 p = polynomial t15
560
561 test_trilinear_reproduced_t16 :: Assertion
562 test_trilinear_reproduced_t16 =
563 assertTrue "trilinears are reproduced correctly" $
564 and [p (i', j', k') ~= value_at trilinear i j k
565 | i <- [0..2],
566 j <- [0..2],
567 k <- [0..2],
568 let i' = fromIntegral i,
569 let j' = fromIntegral j,
570 let k' = fromIntegral k]
571 where
572 g = make_grid 1 trilinear
573 c0 = fromJust $ cube_at g 1 1 1
574 t16 = tetrahedron16 c0
575 p = polynomial t16
576
577 test_trilinear_reproduced_t17 :: Assertion
578 test_trilinear_reproduced_t17 =
579 assertTrue "trilinears are reproduced correctly" $
580 and [p (i', j', k') ~= value_at trilinear i j k
581 | i <- [0..2],
582 j <- [0..2],
583 k <- [0..2],
584 let i' = fromIntegral i,
585 let j' = fromIntegral j,
586 let k' = fromIntegral k]
587 where
588 g = make_grid 1 trilinear
589 c0 = fromJust $ cube_at g 1 1 1
590 t17 = tetrahedron17 c0
591 p = polynomial t17
592
593 test_trilinear_reproduced_t18 :: Assertion
594 test_trilinear_reproduced_t18 =
595 assertTrue "trilinears are reproduced correctly" $
596 and [p (i', j', k') ~= value_at trilinear i j k
597 | i <- [0..2],
598 j <- [0..2],
599 k <- [0..2],
600 let i' = fromIntegral i,
601 let j' = fromIntegral j,
602 let k' = fromIntegral k]
603 where
604 g = make_grid 1 trilinear
605 c0 = fromJust $ cube_at g 1 1 1
606 t18 = tetrahedron18 c0
607 p = polynomial t18
608
609 test_trilinear_reproduced_t19 :: Assertion
610 test_trilinear_reproduced_t19 =
611 assertTrue "trilinears are reproduced correctly" $
612 and [p (i', j', k') ~= value_at trilinear i j k
613 | i <- [0..2],
614 j <- [0..2],
615 k <- [0..2],
616 let i' = fromIntegral i,
617 let j' = fromIntegral j,
618 let k' = fromIntegral k]
619 where
620 g = make_grid 1 trilinear
621 c0 = fromJust $ cube_at g 1 1 1
622 t19 = tetrahedron19 c0
623 p = polynomial t19
624
625 test_trilinear_reproduced_t20 :: Assertion
626 test_trilinear_reproduced_t20 =
627 assertTrue "trilinears are reproduced correctly" $
628 and [p (i', j', k') ~= value_at trilinear i j k
629 | i <- [0..2],
630 j <- [0..2],
631 k <- [0..2],
632 let i' = fromIntegral i,
633 let j' = fromIntegral j,
634 let k' = fromIntegral k]
635 where
636 g = make_grid 1 trilinear
637 c0 = fromJust $ cube_at g 1 1 1
638 t20 = tetrahedron20 c0
639 p = polynomial t20
640
641
642 test_trilinear_reproduced_t21 :: Assertion
643 test_trilinear_reproduced_t21 =
644 assertTrue "trilinears are reproduced correctly" $
645 and [p (i', j', k') ~= value_at trilinear i j k
646 | i <- [0..2],
647 j <- [0..2],
648 k <- [0..2],
649 let i' = fromIntegral i,
650 let j' = fromIntegral j,
651 let k' = fromIntegral k]
652 where
653 g = make_grid 1 trilinear
654 c0 = fromJust $ cube_at g 1 1 1
655 t21 = tetrahedron21 c0
656 p = polynomial t21
657
658 test_trilinear_reproduced_t22 :: Assertion
659 test_trilinear_reproduced_t22 =
660 assertTrue "trilinears are reproduced correctly" $
661 and [p (i', j', k') ~= value_at trilinear i j k
662 | i <- [0..2],
663 j <- [0..2],
664 k <- [0..2],
665 let i' = fromIntegral i,
666 let j' = fromIntegral j,
667 let k' = fromIntegral k]
668 where
669 g = make_grid 1 trilinear
670 c0 = fromJust $ cube_at g 1 1 1
671 t22 = tetrahedron22 c0
672 p = polynomial t22
673
674
675 test_trilinear_reproduced_t23 :: Assertion
676 test_trilinear_reproduced_t23 =
677 assertTrue "trilinears are reproduced correctly" $
678 and [p (i', j', k') ~= value_at trilinear i j k
679 | i <- [0..2],
680 j <- [0..2],
681 k <- [0..2],
682 let i' = fromIntegral i,
683 let j' = fromIntegral j,
684 let k' = fromIntegral k]
685 where
686 g = make_grid 1 trilinear
687 c0 = fromJust $ cube_at g 1 1 1
688 t19 = tetrahedron19 c0
689 p = polynomial t19
690
691
692 test_zeros_reproduced :: Assertion
693 test_zeros_reproduced =
694 assertTrue "the zero function is reproduced correctly" $
695 and [p (i', j', k') ~= value_at zeros i j k
696 | i <- [0..2],
697 j <- [0..2],
698 k <- [0..2],
699 let i' = fromIntegral i,
700 let j' = fromIntegral j,
701 let k' = fromIntegral k]
702 where
703 g = make_grid 1 zeros
704 c0 = fromJust $ cube_at g 1 1 1
705 t0 = tetrahedron0 c0
706 p = polynomial t0
707
708
709 -- | Make sure we can reproduce a 9x9x9 trilinear from the 3x3x3 one.
710 test_trilinearx2_reproduced_t0 :: Assertion
711 test_trilinearx2_reproduced_t0 =
712 assertTrue "trilinearx2 is reproduced correctly" $
713 and [p (i', j', k') ~= value_at trilinearx2 i j k
714 | i <- [0..8],
715 j <- [0..8],
716 k <- [0..8],
717 let i' = (fromIntegral i) * 0.5,
718 let j' = (fromIntegral j) * 0.5,
719 let k' = (fromIntegral k) * 0.5]
720 where
721 g = make_grid 1 trilinear
722 c0 = fromJust $ cube_at g 1 1 1
723 t0 = tetrahedron0 c0
724 p = polynomial t0