code: public static boolean isEqualsTriangle(DMatrix a, DMatrix b, boolean upper, double tol)
      {
          if( a.getNumRows() != b.getNumRows() || a.getNumCols() != b.getNumCols() ) {
              return false;
          }
  
          if( upper ) {
              for( int i = 0; i < a.getNumRows(); i++ ) {
                  for( int j = i; j < a.getNumCols(); j++ ) {
                      if( Math.abs(a.get(i,j)-b.get(i,j)) > tol )
                          return false;
                  }
              }
          } else {
              for( int i = 0; i < a.getNumRows(); i++ ) {
                  int end = Math.min(i,a.getNumCols()-1);
  
                  for( int j = 0; j <= end; j++ ) {
                      if( Math.abs(a.get(i,j)-b.get(i,j)) > tol )
                          return false;
                  }
              }
          }
  
          return true;
      }
docs: <p>
  Checks to see if each element in the upper or lower triangular portion of the two matrices are within tolerance of
  each other: tol &ge; |a<sub>ij</sub> - b<sub>ij</sub>|.
  <p>
  
  <p>
  NOTE: If any of the elements are not countable then false is returned.<br>
  NOTE: If a tolerance of zero is passed in this is equivalent to calling
  {@link #isEquals(DMatrixD1, DMatrixD1)}
  </p>
  
  @param a A matrix. Not modified.
  @param b A matrix. Not modified.
  @param upper true of upper triangular and false for lower.
  @param tol How close to being identical each element needs to be.
  @return true if equals and false otherwise.