1 -- | The Grid module just contains the Grid type and two constructors
2 -- for it. We hide the main Grid constructor because we don't want
3 -- to allow instantiation of a grid with h <= 0.
4 module Grid (empty_grid,
11 -- | Our problem is defined on a Grid. The grid size is given by the
12 -- positive number h. The function values are the values of the
13 -- function at the grid points, which are distance h from one
14 -- another in each direction (x,y,z).
15 data Grid = Grid { h :: Double, -- MUST BE GREATER THAN ZERO!
16 function_values :: [[[Double]]] }
20 -- | The constructor that we want people to use. If we're passed a
21 -- non-positive grid size, we throw an error.
22 make_grid :: Double -> [[[Double]]] -> Grid
23 make_grid grid_size values
24 | grid_size <= 0 = error "grid size must be positive"
25 | otherwise = Grid grid_size values
28 -- | Creates an empty grid with grid size 1.
30 empty_grid = Grid 1 [[[]]]