4 import Data.Maybe (fromJust)
10 import Cube hiding (i, j, k)
12 import FunctionValues (value_at)
17 instance Arbitrary Grid where
19 (Positive h') <- arbitrary :: Gen (Positive Double)
20 fvs <- arbitrary :: Gen [[[Double]]]
21 return (make_grid h' fvs)
24 -- | Check the value of c0030 for tetrahedron0 belonging to the
25 -- cube centered on (1,1,1) with a grid constructed from the
26 -- trilinear values. See example one in the paper.
27 test_trilinear_c0030 :: Assertion
28 test_trilinear_c0030 =
29 assertAlmostEqual "c0030 is correct" (c t 0 0 3 0) (17/8)
31 g = make_grid 1 trilinear
32 cube = fromJust $ cube_at g 1 1 1
36 -- | Check the value of c0003 for tetrahedron0 belonging to the
37 -- cube centered on (1,1,1) with a grid constructed from the
38 -- trilinear values. See example one in the paper.
39 test_trilinear_c0003 :: Assertion
40 test_trilinear_c0003 =
41 assertAlmostEqual "c0003 is correct" (c t 0 0 0 3) (27/8)
43 g = make_grid 1 trilinear
44 cube = fromJust $ cube_at g 1 1 1
48 -- | Check the value of c0021 for tetrahedron0 belonging to the
49 -- cube centered on (1,1,1) with a grid constructed from the
50 -- trilinear values. See example one in the paper.
51 test_trilinear_c0021 :: Assertion
52 test_trilinear_c0021 =
53 assertAlmostEqual "c0021 is correct" (c t 0 0 2 1) (61/24)
55 g = make_grid 1 trilinear
56 cube = fromJust $ cube_at g 1 1 1
60 -- | Check the value of c0012 for tetrahedron0 belonging to the
61 -- cube centered on (1,1,1) with a grid constructed from the
62 -- trilinear values. See example one in the paper.
63 test_trilinear_c0012 :: Assertion
64 test_trilinear_c0012 =
65 assertAlmostEqual "c0012 is correct" (c t 0 0 1 2) (71/24)
67 g = make_grid 1 trilinear
68 cube = fromJust $ cube_at g 1 1 1
72 -- | Check the value of c0120 for tetrahedron0 belonging to the
73 -- cube centered on (1,1,1) with a grid constructed from the
74 -- trilinear values. See example one in the paper.
75 test_trilinear_c0120 :: Assertion
76 test_trilinear_c0120 =
77 assertAlmostEqual "c0120 is correct" (c t 0 1 2 0) (55/24)
79 g = make_grid 1 trilinear
80 cube = fromJust $ cube_at g 1 1 1
84 -- | Check the value of c0102 for tetrahedron0 belonging to the
85 -- cube centered on (1,1,1) with a grid constructed from the
86 -- trilinear values. See example one in the paper.
87 test_trilinear_c0102 :: Assertion
88 test_trilinear_c0102 =
89 assertAlmostEqual "c0102 is correct" (c t 0 1 0 2) (73/24)
91 g = make_grid 1 trilinear
92 cube = fromJust $ cube_at g 1 1 1
96 -- | Check the value of c0111 for tetrahedron0 belonging to the
97 -- cube centered on (1,1,1) with a grid constructed from the
98 -- trilinear values. See example one in the paper.
99 test_trilinear_c0111 :: Assertion
100 test_trilinear_c0111 =
101 assertAlmostEqual "c0111 is correct" (c t 0 1 1 1) (8/3)
103 g = make_grid 1 trilinear
104 cube = fromJust $ cube_at g 1 1 1
105 t = tetrahedron0 cube
108 -- | Check the value of c0210 for tetrahedron0 belonging to the
109 -- cube centered on (1,1,1) with a grid constructed from the
110 -- trilinear values. See example one in the paper.
111 test_trilinear_c0210 :: Assertion
112 test_trilinear_c0210 =
113 assertAlmostEqual "c0210 is correct" (c t 0 2 1 0) (29/12)
115 g = make_grid 1 trilinear
116 cube = fromJust $ cube_at g 1 1 1
117 t = tetrahedron0 cube
120 -- | Check the value of c0201 for tetrahedron0 belonging to the
121 -- cube centered on (1,1,1) with a grid constructed from the
122 -- trilinear values. See example one in the paper.
123 test_trilinear_c0201 :: Assertion
124 test_trilinear_c0201 =
125 assertAlmostEqual "c0201 is correct" (c t 0 2 0 1) (11/4)
127 g = make_grid 1 trilinear
128 cube = fromJust $ cube_at g 1 1 1
129 t = tetrahedron0 cube
132 -- | Check the value of c0300 for tetrahedron0 belonging to the
133 -- cube centered on (1,1,1) with a grid constructed from the
134 -- trilinear values. See example one in the paper.
135 test_trilinear_c0300 :: Assertion
136 test_trilinear_c0300 =
137 assertAlmostEqual "c0300 is correct" (c t 0 3 0 0) (5/2)
139 g = make_grid 1 trilinear
140 cube = fromJust $ cube_at g 1 1 1
141 t = tetrahedron0 cube
144 -- | Check the value of c1020 for tetrahedron0 belonging to the
145 -- cube centered on (1,1,1) with a grid constructed from the
146 -- trilinear values. See example one in the paper.
147 test_trilinear_c1020 :: Assertion
148 test_trilinear_c1020 =
149 assertAlmostEqual "c1020 is correct" (c t 1 0 2 0) (8/3)
151 g = make_grid 1 trilinear
152 cube = fromJust $ cube_at g 1 1 1
153 t = tetrahedron0 cube
156 -- | Check the value of c1002 for tetrahedron0 belonging to the
157 -- cube centered on (1,1,1) with a grid constructed from the
158 -- trilinear values. See example one in the paper.
159 test_trilinear_c1002 :: Assertion
160 test_trilinear_c1002 =
161 assertAlmostEqual "c1002 is correct" (c t 1 0 0 2) (23/6)
163 g = make_grid 1 trilinear
164 cube = fromJust $ cube_at g 1 1 1
165 t = tetrahedron0 cube
168 -- | Check the value of c1011 for tetrahedron0 belonging to the
169 -- cube centered on (1,1,1) with a grid constructed from the
170 -- trilinear values. See example one in the paper.
171 test_trilinear_c1011 :: Assertion
172 test_trilinear_c1011 =
173 assertAlmostEqual "c1011 is correct" (c t 1 0 1 1) (13/4)
175 g = make_grid 1 trilinear
176 cube = fromJust $ cube_at g 1 1 1
177 t = tetrahedron0 cube
180 -- | Check the value of c1110 for tetrahedron0 belonging to the
181 -- cube centered on (1,1,1) with a grid constructed from the
182 -- trilinear values. See example one in the paper.
183 test_trilinear_c1110 :: Assertion
184 test_trilinear_c1110 =
185 assertAlmostEqual "c1110 is correct" (c t 1 1 1 0) (23/8)
187 g = make_grid 1 trilinear
188 cube = fromJust $ cube_at g 1 1 1
189 t = tetrahedron0 cube
192 -- | Check the value of c1101 for tetrahedron0 belonging to the
193 -- cube centered on (1,1,1) with a grid constructed from the
194 -- trilinear values. See example one in the paper.
195 test_trilinear_c1101 :: Assertion
196 test_trilinear_c1101 =
197 assertAlmostEqual "c1101 is correct" (c t 1 1 0 1) (27/8)
199 g = make_grid 1 trilinear
200 cube = fromJust $ cube_at g 1 1 1
201 t = tetrahedron0 cube
204 -- | Check the value of c1200 for tetrahedron0 belonging to the
205 -- cube centered on (1,1,1) with a grid constructed from the
206 -- trilinear values. See example one in the paper.
207 test_trilinear_c1200 :: Assertion
208 test_trilinear_c1200 =
209 assertAlmostEqual "c1200 is correct" (c t 1 2 0 0) 3
211 g = make_grid 1 trilinear
212 cube = fromJust $ cube_at g 1 1 1
213 t = tetrahedron0 cube
216 -- | Check the value of c2010 for tetrahedron0 belonging to the
217 -- cube centered on (1,1,1) with a grid constructed from the
218 -- trilinear values. See example one in the paper.
219 test_trilinear_c2010 :: Assertion
220 test_trilinear_c2010 =
221 assertAlmostEqual "c2010 is correct" (c t 2 0 1 0) (10/3)
223 g = make_grid 1 trilinear
224 cube = fromJust $ cube_at g 1 1 1
225 t = tetrahedron0 cube
228 -- | Check the value of c2001 for tetrahedron0 belonging to the
229 -- cube centered on (1,1,1) with a grid constructed from the
230 -- trilinear values. See example one in the paper.
231 test_trilinear_c2001 :: Assertion
232 test_trilinear_c2001 =
233 assertAlmostEqual "c2001 is correct" (c t 2 0 0 1) 4
235 g = make_grid 1 trilinear
236 cube = fromJust $ cube_at g 1 1 1
237 t = tetrahedron0 cube
240 -- | Check the value of c2100 for tetrahedron0 belonging to the
241 -- cube centered on (1,1,1) with a grid constructed from the
242 -- trilinear values. See example one in the paper.
243 test_trilinear_c2100 :: Assertion
244 test_trilinear_c2100 =
245 assertAlmostEqual "c2100 is correct" (c t 2 1 0 0) (7/2)
247 g = make_grid 1 trilinear
248 cube = fromJust $ cube_at g 1 1 1
249 t = tetrahedron0 cube
252 -- | Check the value of c3000 for tetrahedron0 belonging to the
253 -- cube centered on (1,1,1) with a grid constructed from the
254 -- trilinear values. See example one in the paper.
255 test_trilinear_c3000 :: Assertion
256 test_trilinear_c3000 =
257 assertAlmostEqual "c3000 is correct" (c t 3 0 0 0) 4
259 g = make_grid 1 trilinear
260 cube = fromJust $ cube_at g 1 1 1
261 t = tetrahedron0 cube
264 -- | Make sure that v0 of tetrahedron0 belonging to the cube centered
265 -- on (1,1,1) with a grid constructed from the trilinear values
266 -- winds up in the right place. See example one in the paper.
267 test_trilinear_f0_t0_v0 :: Assertion
268 test_trilinear_f0_t0_v0 =
269 assertEqual "v0 is correct" (v0 t) (1, 1, 1)
271 g = make_grid 1 trilinear
272 cube = fromJust $ cube_at g 1 1 1
273 t = tetrahedron0 cube
276 -- | Make sure that v1 of tetrahedron0 belonging to the cube centered
277 -- on (1,1,1) with a grid constructed from the trilinear values
278 -- winds up in the right place. See example one in the paper.
279 test_trilinear_f0_t0_v1 :: Assertion
280 test_trilinear_f0_t0_v1 =
281 assertEqual "v1 is correct" (v1 t) (0.5, 1, 1)
283 g = make_grid 1 trilinear
284 cube = fromJust $ cube_at g 1 1 1
285 t = tetrahedron0 cube
288 -- | Make sure that v2 of tetrahedron0 belonging to the cube centered
289 -- on (1,1,1) with a grid constructed from the trilinear values
290 -- winds up in the right place. See example one in the paper.
291 test_trilinear_f0_t0_v2 :: Assertion
292 test_trilinear_f0_t0_v2 =
293 assertEqual "v2 is correct" (v2 t) (0.5, 0.5, 1.5)
295 g = make_grid 1 trilinear
296 cube = fromJust $ cube_at g 1 1 1
297 t = tetrahedron0 cube
300 -- | Make sure that v3 of tetrahedron0 belonging to the cube centered
301 -- on (1,1,1) with a grid constructed from the trilinear values
302 -- winds up in the right place. See example one in the paper.
303 test_trilinear_f0_t0_v3 :: Assertion
304 test_trilinear_f0_t0_v3 =
305 assertClose "v3 is correct" (v3 t) (0.5, 1.5, 1.5)
307 g = make_grid 1 trilinear
308 cube = fromJust $ cube_at g 1 1 1
309 t = tetrahedron0 cube
312 test_trilinear_reproduced_t0 :: Assertion
313 test_trilinear_reproduced_t0 =
314 assertTrue "trilinears are reproduced correctly" $
315 and [p (i', j', k') ~= value_at trilinear i j k
319 let i' = fromIntegral i,
320 let j' = fromIntegral j,
321 let k' = fromIntegral k]
323 g = make_grid 1 trilinear
324 c0 = fromJust $ cube_at g 1 1 1
328 test_trilinear_reproduced_t1 :: Assertion
329 test_trilinear_reproduced_t1 =
330 assertTrue "trilinears are reproduced correctly" $
331 and [p (i', j', k') ~= value_at trilinear i j k
335 let i' = fromIntegral i,
336 let j' = fromIntegral j,
337 let k' = fromIntegral k]
339 g = make_grid 1 trilinear
340 c0 = fromJust $ cube_at g 1 1 1
344 test_trilinear_reproduced_t2 :: Assertion
345 test_trilinear_reproduced_t2 =
346 assertTrue "trilinears are reproduced correctly" $
347 and [p (i', j', k') ~= value_at trilinear i j k
351 let i' = fromIntegral i,
352 let j' = fromIntegral j,
353 let k' = fromIntegral k]
355 g = make_grid 1 trilinear
356 c0 = fromJust $ cube_at g 1 1 1
360 test_trilinear_reproduced_t3 :: Assertion
361 test_trilinear_reproduced_t3 =
362 assertTrue "trilinears are reproduced correctly" $
363 and [p (i', j', k') ~= value_at trilinear i j k
367 let i' = fromIntegral i,
368 let j' = fromIntegral j,
369 let k' = fromIntegral k]
371 g = make_grid 1 trilinear
372 c0 = fromJust $ cube_at g 1 1 1
376 test_trilinear_reproduced_t4 :: Assertion
377 test_trilinear_reproduced_t4 =
378 assertTrue "trilinears are reproduced correctly" $
379 and [p (i', j', k') ~= value_at trilinear i j k
383 let i' = fromIntegral i,
384 let j' = fromIntegral j,
385 let k' = fromIntegral k]
387 g = make_grid 1 trilinear
388 c0 = fromJust $ cube_at g 1 1 1
392 test_trilinear_reproduced_t5 :: Assertion
393 test_trilinear_reproduced_t5 =
394 assertTrue "trilinears are reproduced correctly" $
395 and [p (i', j', k') ~= value_at trilinear i j k
399 let i' = fromIntegral i,
400 let j' = fromIntegral j,
401 let k' = fromIntegral k]
403 g = make_grid 1 trilinear
404 c0 = fromJust $ cube_at g 1 1 1
408 test_trilinear_reproduced_t6 :: Assertion
409 test_trilinear_reproduced_t6 =
410 assertTrue "trilinears are reproduced correctly" $
411 and [p (i', j', k') ~= value_at trilinear i j k
415 let i' = fromIntegral i,
416 let j' = fromIntegral j,
417 let k' = fromIntegral k]
419 g = make_grid 1 trilinear
420 c0 = fromJust $ cube_at g 1 1 1
424 test_trilinear_reproduced_t7 :: Assertion
425 test_trilinear_reproduced_t7 =
426 assertTrue "trilinears are reproduced correctly" $
427 and [p (i', j', k') ~= value_at trilinear i j k
431 let i' = fromIntegral i,
432 let j' = fromIntegral j,
433 let k' = fromIntegral k]
435 g = make_grid 1 trilinear
436 c0 = fromJust $ cube_at g 1 1 1
440 test_trilinear_reproduced_t8 :: Assertion
441 test_trilinear_reproduced_t8 =
442 assertTrue "trilinears are reproduced correctly" $
443 and [p (i', j', k') ~= value_at trilinear i j k
447 let i' = fromIntegral i,
448 let j' = fromIntegral j,
449 let k' = fromIntegral k]
451 g = make_grid 1 trilinear
452 c0 = fromJust $ cube_at g 1 1 1
456 test_trilinear_reproduced_t9 :: Assertion
457 test_trilinear_reproduced_t9 =
458 assertTrue "trilinears are reproduced correctly" $
459 and [p (i', j', k') ~= value_at trilinear i j k
463 let i' = fromIntegral i,
464 let j' = fromIntegral j,
465 let k' = fromIntegral k]
467 g = make_grid 1 trilinear
468 c0 = fromJust $ cube_at g 1 1 1
472 test_trilinear_reproduced_t10 :: Assertion
473 test_trilinear_reproduced_t10 =
474 assertTrue "trilinears are reproduced correctly" $
475 and [p (i', j', k') ~= value_at trilinear i j k
479 let i' = fromIntegral i,
480 let j' = fromIntegral j,
481 let k' = fromIntegral k]
483 g = make_grid 1 trilinear
484 c0 = fromJust $ cube_at g 1 1 1
485 t10 = tetrahedron10 c0
488 test_trilinear_reproduced_t11 :: Assertion
489 test_trilinear_reproduced_t11 =
490 assertTrue "trilinears are reproduced correctly" $
491 and [p (i', j', k') ~= value_at trilinear i j k
495 let i' = fromIntegral i,
496 let j' = fromIntegral j,
497 let k' = fromIntegral k]
499 g = make_grid 1 trilinear
500 c0 = fromJust $ cube_at g 1 1 1
501 t11 = tetrahedron11 c0
504 test_trilinear_reproduced_t12 :: Assertion
505 test_trilinear_reproduced_t12 =
506 assertTrue "trilinears are reproduced correctly" $
507 and [p (i', j', k') ~= value_at trilinear i j k
511 let i' = fromIntegral i,
512 let j' = fromIntegral j,
513 let k' = fromIntegral k]
515 g = make_grid 1 trilinear
516 c0 = fromJust $ cube_at g 1 1 1
517 t12 = tetrahedron12 c0
520 test_trilinear_reproduced_t13 :: Assertion
521 test_trilinear_reproduced_t13 =
522 assertTrue "trilinears are reproduced correctly" $
523 and [p (i', j', k') ~= value_at trilinear i j k
527 let i' = fromIntegral i,
528 let j' = fromIntegral j,
529 let k' = fromIntegral k]
531 g = make_grid 1 trilinear
532 c0 = fromJust $ cube_at g 1 1 1
533 t13 = tetrahedron13 c0
537 test_trilinear_reproduced_t14 :: Assertion
538 test_trilinear_reproduced_t14 =
539 assertTrue "trilinears are reproduced correctly" $
540 and [p (i', j', k') ~= value_at trilinear i j k
544 let i' = fromIntegral i,
545 let j' = fromIntegral j,
546 let k' = fromIntegral k]
548 g = make_grid 1 trilinear
549 c0 = fromJust $ cube_at g 1 1 1
550 t14 = tetrahedron14 c0
553 test_trilinear_reproduced_t15 :: Assertion
554 test_trilinear_reproduced_t15 =
555 assertTrue "trilinears are reproduced correctly" $
556 and [p (i', j', k') ~= value_at trilinear i j k
560 let i' = fromIntegral i,
561 let j' = fromIntegral j,
562 let k' = fromIntegral k]
564 g = make_grid 1 trilinear
565 c0 = fromJust $ cube_at g 1 1 1
566 t15 = tetrahedron15 c0
569 test_trilinear_reproduced_t16 :: Assertion
570 test_trilinear_reproduced_t16 =
571 assertTrue "trilinears are reproduced correctly" $
572 and [p (i', j', k') ~= value_at trilinear i j k
576 let i' = fromIntegral i,
577 let j' = fromIntegral j,
578 let k' = fromIntegral k]
580 g = make_grid 1 trilinear
581 c0 = fromJust $ cube_at g 1 1 1
582 t16 = tetrahedron16 c0
585 test_trilinear_reproduced_t17 :: Assertion
586 test_trilinear_reproduced_t17 =
587 assertTrue "trilinears are reproduced correctly" $
588 and [p (i', j', k') ~= value_at trilinear i j k
592 let i' = fromIntegral i,
593 let j' = fromIntegral j,
594 let k' = fromIntegral k]
596 g = make_grid 1 trilinear
597 c0 = fromJust $ cube_at g 1 1 1
598 t17 = tetrahedron17 c0
601 test_trilinear_reproduced_t18 :: Assertion
602 test_trilinear_reproduced_t18 =
603 assertTrue "trilinears are reproduced correctly" $
604 and [p (i', j', k') ~= value_at trilinear i j k
608 let i' = fromIntegral i,
609 let j' = fromIntegral j,
610 let k' = fromIntegral k]
612 g = make_grid 1 trilinear
613 c0 = fromJust $ cube_at g 1 1 1
614 t18 = tetrahedron18 c0
617 test_trilinear_reproduced_t19 :: Assertion
618 test_trilinear_reproduced_t19 =
619 assertTrue "trilinears are reproduced correctly" $
620 and [p (i', j', k') ~= value_at trilinear i j k
624 let i' = fromIntegral i,
625 let j' = fromIntegral j,
626 let k' = fromIntegral k]
628 g = make_grid 1 trilinear
629 c0 = fromJust $ cube_at g 1 1 1
630 t19 = tetrahedron19 c0
633 test_trilinear_reproduced_t20 :: Assertion
634 test_trilinear_reproduced_t20 =
635 assertTrue "trilinears are reproduced correctly" $
636 and [p (i', j', k') ~= value_at trilinear i j k
640 let i' = fromIntegral i,
641 let j' = fromIntegral j,
642 let k' = fromIntegral k]
644 g = make_grid 1 trilinear
645 c0 = fromJust $ cube_at g 1 1 1
646 t20 = tetrahedron20 c0
650 test_trilinear_reproduced_t21 :: Assertion
651 test_trilinear_reproduced_t21 =
652 assertTrue "trilinears are reproduced correctly" $
653 and [p (i', j', k') ~= value_at trilinear i j k
657 let i' = fromIntegral i,
658 let j' = fromIntegral j,
659 let k' = fromIntegral k]
661 g = make_grid 1 trilinear
662 c0 = fromJust $ cube_at g 1 1 1
663 t21 = tetrahedron21 c0
666 test_trilinear_reproduced_t22 :: Assertion
667 test_trilinear_reproduced_t22 =
668 assertTrue "trilinears are reproduced correctly" $
669 and [p (i', j', k') ~= value_at trilinear i j k
673 let i' = fromIntegral i,
674 let j' = fromIntegral j,
675 let k' = fromIntegral k]
677 g = make_grid 1 trilinear
678 c0 = fromJust $ cube_at g 1 1 1
679 t22 = tetrahedron22 c0
683 test_trilinear_reproduced_t23 :: Assertion
684 test_trilinear_reproduced_t23 =
685 assertTrue "trilinears are reproduced correctly" $
686 and [p (i', j', k') ~= value_at trilinear i j k
690 let i' = fromIntegral i,
691 let j' = fromIntegral j,
692 let k' = fromIntegral k]
694 g = make_grid 1 trilinear
695 c0 = fromJust $ cube_at g 1 1 1
696 t19 = tetrahedron19 c0
700 test_zeros_reproduced :: Assertion
701 test_zeros_reproduced =
702 assertTrue "the zero function is reproduced correctly" $
703 and [p (i', j', k') ~= value_at zeros i j k
707 let i' = fromIntegral i,
708 let j' = fromIntegral j,
709 let k' = fromIntegral k]
711 g = make_grid 1 zeros
712 c0 = fromJust $ cube_at g 1 1 1