Example usage for java.lang Double doubleToLongBits

List of usage examples for java.lang Double doubleToLongBits

Introduction

In this page you can find the example usage for java.lang Double doubleToLongBits.

Prototype

@HotSpotIntrinsicCandidate
public static long doubleToLongBits(double value) 

Source Link

Document

Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout.

Usage

From source file:com.opengamma.strata.math.impl.statistics.distribution.NonCentralChiSquaredDistribution.java

private double getFraserApproxCDF(double x) {
    double s = Math.sqrt(_lambdaOverTwo * 2.0);
    double mu = Math.sqrt(x);
    double z;//from  w w  w . jav  a2 s . c o m
    if (Double.doubleToLongBits(mu) == Double.doubleToLongBits(s)) {
        z = (1 - _dofOverTwo * 2.0) / 2 / s;
    } else {
        z = mu - s - (_dofOverTwo * 2.0 - 1) / 2 * (Math.log(mu) - Math.log(s)) / (mu - s);
    }
    return (new NormalDistribution(0, 1)).getCDF(z);
}

From source file:dk.statsbiblioteket.netark.dvenabler.wrapper.NumericDocValuesWrapper.java

@Override
public long get(int docID) {
    tracker.ping(docID);/*from ww  w . j a v a 2 s. co  m*/
    try {
        IndexableField iField = reader.document(docID, FIELDS).getField(dvConfig.getName());
        if (iField == null) {
            log.warn("No stored value for field '" + dvConfig.getName() + "' in doc " + docID
                    + ". Returning -1");
            // This should have been handled by {@link DVAtomicReader#getDocsWithField}
            return -1;
        }
        Number number = iField.numericValue();
        if (number == null) {
            throw new RuntimeException("No numeric value '" + iField.stringValue() + "' for field '"
                    + dvConfig.getName() + "' in doc " + docID + ". This looks like a non-numeric field!");
        }
        // TODO: Determine correct method to call from field info
        switch (dvConfig.getNumericType()) {
        case LONG:
            return number.longValue();
        case INT:
            return number.intValue();
        case DOUBLE:
            return Double.doubleToLongBits(number.doubleValue());
        case FLOAT:
            return Float.floatToIntBits(number.longValue());
        default:
            throw new IllegalStateException(
                    "Unknown NumericType " + dvConfig.getNumericType() + " for field " + dvConfig.getName());
        }
    } catch (IOException e) {
        throw new RuntimeException("Unable to get field '" + dvConfig.getName() + "' from docID " + docID, e);
    }
}

From source file:org.numenta.nupic.algorithms.Statistic.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    long temp = Double.doubleToLongBits(mean);
    result = prime * result + (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(stdev);
    result = prime * result + (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(variance);
    result = prime * result + (int) (temp ^ (temp >>> 32));
    return result;
}

From source file:com.opengamma.analytics.financial.interestrate.future.derivative.BondFuturesTransaction.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + _quantity;
    long temp;/*from  w w  w. j av a  2 s. co  m*/
    temp = Double.doubleToLongBits(_referencePrice);
    result = prime * result + (int) (temp ^ (temp >>> 32));
    result = prime * result + _underlyingFuture.hashCode();
    return result;
}

From source file:com.opengamma.analytics.math.surface.NodalSurfaceMultiplicativeShiftFunction.java

/**
 * {@inheritDoc}/*from  ww  w .  j a v a2  s . co m*/
 * @throws IllegalArgumentException If the point to shift is not a nodal point of the surface 
 */
@Override
public NodalDoublesSurface evaluate(final NodalDoublesSurface surface, final double x, final double y,
        final double percentage, final String newName) {
    Validate.notNull(surface, "surface");
    final double[] xData = surface.getXDataAsPrimitive();
    final double[] yData = surface.getYDataAsPrimitive();
    final double[] zData = surface.getZDataAsPrimitive();
    final int n = zData.length;
    for (int i = 0; i < n; i++) {
        if (Double.doubleToLongBits(xData[i]) == Double.doubleToLongBits(x)) {
            if (Double.doubleToLongBits(yData[i]) == Double.doubleToLongBits(y)) {
                final double[] shiftedZ = Arrays.copyOf(zData, n);
                shiftedZ[i] *= 1 + percentage;
                return NodalDoublesSurface.from(xData, yData, shiftedZ, newName);
            }
        }
    }
    throw new IllegalArgumentException("No x-y data in surface for (" + x + ", " + y + ")");
}

From source file:org.jberet.support.io.StockTrade.java

@Override
public int hashCode() {
    int result;/*from  ww w.j a v a  2  s .c  o m*/
    long temp;
    result = date.hashCode();
    result = 31 * result + time.hashCode();
    temp = Double.doubleToLongBits(open);
    result = 31 * result + (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(high);
    result = 31 * result + (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(low);
    result = 31 * result + (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(close);
    result = 31 * result + (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(volume);
    result = 31 * result + (int) (temp ^ (temp >>> 32));
    return result;
}

From source file:org.wicketstuff.gmap.api.GLatLng.java

/**
 * @see java.lang.Object#hashCode()//w  w w  .  jav a 2  s.  c o m
 */
@Override
public int hashCode() {
    final int PRIME = 31;
    int result = super.hashCode();
    long temp;
    temp = Double.doubleToLongBits(lat);
    result = PRIME * result + (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(lng);
    result = PRIME * result + (int) (temp ^ (temp >>> 32));
    result = PRIME * result + (unbounded ? 1231 : 1237);
    return result;
}

From source file:com.opengamma.analytics.math.interpolation.KrigingInterpolatorND.java

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }//  ww w.  j  a  v a  2 s  .c o m
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final KrigingInterpolatorND other = (KrigingInterpolatorND) obj;
    return Double.doubleToLongBits(_beta) == Double.doubleToLongBits(other._beta);
}

From source file:com.opengamma.analytics.financial.pnl.SensitivityAndReturnDataBundle.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((_sensitivity == null) ? 0 : _sensitivity.hashCode());
    result = prime * result + ((_underlyingReturnTS == null) ? 0 : _underlyingReturnTS.hashCode());
    long temp;// ww w  .j  av a  2 s  .  c  om
    temp = Double.doubleToLongBits(_value);
    result = prime * result + (int) (temp ^ (temp >>> 32));
    return result;
}

From source file:com.eTilbudsavis.etasdk.model.Size.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    long temp;/*from   w  w w. j a v a 2s .c  o  m*/
    temp = Double.doubleToLongBits(mFrom);
    result = prime * result + (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(mTo);
    result = prime * result + (int) (temp ^ (temp >>> 32));
    return result;
}