4 import Data.Maybe (fromJust)
17 instance Arbitrary Grid where
19 (Positive h') <- arbitrary :: Gen (Positive Double)
20 fv <- arbitrary :: Gen [[[Double]]]
21 return (make_grid h' fv)
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 ],
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)
45 g = make_grid 1 trilinear
46 cube = fromJust $ cube_at g 1 1 1
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)
57 g = make_grid 1 trilinear
58 cube = fromJust $ cube_at g 1 1 1
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)
69 g = make_grid 1 trilinear
70 cube = fromJust $ cube_at g 1 1 1
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)
81 g = make_grid 1 trilinear
82 cube = fromJust $ cube_at g 1 1 1
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)
93 g = make_grid 1 trilinear
94 cube = fromJust $ cube_at g 1 1 1
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)
105 g = make_grid 1 trilinear
106 cube = fromJust $ cube_at g 1 1 1
107 t = tetrahedron0 cube
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)
117 g = make_grid 1 trilinear
118 cube = fromJust $ cube_at g 1 1 1
119 t = tetrahedron0 cube
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)
129 g = make_grid 1 trilinear
130 cube = fromJust $ cube_at g 1 1 1
131 t = tetrahedron0 cube
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)
141 g = make_grid 1 trilinear
142 cube = fromJust $ cube_at g 1 1 1
143 t = tetrahedron0 cube
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)
153 g = make_grid 1 trilinear
154 cube = fromJust $ cube_at g 1 1 1
155 t = tetrahedron0 cube
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)
165 g = make_grid 1 trilinear
166 cube = fromJust $ cube_at g 1 1 1
167 t = tetrahedron0 cube
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)
177 g = make_grid 1 trilinear
178 cube = fromJust $ cube_at g 1 1 1
179 t = tetrahedron0 cube
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)
189 g = make_grid 1 trilinear
190 cube = fromJust $ cube_at g 1 1 1
191 t = tetrahedron0 cube
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)
201 g = make_grid 1 trilinear
202 cube = fromJust $ cube_at g 1 1 1
203 t = tetrahedron0 cube
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)
213 g = make_grid 1 trilinear
214 cube = fromJust $ cube_at g 1 1 1
215 t = tetrahedron0 cube
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
225 g = make_grid 1 trilinear
226 cube = fromJust $ cube_at g 1 1 1
227 t = tetrahedron0 cube
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)
237 g = make_grid 1 trilinear
238 cube = fromJust $ cube_at g 1 1 1
239 t = tetrahedron0 cube
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
249 g = make_grid 1 trilinear
250 cube = fromJust $ cube_at g 1 1 1
251 t = tetrahedron0 cube
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)
261 g = make_grid 1 trilinear
262 cube = fromJust $ cube_at g 1 1 1
263 t = tetrahedron0 cube
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
273 g = make_grid 1 trilinear
274 cube = fromJust $ cube_at g 1 1 1
275 t = tetrahedron0 cube
278 -- | A list of all HUnit tests defined in this module.
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]