List of usage examples for java.lang Double doubleToLongBits
@HotSpotIntrinsicCandidate public static long doubleToLongBits(double value)
From source file:com.opengamma.analytics.math.surface.InterpolatedSurfaceAdditiveShiftFunction.java
/** * {@inheritDoc}//from w w w . j a v a2 s . c o m */ @Override public InterpolatedDoublesSurface evaluate(final InterpolatedDoublesSurface surface, final double x, final double y, final double shift, 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 = xData.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] += shift; return InterpolatedDoublesSurface.from(xData, yData, shiftedZ, surface.getInterpolator(), newName); } } } final double[] newX = new double[n + 1]; final double[] newY = new double[n + 1]; final double[] newZ = new double[n + 1]; for (int i = 0; i < n; i++) { newX[i] = xData[i]; newY[i] = yData[i]; newZ[i] = zData[i]; } newX[n] = x; newY[n] = y; newZ[n] = surface.getZValue(x, y) + shift; return InterpolatedDoublesSurface.from(newX, newY, newZ, surface.getInterpolator(), newName); }
From source file:com.addthis.bundle.value.DefaultDouble.java
@Override public ValueBytes asBytes() throws ValueTranslationException { return ValueFactory.create(LessBytes.toBytes(Double.doubleToLongBits(value))); }
From source file:com.opengamma.analytics.financial.interestrate.payments.derivative.PaymentFixed.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }//ww w .ja v a 2 s . c o m if (!super.equals(obj)) { return false; } if (getClass() != obj.getClass()) { return false; } PaymentFixed other = (PaymentFixed) obj; if (Double.doubleToLongBits(_amount) != Double.doubleToLongBits(other._amount)) { return false; } return true; }
From source file:edu.oregonstate.eecs.mcplan.domains.racetrack.AccelerateAction.java
@Override public int hashCode() { final long bits = (41 + 37 * Double.doubleToLongBits(v)) * 43 + Double.doubleToLongBits(theta); return (int) (bits ^ (bits >>> 32)); }
From source file:com.opengamma.analytics.math.surface.InterpolatedSurfaceMultiplicativeShiftFunction.java
/** * {@inheritDoc}//from w w w. j a v a 2s. c om */ @Override public InterpolatedDoublesSurface evaluate(final InterpolatedDoublesSurface 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 = xData.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 InterpolatedDoublesSurface.from(xData, yData, shiftedZ, surface.getInterpolator(), newName); } } } final double[] newX = new double[n + 1]; final double[] newY = new double[n + 1]; final double[] newZ = new double[n + 1]; for (int i = 0; i < n; i++) { newX[i] = xData[i]; newY[i] = yData[i]; newZ[i] = zData[i]; } newX[n] = x; newY[n] = y; newZ[n] = surface.getZValue(x, y) + percentage; return InterpolatedDoublesSurface.from(newX, newY, newZ, surface.getInterpolator(), newName); }
From source file:com.opengamma.analytics.math.surface.NodalSurfaceAdditiveShiftFunction.java
/** * {@inheritDoc}//from ww w. ja v a 2 s. c o 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 shift, 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] += shift; return NodalDoublesSurface.from(xData, yData, shiftedZ, newName); } } } throw new IllegalArgumentException("No x-y data in surface for (" + x + ", " + y + ")"); }
From source file:com.opengamma.analytics.math.statistics.distribution.NonCentralChiSquaredDistribution.java
private double getFraserApproxCDF(final double x) { final double s = Math.sqrt(_lambdaOverTwo * 2.0); final double mu = Math.sqrt(x); double z;/*www .j a va 2 s . co 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:com.opengamma.analytics.financial.model.option.definition.GapOptionDefinition.java
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); long temp;/* ww w . j av a2 s . c om*/ temp = Double.doubleToLongBits(_payoffStrike); result = prime * result + (int) (temp ^ (temp >>> 32)); return result; }
From source file:Main.java
/** * Converts a <code>double</code> value to a sortable signed <code>long</code>. * The value is converted by getting their IEEE 754 floating-point "double format" * bit layout and then some bits are swapped, to be able to compare the result as long. * By this the precision is not reduced, but the value can easily used as a long. * The sort order (including {@link Double#NaN}) is defined by * {@link Double#compareTo}; {@code NaN} is greater than positive infinity. * @see #sortableLongToDouble//from w ww. j av a 2 s. c o m */ public static long doubleToSortableLong(double val) { long f = Double.doubleToLongBits(val); if (f < 0) f ^= 0x7fffffffffffffffL; return f; }
From source file:com.opengamma.analytics.financial.model.option.definition.CashOrNothingOptionDefinition.java
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); long temp;/* w w w .j a v a 2s.c om*/ temp = Double.doubleToLongBits(_payment); result = prime * result + (int) (temp ^ (temp >>> 32)); return result; }