private double[] Reshape(Matrix[] block, bool rowPacked)
{
int xDim = block[0].getColumnDimension(); //x and y dimensions are the same for all items in the block Matrix
int yDim = block[0].getRowDimension();
int tDim = block.Length;
List<double> reshapedBlock = new List<double>(xDim * yDim * tDim); //initialized to the number of elements in the 3D matrix for optimization
if (rowPacked) //builds an array from row packed copy of block
{
foreach (var item in block)
reshapedBlock.AddRange(item.getRowPackedCopy());
}
else //builds an array from column packed copy of block
{
foreach (var item in block)
reshapedBlock.AddRange(item.getColumnPackedCopy());
}
return reshapedBlock.ToArray();
}