ph-math/src/main/java/com/helger/numbercruncher/matrix/Matrix.java
public Matrix subtract (final Matrix m) throws MatrixException
  {
    // Validate m's size.
    if ((m_nRows != m.m_nRows) && (m_nCols != m.m_nCols))
    {
      throw new MatrixException (MatrixException.INVALID_DIMENSIONS);
    }

    final float dv[][] = new float [m_nRows] [m_nCols]; // difference values

    // Compute values of the difference.
    for (int r = 0; r < m_nRows; ++r)
    {
      for (int c = 0; c < m_nCols; ++c)
      {
        dv[r][c] = m_aValues[r][c] - m.m_aValues[r][c];
      }
    }

    return new Matrix (dv);
  }
public Matrix subtract (final Matrix m) throws MatrixException
  {
    // Validate m's size.
    if ((m_nRows != m.m_nRows) && (m_nCols != m.m_nCols))
    {
      throw new MatrixException (MatrixException.INVALID_DIMENSIONS);
    }

    final float dv[][] = new float [m_nRows] [m_nCols]; // difference values

    // Compute values of the difference.
    for (int r = 0; r < m_nRows; ++r)
    {
      for (int c = 0; c < m_nCols; ++c)
      {
        dv[r][c] = m_aValues[r][c] - m.m_aValues[r][c];
      }
    }

    return new Matrix (dv);
  }
public Matrix subtract ( final Matrix m ) throws MatrixException { // Validate m's size. if ( ( m_nRows != m . m_nRows ) && ( m_nCols != m . m_nCols ) ) { throw new MatrixException ( MatrixException . INVALID_DIMENSIONS ) ; } final float dv [ ] [ ] = new float [ m_nRows ] [ m_nCols ] ; // difference values // Compute values of the difference. for ( int r = 0 ; r < m_nRows ; ++ r ) { for ( int c = 0 ; c < m_nCols ; ++ c ) { dv [ r ] [ c ] = m_aValues [ r ] [ c ] - m . m_aValues [ r ] [ c ] ; } } return new Matrix ( dv ) ; }
Subtract another matrix from this matrix.

@param m
the matrix subrrahend
@return the difference matrix
@throws MatrixException
for invalid size
Subtract another matrix from this matrix .