Pack a four dimensional array into a one dimensional vec to avoid the speed penalty of
following multiple pointers and increase memory locality for caching.
x and y dimensions are in the plane of the input. Each dimension can expand by at most two
in each axis per round (one positive and one negative). Adding padding at the edges to avoid
boundary checks gives a maximum width of 8 + 2 * (6 + 1) = 22 for the x and y dimensions and
1 + 2 * (6 + 1) = 15 for the z and w dimensions.