Two-dimensional implementation of ndarray to avoid dynamic code generation eval.