let bounded distance =
let length = 2*range +1 in
let init x y =
Femtolib.Array_simulate_2d.init length length (fun i j -> i+x-range, j+y-range)
|> Array.to_list
|> List.filter (fun (i,j) ->
(i <> x || j <> y)
&& distance (i,j) (x,y) <= range
&& 0 <= i && i < width && 0 <= j && j < height)
|> Array.of_list
|> Array.map (fun (i,j) -> Femtolib.Array_simulate_2d.to_1d width height i j) in
Femtolib.Array_simulate_2d.init width height init