Exemplo n.º 1
0
 /**
  * Get a hashCode for the complex number. Any {@code Double.NaN} value in real or imaginary part
  * produces the same hash code {@code 7}.
  *
  * @return a hash code value for this object.
  */
 @Override
 public int hashCode() {
   if (isNaN) {
     return 7;
   }
   return 37 * (17 * MathUtils.hash(imaginary) + MathUtils.hash(real));
 }
 /**
  * Computes a hashcode for the matrix.
  *
  * @return hashcode for matrix
  */
 @Override
 public int hashCode() {
   int ret = 7;
   final int nRows = getRowDimension();
   final int nCols = getColumnDimension();
   ret = ret * 31 + nRows;
   ret = ret * 31 + nCols;
   for (int row = 0; row < nRows; ++row) {
     for (int col = 0; col < nCols; ++col) {
       ret = ret * 31 + (11 * (row + 1) + 17 * (col + 1)) * MathUtils.hash(getEntry(row, col));
     }
   }
   return ret;
 }