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