/*public static Matrix<T> operator +(Matrix<T> firstMatrix, Matrix<T> secondMatrix) * { * if (!firstMatrix.GetType().IsValueType && (firstMatrix as IComparable<T>) == null) * { * throw new InvalidOperationException(); * } * * int order = firstMatrix.Order; * if (order != secondMatrix.Order) * { * throw new InvalidOperationException(); * } * * Matrix<T> resultMatrix = new Matrix<T>(order); * for (int i = 0; i < order; i++) * { * for (int j = 0; j < order; j++) * { * resultMatrix[i, j] = (dynamic)firstMatrix[i, j] + (dynamic)secondMatrix[i, j]; * } * } * * return resultMatrix; * }*/ /// <summary> /// Notify if some element changed /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Parameters</param> protected virtual void OnMatrixElementChange(object sender, MatrixElementChangeEventArgs <T> e) { if (MatrixElementChangeEvent != null) { MatrixElementChangeEvent.Invoke(sender, e); } }
/// <summary> /// Matrix indexer /// </summary> /// <param name="i">Row</param> /// <param name="j">Column</param> /// <returns>Value</returns> public T this[int i, int j] { get { return(_grid[i, j]); } set { MatrixElementChangeEventArgs <T> arg = new MatrixElementChangeEventArgs <T>( _grid[i, j], value, i, j); OnMatrixElementChange(this, arg); _grid[i, j] = value; } }