/// <summary>
/// Performs an element wise operation on the input Matrix.
/// </summary>
/// <param name="m">Matrix.</param>
/// <param name="fnElementWiseOp">Function to update each cell specified by the value and cell coordinates.</param>
/// <returns>A Matrix.</returns>
public static Matrix Each(Matrix m, Func <double, int, int, double> fnElementWiseOp)
{
var copy = m.ToArray();
for (int i = 0; i < m.Rows; i++)
{
for (int j = 0; j < m.Cols; j++)
{
copy[i][j] = fnElementWiseOp(copy[i][j], i, j);
}
}
return(copy);
}