]> gitweb.michael.orlitzky.com - spline3.git/commitdiff
Inline the two inner functions of the zoom traversal.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 24 Aug 2011 17:05:46 +0000 (13:05 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 24 Aug 2011 17:05:46 +0000 (13:05 -0400)
src/Grid.hs

index 517e3b1bcb45a1ba870db54853133bd02f4142db..b8f1d759e1f268a1e71c33cfa5b7dd3dcb58919a 100644 (file)
@@ -105,24 +105,31 @@ find_containing_cube g p =
       k = calculate_containing_cube_coordinate g z
 
 
+{-# INLINE zoom_lookup #-}
+zoom_lookup :: Grid -> a -> (R.DIM3 -> Double)
+zoom_lookup g _ = zoom_result g
+
+
+{-# INLINE zoom_result #-}
+zoom_result :: Grid -> R.DIM3 -> Double
+zoom_result g (R.Z R.:. i R.:. j R.:. k) =
+  f p
+  where
+    i' = fromIntegral i
+    j' = fromIntegral j
+    k' = fromIntegral k
+    p  = (i', j', k') :: Point
+    c = find_containing_cube g p
+    t = head (find_containing_tetrahedra c p)
+    f = polynomial t
+
+
 zoom :: Grid -> Int -> Values3D
 zoom g scale_factor
     | xsize == 0 || ysize == 0 || zsize == 0 = empty3d
     | otherwise =
-        R.traverse arr transExtent (\_ -> newlookup)
+        R.force $ R.traverse arr transExtent (zoom_lookup g)
           where
-            fvs = function_values g
-            (xsize, ysize, zsize) = dims fvs
-            arr = fvs
+            arr = function_values g
+            (xsize, ysize, zsize) = dims arr
             transExtent = zoom_shape scale_factor
-            newlookup :: R.DIM3 -> Double
-            newlookup (R.Z R.:. i R.:. j R.:. k) =
-                f p
-                  where
-                    i' = fromIntegral i
-                    j' = fromIntegral j
-                    k' = fromIntegral k
-                    p = (i', j', k') :: Point
-                    c = find_containing_cube g p
-                    t = head (find_containing_tetrahedra c p)
-                    f = polynomial t