code: public static boolean hasNaN( DMatrixD1 m )
      {
          int length = m.getNumElements();
  
          for( int i = 0; i < length; i++ ) {
              if( Double.isNaN(m.get(i)))
                  return true;
          }
          return false;
      }
docs: Checks to see if any element in the matrix is NaN.
  
  @param m A matrix. Not modified.
  @return True if any element in the matrix is NaN.