public static boolean isIdentical(DMatrix a, DMatrix b , double tol ) {
        if( a.getNumRows() != b.getNumRows() || a.getNumCols() != b.getNumCols() ) {
            return false;
        }
        if( tol < 0 )
            throw new IllegalArgumentException("Tolerance must be greater than or equal to zero.");

        final int numRows = a.getNumRows();
        final int numCols = a.getNumCols();

        for (int row = 0; row < numRows; row++) {
            for (int col = 0; col < numCols; col++) {
                if( !UtilEjml.isIdentical(a.unsafe_get(row,col),b.unsafe_get(row,col), tol))
                    return false;
            }
        }
        return true;
    }
public static boolean isIdentical ( DMatrix a , DMatrix b , double tol ) { if ( a . getNumRows ( ) != b . getNumRows ( ) || a . getNumCols ( ) != b . getNumCols ( ) ) { return false ; } if ( tol < 0 ) throw new IllegalArgumentException ( "Tolerance must be greater than or equal to zero." ) ; final int numRows = a . getNumRows ( ) ; final int numCols = a . getNumCols ( ) ; for ( int row = 0 ; row < numRows ; row ++ ) { for ( int col = 0 ; col < numCols ; col ++ ) { if ( ! UtilEjml . isIdentical ( a . unsafe_get ( row , col ) , b . unsafe_get ( row , col ) , tol ) ) return false ; } } return true ; }
<p>
Checks to see if each corresponding element in the two matrices are
within tolerance of each other or have the some symbolic meaning.  This
can handle NaN and Infinite numbers.
<p>

<p>
If both elements are countable then the following equality test is used:<br>
|a<sub>ij</sub> - b<sub>ij</sub>| &le; tol.<br>
Otherwise both numbers must both be Double.NaN, Double.POSITIVE_INFINITY, or
Double.NEGATIVE_INFINITY to be identical.
</p>

@param a A matrix. Not modified.
@param b A matrix. Not modified.
@param tol Tolerance for equality.
@return true if identical and false otherwise.