module Examples ( naturals, naturals_1d, trilinear, trilinear_zoom_2, trilinear9x9x9, zeros ) where 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 ], [ 1, 4, 7 ] ], [ [ 1, 2, 3 ], [ 1, 4, 7 ], [ 1, 6, 11 ] ], [ [ 1, 2, 3 ], [ 1, 5, 9 ], [ 1, 8, 15 ]]] n_cube :: Int -> DIM3 n_cube n = (Z :. n :. n :. n) trilinear :: Values3D 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 -- 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 :: Values3D 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 -- points (hi, hj, jk) with h = 0.5. We should be able to reproduce -- this from splines based on the 3x3x3 trilinear. trilinear9x9x9_list :: [[[Double]]] trilinear9x9x9_list = [[[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 1.75, 2.5, 3.25, 4, 4.75, 5.5, 6.25, 7], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2.25, 3.5, 4.75, 6, 7.25, 8.5, 9.75, 11], [1, 2.5, 4, 5.5, 7, 8.5, 10, 11.5, 13], [1, 2.75, 4.5, 6.25, 8, 9.75, 11.5, 13.25, 15], [1, 3, 5, 7, 9, 11, 13, 15, 17], [1, 3.25, 5.5, 7.75, 10, 12.25, 14.5, 16.75, 19], [1, 3.5, 6, 8.5, 11, 13.5, 16, 18.5, 21]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 1.875, 2.75, 3.625, 4.5, 5.375, 6.25, 7.125, 8], [1, 2.25, 3.5, 4.75, 6, 7.25, 8.5, 9.75, 11], [1, 2.625, 4.25, 5.875, 7.5, 9.125, 10.75, 12.375, 14], [1, 3, 5, 7, 9, 11, 13, 15, 17], [1, 3.375, 5.75, 8.125, 10.5, 12.875, 15.25, 17.625, 20], [1, 3.75, 6.5, 9.25, 12, 14.75, 17.5, 20.25, 23], [1, 4.125, 7.25, 10.375, 13.5, 16.625, 19.75, 22.875, 26], [1, 4.5, 8, 11.5, 15, 18.5, 22, 25.5, 29]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2.5, 4, 5.5, 7, 8.5, 10, 11.5, 13], [1, 3, 5, 7, 9, 11, 13, 15, 17], [1, 3.5, 6, 8.5, 11, 13.5, 16, 18.5, 21], [1, 4, 7, 10, 13, 16, 19, 22, 25], [1, 4.5, 8, 11.5, 15, 18.5, 22, 25.5, 29], [1, 5, 9, 13, 17, 21, 25, 29, 33], [1, 5.5, 10, 14.5, 19, 23.5, 28, 32.5, 37]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2.125, 3.25, 4.375, 5.5, 6.625, 7.75, 8.875, 10], [1, 2.75, 4.5, 6.25, 8, 9.75, 11.5, 13.25, 15], [1, 3.375, 5.75, 8.125, 10.5, 12.875, 15.25, 17.625, 20], [1, 4, 7, 10, 13, 16, 19, 22, 25], [1, 4.625, 8.25, 11.875, 15.5, 19.125, 22.75, 26.375, 30], [1, 5.25, 9.5, 13.75, 18, 22.25, 26.5, 30.75, 35], [1, 5.875, 10.75, 15.625, 20.5, 25.375, 30.25, 35.125, 40], [1, 6.5, 12, 17.5, 23, 28.5, 34, 39.5, 45]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2.25, 3.5, 4.75, 6, 7.25, 8.5, 9.75, 11], [1, 3, 5, 7, 9, 11, 13, 15, 17], [1, 3.75, 6.5, 9.25, 12, 14.75, 17.5, 20.25, 23], [1, 4.5, 8, 11.5, 15, 18.5, 22, 25.5, 29], [1, 5.25, 9.5, 13.75, 18, 22.25, 26.5, 30.75, 35], [1, 6, 11, 16, 21, 26, 31, 36, 41], [1, 6.75, 12.5, 18.25, 24, 29.75, 35.5, 41.25, 47], [1, 7.5, 14, 20.5, 27, 33.5, 40, 46.5, 53]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2.375, 3.75, 5.125, 6.5, 7.875, 9.25, 10.625, 12], [1, 3.25, 5.5, 7.75, 10, 12.25, 14.5, 16.75, 19], [1, 4.125, 7.25, 10.375, 13.5, 16.625, 19.75, 22.875, 26], [1, 5, 9, 13, 17, 21, 25, 29, 33], [1, 5.875, 10.75, 15.625, 20.5, 25.375, 30.25, 35.125, 40], [1, 6.75, 12.5, 18.25, 24, 29.75, 35.5, 41.25, 47], [1, 7.625, 14.25, 20.875, 27.5, 34.125, 40.75, 47.375, 54], [1, 8.5, 16, 23.5, 31, 38.5, 46, 53.5, 61]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2.5, 4, 5.5, 7, 8.5, 10, 11.5, 13], [1, 3.5, 6, 8.5, 11, 13.5, 16, 18.5, 21], [1, 4.5, 8, 11.5, 15, 18.5, 22, 25.5, 29], [1, 5.5, 10, 14.5, 19, 23.5, 28, 32.5, 37], [1, 6.5, 12, 17.5, 23, 28.5, 34, 39.5, 45], [1, 7.5, 14, 20.5, 27, 33.5, 40, 46.5, 53], [1, 8.5, 16, 23.5, 31, 38.5, 46, 53.5, 61], [1, 9.5, 18, 26.5, 35, 43.5, 52, 60.5, 69]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2.625, 4.25, 5.875, 7.5, 9.125, 10.75, 12.375, 14], [1, 3.75, 6.5, 9.25, 12, 14.75, 17.5, 20.25, 23], [1, 4.875, 8.75, 12.625, 16.5, 20.375, 24.25, 28.125, 32], [1, 6, 11, 16, 21, 26, 31, 36, 41], [1, 7.125, 13.25, 19.375, 25.5, 31.625, 37.75, 43.875, 50], [1, 8.25, 15.5, 22.75, 30, 37.25, 44.5, 51.75, 59], [1, 9.375, 17.75, 26.125, 34.5, 42.875, 51.25, 59.625, 68], [1, 10.5, 20, 29.5, 39, 48.5, 58, 67.5, 77]], [[1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [1, 2.75, 4.5, 6.25, 8, 9.75, 11.5, 13.25, 15], [1, 4, 7, 10, 13, 16, 19, 22, 25], [1, 5.25, 9.5, 13.75, 18, 22.25, 26.5, 30.75, 35], [1, 6.5, 12, 17.5, 23, 28.5, 34, 39.5, 45], [1, 7.75, 14.5, 21.25, 28, 34.75, 41.5, 48.25, 55], [1, 9, 17, 25, 33, 41, 49, 57, 65], [1, 10.25, 19.5, 28.75, 38, 47.25, 56.5, 65.75, 75], [1, 11.5, 22, 32.5, 43, 53.5, 64, 74.5, 85]]] trilinear9x9x9 :: Values3D trilinear9x9x9 = fromListUnboxed (n_cube 9) $ flatten $ transpose_xz trilinear9x9x9_list -- | A 3x3x3 array of zeros. zeros_list :: [[[Double]]] zeros_list = [ [ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ], [ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ], [ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ]]] -- No need to transpose_xz this one. zeros :: Values3D 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. naturals_list :: [[[Double]]] naturals_list = [ [ [ 0, 1, 2 ], [ 3, 4, 5 ], [ 6, 7, 8 ] ], [ [ 9, 10, 11 ], [ 12, 13, 14 ], [ 15, 16, 17 ] ], [ [ 18, 19, 20 ], [ 21, 22, 23 ], [ 24, 25, 26 ]]] naturals :: Values3D 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)