List of usage examples for java.lang Math signum
public static float signum(float f)
From source file:com.opengamma.analytics.financial.interestrate.swaption.provider.SwaptionPhysicalFixedIborLMMDDMethod.java
/** * Computes the present value sensitivity to LMM volatility parameters. * @param swaption The (physical delivery) swaption. * @param lmmData The LMM and multi-curves provider. * @return The sensitivity./* w ww.j ava2 s. co m*/ */ public double[][] presentValueLMMSensitivity(final SwaptionPhysicalFixedIbor swaption, final LiborMarketModelDisplacedDiffusionProviderInterface lmmData) { ArgumentChecker.notNull(swaption, "Swaption"); ArgumentChecker.notNull(lmmData, "LMM provider"); final Currency ccy = swaption.getCurrency(); final MulticurveProviderInterface multicurves = lmmData.getMulticurveProvider(); final LiborMarketModelDisplacedDiffusionParameters parameters = lmmData.getLMMParameters(); // 1. Swaption CFE preparation final AnnuityPaymentFixed cfe = swaption.getUnderlyingSwap().accept(CFEC, multicurves); final int nbCFInit = cfe.getNumberOfPayments(); final double multFact = Math.signum(cfe.getNthPayment(0).getAmount()); final boolean isCall = (cfe.getNthPayment(0).getAmount() < 0); final double[] cftInit = new double[nbCFInit]; final double[] cfaInit = new double[nbCFInit]; for (int loopcf = 0; loopcf < nbCFInit; loopcf++) { cftInit[loopcf] = cfe.getNthPayment(loopcf).getPaymentTime(); cfaInit[loopcf] = cfe.getNthPayment(loopcf).getAmount() * -multFact; } final double timeToExpiry = swaption.getTimeToExpiry(); // 2. Model data final int nbFactor = parameters.getNbFactor(); final double[][] volLMM = parameters.getVolatility(); final double[] timeLMM = parameters.getIborTime(); // 3. Link cfe dates to lmm final int[] indCFDate = new int[nbCFInit]; int indStart = nbCFInit - 1; int indEnd = 0; for (int loopcf = 0; loopcf < nbCFInit; loopcf++) { indCFDate[loopcf] = Arrays.binarySearch(timeLMM, cftInit[loopcf]); if (indCFDate[loopcf] < 0) { if (timeLMM[-indCFDate[loopcf] - 1] - cftInit[loopcf] < TIME_TOLERANCE) { indCFDate[loopcf] = -indCFDate[loopcf] - 1; } else { if (cftInit[loopcf] - timeLMM[-indCFDate[loopcf] - 2] < TIME_TOLERANCE) { indCFDate[loopcf] = -indCFDate[loopcf] - 2; } else { Validate.isTrue(true, "Instrument time incompatible with LMM"); } } } if (indCFDate[loopcf] < indStart) { indStart = indCFDate[loopcf]; } if (indCFDate[loopcf] > indEnd) { indEnd = indCFDate[loopcf]; } } final int nbCF = indEnd - indStart + 1; final double[] cfa = new double[nbCF]; for (int loopcf = 0; loopcf < nbCFInit; loopcf++) { cfa[indCFDate[loopcf] - indStart] = cfaInit[loopcf]; } final double[] cft = new double[nbCF]; System.arraycopy(timeLMM, indStart, cft, 0, nbCF); final double[] dfLMM = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF; loopcf++) { dfLMM[loopcf] = multicurves.getDiscountFactor(ccy, cft[loopcf]); } final double[][] gammaLMM = new double[nbCF - 1][nbFactor]; final double[] deltaLMM = new double[nbCF - 1]; System.arraycopy(parameters.getAccrualFactor(), indStart, deltaLMM, 0, nbCF - 1); final double[] aLMM = new double[nbCF - 1]; System.arraycopy(parameters.getDisplacement(), indStart, aLMM, 0, nbCF - 1); final double[] liborLMM = new double[nbCF - 1]; final double amr = parameters.getMeanReversion(); for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { gammaLMM[loopcf] = volLMM[indStart + loopcf]; liborLMM[loopcf] = (dfLMM[loopcf] / dfLMM[loopcf + 1] - 1.0d) / deltaLMM[loopcf]; } // TODO: 4. cfe modification (for roller coasters) final double[] cfaMod = new double[nbCF + 1]; final double cfaMod0 = cfa[0]; cfaMod[0] = cfaMod0; // modified strike cfaMod[1] = 0.0; System.arraycopy(cfa, 1, cfaMod, 2, nbCF - 1); // 5. Pricing algorithm final double[] p0 = new double[nbCF]; final double[] dP = new double[nbCF]; double b0 = 0; for (int loopcf = 0; loopcf < nbCF; loopcf++) { p0[loopcf] = dfLMM[loopcf] / dfLMM[0]; dP[loopcf] = cfaMod[loopcf + 1] * p0[loopcf]; b0 += dP[loopcf]; } final double bK = -cfaMod0; final double bM = (b0 + bK) / 2.0d; final double[] rate0Ratio = new double[nbCF - 1]; final double[][] mu0 = new double[nbCF - 1][nbFactor]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { rate0Ratio[loopcf] = (liborLMM[loopcf] + aLMM[loopcf]) / (liborLMM[loopcf] + 1 / deltaLMM[loopcf]); } for (int loopfact = 0; loopfact < nbFactor; loopfact++) { mu0[0][loopfact] = rate0Ratio[0] * gammaLMM[0][loopfact]; } for (int loopcf = 1; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { mu0[loopcf][loopfact] = mu0[loopcf - 1][loopfact] + rate0Ratio[loopcf] * gammaLMM[loopcf][loopfact]; } } final double meanReversionImpact = (Math.exp(2.0d * amr * timeToExpiry) - 1.0d) / (2.0d * amr); final double[] tau = new double[nbCF]; final double[] tau2 = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { tau2[loopcf + 1] += mu0[loopcf][loopfact] * mu0[loopcf][loopfact]; } tau2[loopcf + 1] = tau2[loopcf + 1] * meanReversionImpact; tau[loopcf + 1] = Math.sqrt(tau2[loopcf + 1]); } double sumNum = -bM; double sumDen = 0; for (int loopcf = 0; loopcf < nbCF; loopcf++) { sumNum += dP[loopcf] - dP[loopcf] * tau2[loopcf] / 2.0; sumDen += dP[loopcf] * tau[loopcf]; } final double xBar = sumNum / sumDen; final double[] pM = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF; loopcf++) { pM[loopcf] = p0[loopcf] * (1 - xBar * tau[loopcf] - tau2[loopcf] / 2.0); } final double[] liborM = new double[nbCF - 1]; final double[] alphaM = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { liborM[loopcf] = (pM[loopcf] / pM[loopcf + 1] - 1.0d) / deltaLMM[loopcf]; } for (int loopcf = 0; loopcf < nbCF; loopcf++) { alphaM[loopcf] = cfaMod[loopcf + 1] * pM[loopcf] / bM; } final double[] rateMRatio = new double[nbCF - 1]; final double[][] muM = new double[nbCF - 1][nbFactor]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { rateMRatio[loopcf] = (liborM[loopcf] + aLMM[loopcf]) / (liborM[loopcf] + 1 / deltaLMM[loopcf]); } for (int loopfact = 0; loopfact < nbFactor; loopfact++) { muM[0][loopfact] = rateMRatio[0] * gammaLMM[0][loopfact]; } for (int loopcf = 1; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { muM[loopcf][loopfact] = muM[loopcf - 1][loopfact] + rateMRatio[loopcf] * gammaLMM[loopcf][loopfact]; } } double normSigmaM = 0; final double[] sigmaM = new double[nbFactor]; for (int loopfact = 0; loopfact < nbFactor; loopfact++) { for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { sigmaM[loopfact] += alphaM[loopcf + 1] * muM[loopcf][loopfact]; } normSigmaM += sigmaM[loopfact] * sigmaM[loopfact]; } final double impliedBlackVol = Math.sqrt(normSigmaM * meanReversionImpact); final EuropeanVanillaOption option = new EuropeanVanillaOption(bK, 1, isCall); final BlackPriceFunction blackFunction = new BlackPriceFunction(); final BlackFunctionData dataBlack = new BlackFunctionData(b0, 1.0, impliedBlackVol); final double[] blkAdjoint = blackFunction.getPriceAdjoint(option, dataBlack); // Backward sweep final double pvBar = 1.0; final double impliedBlackVolBar = dfLMM[0] * blkAdjoint[2] * pvBar; final double normSigmaMBar = meanReversionImpact / (2.0 * impliedBlackVol) * impliedBlackVolBar; final double[] sigmaMBar = new double[nbFactor]; for (int loopfact = 0; loopfact < nbFactor; loopfact++) { sigmaMBar[loopfact] = 2 * sigmaM[loopfact] * normSigmaMBar; } final double[][] muMBar = new double[nbCF - 1][nbFactor]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { muMBar[loopcf][loopfact] = alphaM[loopcf + 1] * sigmaMBar[loopfact]; } } for (int loopcf = nbCF - 3; loopcf >= 0; loopcf--) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { muMBar[loopcf][loopfact] += muMBar[loopcf + 1][loopfact]; } } final double[] rateMRatioBar = new double[nbCF - 1]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { rateMRatioBar[loopcf] += gammaLMM[loopcf][loopfact] * muMBar[loopcf][loopfact]; } } final double[] alphaMBar = new double[nbCF]; for (int loopfact = 0; loopfact < nbFactor; loopfact++) { for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { alphaMBar[loopcf + 1] += muM[loopcf][loopfact] * sigmaMBar[loopfact]; } } final double[] liborMBar = new double[nbCF - 1]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { liborMBar[loopcf] = ((liborM[loopcf] + 1 / deltaLMM[loopcf]) - (liborM[loopcf] + aLMM[loopcf])) / ((liborM[loopcf] + 1 / deltaLMM[loopcf]) * (liborM[loopcf] + 1 / deltaLMM[loopcf])) * rateMRatioBar[loopcf]; } final double[] pMBar = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { pMBar[loopcf] += 1.0 / pM[loopcf + 1] / deltaLMM[loopcf] * liborMBar[loopcf]; pMBar[loopcf + 1] += -pM[loopcf] / (pM[loopcf + 1] * pM[loopcf + 1]) / deltaLMM[loopcf] * liborMBar[loopcf]; } for (int loopcf = 0; loopcf < nbCF; loopcf++) { pMBar[loopcf] += cfaMod[loopcf + 1] / bM * alphaMBar[loopcf]; } double xBarBar = 0.0; for (int loopcf = 0; loopcf < nbCF; loopcf++) { xBarBar += -p0[loopcf] * tau[loopcf] * pMBar[loopcf]; } final double sumNumBar = 1.0 / sumDen * xBarBar; final double sumDenBar = -sumNum / (sumDen * sumDen) * xBarBar; final double[] tauBar = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF; loopcf++) { tauBar[loopcf] = -p0[loopcf] * xBar * pMBar[loopcf]; } for (int loopcf = 0; loopcf < nbCF; loopcf++) { tauBar[loopcf] += dP[loopcf] * sumDenBar; } final double[] tau2Bar = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF; loopcf++) { tau2Bar[loopcf] = -p0[loopcf] / 2.0 * pMBar[loopcf]; } for (int loopcf = 0; loopcf < nbCF; loopcf++) { tau2Bar[loopcf] += -dP[loopcf] / 2.0 * sumNumBar; } for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { tau2Bar[loopcf + 1] += 1 / 2.0 / tau[loopcf + 1] * tauBar[loopcf + 1]; } final double[][] mu0Bar = new double[nbCF - 1][nbFactor]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { mu0Bar[loopcf][loopfact] = 2.0 * mu0[loopcf][loopfact] * meanReversionImpact * tau2Bar[loopcf + 1]; } } for (int loopcf = nbCF - 3; loopcf >= 0; loopcf--) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { mu0Bar[loopcf][loopfact] += mu0Bar[loopcf + 1][loopfact]; } } final double[][] gammaLMMBar = new double[nbCF - 1][nbFactor]; for (int loopfact = 0; loopfact < nbFactor; loopfact++) { gammaLMMBar[0][loopfact] = rateMRatio[0] * muMBar[0][loopfact]; } for (int loopcf = 1; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { gammaLMMBar[loopcf][loopfact] += rateMRatio[loopcf] * muMBar[loopcf][loopfact]; } } for (int loopfact = 0; loopfact < nbFactor; loopfact++) { gammaLMMBar[0][loopfact] += rate0Ratio[0] * mu0Bar[0][loopfact]; } for (int loopcf = 1; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { gammaLMMBar[loopcf][loopfact] += rate0Ratio[loopcf] * mu0Bar[loopcf][loopfact]; } } final double[][] volLMMBar = new double[volLMM.length][nbFactor]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { volLMMBar[indStart + loopcf] = gammaLMMBar[loopcf]; } return volLMMBar; }
From source file:blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.java
/** * Clears all connections to and from this node. *///from ww w . j a v a2s . c o m public void clearAllConnectionsFor(BlockPos node, World world, @Nullable IImmersiveConnectable iic, boolean doDrops) { if (iic == null) iic = toIIC(node, world); if (iic != null) iic.removeCable(null); if (getMultimap(world.provider.getDimension()).containsKey(node)) { for (Connection con : getMultimap(world.provider.getDimension()).get(node)) { removeConnection(world, con, iic != null ? iic.getConnectionOffset(con) : Vec3d.ZERO, getVecForIICAt(world, con.end, con)); double dx = node.getX() + .5 + Math.signum(con.end.getX() - con.start.getX()); double dy = node.getY() + .5 + Math.signum(con.end.getY() - con.start.getY()); double dz = node.getZ() + .5 + Math.signum(con.end.getZ() - con.start.getZ()); if (doDrops && world.getGameRules().getBoolean("doTileDrops")) world.spawnEntity(new EntityItem(world, dx, dy, dz, con.cableType.getWireCoil(con))); } } IESaveData.setDirty(world.provider.getDimension()); }
From source file:pct.droid.fragments.VideoPlayerFragment.java
private void doSeekTouch(float coef, float gesturesize, boolean seek) { // No seek action if coef > 0.5 and gesturesize < 1cm if (coef > 0.5 || Math.abs(gesturesize) < 1) { return;/*from w w w . j a v a 2 s.c o m*/ } if (mTouchAction != TOUCH_NONE && mTouchAction != TOUCH_SEEK) { return; } mTouchAction = TOUCH_SEEK; // Size of the jump, 10 minutes max (600000), with a bi-cubic progression, for a 8cm gesture int jump = (int) (Math.signum(gesturesize) * ((600000 * Math.pow((gesturesize / 8), 4)) + 3000)); // Adjust the jump if ((jump > 0) && ((getCurrentTime() + jump) > mControlBar.getSecondaryProgress())) { jump = (int) (mControlBar.getSecondaryProgress() - getCurrentTime()); } if ((jump < 0) && ((getCurrentTime() + jump) < 0)) { jump = (int) -getCurrentTime(); } long currentTime = getCurrentTime(); if (seek && mControlBar.getSecondaryProgress() > 0) { seek(jump); } if (getDuration() > 0) { showPlayerInfo(String.format("%s%s (%s)", jump >= 0 ? "+" : "", StringUtils.millisToString(jump), StringUtils.millisToString(currentTime + jump))); } }
From source file:org.nd4j.linalg.api.complex.BaseComplexFloat.java
@Override public IComplexFloat sqrt() { float a = absoluteValue(); float s2 = (float) Math.sqrt(2); float p = (float) Math.sqrt(a + realComponent()) / s2; float q = (float) Math.sqrt(a - realComponent()) / s2 * Math.signum(imaginaryComponent()); // return Nd4j.createFloat(p, q); throw new UnsupportedOperationException(); }
From source file:syncleus.dann.math.ComplexNumber.java
@Override public final ComplexNumber sqrt() { // The square-root of the complex number (a + i b) is // sqrt(a + i b) = +/- (sqrt(radius + a) + i sqrt(radius - a) sign(b)) // sqrt(2) / 2, // where radius = sqrt(a^2 + b^2). final double radius = Math.sqrt((getReal() * getReal()) + (getImaginary() * getImaginary())); final ComplexNumber intermediate = new ComplexNumber(Math.sqrt(radius + getReal()), Math.sqrt(radius + getReal()) * Math.signum(getImaginary())); return intermediate.multiply(Math.sqrt(2.0)).divide(2.0); }
From source file:com.etmay.brescrollpager.ui.MyScroller.java
/** * Start scrolling based on a fling gesture. The distance travelled will * depend on the initial velocity of the fling. * * @param startX Starting point of the scroll (X) * @param startY Starting point of the scroll (Y) * @param velocityX Initial velocity of the fling (X) measured in pixels per * second./*from w w w . j ava 2 s .co m*/ * @param velocityY Initial velocity of the fling (Y) measured in pixels per * second * @param minX Minimum X value. The scroller will not scroll past this * point. * @param maxX Maximum X value. The scroller will not scroll past this * point. * @param minY Minimum Y value. The scroller will not scroll past this * point. * @param maxY Maximum Y value. The scroller will not scroll past this * point. */ public void fling(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY) { // Continue a scroll or fling in progress if (mFlywheel && !mFinished) { float oldVel = getCurrVelocity(); float dx = (float) (mFinalX - mStartX); float dy = (float) (mFinalY - mStartY); float hyp = (float) Math.hypot(dx, dy); float ndx = dx / hyp; float ndy = dy / hyp; float oldVelocityX = ndx * oldVel; float oldVelocityY = ndy * oldVel; if (Math.signum(velocityX) == Math.signum(oldVelocityX) && Math.signum(velocityY) == Math.signum(oldVelocityY)) { velocityX += oldVelocityX; velocityY += oldVelocityY; } } mMode = FLING_MODE; mFinished = false; float velocity = (float) Math.hypot(velocityX, velocityY); mVelocity = velocity; mDuration = getSplineFlingDuration(velocity); mStartTime = AnimationUtils.currentAnimationTimeMillis(); mStartX = startX; mStartY = startY; float coeffX = velocity == 0 ? 1.0f : velocityX / velocity; float coeffY = velocity == 0 ? 1.0f : velocityY / velocity; double totalDistance = getSplineFlingDistance(velocity); mDistance = (int) (totalDistance * Math.signum(velocity)); mMinX = minX; mMaxX = maxX; mMinY = minY; mMaxY = maxY; mFinalX = startX + (int) Math.round(totalDistance * coeffX); // Pin to mMinX <= mFinalX <= mMaxX mFinalX = Math.min(mFinalX, mMaxX); mFinalX = Math.max(mFinalX, mMinX); mFinalY = startY + (int) Math.round(totalDistance * coeffY); // Pin to mMinY <= mFinalY <= mMaxY mFinalY = Math.min(mFinalY, mMaxY); mFinalY = Math.max(mFinalY, mMinY); }
From source file:blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.java
/** * Clears all connections to and from this node. *//*from w w w . java 2s . co m*/ public boolean clearAllConnectionsFor(BlockPos node, World world, @Nonnull TargetingInfo target) { IImmersiveConnectable iic = toIIC(node, world); WireType type = iic.getCableLimiter(target); if (type == null) return false; int dim = world.provider.getDimension(); resetCachedIndirectConnections(world, node); boolean ret = false; for (Connection con : getMultimap(world.provider.getDimension()).get(node)) { if (con.cableType == type) { removeConnection(world, con); double dx = node.getX() + .5 + Math.signum(con.end.getX() - con.start.getX()); double dy = node.getY() + .5 + Math.signum(con.end.getY() - con.start.getY()); double dz = node.getZ() + .5 + Math.signum(con.end.getZ() - con.start.getZ()); if (world.getGameRules().getBoolean("doTileDrops")) world.spawnEntity(new EntityItem(world, dx, dy, dz, con.cableType.getWireCoil(con))); ret = true; } } if (world.isBlockLoaded(node)) world.addBlockEvent(node, world.getBlockState(node).getBlock(), -1, 0); IESaveData.setDirty(dim); return ret; }
From source file:com.androzic.navigation.NavigationService.java
private void calculateNavigationStatus(Location loc, float smoothspeed, float avgspeed) { double distance = Geo.distance(loc.getLatitude(), loc.getLongitude(), navWaypoint.latitude, navWaypoint.longitude);/*from ww w .j av a2 s.c o m*/ double bearing = Geo.bearing(loc.getLatitude(), loc.getLongitude(), navWaypoint.latitude, navWaypoint.longitude); double track = loc.getBearing(); // turn long turn = Math.round(bearing - track); if (Math.abs(turn) > 180) { turn = turn - (long) (Math.signum(turn)) * 360; } // vmg double vmg = Geo.vmg(smoothspeed, Math.abs(turn)); // ete float curavvmg = (float) Geo.vmg(avgspeed, Math.abs(turn)); if (avvmg == 0.0 || tics % 10 == 0) { for (int i = vmgav.length - 1; i > 0; i--) { avvmg += vmgav[i]; vmgav[i] = vmgav[i - 1]; } avvmg += curavvmg; vmgav[0] = curavvmg; avvmg = avvmg / vmgav.length; } int ete = Integer.MAX_VALUE; if (avvmg > 0) ete = (int) Math.round(distance / avvmg / 60); double xtk = Double.NEGATIVE_INFINITY; if (navRoute != null) { boolean hasNext = hasNextRouteWaypoint(); if (distance < navProximity) { if (hasNext) { nextRouteWaypoint(); return; } else { updateNavigationState(STATE_REACHED); stopNavigation(); return; } } if (prevWaypoint != null) { double dtk = Geo.bearing(prevWaypoint.latitude, prevWaypoint.longitude, navWaypoint.latitude, navWaypoint.longitude); xtk = Geo.xtk(distance, dtk, bearing); if (xtk == Double.NEGATIVE_INFINITY) { if (useTraverse && hasNext) { double cxtk2 = Double.NEGATIVE_INFINITY; MapObject nextWpt = getNextRouteWaypoint(); if (nextWpt != null) { double dtk2 = Geo.bearing(nextWpt.latitude, nextWpt.longitude, navWaypoint.latitude, navWaypoint.longitude); cxtk2 = Geo.xtk(0, dtk2, bearing); } if (cxtk2 != Double.NEGATIVE_INFINITY) { nextRouteWaypoint(); return; } } } } } tics++; if (distance != navDistance || bearing != navBearing || turn != navTurn || vmg != navVMG || ete != navETE || xtk != navXTK) { navDistance = distance; navBearing = bearing; navTurn = turn; navVMG = vmg; navETE = ete; navXTK = xtk; updateNavigationStatus(); } }
From source file:org.nd4j.linalg.api.complex.BaseComplexDouble.java
@Override public IComplexDouble sqrt() { double a = absoluteValue(); double s2 = Math.sqrt(2); double p = Math.sqrt(a + realComponent()) / s2; double q = Math.sqrt(a - realComponent()) / s2 * Math.signum(imaginaryComponent()); throw new UnsupportedOperationException(); }
From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.util.tree.NumberArithmetic.java
/** * Returns the sign of the number./*www .j a v a 2 s . com*/ * * @param a the number * @return the sign of the number * @see Long#signum(long) * @see Math#signum(double) */ public static Number sign(Number a) { if (isFloatingPoint(a)) { return Math.signum(a.doubleValue()); } else { return Long.signum(a.longValue()); } }