4 import Debug.Trace (trace)
9 import FunctionValues (FunctionValues)
10 import Tests.FunctionValues ()
11 import Tetrahedron (b0, b1, b2, b3, c,
12 Tetrahedron(Tetrahedron),
13 v0, v1, v2, v3, volume)
15 instance Arbitrary Cube where
17 (Positive h') <- arbitrary :: Gen (Positive Double)
18 i' <- choose (coordmin, coordmax)
19 j' <- choose (coordmin, coordmax)
20 k' <- choose (coordmin, coordmax)
21 fv' <- arbitrary :: Gen FunctionValues
22 return (Cube h' i' j' k' fv')
24 coordmin = -268435456 -- -(2^29 / 2)
25 coordmax = 268435456 -- +(2^29 / 2)
30 -- | Since the grid size is necessarily positive, all tetrahedrons
31 -- (which comprise cubes of positive volume) must have positive volume
33 prop_all_volumes_positive :: Cube -> Bool
34 prop_all_volumes_positive c =
35 null nonpositive_volumes
38 volumes = map volume ts
39 nonpositive_volumes = filter (<= 0) volumes
41 -- | In fact, since all of the tetrahedra are identical, we should
42 -- already know their volumes. There's 24 tetrahedra to a cube, so
43 -- we'd expect the volume of each one to be (1/24)*h^3.
44 prop_tetrahedron0_volumes_exact :: Cube -> Bool
45 prop_tetrahedron0_volumes_exact c =
46 volume (tetrahedron0 c) ~= (1/24)*(delta^(3::Int))
50 -- | In fact, since all of the tetrahedra are identical, we should
51 -- already know their volumes. There's 24 tetrahedra to a cube, so
52 -- we'd expect the volume of each one to be (1/24)*h^3.
53 prop_tetrahedron1_volumes_exact :: Cube -> Bool
54 prop_tetrahedron1_volumes_exact c =
55 volume (tetrahedron1 c) ~= (1/24)*(delta^(3::Int))
59 -- | In fact, since all of the tetrahedra are identical, we should
60 -- already know their volumes. There's 24 tetrahedra to a cube, so
61 -- we'd expect the volume of each one to be (1/24)*h^3.
62 prop_tetrahedron2_volumes_exact :: Cube -> Bool
63 prop_tetrahedron2_volumes_exact c =
64 volume (tetrahedron2 c) ~= (1/24)*(delta^(3::Int))
68 -- | In fact, since all of the tetrahedra are identical, we should
69 -- already know their volumes. There's 24 tetrahedra to a cube, so
70 -- we'd expect the volume of each one to be (1/24)*h^3.
71 prop_tetrahedron3_volumes_exact :: Cube -> Bool
72 prop_tetrahedron3_volumes_exact c =
73 volume (tetrahedron3 c) ~= (1/24)*(delta^(3::Int))
77 -- | In fact, since all of the tetrahedra are identical, we should
78 -- already know their volumes. There's 24 tetrahedra to a cube, so
79 -- we'd expect the volume of each one to be (1/24)*h^3.
80 prop_tetrahedron4_volumes_exact :: Cube -> Bool
81 prop_tetrahedron4_volumes_exact c =
82 volume (tetrahedron4 c) ~= (1/24)*(delta^(3::Int))
86 -- | In fact, since all of the tetrahedra are identical, we should
87 -- already know their volumes. There's 24 tetrahedra to a cube, so
88 -- we'd expect the volume of each one to be (1/24)*h^3.
89 prop_tetrahedron5_volumes_exact :: Cube -> Bool
90 prop_tetrahedron5_volumes_exact c =
91 volume (tetrahedron5 c) ~= (1/24)*(delta^(3::Int))
95 -- | In fact, since all of the tetrahedra are identical, we should
96 -- already know their volumes. There's 24 tetrahedra to a cube, so
97 -- we'd expect the volume of each one to be (1/24)*h^3.
98 prop_tetrahedron6_volumes_exact :: Cube -> Bool
99 prop_tetrahedron6_volumes_exact c =
100 volume (tetrahedron6 c) ~= (1/24)*(delta^(3::Int))
104 -- | In fact, since all of the tetrahedra are identical, we should
105 -- already know their volumes. There's 24 tetrahedra to a cube, so
106 -- we'd expect the volume of each one to be (1/24)*h^3.
107 prop_tetrahedron7_volumes_exact :: Cube -> Bool
108 prop_tetrahedron7_volumes_exact c =
109 volume (tetrahedron7 c) ~= (1/24)*(delta^(3::Int))
113 -- | All tetrahedron should have their v0 located at the center of the cube.
114 prop_v0_all_equal :: Cube -> Bool
115 prop_v0_all_equal c = (v0 t0) == (v0 t1)
117 t0 = head (tetrahedrons c) -- Doesn't matter which two we choose.
118 t1 = head $ tail (tetrahedrons c)
121 -- | This pretty much repeats the prop_all_volumes_positive property,
122 -- but will let me know which tetrahedrons's vertices are disoriented.
123 prop_tetrahedron0_volumes_positive :: Cube -> Bool
124 prop_tetrahedron0_volumes_positive c =
125 volume (tetrahedron0 c) > 0
127 -- | This pretty much repeats the prop_all_volumes_positive property,
128 -- but will let me know which tetrahedrons's vertices are disoriented.
129 prop_tetrahedron1_volumes_positive :: Cube -> Bool
130 prop_tetrahedron1_volumes_positive c =
131 volume (tetrahedron1 c) > 0
133 -- | This pretty much repeats the prop_all_volumes_positive property,
134 -- but will let me know which tetrahedrons's vertices are disoriented.
135 prop_tetrahedron2_volumes_positive :: Cube -> Bool
136 prop_tetrahedron2_volumes_positive c =
137 volume (tetrahedron2 c) > 0
139 -- | This pretty much repeats the prop_all_volumes_positive property,
140 -- but will let me know which tetrahedrons's vertices are disoriented.
141 prop_tetrahedron3_volumes_positive :: Cube -> Bool
142 prop_tetrahedron3_volumes_positive c =
143 volume (tetrahedron3 c) > 0
145 -- | This pretty much repeats the prop_all_volumes_positive property,
146 -- but will let me know which tetrahedrons's vertices are disoriented.
147 prop_tetrahedron4_volumes_positive :: Cube -> Bool
148 prop_tetrahedron4_volumes_positive c =
149 volume (tetrahedron4 c) > 0
151 -- | This pretty much repeats the prop_all_volumes_positive property,
152 -- but will let me know which tetrahedrons's vertices are disoriented.
153 prop_tetrahedron5_volumes_positive :: Cube -> Bool
154 prop_tetrahedron5_volumes_positive c =
155 volume (tetrahedron5 c) > 0
157 -- | This pretty much repeats the prop_all_volumes_positive property,
158 -- but will let me know which tetrahedrons's vertices are disoriented.
159 prop_tetrahedron6_volumes_positive :: Cube -> Bool
160 prop_tetrahedron6_volumes_positive c =
161 volume (tetrahedron6 c) > 0
163 -- | This pretty much repeats the prop_all_volumes_positive property,
164 -- but will let me know which tetrahedrons's vertices are disoriented.
165 prop_tetrahedron7_volumes_positive :: Cube -> Bool
166 prop_tetrahedron7_volumes_positive c =
167 volume (tetrahedron7 c) > 0
169 -- | This pretty much repeats the prop_all_volumes_positive property,
170 -- but will let me know which tetrahedrons's vertices are disoriented.
171 prop_tetrahedron8_volumes_positive :: Cube -> Bool
172 prop_tetrahedron8_volumes_positive c =
173 volume (tetrahedron8 c) > 0
175 -- | This pretty much repeats the prop_all_volumes_positive property,
176 -- but will let me know which tetrahedrons's vertices are disoriented.
177 prop_tetrahedron9_volumes_positive :: Cube -> Bool
178 prop_tetrahedron9_volumes_positive c =
179 volume (tetrahedron9 c) > 0
181 -- | This pretty much repeats the prop_all_volumes_positive property,
182 -- but will let me know which tetrahedrons's vertices are disoriented.
183 prop_tetrahedron10_volumes_positive :: Cube -> Bool
184 prop_tetrahedron10_volumes_positive c =
185 volume (tetrahedron10 c) > 0
187 -- | This pretty much repeats the prop_all_volumes_positive property,
188 -- but will let me know which tetrahedrons's vertices are disoriented.
189 prop_tetrahedron11_volumes_positive :: Cube -> Bool
190 prop_tetrahedron11_volumes_positive c =
191 volume (tetrahedron11 c) > 0
193 -- | This pretty much repeats the prop_all_volumes_positive property,
194 -- but will let me know which tetrahedrons's vertices are disoriented.
195 prop_tetrahedron12_volumes_positive :: Cube -> Bool
196 prop_tetrahedron12_volumes_positive c =
197 volume (tetrahedron12 c) > 0
199 -- | This pretty much repeats the prop_all_volumes_positive property,
200 -- but will let me know which tetrahedrons's vertices are disoriented.
201 prop_tetrahedron13_volumes_positive :: Cube -> Bool
202 prop_tetrahedron13_volumes_positive c =
203 volume (tetrahedron13 c) > 0
205 -- | This pretty much repeats the prop_all_volumes_positive property,
206 -- but will let me know which tetrahedrons's vertices are disoriented.
207 prop_tetrahedron14_volumes_positive :: Cube -> Bool
208 prop_tetrahedron14_volumes_positive c =
209 volume (tetrahedron14 c) > 0
211 -- | This pretty much repeats the prop_all_volumes_positive property,
212 -- but will let me know which tetrahedrons's vertices are disoriented.
213 prop_tetrahedron15_volumes_positive :: Cube -> Bool
214 prop_tetrahedron15_volumes_positive c =
215 volume (tetrahedron15 c) > 0
217 -- | This pretty much repeats the prop_all_volumes_positive property,
218 -- but will let me know which tetrahedrons's vertices are disoriented.
219 prop_tetrahedron16_volumes_positive :: Cube -> Bool
220 prop_tetrahedron16_volumes_positive c =
221 volume (tetrahedron16 c) > 0
223 -- | This pretty much repeats the prop_all_volumes_positive property,
224 -- but will let me know which tetrahedrons's vertices are disoriented.
225 prop_tetrahedron17_volumes_positive :: Cube -> Bool
226 prop_tetrahedron17_volumes_positive c =
227 volume (tetrahedron17 c) > 0
229 -- | This pretty much repeats the prop_all_volumes_positive property,
230 -- but will let me know which tetrahedrons's vertices are disoriented.
231 prop_tetrahedron18_volumes_positive :: Cube -> Bool
232 prop_tetrahedron18_volumes_positive c =
233 volume (tetrahedron18 c) > 0
235 -- | This pretty much repeats the prop_all_volumes_positive property,
236 -- but will let me know which tetrahedrons's vertices are disoriented.
237 prop_tetrahedron19_volumes_positive :: Cube -> Bool
238 prop_tetrahedron19_volumes_positive c =
239 volume (tetrahedron19 c) > 0
241 -- | This pretty much repeats the prop_all_volumes_positive property,
242 -- but will let me know which tetrahedrons's vertices are disoriented.
243 prop_tetrahedron20_volumes_positive :: Cube -> Bool
244 prop_tetrahedron20_volumes_positive c =
245 volume (tetrahedron20 c) > 0
247 -- | This pretty much repeats the prop_all_volumes_positive property,
248 -- but will let me know which tetrahedrons's vertices are disoriented.
249 prop_tetrahedron21_volumes_positive :: Cube -> Bool
250 prop_tetrahedron21_volumes_positive c =
251 volume (tetrahedron21 c) > 0
253 -- | This pretty much repeats the prop_all_volumes_positive property,
254 -- but will let me know which tetrahedrons's vertices are disoriented.
255 prop_tetrahedron22_volumes_positive :: Cube -> Bool
256 prop_tetrahedron22_volumes_positive c =
257 volume (tetrahedron22 c) > 0
259 -- | This pretty much repeats the prop_all_volumes_positive property,
260 -- but will let me know which tetrahedrons's vertices are disoriented.
261 prop_tetrahedron23_volumes_positive :: Cube -> Bool
262 prop_tetrahedron23_volumes_positive c =
263 volume (tetrahedron23 c) > 0
266 -- | Given in Sorokina and Zeilfelder, p. 79.
267 --prop_c0120_identity1 :: Cube -> Bool
268 --prop_c0120_identity1 cube =
269 -- c0 ~= (c1 + c2) / 2
271 -- c0 = trace ("c0 :" ++ (show (c t0 0 1 2 0))) (c t0 0 1 2 0)
272 -- c1 = trace ("c1 :" ++ (show (c t0 0 0 2 1))) (c t0 0 0 2 1)
273 -- c2 = trace ("c2 :" ++ (show (c t1 0 0 2 1))) (c t1 0 0 2 1)
274 -- t0 = tetrahedron0 cube
275 -- t1 = tetrahedron1 cube
278 -- | Given in Sorokina and Zeilfelder, p. 78.
279 -- prop_cijk1_identity :: Cube -> Bool
280 -- prop_cijk1_identity cube =
281 -- and [ c t0 i j k 1 ~=
282 -- (c t1 (i+1) j k 0) * ((b0 t0) (v3 t1)) +
283 -- (c t1 i (j+1) k 0) * ((b1 t0) (v3 t1)) +
284 -- (c t1 i j (k+1) 0) * ((b2 t0) (v3 t1)) +
285 -- (c t1 i j k 1) * ((b3 t0) (v3 t1)) | i <- [0..2],
290 -- t0 = tetrahedron0 cube
291 -- t1 = tetrahedron1 cube