]> gitweb.michael.orlitzky.com - spline3.git/blob - src/Tests/Grid.hs
Add 23 more tests for trilinear reproduction, testing the remaining tetrahedra.
[spline3.git] / src / Tests / Grid.hs
1 module Tests.Grid
2 where
3
4 import Data.Maybe (fromJust)
5 import Debug.Trace (trace)
6 import Test.HUnit
7 import Test.QuickCheck
8
9 import Assertions
10 import Comparisons
11 import Cube hiding (i, j, k)
12 import Examples
13 import FunctionValues (value_at)
14 import Grid
15 import Tetrahedron
16
17
18 instance Arbitrary Grid where
19 arbitrary = do
20 (Positive h') <- arbitrary :: Gen (Positive Double)
21 fvs <- arbitrary :: Gen [[[Double]]]
22 return (make_grid h' fvs)
23
24
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)
31 where
32 g = make_grid 1 trilinear
33 cube = fromJust $ cube_at g 1 1 1
34 t = tetrahedron0 cube
35
36
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)
43 where
44 g = make_grid 1 trilinear
45 cube = fromJust $ cube_at g 1 1 1
46 t = tetrahedron0 cube
47
48
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)
55 where
56 g = make_grid 1 trilinear
57 cube = fromJust $ cube_at g 1 1 1
58 t = tetrahedron0 cube
59
60
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)
67 where
68 g = make_grid 1 trilinear
69 cube = fromJust $ cube_at g 1 1 1
70 t = tetrahedron0 cube
71
72
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)
79 where
80 g = make_grid 1 trilinear
81 cube = fromJust $ cube_at g 1 1 1
82 t = tetrahedron0 cube
83
84
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)
91 where
92 g = make_grid 1 trilinear
93 cube = fromJust $ cube_at g 1 1 1
94 t = tetrahedron0 cube
95
96
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)
103 where
104 g = make_grid 1 trilinear
105 cube = fromJust $ cube_at g 1 1 1
106 t = tetrahedron0 cube
107
108
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)
115 where
116 g = make_grid 1 trilinear
117 cube = fromJust $ cube_at g 1 1 1
118 t = tetrahedron0 cube
119
120
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)
127 where
128 g = make_grid 1 trilinear
129 cube = fromJust $ cube_at g 1 1 1
130 t = tetrahedron0 cube
131
132
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)
139 where
140 g = make_grid 1 trilinear
141 cube = fromJust $ cube_at g 1 1 1
142 t = tetrahedron0 cube
143
144
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)
151 where
152 g = make_grid 1 trilinear
153 cube = fromJust $ cube_at g 1 1 1
154 t = tetrahedron0 cube
155
156
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)
163 where
164 g = make_grid 1 trilinear
165 cube = fromJust $ cube_at g 1 1 1
166 t = tetrahedron0 cube
167
168
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)
175 where
176 g = make_grid 1 trilinear
177 cube = fromJust $ cube_at g 1 1 1
178 t = tetrahedron0 cube
179
180
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)
187 where
188 g = make_grid 1 trilinear
189 cube = fromJust $ cube_at g 1 1 1
190 t = tetrahedron0 cube
191
192
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)
199 where
200 g = make_grid 1 trilinear
201 cube = fromJust $ cube_at g 1 1 1
202 t = tetrahedron0 cube
203
204
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
211 where
212 g = make_grid 1 trilinear
213 cube = fromJust $ cube_at g 1 1 1
214 t = tetrahedron0 cube
215
216
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)
223 where
224 g = make_grid 1 trilinear
225 cube = fromJust $ cube_at g 1 1 1
226 t = tetrahedron0 cube
227
228
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
235 where
236 g = make_grid 1 trilinear
237 cube = fromJust $ cube_at g 1 1 1
238 t = tetrahedron0 cube
239
240
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)
247 where
248 g = make_grid 1 trilinear
249 cube = fromJust $ cube_at g 1 1 1
250 t = tetrahedron0 cube
251
252
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
259 where
260 g = make_grid 1 trilinear
261 cube = fromJust $ cube_at g 1 1 1
262 t = tetrahedron0 cube
263
264
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)
271 where
272 g = make_grid 1 trilinear
273 cube = fromJust $ cube_at g 1 1 1
274 t = tetrahedron0 cube
275
276
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)
283 where
284 g = make_grid 1 trilinear
285 cube = fromJust $ cube_at g 1 1 1
286 t = tetrahedron0 cube
287
288
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)
295 where
296 g = make_grid 1 trilinear
297 cube = fromJust $ cube_at g 1 1 1
298 t = tetrahedron0 cube
299
300
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)
307 where
308 g = make_grid 1 trilinear
309 cube = fromJust $ cube_at g 1 1 1
310 t = tetrahedron0 cube
311
312
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
317 | i <- [0..2],
318 j <- [0..2],
319 k <- [0..2],
320 let i' = fromIntegral i,
321 let j' = fromIntegral j,
322 let k' = fromIntegral k]
323 where
324 g = make_grid 1 trilinear
325 c0 = fromJust $ cube_at g 1 1 1
326 t0 = tetrahedron0 c0
327 p = polynomial t0
328
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
333 | i <- [0..2],
334 j <- [0..2],
335 k <- [0..2],
336 let i' = fromIntegral i,
337 let j' = fromIntegral j,
338 let k' = fromIntegral k]
339 where
340 g = make_grid 1 trilinear
341 c0 = fromJust $ cube_at g 1 1 1
342 t1 = tetrahedron1 c0
343 p = polynomial t1
344
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
349 | i <- [0..2],
350 j <- [0..2],
351 k <- [0..2],
352 let i' = fromIntegral i,
353 let j' = fromIntegral j,
354 let k' = fromIntegral k]
355 where
356 g = make_grid 1 trilinear
357 c0 = fromJust $ cube_at g 1 1 1
358 t2 = tetrahedron2 c0
359 p = polynomial t2
360
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
365 | i <- [0..2],
366 j <- [0..2],
367 k <- [0..2],
368 let i' = fromIntegral i,
369 let j' = fromIntegral j,
370 let k' = fromIntegral k]
371 where
372 g = make_grid 1 trilinear
373 c0 = fromJust $ cube_at g 1 1 1
374 t3 = tetrahedron3 c0
375 p = polynomial t3
376
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
381 | i <- [0..2],
382 j <- [0..2],
383 k <- [0..2],
384 let i' = fromIntegral i,
385 let j' = fromIntegral j,
386 let k' = fromIntegral k]
387 where
388 g = make_grid 1 trilinear
389 c0 = fromJust $ cube_at g 1 1 1
390 t4 = tetrahedron4 c0
391 p = polynomial t4
392
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
397 | i <- [0..2],
398 j <- [0..2],
399 k <- [0..2],
400 let i' = fromIntegral i,
401 let j' = fromIntegral j,
402 let k' = fromIntegral k]
403 where
404 g = make_grid 1 trilinear
405 c0 = fromJust $ cube_at g 1 1 1
406 t5 = tetrahedron5 c0
407 p = polynomial t5
408
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
413 | i <- [0..2],
414 j <- [0..2],
415 k <- [0..2],
416 let i' = fromIntegral i,
417 let j' = fromIntegral j,
418 let k' = fromIntegral k]
419 where
420 g = make_grid 1 trilinear
421 c0 = fromJust $ cube_at g 1 1 1
422 t6 = tetrahedron6 c0
423 p = polynomial t6
424
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
429 | i <- [0..2],
430 j <- [0..2],
431 k <- [0..2],
432 let i' = fromIntegral i,
433 let j' = fromIntegral j,
434 let k' = fromIntegral k]
435 where
436 g = make_grid 1 trilinear
437 c0 = fromJust $ cube_at g 1 1 1
438 t7 = tetrahedron7 c0
439 p = polynomial t7
440
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
445 | i <- [0..2],
446 j <- [0..2],
447 k <- [0..2],
448 let i' = fromIntegral i,
449 let j' = fromIntegral j,
450 let k' = fromIntegral k]
451 where
452 g = make_grid 1 trilinear
453 c0 = fromJust $ cube_at g 1 1 1
454 t8 = tetrahedron8 c0
455 p = polynomial t8
456
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
461 | i <- [0..2],
462 j <- [0..2],
463 k <- [0..2],
464 let i' = fromIntegral i,
465 let j' = fromIntegral j,
466 let k' = fromIntegral k]
467 where
468 g = make_grid 1 trilinear
469 c0 = fromJust $ cube_at g 1 1 1
470 t9 = tetrahedron9 c0
471 p = polynomial t9
472
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
477 | i <- [0..2],
478 j <- [0..2],
479 k <- [0..2],
480 let i' = fromIntegral i,
481 let j' = fromIntegral j,
482 let k' = fromIntegral k]
483 where
484 g = make_grid 1 trilinear
485 c0 = fromJust $ cube_at g 1 1 1
486 t10 = tetrahedron10 c0
487 p = polynomial t10
488
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
493 | i <- [0..2],
494 j <- [0..2],
495 k <- [0..2],
496 let i' = fromIntegral i,
497 let j' = fromIntegral j,
498 let k' = fromIntegral k]
499 where
500 g = make_grid 1 trilinear
501 c0 = fromJust $ cube_at g 1 1 1
502 t11 = tetrahedron11 c0
503 p = polynomial t11
504
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
509 | i <- [0..2],
510 j <- [0..2],
511 k <- [0..2],
512 let i' = fromIntegral i,
513 let j' = fromIntegral j,
514 let k' = fromIntegral k]
515 where
516 g = make_grid 1 trilinear
517 c0 = fromJust $ cube_at g 1 1 1
518 t12 = tetrahedron12 c0
519 p = polynomial t12
520
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
525 | i <- [0..2],
526 j <- [0..2],
527 k <- [0..2],
528 let i' = fromIntegral i,
529 let j' = fromIntegral j,
530 let k' = fromIntegral k]
531 where
532 g = make_grid 1 trilinear
533 c0 = fromJust $ cube_at g 1 1 1
534 t13 = tetrahedron13 c0
535 p = polynomial t13
536
537
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
542 | i <- [0..2],
543 j <- [0..2],
544 k <- [0..2],
545 let i' = fromIntegral i,
546 let j' = fromIntegral j,
547 let k' = fromIntegral k]
548 where
549 g = make_grid 1 trilinear
550 c0 = fromJust $ cube_at g 1 1 1
551 t14 = tetrahedron14 c0
552 p = polynomial t14
553
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
558 | i <- [0..2],
559 j <- [0..2],
560 k <- [0..2],
561 let i' = fromIntegral i,
562 let j' = fromIntegral j,
563 let k' = fromIntegral k]
564 where
565 g = make_grid 1 trilinear
566 c0 = fromJust $ cube_at g 1 1 1
567 t15 = tetrahedron15 c0
568 p = polynomial t15
569
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
574 | i <- [0..2],
575 j <- [0..2],
576 k <- [0..2],
577 let i' = fromIntegral i,
578 let j' = fromIntegral j,
579 let k' = fromIntegral k]
580 where
581 g = make_grid 1 trilinear
582 c0 = fromJust $ cube_at g 1 1 1
583 t16 = tetrahedron16 c0
584 p = polynomial t16
585
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
590 | i <- [0..2],
591 j <- [0..2],
592 k <- [0..2],
593 let i' = fromIntegral i,
594 let j' = fromIntegral j,
595 let k' = fromIntegral k]
596 where
597 g = make_grid 1 trilinear
598 c0 = fromJust $ cube_at g 1 1 1
599 t17 = tetrahedron17 c0
600 p = polynomial t17
601
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
606 | i <- [0..2],
607 j <- [0..2],
608 k <- [0..2],
609 let i' = fromIntegral i,
610 let j' = fromIntegral j,
611 let k' = fromIntegral k]
612 where
613 g = make_grid 1 trilinear
614 c0 = fromJust $ cube_at g 1 1 1
615 t18 = tetrahedron18 c0
616 p = polynomial t18
617
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
622 | i <- [0..2],
623 j <- [0..2],
624 k <- [0..2],
625 let i' = fromIntegral i,
626 let j' = fromIntegral j,
627 let k' = fromIntegral k]
628 where
629 g = make_grid 1 trilinear
630 c0 = fromJust $ cube_at g 1 1 1
631 t19 = tetrahedron19 c0
632 p = polynomial t19
633
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
638 | i <- [0..2],
639 j <- [0..2],
640 k <- [0..2],
641 let i' = fromIntegral i,
642 let j' = fromIntegral j,
643 let k' = fromIntegral k]
644 where
645 g = make_grid 1 trilinear
646 c0 = fromJust $ cube_at g 1 1 1
647 t20 = tetrahedron20 c0
648 p = polynomial t20
649
650
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
655 | i <- [0..2],
656 j <- [0..2],
657 k <- [0..2],
658 let i' = fromIntegral i,
659 let j' = fromIntegral j,
660 let k' = fromIntegral k]
661 where
662 g = make_grid 1 trilinear
663 c0 = fromJust $ cube_at g 1 1 1
664 t21 = tetrahedron21 c0
665 p = polynomial t21
666
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
671 | i <- [0..2],
672 j <- [0..2],
673 k <- [0..2],
674 let i' = fromIntegral i,
675 let j' = fromIntegral j,
676 let k' = fromIntegral k]
677 where
678 g = make_grid 1 trilinear
679 c0 = fromJust $ cube_at g 1 1 1
680 t22 = tetrahedron22 c0
681 p = polynomial t22
682
683
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
688 | i <- [0..2],
689 j <- [0..2],
690 k <- [0..2],
691 let i' = fromIntegral i,
692 let j' = fromIntegral j,
693 let k' = fromIntegral k]
694 where
695 g = make_grid 1 trilinear
696 c0 = fromJust $ cube_at g 1 1 1
697 t19 = tetrahedron19 c0
698 p = polynomial t19
699
700
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
705 | i <- [0..2],
706 j <- [0..2],
707 k <- [0..2],
708 let i' = fromIntegral i,
709 let j' = fromIntegral j,
710 let k' = fromIntegral k]
711 where
712 g = make_grid 1 zeros
713 c0 = fromJust $ cube_at g 1 1 1
714 t0 = tetrahedron0 c0
715 p = polynomial t0