private static CoolMatrix PerformOperation(CoolMatrix matrix, int number, OperationDelegate operationDelegate) { var tempMatrix = new CoolMatrix(matrix); for (var i = 0; i < matrix.Size.Width; i++) { for (var j = 0; j < matrix.Size.Height; j++) { tempMatrix[i, j] = operationDelegate(matrix[i, j], number); } } return tempMatrix; }
private static CoolMatrix PerformOperation(CoolMatrix leftMatrix, CoolMatrix rightMatrix, OperationDelegate operationDelegate) { if (leftMatrix.Size != rightMatrix.Size) throw new ArgumentException(); var tempMatrix = new CoolMatrix(leftMatrix); for (var i = 0; i < leftMatrix.Size.Width; i++) { for (var j = 0; j < leftMatrix.Size.Height; j++) { tempMatrix[i, j] = operationDelegate(leftMatrix[i, j], rightMatrix[i, j]); } } return tempMatrix; }