For an example if I want to iterate test and perfrorm operations on elements from that array but they have to be formatted in a particular way.
Essentially I am trying to loop over a 2d array using a 2d array.
double[,] test = {
{9, 8, 7, 6, 5, 4, 3, 2},
{8, 7, 6, 5, 4, 3, 2, 1},
{7, 6, 5, 4, 3, 2, 1, 0},
{6, 5, 4, 3, 2, 1, 0, 0},
{5, 4, 3, 2, 1, 0, 0, 0},
{4, 3, 2, 1, 0, 0, 0, 0},
{3, 2, 1, 0, 0, 0, 0, 0},
{2, 1, 0, 0, 0, 0, 0, 0},
};
double[,] subset = new double[2,2]; //used in math
What I would like to be able to do is to iterate over any size matrix (assuming that they are even sized and square) with each iteration looking like this:
Iteration 1:
subset[0,0] = test[0,0];
subset[0,1] = test[0,1];
subset[1,0] = test[1,0];
subset[1,1] = test[1,1];
So basically it selected a square same size as subset out of the large matrix.
Iteration 2:
subset[0,2] = test[0,2];
subset[1,2] = test[1,2];
subset[0,3] = test[0,3];
subset[1,3] = test[1,3];
yield return(msdn.microsoft.com/en-us/library/9k7k7cf0.aspx). Basically, the extension method will iterate over the array and callsyield returnon a subset of the array each iteration. Using this, you can customize how big and which indices will be included in the subset. With that said, you can take the extension method a step further and make each "iteration" smarter by using offsets to skip over chunks of the array that wereyield returned already.nxm) sub-matrices. What should happen if the parent matrix's size in either direction isn't a multiple of the requested sub-matrix's dimension? In your example you're trying to chunk an 8x8 matrix into 2x2 sub-matrices, but what should happen if it was 9x9 instead?