4 import Data.Maybe (fromJust)
5 import Debug.Trace (trace)
11 import Cube hiding (i, j, k)
13 import FunctionValues (value_at)
18 instance Arbitrary Grid where
20 (Positive h') <- arbitrary :: Gen (Positive Double)
21 fvs <- arbitrary :: Gen [[[Double]]]
22 return (make_grid h' fvs)
25 -- | Check the value of c0030 for tetrahedron0 belonging to the
26 -- cube centered on (1,1,1) with a grid constructed from the
27 -- trilinear values. See example one in the paper.
28 test_trilinear_c0030 :: Assertion
29 test_trilinear_c0030 =
30 assertAlmostEqual "c0030 is correct" (c t 0 0 3 0) (17/8)
32 g = make_grid 1 trilinear
33 cube = fromJust $ cube_at g 1 1 1
37 -- | Check the value of c0003 for tetrahedron0 belonging to the
38 -- cube centered on (1,1,1) with a grid constructed from the
39 -- trilinear values. See example one in the paper.
40 test_trilinear_c0003 :: Assertion
41 test_trilinear_c0003 =
42 assertAlmostEqual "c0003 is correct" (c t 0 0 0 3) (27/8)
44 g = make_grid 1 trilinear
45 cube = fromJust $ cube_at g 1 1 1
49 -- | Check the value of c0021 for tetrahedron0 belonging to the
50 -- cube centered on (1,1,1) with a grid constructed from the
51 -- trilinear values. See example one in the paper.
52 test_trilinear_c0021 :: Assertion
53 test_trilinear_c0021 =
54 assertAlmostEqual "c0021 is correct" (c t 0 0 2 1) (61/24)
56 g = make_grid 1 trilinear
57 cube = fromJust $ cube_at g 1 1 1
61 -- | Check the value of c0012 for tetrahedron0 belonging to the
62 -- cube centered on (1,1,1) with a grid constructed from the
63 -- trilinear values. See example one in the paper.
64 test_trilinear_c0012 :: Assertion
65 test_trilinear_c0012 =
66 assertAlmostEqual "c0012 is correct" (c t 0 0 1 2) (71/24)
68 g = make_grid 1 trilinear
69 cube = fromJust $ cube_at g 1 1 1
73 -- | Check the value of c0120 for tetrahedron0 belonging to the
74 -- cube centered on (1,1,1) with a grid constructed from the
75 -- trilinear values. See example one in the paper.
76 test_trilinear_c0120 :: Assertion
77 test_trilinear_c0120 =
78 assertAlmostEqual "c0120 is correct" (c t 0 1 2 0) (55/24)
80 g = make_grid 1 trilinear
81 cube = fromJust $ cube_at g 1 1 1
85 -- | Check the value of c0102 for tetrahedron0 belonging to the
86 -- cube centered on (1,1,1) with a grid constructed from the
87 -- trilinear values. See example one in the paper.
88 test_trilinear_c0102 :: Assertion
89 test_trilinear_c0102 =
90 assertAlmostEqual "c0102 is correct" (c t 0 1 0 2) (73/24)
92 g = make_grid 1 trilinear
93 cube = fromJust $ cube_at g 1 1 1
97 -- | Check the value of c0111 for tetrahedron0 belonging to the
98 -- cube centered on (1,1,1) with a grid constructed from the
99 -- trilinear values. See example one in the paper.
100 test_trilinear_c0111 :: Assertion
101 test_trilinear_c0111 =
102 assertAlmostEqual "c0111 is correct" (c t 0 1 1 1) (8/3)
104 g = make_grid 1 trilinear
105 cube = fromJust $ cube_at g 1 1 1
106 t = tetrahedron0 cube
109 -- | Check the value of c0210 for tetrahedron0 belonging to the
110 -- cube centered on (1,1,1) with a grid constructed from the
111 -- trilinear values. See example one in the paper.
112 test_trilinear_c0210 :: Assertion
113 test_trilinear_c0210 =
114 assertAlmostEqual "c0210 is correct" (c t 0 2 1 0) (29/12)
116 g = make_grid 1 trilinear
117 cube = fromJust $ cube_at g 1 1 1
118 t = tetrahedron0 cube
121 -- | Check the value of c0201 for tetrahedron0 belonging to the
122 -- cube centered on (1,1,1) with a grid constructed from the
123 -- trilinear values. See example one in the paper.
124 test_trilinear_c0201 :: Assertion
125 test_trilinear_c0201 =
126 assertAlmostEqual "c0201 is correct" (c t 0 2 0 1) (11/4)
128 g = make_grid 1 trilinear
129 cube = fromJust $ cube_at g 1 1 1
130 t = tetrahedron0 cube
133 -- | Check the value of c0300 for tetrahedron0 belonging to the
134 -- cube centered on (1,1,1) with a grid constructed from the
135 -- trilinear values. See example one in the paper.
136 test_trilinear_c0300 :: Assertion
137 test_trilinear_c0300 =
138 assertAlmostEqual "c0300 is correct" (c t 0 3 0 0) (5/2)
140 g = make_grid 1 trilinear
141 cube = fromJust $ cube_at g 1 1 1
142 t = tetrahedron0 cube
145 -- | Check the value of c1020 for tetrahedron0 belonging to the
146 -- cube centered on (1,1,1) with a grid constructed from the
147 -- trilinear values. See example one in the paper.
148 test_trilinear_c1020 :: Assertion
149 test_trilinear_c1020 =
150 assertAlmostEqual "c1020 is correct" (c t 1 0 2 0) (8/3)
152 g = make_grid 1 trilinear
153 cube = fromJust $ cube_at g 1 1 1
154 t = tetrahedron0 cube
157 -- | Check the value of c1002 for tetrahedron0 belonging to the
158 -- cube centered on (1,1,1) with a grid constructed from the
159 -- trilinear values. See example one in the paper.
160 test_trilinear_c1002 :: Assertion
161 test_trilinear_c1002 =
162 assertAlmostEqual "c1002 is correct" (c t 1 0 0 2) (23/6)
164 g = make_grid 1 trilinear
165 cube = fromJust $ cube_at g 1 1 1
166 t = tetrahedron0 cube
169 -- | Check the value of c1011 for tetrahedron0 belonging to the
170 -- cube centered on (1,1,1) with a grid constructed from the
171 -- trilinear values. See example one in the paper.
172 test_trilinear_c1011 :: Assertion
173 test_trilinear_c1011 =
174 assertAlmostEqual "c1011 is correct" (c t 1 0 1 1) (13/4)
176 g = make_grid 1 trilinear
177 cube = fromJust $ cube_at g 1 1 1
178 t = tetrahedron0 cube
181 -- | Check the value of c1110 for tetrahedron0 belonging to the
182 -- cube centered on (1,1,1) with a grid constructed from the
183 -- trilinear values. See example one in the paper.
184 test_trilinear_c1110 :: Assertion
185 test_trilinear_c1110 =
186 assertAlmostEqual "c1110 is correct" (c t 1 1 1 0) (23/8)
188 g = make_grid 1 trilinear
189 cube = fromJust $ cube_at g 1 1 1
190 t = tetrahedron0 cube
193 -- | Check the value of c1101 for tetrahedron0 belonging to the
194 -- cube centered on (1,1,1) with a grid constructed from the
195 -- trilinear values. See example one in the paper.
196 test_trilinear_c1101 :: Assertion
197 test_trilinear_c1101 =
198 assertAlmostEqual "c1101 is correct" (c t 1 1 0 1) (27/8)
200 g = make_grid 1 trilinear
201 cube = fromJust $ cube_at g 1 1 1
202 t = tetrahedron0 cube
205 -- | Check the value of c1200 for tetrahedron0 belonging to the
206 -- cube centered on (1,1,1) with a grid constructed from the
207 -- trilinear values. See example one in the paper.
208 test_trilinear_c1200 :: Assertion
209 test_trilinear_c1200 =
210 assertAlmostEqual "c1200 is correct" (c t 1 2 0 0) 3
212 g = make_grid 1 trilinear
213 cube = fromJust $ cube_at g 1 1 1
214 t = tetrahedron0 cube
217 -- | Check the value of c2010 for tetrahedron0 belonging to the
218 -- cube centered on (1,1,1) with a grid constructed from the
219 -- trilinear values. See example one in the paper.
220 test_trilinear_c2010 :: Assertion
221 test_trilinear_c2010 =
222 assertAlmostEqual "c2010 is correct" (c t 2 0 1 0) (10/3)
224 g = make_grid 1 trilinear
225 cube = fromJust $ cube_at g 1 1 1
226 t = tetrahedron0 cube
229 -- | Check the value of c2001 for tetrahedron0 belonging to the
230 -- cube centered on (1,1,1) with a grid constructed from the
231 -- trilinear values. See example one in the paper.
232 test_trilinear_c2001 :: Assertion
233 test_trilinear_c2001 =
234 assertAlmostEqual "c2001 is correct" (c t 2 0 0 1) 4
236 g = make_grid 1 trilinear
237 cube = fromJust $ cube_at g 1 1 1
238 t = tetrahedron0 cube
241 -- | Check the value of c2100 for tetrahedron0 belonging to the
242 -- cube centered on (1,1,1) with a grid constructed from the
243 -- trilinear values. See example one in the paper.
244 test_trilinear_c2100 :: Assertion
245 test_trilinear_c2100 =
246 assertAlmostEqual "c2100 is correct" (c t 2 1 0 0) (7/2)
248 g = make_grid 1 trilinear
249 cube = fromJust $ cube_at g 1 1 1
250 t = tetrahedron0 cube
253 -- | Check the value of c3000 for tetrahedron0 belonging to the
254 -- cube centered on (1,1,1) with a grid constructed from the
255 -- trilinear values. See example one in the paper.
256 test_trilinear_c3000 :: Assertion
257 test_trilinear_c3000 =
258 assertAlmostEqual "c3000 is correct" (c t 3 0 0 0) 4
260 g = make_grid 1 trilinear
261 cube = fromJust $ cube_at g 1 1 1
262 t = tetrahedron0 cube
265 -- | Make sure that v0 of tetrahedron0 belonging to the cube centered
266 -- on (1,1,1) with a grid constructed from the trilinear values
267 -- winds up in the right place. See example one in the paper.
268 test_trilinear_f0_t0_v0 :: Assertion
269 test_trilinear_f0_t0_v0 =
270 assertEqual "v0 is correct" (v0 t) (1, 1, 1)
272 g = make_grid 1 trilinear
273 cube = fromJust $ cube_at g 1 1 1
274 t = tetrahedron0 cube
277 -- | Make sure that v1 of tetrahedron0 belonging to the cube centered
278 -- on (1,1,1) with a grid constructed from the trilinear values
279 -- winds up in the right place. See example one in the paper.
280 test_trilinear_f0_t0_v1 :: Assertion
281 test_trilinear_f0_t0_v1 =
282 assertEqual "v1 is correct" (v1 t) (0.5, 1, 1)
284 g = make_grid 1 trilinear
285 cube = fromJust $ cube_at g 1 1 1
286 t = tetrahedron0 cube
289 -- | Make sure that v2 of tetrahedron0 belonging to the cube centered
290 -- on (1,1,1) with a grid constructed from the trilinear values
291 -- winds up in the right place. See example one in the paper.
292 test_trilinear_f0_t0_v2 :: Assertion
293 test_trilinear_f0_t0_v2 =
294 assertEqual "v2 is correct" (v2 t) (0.5, 0.5, 1.5)
296 g = make_grid 1 trilinear
297 cube = fromJust $ cube_at g 1 1 1
298 t = tetrahedron0 cube
301 -- | Make sure that v3 of tetrahedron0 belonging to the cube centered
302 -- on (1,1,1) with a grid constructed from the trilinear values
303 -- winds up in the right place. See example one in the paper.
304 test_trilinear_f0_t0_v3 :: Assertion
305 test_trilinear_f0_t0_v3 =
306 assertClose "v3 is correct" (v3 t) (0.5, 1.5, 1.5)
308 g = make_grid 1 trilinear
309 cube = fromJust $ cube_at g 1 1 1
310 t = tetrahedron0 cube
313 test_trilinear_reproduced_t0 :: Assertion
314 test_trilinear_reproduced_t0 =
315 assertTrue "trilinears are reproduced correctly" $
316 and [p (i', j', k') ~= value_at trilinear i j k
320 let i' = fromIntegral i,
321 let j' = fromIntegral j,
322 let k' = fromIntegral k]
324 g = make_grid 1 trilinear
325 c0 = fromJust $ cube_at g 1 1 1
329 test_trilinear_reproduced_t1 :: Assertion
330 test_trilinear_reproduced_t1 =
331 assertTrue "trilinears are reproduced correctly" $
332 and [p (i', j', k') ~= value_at trilinear i j k
336 let i' = fromIntegral i,
337 let j' = fromIntegral j,
338 let k' = fromIntegral k]
340 g = make_grid 1 trilinear
341 c0 = fromJust $ cube_at g 1 1 1
345 test_trilinear_reproduced_t2 :: Assertion
346 test_trilinear_reproduced_t2 =
347 assertTrue "trilinears are reproduced correctly" $
348 and [p (i', j', k') ~= value_at trilinear i j k
352 let i' = fromIntegral i,
353 let j' = fromIntegral j,
354 let k' = fromIntegral k]
356 g = make_grid 1 trilinear
357 c0 = fromJust $ cube_at g 1 1 1
361 test_trilinear_reproduced_t3 :: Assertion
362 test_trilinear_reproduced_t3 =
363 assertTrue "trilinears are reproduced correctly" $
364 and [p (i', j', k') ~= value_at trilinear i j k
368 let i' = fromIntegral i,
369 let j' = fromIntegral j,
370 let k' = fromIntegral k]
372 g = make_grid 1 trilinear
373 c0 = fromJust $ cube_at g 1 1 1
377 test_trilinear_reproduced_t4 :: Assertion
378 test_trilinear_reproduced_t4 =
379 assertTrue "trilinears are reproduced correctly" $
380 and [p (i', j', k') ~= value_at trilinear i j k
384 let i' = fromIntegral i,
385 let j' = fromIntegral j,
386 let k' = fromIntegral k]
388 g = make_grid 1 trilinear
389 c0 = fromJust $ cube_at g 1 1 1
393 test_trilinear_reproduced_t5 :: Assertion
394 test_trilinear_reproduced_t5 =
395 assertTrue "trilinears are reproduced correctly" $
396 and [p (i', j', k') ~= value_at trilinear i j k
400 let i' = fromIntegral i,
401 let j' = fromIntegral j,
402 let k' = fromIntegral k]
404 g = make_grid 1 trilinear
405 c0 = fromJust $ cube_at g 1 1 1
409 test_trilinear_reproduced_t6 :: Assertion
410 test_trilinear_reproduced_t6 =
411 assertTrue "trilinears are reproduced correctly" $
412 and [p (i', j', k') ~= value_at trilinear i j k
416 let i' = fromIntegral i,
417 let j' = fromIntegral j,
418 let k' = fromIntegral k]
420 g = make_grid 1 trilinear
421 c0 = fromJust $ cube_at g 1 1 1
425 test_trilinear_reproduced_t7 :: Assertion
426 test_trilinear_reproduced_t7 =
427 assertTrue "trilinears are reproduced correctly" $
428 and [p (i', j', k') ~= value_at trilinear i j k
432 let i' = fromIntegral i,
433 let j' = fromIntegral j,
434 let k' = fromIntegral k]
436 g = make_grid 1 trilinear
437 c0 = fromJust $ cube_at g 1 1 1
441 test_trilinear_reproduced_t8 :: Assertion
442 test_trilinear_reproduced_t8 =
443 assertTrue "trilinears are reproduced correctly" $
444 and [p (i', j', k') ~= value_at trilinear i j k
448 let i' = fromIntegral i,
449 let j' = fromIntegral j,
450 let k' = fromIntegral k]
452 g = make_grid 1 trilinear
453 c0 = fromJust $ cube_at g 1 1 1
457 test_trilinear_reproduced_t9 :: Assertion
458 test_trilinear_reproduced_t9 =
459 assertTrue "trilinears are reproduced correctly" $
460 and [p (i', j', k') ~= value_at trilinear i j k
464 let i' = fromIntegral i,
465 let j' = fromIntegral j,
466 let k' = fromIntegral k]
468 g = make_grid 1 trilinear
469 c0 = fromJust $ cube_at g 1 1 1
473 test_trilinear_reproduced_t10 :: Assertion
474 test_trilinear_reproduced_t10 =
475 assertTrue "trilinears are reproduced correctly" $
476 and [p (i', j', k') ~= value_at trilinear i j k
480 let i' = fromIntegral i,
481 let j' = fromIntegral j,
482 let k' = fromIntegral k]
484 g = make_grid 1 trilinear
485 c0 = fromJust $ cube_at g 1 1 1
486 t10 = tetrahedron10 c0
489 test_trilinear_reproduced_t11 :: Assertion
490 test_trilinear_reproduced_t11 =
491 assertTrue "trilinears are reproduced correctly" $
492 and [p (i', j', k') ~= value_at trilinear i j k
496 let i' = fromIntegral i,
497 let j' = fromIntegral j,
498 let k' = fromIntegral k]
500 g = make_grid 1 trilinear
501 c0 = fromJust $ cube_at g 1 1 1
502 t11 = tetrahedron11 c0
505 test_trilinear_reproduced_t12 :: Assertion
506 test_trilinear_reproduced_t12 =
507 assertTrue "trilinears are reproduced correctly" $
508 and [p (i', j', k') ~= value_at trilinear i j k
512 let i' = fromIntegral i,
513 let j' = fromIntegral j,
514 let k' = fromIntegral k]
516 g = make_grid 1 trilinear
517 c0 = fromJust $ cube_at g 1 1 1
518 t12 = tetrahedron12 c0
521 test_trilinear_reproduced_t13 :: Assertion
522 test_trilinear_reproduced_t13 =
523 assertTrue "trilinears are reproduced correctly" $
524 and [p (i', j', k') ~= value_at trilinear i j k
528 let i' = fromIntegral i,
529 let j' = fromIntegral j,
530 let k' = fromIntegral k]
532 g = make_grid 1 trilinear
533 c0 = fromJust $ cube_at g 1 1 1
534 t13 = tetrahedron13 c0
538 test_trilinear_reproduced_t14 :: Assertion
539 test_trilinear_reproduced_t14 =
540 assertTrue "trilinears are reproduced correctly" $
541 and [p (i', j', k') ~= value_at trilinear i j k
545 let i' = fromIntegral i,
546 let j' = fromIntegral j,
547 let k' = fromIntegral k]
549 g = make_grid 1 trilinear
550 c0 = fromJust $ cube_at g 1 1 1
551 t14 = tetrahedron14 c0
554 test_trilinear_reproduced_t15 :: Assertion
555 test_trilinear_reproduced_t15 =
556 assertTrue "trilinears are reproduced correctly" $
557 and [p (i', j', k') ~= value_at trilinear i j k
561 let i' = fromIntegral i,
562 let j' = fromIntegral j,
563 let k' = fromIntegral k]
565 g = make_grid 1 trilinear
566 c0 = fromJust $ cube_at g 1 1 1
567 t15 = tetrahedron15 c0
570 test_trilinear_reproduced_t16 :: Assertion
571 test_trilinear_reproduced_t16 =
572 assertTrue "trilinears are reproduced correctly" $
573 and [p (i', j', k') ~= value_at trilinear i j k
577 let i' = fromIntegral i,
578 let j' = fromIntegral j,
579 let k' = fromIntegral k]
581 g = make_grid 1 trilinear
582 c0 = fromJust $ cube_at g 1 1 1
583 t16 = tetrahedron16 c0
586 test_trilinear_reproduced_t17 :: Assertion
587 test_trilinear_reproduced_t17 =
588 assertTrue "trilinears are reproduced correctly" $
589 and [p (i', j', k') ~= value_at trilinear i j k
593 let i' = fromIntegral i,
594 let j' = fromIntegral j,
595 let k' = fromIntegral k]
597 g = make_grid 1 trilinear
598 c0 = fromJust $ cube_at g 1 1 1
599 t17 = tetrahedron17 c0
602 test_trilinear_reproduced_t18 :: Assertion
603 test_trilinear_reproduced_t18 =
604 assertTrue "trilinears are reproduced correctly" $
605 and [p (i', j', k') ~= value_at trilinear i j k
609 let i' = fromIntegral i,
610 let j' = fromIntegral j,
611 let k' = fromIntegral k]
613 g = make_grid 1 trilinear
614 c0 = fromJust $ cube_at g 1 1 1
615 t18 = tetrahedron18 c0
618 test_trilinear_reproduced_t19 :: Assertion
619 test_trilinear_reproduced_t19 =
620 assertTrue "trilinears are reproduced correctly" $
621 and [p (i', j', k') ~= value_at trilinear i j k
625 let i' = fromIntegral i,
626 let j' = fromIntegral j,
627 let k' = fromIntegral k]
629 g = make_grid 1 trilinear
630 c0 = fromJust $ cube_at g 1 1 1
631 t19 = tetrahedron19 c0
634 test_trilinear_reproduced_t20 :: Assertion
635 test_trilinear_reproduced_t20 =
636 assertTrue "trilinears are reproduced correctly" $
637 and [p (i', j', k') ~= value_at trilinear i j k
641 let i' = fromIntegral i,
642 let j' = fromIntegral j,
643 let k' = fromIntegral k]
645 g = make_grid 1 trilinear
646 c0 = fromJust $ cube_at g 1 1 1
647 t20 = tetrahedron20 c0
651 test_trilinear_reproduced_t21 :: Assertion
652 test_trilinear_reproduced_t21 =
653 assertTrue "trilinears are reproduced correctly" $
654 and [p (i', j', k') ~= value_at trilinear i j k
658 let i' = fromIntegral i,
659 let j' = fromIntegral j,
660 let k' = fromIntegral k]
662 g = make_grid 1 trilinear
663 c0 = fromJust $ cube_at g 1 1 1
664 t21 = tetrahedron21 c0
667 test_trilinear_reproduced_t22 :: Assertion
668 test_trilinear_reproduced_t22 =
669 assertTrue "trilinears are reproduced correctly" $
670 and [p (i', j', k') ~= value_at trilinear i j k
674 let i' = fromIntegral i,
675 let j' = fromIntegral j,
676 let k' = fromIntegral k]
678 g = make_grid 1 trilinear
679 c0 = fromJust $ cube_at g 1 1 1
680 t22 = tetrahedron22 c0
684 test_trilinear_reproduced_t23 :: Assertion
685 test_trilinear_reproduced_t23 =
686 assertTrue "trilinears are reproduced correctly" $
687 and [p (i', j', k') ~= value_at trilinear i j k
691 let i' = fromIntegral i,
692 let j' = fromIntegral j,
693 let k' = fromIntegral k]
695 g = make_grid 1 trilinear
696 c0 = fromJust $ cube_at g 1 1 1
697 t19 = tetrahedron19 c0
701 test_zeros_reproduced :: Assertion
702 test_zeros_reproduced =
703 assertTrue "the zero function is reproduced correctly" $
704 and [p (i', j', k') ~= value_at zeros i j k
708 let i' = fromIntegral i,
709 let j' = fromIntegral j,
710 let k' = fromIntegral k]
712 g = make_grid 1 zeros
713 c0 = fromJust $ cube_at g 1 1 1