Implement an algorithm to map a high-dimensional weight matrix onto a grid of limited-size crossbar arrays for TETRAMEM.