List of usage examples for java.lang Double POSITIVE_INFINITY
double POSITIVE_INFINITY
To view the source code for java.lang Double POSITIVE_INFINITY.
Click Source Link
From source file:cc.redberry.core.number.NumberUtils.java
public static Numeric createNumeric(double d) { //todo review performance profit if (d == 0)// w w w .j av a 2 s.com return Numeric.ZERO; else if (d == 1) return Numeric.ONE; else if (d == Double.POSITIVE_INFINITY) return Numeric.POSITIVE_INFINITY; else if (d == Double.NEGATIVE_INFINITY) return Numeric.NEGATIVE_INFINITY; else if (d != d)// d is NaN return Numeric.NaN; else return new Numeric(d); }
From source file:Main.java
private static Integer indexOfClosestZoom(Camera.Parameters parameters, double targetZoomRatio) { List<Integer> ratios = parameters.getZoomRatios(); Log.i(TAG, "Zoom ratios: " + ratios); int maxZoom = parameters.getMaxZoom(); if (ratios == null || ratios.isEmpty() || ratios.size() != maxZoom + 1) { Log.w(TAG, "Invalid zoom ratios!"); return null; }/* w ww . j a v a2 s.com*/ double target100 = 100.0 * targetZoomRatio; double smallestDiff = Double.POSITIVE_INFINITY; int closestIndex = 0; for (int i = 0; i < ratios.size(); i++) { double diff = Math.abs(ratios.get(i) - target100); if (diff < smallestDiff) { smallestDiff = diff; closestIndex = i; } } Log.i(TAG, "Chose zoom ratio of " + (ratios.get(closestIndex) / 100.0)); return closestIndex; }
From source file:com.wormsim.tracking.ConstantDouble.java
@Override public double getDataCount() { return Double.POSITIVE_INFINITY; }
From source file:com.wormsim.tracking.ConstantDouble.java
@Override public double getEffectiveDataCount() { return Double.POSITIVE_INFINITY; }
From source file:cpcc.vvrte.services.task.AcoTspSimple.java
/** * @param costMatrix the cost matrix./*w ww .j a va 2 s. c o m*/ * @param maxIterations the maximum number of iterations * @param boost the boost value. * @return the best path as a list of integers. */ public static List<Integer> calculateBestPath(double[][] costMatrix, int maxIterations, int boost) { if (costMatrix.length == 0 || costMatrix.length != costMatrix[0].length) { throw new IllegalStateException("Cost matrix heigth and width must be equal!"); } double[][] pheromoneTrails = new double[costMatrix.length][costMatrix.length]; for (int k = 0, l = costMatrix.length; k < l; ++k) { for (int j = 0; j < l; ++j) { pheromoneTrails[k][j] = 0; } } double bestLen = Double.POSITIVE_INFINITY; List<Integer> bestPath = new ArrayList<Integer>(); for (int iteration = 0; iteration < maxIterations; iteration++) { List<Integer> path = generatePath(costMatrix, pheromoneTrails); double pathLen = realPathLength(costMatrix, path); if (pathLen < bestLen) { updatePheromoneTrails(pheromoneTrails, path, boost); bestLen = pathLen; bestPath = path; } evaporatePheromoneTrails(pheromoneTrails, (double) boost / (double) maxIterations); } return bestPath; }
From source file:br.unicamp.ic.recod.gpsi.measures.gpsiNormalBhattacharyyaDistanceScore.java
@Override public double score(double[][][] input) { Mean mean = new Mean(); Variance var = new Variance(); double mu0, sigs0, mu1, sigs1; double dist[][] = new double[2][]; dist[0] = MatrixUtils.createRealMatrix(input[0]).getColumn(0); dist[1] = MatrixUtils.createRealMatrix(input[1]).getColumn(0); mu0 = mean.evaluate(dist[0]);/*from w w w . jav a 2 s . c om*/ sigs0 = var.evaluate(dist[0]) + Double.MIN_VALUE; mu1 = mean.evaluate(dist[1]); sigs1 = var.evaluate(dist[1]) + Double.MIN_VALUE; double distance = (Math.log((sigs0 / sigs1 + sigs1 / sigs0 + 2) / 4) + (Math.pow(mu1 - mu0, 2.0) / (sigs0 + sigs1))) / 4; return distance == Double.POSITIVE_INFINITY ? 0 : distance; }
From source file:eu.crisis_economics.abm.contracts.TwoPartyContract.java
/** Contract with no expiry. */ protected TwoPartyContract(SettlementParty firstParty, SettlementParty secondParty) { this(firstParty, secondParty, Double.POSITIVE_INFINITY); }
From source file:Main.java
/** * Returns the floating-point value adjacent to <code>d</code> in * the direction of positive infinity. This method is * semantically equivalent to <code>nextAfter(d, * Double.POSITIVE_INFINITY)</code>; however, a <code>nextUp</code> * implementation may run faster than its equivalent * <code>nextAfter</code> call. * * <p>Special Cases:/* w ww . j a va 2 s . c o m*/ * <ul> * <li> If the argument is NaN, the result is NaN. * * <li> If the argument is positive infinity, the result is * positive infinity. * * <li> If the argument is zero, the result is * <code>Double.MIN_VALUE</code> * * </ul> * * @param d starting floating-point value * @return The adjacent floating-point value closer to positive * infinity. * @author Joseph D. Darcy */ public static double nextUp(double d) { if (isNaN(d) || d == Double.POSITIVE_INFINITY) return d; else { d += 0.0d; return Double.longBitsToDouble(Double.doubleToRawLongBits(d) + ((d >= 0.0d) ? +1L : -1L)); } }
From source file:Main.java
/** * Determines the minimum and maximum values in the two dimensional array <tt>multi</tt>, ignoring any instances of <tt>noDataValue</tt> * ./*from w w w. ja v a 2 s . c o m*/ * * @param multi * @param noDataValue * @return a <tt>double[]</tt> where [0]==minimum and [1]==maximum */ public static double[] minMax(double[][] multi, double noDataValue) { double[] ret = null; double min = Double.POSITIVE_INFINITY, max = Double.NEGATIVE_INFINITY; double val; for (int i = 0; i < multi.length; i++) { for (int j = 0; j < multi[i].length; j++) { val = multi[i][j]; if (val != noDataValue) { min = (val < min) ? val : min; max = (val > max) ? val : max; } } } if (!Double.isInfinite(min) & !Double.isInfinite(max)) { ret = new double[] { min, max }; } return ret; }
From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.core.indicator.Spacing.java
/** * Computes the spread metric for the specified problem given an * approximation set.// ww w. j a v a 2s.co m * * @param problem the problem * @param approximationSet an approximation set for the problem * @return the spread metric for the specified problem given an * approximation set */ static double evaluate(Problem problem, NondominatedPopulation approximationSet) { if (approximationSet.size() < 2) { return 0.0; } double[] d = new double[approximationSet.size()]; for (int i = 0; i < approximationSet.size(); i++) { double min = Double.POSITIVE_INFINITY; Solution solutionI = approximationSet.get(i); if (solutionI.violatesConstraints()) { continue; } for (int j = 0; j < approximationSet.size(); j++) { if (i != j) { Solution solutionJ = approximationSet.get(j); if (solutionJ.violatesConstraints()) { continue; } min = Math.min(min, IndicatorUtils.manhattanDistance(problem, solutionI, solutionJ)); } } d[i] = min; } double dbar = StatUtils.sum(d) / approximationSet.size(); double sum = 0.0; for (int i = 0; i < approximationSet.size(); i++) { if (approximationSet.get(i).violatesConstraints()) { continue; } sum += Math.pow(d[i] - dbar, 2.0); } return Math.sqrt(sum / (approximationSet.size() - 1)); }