List of usage examples for java.lang Double doubleToLongBits
@HotSpotIntrinsicCandidate public static long doubleToLongBits(double value)
From source file:com.opengamma.analytics.math.interpolation.GridInterpolator2D.java
private Map<Double, Interpolator1DDataBundle> testData(final Map<DoublesPair, Double> data) { final Map<Double, Interpolator1DDataBundle> result = new TreeMap<Double, Interpolator1DDataBundle>(); final TreeMap<DoublesPair, Double> sorted = new TreeMap<DoublesPair, Double>(_comparator); sorted.putAll(data);/*from w w w. j a va 2 s . c o m*/ final Iterator<Map.Entry<DoublesPair, Double>> iterator = sorted.entrySet().iterator(); final Map.Entry<DoublesPair, Double> firstEntry = iterator.next(); double x = firstEntry.getKey().first; Map<Double, Double> yzValues = new TreeMap<Double, Double>(); yzValues.put(firstEntry.getKey().second, firstEntry.getValue()); while (iterator.hasNext()) { final Map.Entry<DoublesPair, Double> nextEntry = iterator.next(); final double newX = nextEntry.getKey().first; if (Double.doubleToLongBits(newX) != Double.doubleToLongBits(x)) { final Interpolator1DDataBundle interpolatorData = _yInterpolator.getDataBundle(yzValues); result.put(x, interpolatorData); yzValues = new TreeMap<Double, Double>(); yzValues.put(nextEntry.getKey().second, nextEntry.getValue()); x = newX; } else { yzValues.put(nextEntry.getKey().second, nextEntry.getValue()); } if (!iterator.hasNext()) { yzValues.put(nextEntry.getKey().second, nextEntry.getValue()); final Interpolator1DDataBundle interpolatorData = _yInterpolator.getDataBundle(yzValues); result.put(x, interpolatorData); } } return result; }
From source file:com.opengamma.analytics.financial.model.interestrate.definition.HullWhiteOneFactorPiecewiseConstantParameters.java
@Override public boolean equals(final Object obj) { if (this == obj) { return true; }/*from www . j a v a 2 s. com*/ if (!(obj instanceof HullWhiteOneFactorPiecewiseConstantParameters)) { return false; } final HullWhiteOneFactorPiecewiseConstantParameters other = (HullWhiteOneFactorPiecewiseConstantParameters) obj; if (Double.doubleToLongBits(_meanReversion) != Double.doubleToLongBits(other._meanReversion)) { return false; } if (!ObjectUtils.equals(_volatility, other._volatility)) { return false; } if (!ObjectUtils.equals(_volatilityTime, other._volatilityTime)) { return false; } return true; }
From source file:io.yields.math.framework.kpi.ScoreResult.java
@Override public int hashCode() { int result;//from w w w .j a v a 2 s. c o m long temp; result = name != null ? name.hashCode() : 0; result = 31 * result + (group != null ? group.hashCode() : 0); result = 31 * result + (official ? 1 : 0); temp = Double.doubleToLongBits(score); result = 31 * result + (int) (temp ^ (temp >>> 32)); return result; }
From source file:gsn.beans.AddressBean.java
public int hashCode() { final int prime = 31; int result = 1; long temp;/*w w w . ja v a 2 s . c o m*/ temp = Double.doubleToLongBits(random); result = prime * result + (int) (temp ^ (temp >>> 32)); return result; }
From source file:com.opengamma.analytics.math.statistics.distribution.GeneralizedExtremeValueDistribution.java
@Override public boolean equals(final Object obj) { if (this == obj) { return true; }// w w w . j av a 2 s . com if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final GeneralizedExtremeValueDistribution other = (GeneralizedExtremeValueDistribution) obj; if (Double.doubleToLongBits(_ksi) != Double.doubleToLongBits(other._ksi)) { return false; } if (Double.doubleToLongBits(_mu) != Double.doubleToLongBits(other._mu)) { return false; } return Double.doubleToLongBits(_sigma) == Double.doubleToLongBits(other._sigma); }
From source file:com.opengamma.analytics.math.regression.LeastSquaresRegressionResult.java
@Override public boolean equals(final Object obj) { if (this == obj) { return true; }//from w w w . j a v a 2 s. com if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final LeastSquaresRegressionResult other = (LeastSquaresRegressionResult) obj; if (!Arrays.equals(_betas, other._betas)) { return false; } if (_hasIntercept != other._hasIntercept) { return false; } if (Double.doubleToLongBits(_meanSquareError) != Double.doubleToLongBits(other._meanSquareError)) { return false; } if (!Arrays.equals(_pValues, other._pValues)) { return false; } if (Double.doubleToLongBits(_rSquared) != Double.doubleToLongBits(other._rSquared)) { return false; } if (Double.doubleToLongBits(_rSquaredAdjusted) != Double.doubleToLongBits(other._rSquaredAdjusted)) { return false; } if (!Arrays.equals(_residuals, other._residuals)) { return false; } if (!Arrays.equals(_standardErrorOfBeta, other._standardErrorOfBeta)) { return false; } if (!Arrays.equals(_tStats, other._tStats)) { return false; } return true; }
From source file:com.opengamma.maths.lowlevelapi.datatypes.primitive.PackedMatrix.java
/** * Constructs from array of arrays *but* allows zeros to be packed into the data structure. * This is particularly useful for banded matrices in which * allowing some zero padding is beneficial in terms of making access patterns more simple. * @param aMatrix is an n columns x m rows matrix stored as a row major array of arrays. * @param zeroPattern is enumerated based on {@link allowZerosOn} to allow the packing of zeros in the packed data structure. * @param rows is the number of rows in the matrix that is to be represented * @param cols is the number of columns in the matrix that is to be represented *//* w w w.j a v a2s .co m*/ public PackedMatrix(double[][] aMatrix, allowZerosOn zeroPattern, int rows, int cols) { Validate.notNull(aMatrix); // test if ragged if (MatrixPrimitiveUtils.isRagged(aMatrix)) { throw new NotImplementedException("Construction from ragged array not implemented"); } _rows = rows; _cols = cols; _els = _rows * _cols; double[] tmp = new double[_els]; _rowPtr = new int[_rows]; _colCount = new int[_rows + 1]; boolean isSet; double val; int count = 0; _colCount[0] = 0; switch (zeroPattern) { case bothSides: { // make flat! for (int i = 0; i < _rows; i++) { _rowPtr[i] = 0; for (int j = 0; j < _cols; j++) { //for each col tmp[count] = aMatrix[i][j]; // assign to tmp count++; } _colCount[i + 1] += count; } break; } case rightSide: { for (int i = 0; i < _rows; i++) { isSet = false; // init each starting point as not being set and look for it. for (int j = 0; j < cols; j++) { //for each col val = aMatrix[i][j]; // get the value if (Double.doubleToLongBits(val) != 0L || isSet) { // test if not zero and whether we have found the start of the data yet tmp[count] = val; // assign to tmp count++; if (!isSet) { // if we haven't already set the starting point in the row _rowPtr[i] = j; // assign this element as the starting point isSet = true; // and ensure we don't come back here for this row } } } _colCount[i + 1] += count; } break; } case leftSide: { for (int i = 0; i < _rows; i++) { isSet = false; // init each starting point as not being set and look for it. // search backwards and find the end point int end = -1; for (int j = _cols - 1; j >= 0; j--) { val = aMatrix[i][j]; if (Double.doubleToLongBits(val) != 0L) { // test if not zero end = j; break; } } // flatten for (int j = 0; j < end + 1; j++) { //for each col val = aMatrix[i][j]; // get the value tmp[count] = val; // assign to tmp count++; if (!isSet) { // if we haven't already set the starting point in the row _rowPtr[i] = j; // assign this element as the starting point isSet = true; // and ensure we don't come back here for this row } } _colCount[i + 1] += count; } break; } case none: { // make flat! for (int i = 0; i < _rows; i++) { isSet = false; // init each starting point as not being set and look for it. // search backwards and find the end point int end = 0; for (int j = _cols - 1; j >= 0; j--) { val = aMatrix[i][j]; if (Double.doubleToLongBits(val) != 0L) { // test if not zero end = j; break; } } // flatten for (int j = 0; j < end + 1; j++) { //for each col val = aMatrix[i][j]; // get the value if (Double.doubleToLongBits(val) != 0L || isSet) { // test if not zero tmp[count] = val; // assign to tmp count++; if (!isSet) { // if we haven't already set the starting point in the row _rowPtr[i] = j; // assign this element as the starting point isSet = true; // and ensure we don't come back here for this row } } } _colCount[i + 1] += count; } break; } } _data = Arrays.copyOfRange(tmp, 0, count); }
From source file:com.opengamma.analytics.financial.model.option.pricing.fourier.CGMYCharacteristicExponent.java
@Override public boolean equals(final Object obj) { if (this == obj) { return true; }/*from www .j a v a 2 s. c om*/ if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final CGMYCharacteristicExponent other = (CGMYCharacteristicExponent) obj; if (Double.doubleToLongBits(_c) != Double.doubleToLongBits(other._c)) { return false; } if (Double.doubleToLongBits(_g) != Double.doubleToLongBits(other._g)) { return false; } if (Double.doubleToLongBits(_m) != Double.doubleToLongBits(other._m)) { return false; } return Double.doubleToLongBits(_y) == Double.doubleToLongBits(other._y); }
From source file:com.opengamma.analytics.financial.instrument.payment.CouponDefinition.java
@Override public boolean equals(final Object obj) { if (this == obj) { return true; }/*from ww w . jav a2 s . c o m*/ if (!super.equals(obj)) { return false; } if (getClass() != obj.getClass()) { return false; } final CouponDefinition other = (CouponDefinition) obj; if (!ObjectUtils.equals(_accrualEndDate, other._accrualEndDate)) { return false; } if (!ObjectUtils.equals(_accrualStartDate, other._accrualStartDate)) { return false; } if (Double.doubleToLongBits(_notional) != Double.doubleToLongBits(other._notional)) { return false; } if (Double.doubleToLongBits(_paymentYearFraction) != Double.doubleToLongBits(other._paymentYearFraction)) { return false; } return true; }
From source file:com.opengamma.analytics.math.surface.InterpolatedSurfaceAdditiveShiftFunction.java
/** * {@inheritDoc}//from w ww. j av a 2 s . co m */ @Override public InterpolatedDoublesSurface evaluate(final InterpolatedDoublesSurface surface, final double[] xShift, final double[] yShift, final double[] shift, final String newName) { Validate.notNull(surface, "surface"); Validate.notNull(xShift, "x shift"); Validate.notNull(yShift, "y shift"); Validate.notNull(shift, "shifts"); final int n = xShift.length; if (n == 0) { return InterpolatedDoublesSurface.from(surface.getXDataAsPrimitive(), surface.getYDataAsPrimitive(), surface.getZDataAsPrimitive(), surface.getInterpolator(), newName); } Validate.isTrue(n == yShift.length && n == shift.length); final Double[] x = surface.getXData(); final Double[] y = surface.getYData(); final Double[] z = surface.getZData(); final List<Double> newX = new ArrayList<Double>(Arrays.asList(x)); final List<Double> newY = new ArrayList<Double>(Arrays.asList(y)); final List<Double> newZ = new ArrayList<Double>(Arrays.asList(z)); final int size = surface.size(); for (int i = 0; i < n; i++) { boolean foundValue = false; for (int j = 0; j < size; j++) { if (Double.doubleToLongBits(x[j]) == Double.doubleToLongBits(xShift[i]) && Double.doubleToLongBits(y[j]) == Double.doubleToLongBits(yShift[i])) { newZ.set(j, z[j] + shift[i]); foundValue = true; } } if (!foundValue) { newX.add(xShift[i]); newY.add(yShift[i]); newZ.add(surface.getZValue(xShift[i], yShift[i]) + shift[i]); } } return InterpolatedDoublesSurface.from(newX, newY, newZ, surface.getInterpolator(), newName); }