]> gitweb.michael.orlitzky.com - spline3.git/blobdiff - src/Tetrahedron.hs
src/Tetrahedron.hs: use explicit FunctionValues(..) imports.
[spline3.git] / src / Tetrahedron.hs
index 8e9acd38c8b9a0b858f56287fc8aa0c637fd8beb..87bfd5e8a65b8621179d480bd636a1feeed6854b 100644 (file)
@@ -1,3 +1,7 @@
+-- The local "coefficient" function defined within the "c" function
+-- pattern matches on a bunch of integers, but doesn't handle the
+-- "otherwise" case for performance reasons.
+{-# OPTIONS_GHC -Wno-incomplete-patterns #-}
 {-# LANGUAGE BangPatterns #-}
 
 module Tetrahedron (
@@ -16,16 +20,25 @@ where
 
 import Data.Vector ( singleton, snoc )
 import qualified Data.Vector as V ( sum )
-import Test.Framework ( Test, testGroup )
-import Test.Framework.Providers.HUnit ( testCase )
-import Test.Framework.Providers.QuickCheck2 ( testProperty )
-import Test.HUnit (Assertion, assertEqual)
-import Test.QuickCheck ( Arbitrary(..), Gen, Property, (==>) )
+import Test.Tasty ( TestTree, testGroup )
+import Test.Tasty.HUnit ( Assertion, assertEqual, testCase )
+import Test.Tasty.QuickCheck (
+  Arbitrary( arbitrary ),
+  Gen,
+  Property,
+  (==>),
+  testProperty )
 
 import Comparisons ( (~=) )
-import FunctionValues ( FunctionValues(..), empty_values )
+import FunctionValues (
+  FunctionValues( front, back, left, right, top, down, front_left,
+                  front_right, front_down, front_top, back_left, back_right,
+                  back_down, back_top, left_down, left_top, right_down,
+                  right_top, front_left_down, front_left_top,
+                  front_right_down, front_right_top, interior ),
+  empty_values )
 import Misc ( factorial )
-import Point ( Point(..), scale )
+import Point ( Point(Point), scale )
 import RealFunction ( RealFunction, cmult, fexp )
 
 data Tetrahedron =
@@ -104,7 +117,7 @@ beta t i j k l =
   coefficient `cmult` (b0_term * b1_term * b2_term * b3_term)
   where
     denominator = (factorial i)*(factorial j)*(factorial k)*(factorial l)
-    coefficient = 6 / (fromIntegral denominator)
+    coefficient = (6 / (fromIntegral denominator)) :: Double
     b0_term = (b0 t) `fexp` i
     b1_term = (b1 t) `fexp` j
     b2_term = (b2 t) `fexp` k
@@ -321,7 +334,7 @@ b3 t point = (volume inner_tetrahedron) / (precomputed_volume t)
 -- | Check the volume of a particular tetrahedron (computed by hand)
 --   Its vertices are in clockwise order, so the volume should be
 --   negative.
-tetrahedron1_geometry_tests :: Test.Framework.Test
+tetrahedron1_geometry_tests :: TestTree
 tetrahedron1_geometry_tests =
   testGroup "tetrahedron1 geometry"
               [ testCase "volume1" volume1 ]
@@ -347,7 +360,7 @@ tetrahedron1_geometry_tests =
 -- | Check the volume of a particular tetrahedron (computed by hand)
 --   Its vertices are in counter-clockwise order, so the volume should
 --   be positive.
-tetrahedron2_geometry_tests :: Test.Framework.Test
+tetrahedron2_geometry_tests :: TestTree
 tetrahedron2_geometry_tests =
   testGroup "tetrahedron2 geometry"
               [ testCase "volume1" volume1 ]
@@ -494,17 +507,17 @@ prop_swapping_vertices_doesnt_affect_coefficients4 t =
 
 
 
-tetrahedron_tests :: Test.Framework.Test
+tetrahedron_tests :: TestTree
 tetrahedron_tests =
-    testGroup "Tetrahedron Tests" [
+    testGroup "Tetrahedron tests" [
       tetrahedron1_geometry_tests,
       tetrahedron2_geometry_tests ]
 
 
 
-p78_24_properties :: Test.Framework.Test
+p78_24_properties :: TestTree
 p78_24_properties =
-  testGroup "p. 78, Section (2.4) Properties" [
+  testGroup "p. 78, Section (2.4) properties" [
     testProperty "c3000 identity" prop_c3000_identity,
     testProperty "c2100 identity" prop_c2100_identity,
     testProperty "c1110 identity" prop_c1110_identity]
@@ -556,9 +569,9 @@ p78_24_properties =
 
 
 
-tetrahedron_properties :: Test.Framework.Test
+tetrahedron_properties :: TestTree
 tetrahedron_properties =
-  testGroup "Tetrahedron Properties" [
+  testGroup "Tetrahedron properties" [
     p78_24_properties,
     testProperty "b0_v0_always_unity" prop_b0_v0_always_unity,
     testProperty "b0_v1_always_zero" prop_b0_v1_always_zero,