/// <summary> /// Subtracts a matrix from a matrix and put the result in a third matrix. /// </summary> /// <param name="a">A <see cref="MatrixF"/> instance to subtract from.</param> /// <param name="b">A <see cref="MatrixF"/> instance to subtract.</param> /// <param name="result">A <see cref="MatrixF"/> instance to hold the result.</param> /// <remarks>result[x][y] = a[x][y] - b[x][y]</remarks> /// <exception cref="System.ArgumentException">Matrix dimentions do not match.</exception> public static void Subtract(MatrixF a, MatrixF b, MatrixF result) { if ((!MatrixF.EqualDimentions(a,b)) && (!MatrixF.EqualDimentions(a,result))) { throw new ArgumentException("Matrix dimentions do not match."); } for(int r = 0; r < a.Rows; r++) { for(int c = 0; c < a.Columns; c++) { result._data[r][c] = a._data[r][c] - b._data[r][c]; } } }
/// <summary> /// Subtracts a matrix from a matrix. /// </summary> /// <param name="a">A <see cref="MatrixF"/> instance to subtract from.</param> /// <param name="b">A <see cref="MatrixF"/> instance to subtract.</param> /// <returns>A new <see cref="MatrixF"/> instance containing the difference.</returns> /// <remarks>result[x][y] = a[x][y] - b[x][y]</remarks> /// <exception cref="System.ArgumentException">Matrix dimentions do not match.</exception> public static MatrixF Subtract(MatrixF a, MatrixF b) { if (!MatrixF.EqualDimentions(a,b)) { throw new ArgumentException("Matrix dimentions do not match."); } MatrixF result = new MatrixF(a.Rows, a.Columns); for(int r = 0; r < a.Rows; r++) { for(int c = 0; c < a.Columns; c++) { result._data[r][c] = a._data[r][c] - b._data[r][c]; } } return result; }