public static boolean isEquivalent(DMatrix a , DMatrix b , double tol )
    {
        if( a.getNumRows() != b.getNumRows() || a.getNumCols() != b.getNumCols() )
            return false;

        for( int i = 0; i < a.getNumRows(); i++ ) {
            for( int j = 0; j < a.getNumCols(); j++ ) {
                double diff = Math.abs(a.get(i,j) - b.get(i,j));

                if( diff > tol )
                    return false;
            }
        }

        return true;
    }
public static boolean isEquivalent ( DMatrix a , DMatrix b , double tol ) { if ( a . getNumRows ( ) != b . getNumRows ( ) || a . getNumCols ( ) != b . getNumCols ( ) ) return false ; for ( int i = 0 ; i < a . getNumRows ( ) ; i ++ ) { for ( int j = 0 ; j < a . getNumCols ( ) ; j ++ ) { double diff = Math . abs ( a . get ( i , j ) - b . get ( i , j ) ) ; if ( diff > tol ) return false ; } } return true ; }
}