From: Michael Orlitzky Date: Thu, 25 Apr 2024 23:03:11 +0000 (-0400) Subject: src/*.hs: fix all -Woperator-whitespace warnings X-Git-Tag: 1.0.2~8 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=0696fc4f3e428d2156f0be4ca40728abf2e35abe;p=spline3.git src/*.hs: fix all -Woperator-whitespace warnings This is stupid. --- diff --git a/src/Cardinal.hs b/src/Cardinal.hs index 74a729f..d3a76b6 100644 --- a/src/Cardinal.hs +++ b/src/Cardinal.hs @@ -270,22 +270,22 @@ test_c_tilde_2100_rotation_correct = assertEqual "auto-rotate equals manual rotate" ((ccwz . ccwz . cwy) expr1) expr2 where expr1 = - (3/8)*I + - (1/12)*(T + R + L + D) + - (1/64)*(FT + FR + FL + FD) + - (7/48)*F + - (1/48)*B + - (1/96)*(RT + LD + LT + RD) + - (1/192)*(BT + BR + BL + BD) + (3 / 8)*I + + (1 / 12)*(T + R + L + D) + + (1 / 64)*(FT + FR + FL + FD) + + (7 / 48)*F + + (1 / 48)*B + + (1 / 96)*(RT + LD + LT + RD) + + (1 / 192)*(BT + BR + BL + BD) expr2 = - (3/8)*I + - (1/12)*(F + L + R + B) + - (1/64)*(FT + LT + RT + BT) + - (7/48)*T + - (1/48)*D + - (1/96)*(FL + BR + FR + BL) + - (1/192)*(FD + LD + RD + BD) + (3 / 8)*I + + (1 / 12)*(F + L + R + B) + + (1 / 64)*(FT + LT + RT + BT) + + (7 / 48)*T + + (1 / 48)*D + + (1 / 96)*(FL + BR + FR + BL) + + (1 / 192)*(FD + LD + RD + BD) -- | A list of all directions, sans the interior and composite types. all_directions :: [Cardinal] diff --git a/src/Cube.hs b/src/Cube.hs index 4992851..026f4e9 100644 --- a/src/Cube.hs +++ b/src/Cube.hs @@ -113,42 +113,42 @@ instance Show Cube where -- | The left-side boundary of the cube. See Sorokina and Zeilfelder, -- p. 76. xmin :: Cube -> Double -xmin cube = (i' - 1/2) +xmin cube = (i' - 1 / 2) where i' = fromIntegral (i cube) :: Double -- | The right-side boundary of the cube. See Sorokina and Zeilfelder, -- p. 76. xmax :: Cube -> Double -xmax cube = (i' + 1/2) +xmax cube = (i' + 1 / 2) where i' = fromIntegral (i cube) :: Double -- | The front boundary of the cube. See Sorokina and Zeilfelder, -- p. 76. ymin :: Cube -> Double -ymin cube = (j' - 1/2) +ymin cube = (j' - 1 / 2) where j' = fromIntegral (j cube) :: Double -- | The back boundary of the cube. See Sorokina and Zeilfelder, -- p. 76. ymax :: Cube -> Double -ymax cube = (j' + 1/2) +ymax cube = (j' + 1 / 2) where j' = fromIntegral (j cube) :: Double -- | The bottom boundary of the cube. See Sorokina and Zeilfelder, -- p. 76. zmin :: Cube -> Double -zmin cube = (k' - 1/2) +zmin cube = (k' - 1 / 2) where k' = fromIntegral (k cube) :: Double -- | The top boundary of the cube. See Sorokina and Zeilfelder, -- p. 76. zmax :: Cube -> Double -zmax cube = (k' + 1/2) +zmax cube = (k' + 1 / 2) where k' = fromIntegral (k cube) :: Double @@ -170,7 +170,7 @@ center cube = top_face :: Cube -> Face.Face top_face cube = Face.Face v0' v1' v2' v3' where - delta = (1/2) :: Double + delta = (1 / 2) :: Double cc = center cube v0' = cc + ( Point delta (-delta) delta ) v1' = cc + ( Point delta delta delta ) @@ -183,7 +183,7 @@ top_face cube = Face.Face v0' v1' v2' v3' back_face :: Cube -> Face.Face back_face cube = Face.Face v0' v1' v2' v3' where - delta = (1/2) :: Double + delta = (1 / 2) :: Double cc = center cube v0' = cc + ( Point delta (-delta) (-delta) ) v1' = cc + ( Point delta delta (-delta) ) @@ -195,7 +195,7 @@ back_face cube = Face.Face v0' v1' v2' v3' down_face :: Cube -> Face.Face down_face cube = Face.Face v0' v1' v2' v3' where - delta = (1/2) :: Double + delta = (1 / 2) :: Double cc = center cube v0' = cc + ( Point (-delta) (-delta) (-delta) ) v1' = cc + ( Point (-delta) delta (-delta) ) @@ -208,7 +208,7 @@ down_face cube = Face.Face v0' v1' v2' v3' front_face :: Cube -> Face.Face front_face cube = Face.Face v0' v1' v2' v3' where - delta = (1/2) :: Double + delta = (1 / 2) :: Double cc = center cube v0' = cc + ( Point (-delta) (-delta) delta ) v1' = cc + ( Point (-delta) delta delta ) @@ -219,7 +219,7 @@ front_face cube = Face.Face v0' v1' v2' v3' left_face :: Cube -> Face.Face left_face cube = Face.Face v0' v1' v2' v3' where - delta = (1/2) :: Double + delta = (1 / 2) :: Double cc = center cube v0' = cc + ( Point delta (-delta) delta ) v1' = cc + ( Point (-delta) (-delta) delta ) @@ -231,7 +231,7 @@ left_face cube = Face.Face v0' v1' v2' v3' right_face :: Cube -> Face.Face right_face cube = Face.Face v0' v1' v2' v3' where - delta = (1/2) :: Double + delta = (1 / 2) :: Double cc = center cube v0' = cc + ( Point (-delta) delta delta) v1' = cc + ( Point delta delta delta ) @@ -735,7 +735,7 @@ prop_all_volumes_positive cube = -- we'd expect the volume of each one to be 1/24. prop_all_volumes_exact :: Cube -> Bool prop_all_volumes_exact cube = - and [volume t ~~= 1/24 | t <- tetrahedra cube] + and [volume t ~~= 1 / 24 | t <- tetrahedra cube] -- | All tetrahedron should have their v0 located at the center of the -- cube. @@ -940,7 +940,7 @@ prop_c2100_identity2 cube = prop_c3000_identity :: Cube -> Bool prop_c3000_identity cube = c t0 3 0 0 0 ~= c t0 2 1 0 0 + c t6 2 1 0 0 - - ((c t0 2 0 1 0 + c t0 2 0 0 1)/ 2) + - ((c t0 2 0 1 0 + c t0 2 0 0 1) / 2) where t0 = tetrahedron cube 0 t6 = tetrahedron cube 6 @@ -951,7 +951,7 @@ prop_c3000_identity cube = prop_c2010_identity :: Cube -> Bool prop_c2010_identity cube = c t0 2 0 1 0 ~= c t0 1 1 1 0 + c t6 1 1 0 1 - - ((c t0 1 0 2 0 + c t0 1 0 1 1)/ 2) + - ((c t0 1 0 2 0 + c t0 1 0 1 1) / 2) where t0 = tetrahedron cube 0 t6 = tetrahedron cube 6 @@ -962,7 +962,7 @@ prop_c2010_identity cube = prop_c2001_identity :: Cube -> Bool prop_c2001_identity cube = c t0 2 0 0 1 ~= c t0 1 1 0 1 + c t6 1 1 1 0 - - ((c t0 1 0 0 2 + c t0 1 0 1 1)/ 2) + - ((c t0 1 0 0 2 + c t0 1 0 1 1) / 2) where t0 = tetrahedron cube 0 t6 = tetrahedron cube 6 @@ -973,7 +973,7 @@ prop_c2001_identity cube = prop_c1020_identity :: Cube -> Bool prop_c1020_identity cube = c t0 1 0 2 0 ~= c t0 0 1 2 0 + c t6 0 1 0 2 - - ((c t0 0 0 3 0 + c t0 0 0 2 1)/ 2) + - ((c t0 0 0 3 0 + c t0 0 0 2 1) / 2) where t0 = tetrahedron cube 0 t6 = tetrahedron cube 6 @@ -984,7 +984,7 @@ prop_c1020_identity cube = prop_c1002_identity :: Cube -> Bool prop_c1002_identity cube = c t0 1 0 0 2 ~= c t0 0 1 0 2 + c t6 0 1 2 0 - - ((c t0 0 0 0 3 + c t0 0 0 1 2)/ 2) + - ((c t0 0 0 0 3 + c t0 0 0 1 2) / 2) where t0 = tetrahedron cube 0 t6 = tetrahedron cube 6 @@ -995,7 +995,7 @@ prop_c1002_identity cube = prop_c1011_identity :: Cube -> Bool prop_c1011_identity cube = c t0 1 0 1 1 ~= c t0 0 1 1 1 + c t6 0 1 1 1 - - ((c t0 0 0 1 2 + c t0 0 0 2 1)/ 2) + ((c t0 0 0 1 2 + c t0 0 0 2 1) / 2) where t0 = tetrahedron cube 0 t6 = tetrahedron cube 6 @@ -1019,23 +1019,23 @@ prop_c_tilde_2100_rotation_correct cube = -- What gets computed for c2100 of t6. expr1 = eval (function_values t6) $ - (3/8)*I + - (1/12)*(T + R + L + D) + - (1/64)*(FT + FR + FL + FD) + - (7/48)*F + - (1/48)*B + - (1/96)*(RT + LD + LT + RD) + - (1/192)*(BT + BR + BL + BD) + (3 / 8)*I + + (1 / 12)*(T + R + L + D) + + (1 / 64)*(FT + FR + FL + FD) + + (7 / 48)*F + + (1 / 48)*B + + (1 / 96)*(RT + LD + LT + RD) + + (1 / 192)*(BT + BR + BL + BD) -- What should be computed for c2100 of t6. expr2 = eval (function_values t0) $ - (3/8)*I + - (1/12)*(F + R + L + B) + - (1/64)*(FT + RT + LT + BT) + - (7/48)*T + - (1/48)*D + - (1/96)*(FR + FL + BR + BL) + - (1/192)*(FD + RD + LD + BD) + (3 / 8)*I + + (1 / 12)*(F + R + L + B) + + (1 / 64)*(FT + RT + LT + BT) + + (7 / 48)*T + + (1 / 48)*D + + (1 / 96)*(FR + FL + BR + BL) + + (1 / 192)*(FD + RD + LD + BD) -- | We know what (c t6 2 1 0 0) should be from Sorokina and @@ -1052,13 +1052,13 @@ prop_c_tilde_2100_correct cube = t6 = tetrahedron cube 6 fvs = function_values t0 expected = eval fvs $ - (3/8)*I + - (1/12)*(F + R + L + B) + - (1/64)*(FT + RT + LT + BT) + - (7/48)*T + - (1/48)*D + - (1/96)*(FR + FL + BR + BL) + - (1/192)*(FD + RD + LD + BD) + (3 / 8)*I + + (1 / 12)*(F + R + L + B) + + (1 / 64)*(FT + RT + LT + BT) + + (7 / 48)*T + + (1 / 48)*D + + (1 / 96)*(FR + FL + BR + BL) + + (1 / 192)*(FD + RD + LD + BD) -- Tests to check that the correct edges are incidental. diff --git a/src/Examples.hs b/src/Examples.hs index 350829a..93a7cbf 100644 --- a/src/Examples.hs +++ b/src/Examples.hs @@ -46,7 +46,7 @@ trilinear = fromListUnboxed (n_cube 3) $ -- points (hi, hj, jk) with h = 0.5. We should be able to reproduce -- this from splines based on the 3x3x3 trilinear. trilinear_zoom_2_list :: [[[Double]]] -trilinear_zoom_2_list = [[[1, 3/2, 2, 5/2, 3], [1, 7/4, 5/2, 13/4, 4], [1, 2, 3, 4, 5], [1, 9/4, 7/2, 19/4, 6], [1, 5/2, 4, 11/2, 7]], [[1, 3/2, 2, 5/2, 3], [1, 15/8, 11/4, 29/8, 9/2], [1, 9/4, 7/2, 19/4, 6], [1, 21/8, 17/4, 47/8, 15/2], [1, 3, 5, 7, 9]], [[1, 3/2, 2, 5/2, 3], [1, 2, 3, 4, 5], [1, 5/2, 4, 11/2, 7], [1, 3, 5, 7, 9], [1, 7/2, 6, 17/2, 11]], [[1, 3/2, 2, 5/2, 3], [1, 17/8, 13/4, 35/8, 11/2], [1, 11/4, 9/2, 25/4, 8], [1, 27/8, 23/4, 65/8, 21/2], [1, 4, 7, 10, 13]], [[1, 3/2, 2, 5/2, 3], [1, 9/4, 7/2, 19/4, 6], [1, 3, 5, 7, 9], [1, 15/4, 13/2, 37/4, 12], [1, 9/2, 8, 23/2, 15]]] +trilinear_zoom_2_list = [[[1, 3 / 2, 2, 5 / 2, 3], [1, 7 / 4, 5 / 2, 13 / 4, 4], [1, 2, 3, 4, 5], [1, 9 / 4, 7 / 2, 19 / 4, 6], [1, 5 / 2, 4, 11 / 2, 7]], [[1, 3 / 2, 2, 5 / 2, 3], [1, 15 / 8, 11 / 4, 29 / 8, 9 / 2], [1, 9 / 4, 7 / 2, 19 / 4, 6], [1, 21 / 8, 17 / 4, 47 / 8, 15 / 2], [1, 3, 5, 7, 9]], [[1, 3 / 2, 2, 5 / 2, 3], [1, 2, 3, 4, 5], [1, 5 / 2, 4, 11 / 2, 7], [1, 3, 5, 7, 9], [1, 7 / 2, 6, 17 / 2, 11]], [[1, 3 / 2, 2, 5 / 2, 3], [1, 17 / 8, 13 / 4, 35 / 8, 11 / 2], [1, 11 / 4, 9 / 2, 25 / 4, 8], [1, 27 / 8, 23 / 4, 65 / 8, 21 / 2], [1, 4, 7, 10, 13]], [[1, 3 / 2, 2, 5 / 2, 3], [1, 9 / 4, 7 / 2, 19 / 4, 6], [1, 3, 5, 7, 9], [1, 15 / 4, 13 / 2, 37 / 4, 12], [1, 9 / 2, 8, 23 / 2, 15]]] trilinear_zoom_2 :: Values3D trilinear_zoom_2 = fromListUnboxed (n_cube 6) $ diff --git a/src/Face.hs b/src/Face.hs index de24a43..ce4a5d5 100644 --- a/src/Face.hs +++ b/src/Face.hs @@ -28,4 +28,4 @@ instance Show Face where -- tetrahedron. center :: Face -> Point center (Face v0' v1' v2' v3') = - (v0' + v1' + v2' + v3') `scale` (1/4) + (v0' + v1' + v2' + v3') `scale` (1 / 4) diff --git a/src/FunctionValues.hs b/src/FunctionValues.hs index 62b861c..bc14146 100644 --- a/src/FunctionValues.hs +++ b/src/FunctionValues.hs @@ -290,32 +290,32 @@ value_at v3d !i !j !k -- object centered at (i,j,k) make_values :: Values3D -> Int -> Int -> Int -> FunctionValues make_values values !i !j !k = - empty_values { front = value_at values (i-1) j k, - back = value_at values (i+1) j k, - left = value_at values i (j-1) k, - right = value_at values i (j+1) k, - down = value_at values i j (k-1), - top = value_at values i j (k+1), - front_left = value_at values (i-1) (j-1) k, - front_right = value_at values (i-1) (j+1) k, - front_down =value_at values (i-1) j (k-1), - front_top = value_at values (i-1) j (k+1), - back_left = value_at values (i+1) (j-1) k, - back_right = value_at values (i+1) (j+1) k, - back_down = value_at values (i+1) j (k-1), - back_top = value_at values (i+1) j (k+1), - left_down = value_at values i (j-1) (k-1), - left_top = value_at values i (j-1) (k+1), - right_down = value_at values i (j+1) (k-1), - right_top = value_at values i (j+1) (k+1), - front_left_down = value_at values (i-1) (j-1) (k-1), - front_left_top = value_at values (i-1) (j-1) (k+1), - front_right_down = value_at values (i-1) (j+1) (k-1), - front_right_top = value_at values (i-1) (j+1) (k+1), - back_left_down = value_at values (i+1) (j-1) (k-1), - back_left_top = value_at values (i+1) (j-1) (k+1), - back_right_down = value_at values (i+1) (j+1) (k-1), - back_right_top = value_at values (i+1) (j+1) (k+1), + empty_values { front = value_at values (i - 1) j k, + back = value_at values (i + 1) j k, + left = value_at values i (j - 1) k, + right = value_at values i (j + 1) k, + down = value_at values i j (k - 1), + top = value_at values i j (k + 1), + front_left = value_at values (i - 1) (j - 1) k, + front_right = value_at values (i - 1) (j + 1) k, + front_down =value_at values (i - 1) j (k - 1), + front_top = value_at values (i - 1) j (k + 1), + back_left = value_at values (i + 1) (j - 1) k, + back_right = value_at values (i + 1) (j + 1) k, + back_down = value_at values (i + 1) j (k - 1), + back_top = value_at values (i + 1) j (k + 1), + left_down = value_at values i (j - 1) (k - 1), + left_top = value_at values i (j - 1) (k + 1), + right_down = value_at values i (j + 1) (k - 1), + right_top = value_at values i (j + 1) (k + 1), + front_left_down = value_at values (i - 1) (j - 1) (k - 1), + front_left_top = value_at values (i - 1) (j - 1) (k + 1), + front_right_down = value_at values (i - 1) (j + 1) (k - 1), + front_right_top = value_at values (i - 1) (j + 1) (k + 1), + back_left_down = value_at values (i + 1) (j - 1) (k - 1), + back_left_top = value_at values (i + 1) (j - 1) (k + 1), + back_right_down = value_at values (i + 1) (j + 1) (k - 1), + back_right_top = value_at values (i + 1) (j + 1) (k + 1), interior = value_at values i j k } -- | Takes a 'FunctionValues' and a function that transforms one diff --git a/src/Grid.hs b/src/Grid.hs index 43e60ef..d98bda1 100644 --- a/src/Grid.hs +++ b/src/Grid.hs @@ -77,7 +77,7 @@ cube_at !g !i !j !k = where fvs = function_values g fvs' = make_values fvs i j k - tet_vol = (1/24) :: Double + tet_vol = (1 / 24) :: Double -- The first cube along any axis covers (-1/2, 1/2). The second @@ -96,7 +96,7 @@ calculate_containing_cube_coordinate g coord | otherwise = (ceiling (coord + offset)) - 1 where (xsize, ysize, zsize) = dims (function_values g) - offset = (1/2) :: Double + offset = (1 / 2) :: Double -- | Takes a 'Grid', and returns a 'Cube' containing the given 'Point'. @@ -121,7 +121,7 @@ zoom_result v3d (sfx, sfy, sfz) (Z :. m :. n :. o) = f p where g = Grid v3d - offset = (1/2) :: Double + offset = (1 / 2) :: Double m' = (fromIntegral m) / (fromIntegral sfx) - offset n' = (fromIntegral n) / (fromIntegral sfy) - offset o' = (fromIntegral o) / (fromIntegral sfz) - offset @@ -191,63 +191,63 @@ trilinear_c0_t0_tests = test_trilinear_c0030 :: Assertion test_trilinear_c0030 = - assertAlmostEqual "c0030 is correct" (c t 0 0 3 0) (17/8) + assertAlmostEqual "c0030 is correct" (c t 0 0 3 0) (17 / 8) test_trilinear_c0003 :: Assertion test_trilinear_c0003 = - assertAlmostEqual "c0003 is correct" (c t 0 0 0 3) (27/8) + assertAlmostEqual "c0003 is correct" (c t 0 0 0 3) (27 / 8) test_trilinear_c0021 :: Assertion test_trilinear_c0021 = - assertAlmostEqual "c0021 is correct" (c t 0 0 2 1) (61/24) + assertAlmostEqual "c0021 is correct" (c t 0 0 2 1) (61 / 24) test_trilinear_c0012 :: Assertion test_trilinear_c0012 = - assertAlmostEqual "c0012 is correct" (c t 0 0 1 2) (71/24) + assertAlmostEqual "c0012 is correct" (c t 0 0 1 2) (71 / 24) test_trilinear_c0120 :: Assertion test_trilinear_c0120 = - assertAlmostEqual "c0120 is correct" (c t 0 1 2 0) (55/24) + assertAlmostEqual "c0120 is correct" (c t 0 1 2 0) (55 / 24) test_trilinear_c0102 :: Assertion test_trilinear_c0102 = - assertAlmostEqual "c0102 is correct" (c t 0 1 0 2) (73/24) + assertAlmostEqual "c0102 is correct" (c t 0 1 0 2) (73 / 24) test_trilinear_c0111 :: Assertion test_trilinear_c0111 = - assertAlmostEqual "c0111 is correct" (c t 0 1 1 1) (8/3) + assertAlmostEqual "c0111 is correct" (c t 0 1 1 1) (8 / 3) test_trilinear_c0210 :: Assertion test_trilinear_c0210 = - assertAlmostEqual "c0210 is correct" (c t 0 2 1 0) (29/12) + assertAlmostEqual "c0210 is correct" (c t 0 2 1 0) (29 / 12) test_trilinear_c0201 :: Assertion test_trilinear_c0201 = - assertAlmostEqual "c0201 is correct" (c t 0 2 0 1) (11/4) + assertAlmostEqual "c0201 is correct" (c t 0 2 0 1) (11 / 4) test_trilinear_c0300 :: Assertion test_trilinear_c0300 = - assertAlmostEqual "c0300 is correct" (c t 0 3 0 0) (5/2) + assertAlmostEqual "c0300 is correct" (c t 0 3 0 0) (5 / 2) test_trilinear_c1020 :: Assertion test_trilinear_c1020 = - assertAlmostEqual "c1020 is correct" (c t 1 0 2 0) (8/3) + assertAlmostEqual "c1020 is correct" (c t 1 0 2 0) (8 / 3) test_trilinear_c1002 :: Assertion test_trilinear_c1002 = - assertAlmostEqual "c1002 is correct" (c t 1 0 0 2) (23/6) + assertAlmostEqual "c1002 is correct" (c t 1 0 0 2) (23 / 6) test_trilinear_c1011 :: Assertion test_trilinear_c1011 = - assertAlmostEqual "c1011 is correct" (c t 1 0 1 1) (13/4) + assertAlmostEqual "c1011 is correct" (c t 1 0 1 1) (13 / 4) test_trilinear_c1110 :: Assertion test_trilinear_c1110 = - assertAlmostEqual "c1110 is correct" (c t 1 1 1 0) (23/8) + assertAlmostEqual "c1110 is correct" (c t 1 1 1 0) (23 / 8) test_trilinear_c1101 :: Assertion test_trilinear_c1101 = - assertAlmostEqual "c1101 is correct" (c t 1 1 0 1) (27/8) + assertAlmostEqual "c1101 is correct" (c t 1 1 0 1) (27 / 8) test_trilinear_c1200 :: Assertion test_trilinear_c1200 = @@ -255,7 +255,7 @@ trilinear_c0_t0_tests = test_trilinear_c2010 :: Assertion test_trilinear_c2010 = - assertAlmostEqual "c2010 is correct" (c t 2 0 1 0) (10/3) + assertAlmostEqual "c2010 is correct" (c t 2 0 1 0) (10 / 3) test_trilinear_c2001 :: Assertion test_trilinear_c2001 = @@ -263,7 +263,7 @@ trilinear_c0_t0_tests = test_trilinear_c2100 :: Assertion test_trilinear_c2100 = - assertAlmostEqual "c2100 is correct" (c t 2 1 0 0) (7/2) + assertAlmostEqual "c2100 is correct" (c t 2 1 0 0) (7 / 2) test_trilinear_c3000 :: Assertion test_trilinear_c3000 = @@ -344,12 +344,12 @@ test_trilinear9x9x9_reproduced = prop_cube_indices_never_go_out_of_bounds :: Grid -> Gen Bool prop_cube_indices_never_go_out_of_bounds g = do - let coordmin = negate (1/2) :: Double + let coordmin = negate (1 / 2) :: Double let (xsize, ysize, zsize) = dims $ function_values g - let xmax = (fromIntegral xsize) - (1/2) :: Double - let ymax = (fromIntegral ysize) - (1/2) :: Double - let zmax = (fromIntegral zsize) - (1/2) :: Double + let xmax = (fromIntegral xsize) - (1 / 2) :: Double + let ymax = (fromIntegral ysize) - (1 / 2) :: Double + let zmax = (fromIntegral zsize) - (1 / 2) :: Double x <- choose (coordmin, xmax) y <- choose (coordmin, ymax) diff --git a/src/Point.hs b/src/Point.hs index 004b2e4..d8b8dd8 100644 --- a/src/Point.hs +++ b/src/Point.hs @@ -24,7 +24,7 @@ instance Arbitrary Point where instance Num Point where - (Point x1 y1 z1) + (Point x2 y2 z2) = Point (x1+x2) (y1+y2) (z1+z2) + (Point x1 y1 z1) + (Point x2 y2 z2) = Point (x1 + x2) (y1 + y2) (z1 + z2) (Point x1 y1 z1) - (Point x2 y2 z2) = Point (x1-x2) (y1-y2) (z1-z2) (Point x1 y1 z1) * (Point x2 y2 z2) = Point (x1*x2) (y1*y2) (z1*z2) abs (Point x y z) = Point (abs x) (abs y) (abs z) @@ -44,4 +44,4 @@ scale (Point x y z) d = Point (x*d) (y*d) (z*d) {-# INLINE dot #-} dot :: Point -> Point -> Double dot (Point x1 y1 z1) (Point x2 y2 z2) = - (x2 - x1)^(2::Int) + (y2 - y1)^(2::Int) + (z2 - z1)^(2::Int) + (x2 - x1) ^ (2::Int) + (y2 - y1) ^ (2::Int) + (z2 - z1) ^ (2::Int) diff --git a/src/RealFunction.hs b/src/RealFunction.hs index 37babf6..f6d0482 100644 --- a/src/RealFunction.hs +++ b/src/RealFunction.hs @@ -74,4 +74,4 @@ cmult coeff f = (*coeff) . f fexp :: (RealFunction a) -> Int -> (RealFunction a) fexp f n | n == 0 = const 1 - | otherwise = \x -> (f x)^n + | otherwise = \x -> (f x) ^ n diff --git a/src/Tetrahedron.hs b/src/Tetrahedron.hs index 87bfd5e..9a3e495 100644 --- a/src/Tetrahedron.hs +++ b/src/Tetrahedron.hs @@ -80,7 +80,7 @@ instance Show Tetrahedron where -- We just average the four vertices. barycenter :: Tetrahedron -> Point barycenter (Tetrahedron _ v0' v1' v2' v3' _) = - (v0' + v1' + v2' + v3') `scale` (1/4) + (v0' + v1' + v2' + v3') `scale` (1 / 4) @@ -160,102 +160,102 @@ c !t !i !j !k !l = coefficient :: Int -> Int -> Int -> Int -> Double coefficient 0 0 3 0 = - (1/8) * (i' + f + l' + t' + lt + fl + ft + flt) + (1 / 8) * (i' + f + l' + t' + lt + fl + ft + flt) coefficient 0 0 0 3 = - (1/8) * (i' + f + r + t' + rt + fr + ft + frt) + (1 / 8) * (i' + f + r + t' + rt + fr + ft + frt) coefficient 0 0 2 1 = - (5/24)*(i' + f + t' + ft) + (1/24)*(l' + fl + lt + flt) + (5 / 24)*(i' + f + t' + ft) + (1 / 24)*(l' + fl + lt + flt) coefficient 0 0 1 2 = - (5/24)*(i' + f + t' + ft) + (1/24)*(r + fr + rt + frt) + (5 / 24)*(i' + f + t' + ft) + (1 / 24)*(r + fr + rt + frt) coefficient 0 1 2 0 = - (5/24)*(i' + f) + (1/8)*(l' + t' + fl + ft) - + (1/24)*(lt + flt) + (5 / 24)*(i' + f) + (1 / 8)*(l' + t' + fl + ft) + + (1 / 24)*(lt + flt) coefficient 0 1 0 2 = - (5/24)*(i' + f) + (1/8)*(r + t' + fr + ft) - + (1/24)*(rt + frt) + (5 / 24)*(i' + f) + (1 / 8)*(r + t' + fr + ft) + + (1 / 24)*(rt + frt) coefficient 0 1 1 1 = - (13/48)*(i' + f) + (7/48)*(t' + ft) - + (1/32)*(l' + r + fl + fr) - + (1/96)*(lt + rt + flt + frt) + (13 / 48)*(i' + f) + (7 / 48)*(t' + ft) + + (1 / 32)*(l' + r + fl + fr) + + (1 / 96)*(lt + rt + flt + frt) coefficient 0 2 1 0 = - (13/48)*(i' + f) + (17/192)*(l' + t' + fl + ft) - + (1/96)*(lt + flt) - + (1/64)*(r + d + fr + fd) - + (1/192)*(rt + ld + frt + fld) + (13 / 48)*(i' + f) + (17 / 192)*(l' + t' + fl + ft) + + (1 / 96)*(lt + flt) + + (1 / 64)*(r + d + fr + fd) + + (1 / 192)*(rt + ld + frt + fld) coefficient 0 2 0 1 = - (13/48)*(i' + f) + (17/192)*(r + t' + fr + ft) - + (1/96)*(rt + frt) - + (1/64)*(l' + d + fl + fd) - + (1/192)*(rd + lt + flt + frd) + (13 / 48)*(i' + f) + (17 / 192)*(r + t' + fr + ft) + + (1 / 96)*(rt + frt) + + (1 / 64)*(l' + d + fl + fd) + + (1 / 192)*(rd + lt + flt + frd) coefficient 0 3 0 0 = - (13/48)*(i' + f) + (5/96)*(l' + r + t' + d + fl + fr + ft + fd) - + (1/192)*(rt + rd + lt + ld + frt + frd + flt + fld) + (13 / 48)*(i' + f) + (5 / 96)*(l' + r + t' + d + fl + fr + ft + fd) + + (1 / 192)*(rt + rd + lt + ld + frt + frd + flt + fld) coefficient 1 0 2 0 = - (1/4)*i' + (1/6)*(f + l' + t') - + (1/12)*(lt + fl + ft) + (1 / 4)*i' + (1 / 6)*(f + l' + t') + + (1 / 12)*(lt + fl + ft) coefficient 1 0 0 2 = - (1/4)*i' + (1/6)*(f + r + t') - + (1/12)*(rt + fr + ft) + (1 / 4)*i' + (1 / 6)*(f + r + t') + + (1 / 12)*(rt + fr + ft) coefficient 1 0 1 1 = - (1/3)*i' + (5/24)*(f + t') - + (1/12)*ft - + (1/24)*(l' + r) - + (1/48)*(lt + rt + fl + fr) + (1 / 3)*i' + (5 / 24)*(f + t') + + (1 / 12)*ft + + (1 / 24)*(l' + r) + + (1 / 48)*(lt + rt + fl + fr) coefficient 1 1 1 0 = - (1/3)*i' + (5/24)*f - + (1/8)*(l' + t') - + (5/96)*(fl + ft) - + (1/48)*(d + r + lt) - + (1/96)*(fd + ld + rt + fr) + (1 / 3)*i' + (5 / 24)*f + + (1 / 8)*(l' + t') + + (5 / 96)*(fl + ft) + + (1 / 48)*(d + r + lt) + + (1 / 96)*(fd + ld + rt + fr) coefficient 1 1 0 1 = - (1/3)*i' + (5/24)*f - + (1/8)*(r + t') - + (5/96)*(fr + ft) - + (1/48)*(d + l' + rt) - + (1/96)*(fd + lt + rd + fl) + (1 / 3)*i' + (5 / 24)*f + + (1 / 8)*(r + t') + + (5 / 96)*(fr + ft) + + (1 / 48)*(d + l' + rt) + + (1 / 96)*(fd + lt + rd + fl) coefficient 1 2 0 0 = - (1/3)*i' + (5/24)*f - + (7/96)*(l' + r + t' + d) - + (1/32)*(fl + fr + ft + fd) - + (1/96)*(rt + rd + lt + ld) + (1 / 3)*i' + (5 / 24)*f + + (7 / 96)*(l' + r + t' + d) + + (1 / 32)*(fl + fr + ft + fd) + + (1 / 96)*(rt + rd + lt + ld) coefficient 2 0 1 0 = - (3/8)*i' + (7/48)*(f + t' + l') - + (1/48)*(r + d + b + lt + fl + ft) - + (1/96)*(rt + bt + fr + fd + ld + bl) + (3 / 8)*i' + (7 / 48)*(f + t' + l') + + (1 / 48)*(r + d + b + lt + fl + ft) + + (1 / 96)*(rt + bt + fr + fd + ld + bl) coefficient 2 0 0 1 = - (3/8)*i' + (7/48)*(f + t' + r) - + (1/48)*(l' + d + b + rt + fr + ft) - + (1/96)*(lt + bt + fl + fd + rd + br) + (3 / 8)*i' + (7 / 48)*(f + t' + r) + + (1 / 48)*(l' + d + b + rt + fr + ft) + + (1 / 96)*(lt + bt + fl + fd + rd + br) coefficient 2 1 0 0 = - (3/8)*i' + (1/12)*(t' + r + l' + d) - + (1/64)*(ft + fr + fl + fd) - + (7/48)*f - + (1/48)*b - + (1/96)*(rt + ld + lt + rd) - + (1/192)*(bt + br + bl + bd) + (3 / 8)*i' + (1 / 12)*(t' + r + l' + d) + + (1 / 64)*(ft + fr + fl + fd) + + (7 / 48)*f + + (1 / 48)*b + + (1 / 96)*(rt + ld + lt + rd) + + (1 / 192)*(bt + br + bl + bd) coefficient 3 0 0 0 = - (3/8)*i' + (1/12)*(t' + f + l' + r + d + b) - + (1/96)*(lt + fl + ft + rt + bt + fr) - + (1/96)*(fd + ld + bd + br + rd + bl) + (3 / 8)*i' + (1 / 12)*(t' + f + l' + r + d + b) + + (1 / 96)*(lt + fl + ft + rt + bt + fr) + + (1 / 96)*(fd + ld + bd + br + rd + bl) @@ -295,7 +295,7 @@ det p0 p1 p2 p3 = {-# INLINE volume #-} volume :: Tetrahedron -> Double volume (Tetrahedron _ v0' v1' v2' v3' _) = - (1/6)*(det v0' v1' v2' v3') + (1 / 6)*(det v0' v1' v2' v3') -- | The barycentric coordinates of a point with respect to v0. {-# INLINE b0 #-} @@ -352,7 +352,7 @@ tetrahedron1_geometry_tests = volume1 :: Assertion volume1 = - assertEqual "volume is correct" True (vol ~= (-1/3)) + assertEqual "volume is correct" True (vol ~= (-1 / 3)) where vol = volume t @@ -377,7 +377,7 @@ tetrahedron2_geometry_tests = precomputed_volume = 0 } volume1 :: Assertion - volume1 = assertEqual "volume1 is correct" True (vol ~= (1/3)) + volume1 = assertEqual "volume1 is correct" True (vol ~= (1 / 3)) where vol = volume t @@ -525,7 +525,7 @@ p78_24_properties = -- | Returns the domain point of t with indices i,j,k,l. domain_point :: Tetrahedron -> Int -> Int -> Int -> Int -> Point domain_point t i j k l = - weighted_sum `scale` (1/3) + weighted_sum `scale` (1 / 3) where v0' = (v0 t) `scale` (fromIntegral i) v1' = (v1 t) `scale` (fromIntegral j) @@ -551,10 +551,10 @@ p78_24_properties = (volume t) > 0 ==> c t 2 1 0 0 ~= (term1 - term2 + term3 - term4) where - term1 = (1/3)*(p t 0 3 0 0) - term2 = (5/6)*(p t 3 0 0 0) + term1 = (1 / 3)*(p t 0 3 0 0) + term2 = (5 / 6)*(p t 3 0 0 0) term3 = 3*(p t 2 1 0 0) - term4 = (3/2)*(p t 1 2 0 0) + term4 = (3 / 2)*(p t 1 2 0 0) -- | Given in Sorokina and Zeilfelder, p. 78. prop_c1110_identity :: Tetrahedron -> Property @@ -562,10 +562,10 @@ p78_24_properties = (volume t) > 0 ==> c t 1 1 1 0 ~= (term1 + term2 - term3 - term4) where - term1 = (1/3)*((p t 3 0 0 0) + (p t 0 3 0 0) + (p t 0 0 3 0)) - term2 = (9/2)*(p t 1 1 1 0) - term3 = (3/4)*((p t 2 1 0 0) + (p t 1 2 0 0) + (p t 2 0 1 0)) - term4 = (3/4)*((p t 1 0 2 0) + (p t 0 2 1 0) + (p t 0 1 2 0)) + term1 = (1 / 3)*((p t 3 0 0 0) + (p t 0 3 0 0) + (p t 0 0 3 0)) + term2 = (9 / 2)*(p t 1 1 1 0) + term3 = (3 / 4)*((p t 2 1 0 0) + (p t 1 2 0 0) + (p t 2 0 1 0)) + term4 = (3 / 4)*((p t 1 0 2 0) + (p t 0 2 1 0) + (p t 0 1 2 0)) diff --git a/src/Volumetric.hs b/src/Volumetric.hs index 0d1dfaa..f9e8d54 100644 --- a/src/Volumetric.hs +++ b/src/Volumetric.hs @@ -73,7 +73,7 @@ bracket lower_threshold upper_threshold x where numerator = x - lower_threshold denominator = upper_threshold - lower_threshold - r = numerator/denominator + r = numerator / denominator flip16 :: Word16 -> Word16