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

The following examples show how to use org.apache.commons.math3.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: StatisticalSummaryValues.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(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(getVariance());
    return result;
}
 
Example 3
Source File: Vector1D.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a hashCode for the 1D 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 7785;
    }
    return 997 * MathUtils.hash(x);
}
 
Example 4
Source File: JGenProg2017_0026_t.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 5
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 6
Source File: JGenProg2017_0061_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Get a hashCode for the 3D 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 642;
    }
    return 643 * (164 * MathUtils.hash(x) +  3 * MathUtils.hash(y) +  MathUtils.hash(z));
}
 
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: ArrayRealVector.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc} All {@code NaN} values have the same hash code.
 */
@Override
public int hashCode() {
    if (isNaN()) {
        return 9;
    }
    return MathUtils.hash(data);
}
 
Example 9
Source File: ArrayRealVector.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc} All {@code NaN} values have the same hash code.
 */
@Override
public int hashCode() {
    if (isNaN()) {
        return 9;
    }
    return MathUtils.hash(data);
}
 
Example 10
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 11
Source File: Vector3D.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a hashCode for the 3D 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 642;
    }
    return 643 * (164 * MathUtils.hash(x) +  3 * MathUtils.hash(y) +  MathUtils.hash(z));
}
 
Example 12
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 13
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 14
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 15
Source File: Vector2D.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a hashCode for the 2D 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 542;
    }
    return 122 * (76 * MathUtils.hash(x) +  MathUtils.hash(y));
}
 
Example 16
Source File: 1_Vector3D.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a hashCode for the 3D 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 642;
    }
    return 643 * (164 * MathUtils.hash(x) +  3 * MathUtils.hash(y) +  MathUtils.hash(z));
}
 
Example 17
Source File: DerivativeStructure.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Get a hashCode for the derivative structure.
 * @return a hash code value for this object
 * @since 3.2
 */
@Override
public int hashCode() {
    return 227 + 229 * getFreeParameters() + 233 * getOrder() + 239 * MathUtils.hash(data);
}
 
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());
}