X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FExamples.hs;h=350829af354405bc1a5c4e9c988ec2c549bed8d2;hb=9bb6abd3469f94e2046cd0aac91c64142c52eb52;hp=62d4a00e83b4d6dec627159c49edc362c60e618b;hpb=58a5cb3570198ee1d604288f511ee02d4fc083d4;p=spline3.git diff --git a/src/Examples.hs b/src/Examples.hs index 62d4a00..350829a 100644 --- a/src/Examples.hs +++ b/src/Examples.hs @@ -1,15 +1,25 @@ -module Examples +module Examples ( + naturals, + naturals_1d, + trilinear, + trilinear_zoom_2, + trilinear9x9x9, + zeros ) where -import qualified Data.Array.Repa as Repa - -import Misc -import Values +import Data.Array.Repa ( + (:.)( (:.) ), + DIM3, + Z( Z ), + fromListUnboxed ) +import Misc ( flatten, transpose_xz ) +import Values ( Values3D ) -- | Values of the function f(x,y,z) = 1 + x + xy + xyz taken at nine -- points (hi, hj, jk) with h = 1. From example one in the paper. -- Used in the next bunch of tests. +-- trilinear_list :: [[[Double]]] trilinear_list = [ [ [ 1, 2, 3 ], [ 1, 3, 5 ], @@ -22,11 +32,14 @@ trilinear_list = [ [ [ 1, 2, 3 ], [ 1, 8, 15 ]]] -n_cube :: Int -> Repa.DIM3 -n_cube n = (Repa.Z Repa.:. n Repa.:. n Repa.:. n) +n_cube :: Int -> DIM3 +n_cube n = (Z :. n :. n :. n) trilinear :: Values3D -trilinear = Repa.fromList (n_cube 3) $ flatten trilinear_list +trilinear = fromListUnboxed (n_cube 3) $ + flatten $ + transpose_xz + trilinear_list -- | Values of the function f(x,y,z) = 1 + x + xy + xyz taken at 5^3 @@ -36,7 +49,10 @@ 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 :: Values3D -trilinear_zoom_2 = Repa.fromList (n_cube 6) $ flatten trilinear_zoom_2_list +trilinear_zoom_2 = fromListUnboxed (n_cube 6) $ + flatten $ + transpose_xz + trilinear_zoom_2_list -- | Values of the function f(x,y,z) = 1 + x + xy + xyz taken at nine^3 @@ -47,7 +63,10 @@ trilinear9x9x9_list = [[[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 1.75, 2.5, 3.25 trilinear9x9x9 :: Values3D -trilinear9x9x9 = Repa.fromList (n_cube 9) $ flatten trilinear9x9x9_list +trilinear9x9x9 = fromListUnboxed (n_cube 9) $ + flatten $ + transpose_xz + trilinear9x9x9_list -- | A 3x3x3 array of zeros. @@ -65,8 +84,10 @@ zeros_list = [ [ [ 0, 0, 0 ], [ 0, 0, 0 ]]] +-- No need to transpose_xz this one. zeros :: Values3D -zeros = Repa.fromList (n_cube 3) $ flatten zeros_list +zeros = fromListUnboxed (n_cube 3) $ flatten zeros_list + -- | A 3x3x3 array of numbers, starting at (0,0,0) == 0 and counting -- up to (2,2,2) == 26 in x,y,z order. @@ -84,4 +105,21 @@ naturals_list = [ [ [ 0, 1, 2 ], [ 24, 25, 26 ]]] naturals :: Values3D -naturals = Repa.fromList (n_cube 3) $ flatten naturals_list \ No newline at end of file +naturals = fromListUnboxed (n_cube 3) $ + flatten $ + transpose_xz + naturals_list + + + +naturals_1d_list :: [[[Double]]] +naturals_1d_list =[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]] + + +twenty_vector :: DIM3 +twenty_vector = (Z :. 1 :. 20 :. 1) + +-- | Used in at least one test where we need a 1x20x1 array. +naturals_1d :: Values3D +naturals_1d = fromListUnboxed twenty_vector (flatten naturals_1d_list)