Is there anyway to use LINQ to obtain the maximum of each columns for two dimensional arrays?
Assume that I have the following:
var arrays = new double[5,100]();
I want to get the maximum of arrays[0,:]
, arrays[1,:]
.... arrays[4,:]
. How to use LINQ to do it?
I could have use such method
public double GetMax(double[,] arr, int rowIndex)
{
var colCount = arr.GetLength(1);
double max = 0.0;
for(int i=0; i<colCount; i++)
{
max=Math.Max(Math.Abs(arr[rowIndex, i]), max);
}
return max;
}
But I would prefer a more succinct ways of doing things.