code: public static boolean isIdentical(DMatrixD1 a, DMatrixD1 b , double tol ) {
          if( a.numRows != b.numRows || a.numCols != b.numCols ) {
              return false;
          }
          if( tol < 0 )
              throw new IllegalArgumentException("Tolerance must be greater than or equal to zero.");
  
          final int length = a.getNumElements();
          for( int i = 0; i < length; i++ ) {
              if( !UtilEjml.isIdentical(a.get(i),b.get(i), tol))
                  return false;
          }
  
          return true;
      }
docs: <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.