Java Code Examples for org.apache.commons.math.util.MathUtils#hash()

The following examples show how to use org.apache.commons.math.util.MathUtils#hash() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractRealMatrix.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: Math_98_RealMatrixImpl_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Computes a hashcode for the matrix.
 * 
 * @return hashcode for matrix
 */
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++) {
        final double[] dataRow = data[row];
        for (int col = 0; col < nCols; col++) {
           ret = ret * 31 + (11 * (row+1) + 17 * (col+1)) * 
               MathUtils.hash(dataRow[col]);
       }
    }
    return ret;
}
 
Example 3
Source File: Complex_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Get a hashCode for the complex number.
 * <p>
 * All NaN values have the same hash code.</p>
 *
 * @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));
}
 
Example 4
Source File: ArrayRealVector.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a hashCode for the real vector.
 * <p>All NaN values have the same hash code.</p>
 * @return a hash code value for this object
 */
@Override
public int hashCode() {
    if (isNaN()) {
        return 9;
    }
    return MathUtils.hash(data);
}
 
Example 5
Source File: SummaryStatistics.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns hash code based on values of statistics
 * @return hash code
 */
@Override
public int hashCode() {
    int result = 31 + MathUtils.hash(getGeometricMean());
    result = result * 31 + MathUtils.hash(getGeometricMean());
    result = result * 31 + MathUtils.hash(getMax());
    result = result * 31 + MathUtils.hash(getMean());
    result = result * 31 + MathUtils.hash(getMin());
    result = result * 31 + MathUtils.hash(getN());
    result = result * 31 + MathUtils.hash(getSum());
    result = result * 31 + MathUtils.hash(getSumsq());
    result = result * 31 + MathUtils.hash(getVariance());
    return result;
}
 
Example 6
Source File: MultivariateSummaryStatistics.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns hash code based on values of statistics
 *
 * @return hash code
 */
@Override
public int hashCode() {
    int result = 31 + MathUtils.hash(getGeometricMean());
    result = result * 31 + MathUtils.hash(getGeometricMean());
    result = result * 31 + MathUtils.hash(getMax());
    result = result * 31 + MathUtils.hash(getMean());
    result = result * 31 + MathUtils.hash(getMin());
    result = result * 31 + MathUtils.hash(getN());
    result = result * 31 + MathUtils.hash(getSum());
    result = result * 31 + MathUtils.hash(getSumSq());
    result = result * 31 + MathUtils.hash(getSumLog());
    result = result * 31 + getCovariance().hashCode();
    return result;
}
 
Example 7
Source File: MultivariateSummaryStatistics.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns hash code based on values of statistics
 *
 * @return hash code
 */
@Override
public int hashCode() {
    int result = 31 + MathUtils.hash(getGeometricMean());
    result = result * 31 + MathUtils.hash(getGeometricMean());
    result = result * 31 + MathUtils.hash(getMax());
    result = result * 31 + MathUtils.hash(getMean());
    result = result * 31 + MathUtils.hash(getMin());
    result = result * 31 + MathUtils.hash(getN());
    result = result * 31 + MathUtils.hash(getSum());
    result = result * 31 + MathUtils.hash(getSumSq());
    result = result * 31 + MathUtils.hash(getSumLog());
    result = result * 31 + getCovariance().hashCode();
    return result;
}
 
Example 8
Source File: Math_46_Complex_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * 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));
}
 
Example 9
Source File: Complex.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a hashCode for the complex number.
 * <p>
 * All NaN values have the same hash code.</p>
 * 
 * @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));
}
 
Example 10
Source File: Complex.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a hashCode for the complex number.
 * <p>
 * All NaN values have the same hash code.</p>
 * 
 * @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));
}
 
Example 11
Source File: RealMatrixImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Computes a hashcode for the matrix.
 * 
 * @return hashcode for matrix
 */
public int hashCode() {
    int ret = 7;
    int nRows = getRowDimension();
    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(data[row][col]);
       }
    }
    return ret;
}
 
Example 12
Source File: ArrayRealVector.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a hashCode for the real vector.
 * All {@code NaN} values have the same hash code.
 *
 * @return a hash code.
 */
@Override
public int hashCode() {
    if (isNaN()) {
        return 9;
    }
    return MathUtils.hash(data);
}
 
Example 13
Source File: 1_Complex.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a hashCode for the complex number.
 * <p>
 * All NaN values have the same hash code.</p>
 *
 * @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));
}
 
Example 14
Source File: 1_Complex.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a hashCode for the complex number.
 * <p>
 * All NaN values have the same hash code.</p>
 *
 * @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));
}
 
Example 15
Source File: Complex.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a hashCode for the complex number.
 * <p>
 * All NaN values have the same hash code.</p>
 *
 * @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));
}
 
Example 16
Source File: Complex.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a hashCode for the complex number.
 * <p>
 * All NaN values have the same hash code.</p>
 *
 * @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));
}
 
Example 17
Source File: AbstractStorelessUnivariateStatistic.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns hash code based on getResult() and getN()
 *
 * @return hash code
 */
@Override
public int hashCode() {
    return 31* (31 + MathUtils.hash(getResult())) + MathUtils.hash(getN());
}
 
Example 18
Source File: AbstractStorelessUnivariateStatistic.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns hash code based on getResult() and getN()
 *
 * @return hash code
 */
@Override
public int hashCode() {
    return 31* (31 + MathUtils.hash(getResult())) + MathUtils.hash(getN());
}
 
Example 19
Source File: AbstractStorelessUnivariateStatistic.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns hash code based on getResult() and getN()
 *
 * @return hash code
 */
@Override
public int hashCode() {
    return 31* (31 + MathUtils.hash(getResult())) + MathUtils.hash(getN());
}
 
Example 20
Source File: AbstractStorelessUnivariateStatistic.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns hash code based on getResult() and getN()
 *
 * @return hash code
 */
@Override
public int hashCode() {
    return 31* (31 + MathUtils.hash(getResult())) + MathUtils.hash(getN());
}