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:edu.uci.ics.jung.algorithms.shortestpath.DistanceStatistics.java
/** * Returns the diameter of <code>g</code> using the metric * specified by <code>d</code>. The diameter is defined to be * the maximum, over all pairs of vertices <code>u,v</code>, * of the length of the shortest path from <code>u</code> to * <code>v</code>. If the graph is disconnected (that is, not * all pairs of vertices are reachable from one another), the * value returned will depend on <code>use_max</code>: * if <code>use_max == true</code>, the value returned * will be the the maximum shortest path length over all pairs of <b>connected</b> * vertices; otherwise it will be <code>Double.POSITIVE_INFINITY</code>. */// ww w. ja va2 s .c om public static <V, E> double diameter(Hypergraph<V, E> g, Distance<V> d, boolean use_max) { double diameter = 0; Collection<V> vertices = g.getVertices(); for (V v : vertices) { for (V w : vertices) { if (v.equals(w) == false) // don't include self-distances { Number dist = d.getDistance(v, w); if (dist == null) { if (!use_max) return Double.POSITIVE_INFINITY; } else diameter = Math.max(diameter, dist.doubleValue()); } } } return diameter; }
From source file:gedi.util.math.stat.testing.MantelHaenszelTest.java
/** * Returns this!/* www . j a v a 2 s . co m*/ * @param table * @return * @throws MathException */ public MantelHaenszelTest compute(TwoByTwoByKTable table) { this.table = table; double delta = table.getDelta(); double yates = correct && (delta >= 0.5) ? 0.5 : 0; double deltayates = delta - yates; stat = deltayates * deltayates / table.getVarianceEstimate(); if (h1 == H1.NOT_EQUAL) pval = stat > 30 ? 0 : (1 - chisq.cumulativeProbability(stat)); else if (h1 == H1.LESS_THAN) pval = norm.cumulativeProbability(Math.signum(delta) * Math.sqrt(stat)); else pval = 1 - norm.cumulativeProbability(Math.signum(delta) * Math.sqrt(stat)); estimate = table.getOddsRatio(); double sd = table.computeSD(); if (h1 == H1.LESS_THAN) { lowerConf = 0; upperConf = estimate * Math.exp(norm.inverseCumulativeProbability(confLevel) * sd); } else if (h1 == H1.GREATER_THAN) { lowerConf = estimate * Math.exp(norm.inverseCumulativeProbability(1 - confLevel) * sd); upperConf = Double.POSITIVE_INFINITY; } else { lowerConf = estimate * Math.exp(norm.inverseCumulativeProbability((1 - confLevel) / 2) * sd); upperConf = estimate * Math.exp(-norm.inverseCumulativeProbability((1 - confLevel) / 2) * sd); } return this; }
From source file:org.jfree.data.WaferMapDataset.java
/** * Creates a new dataset./*from ww w . j a v a 2 s .co m*/ * * @param maxChipX * the wafer x-dimension. * @param maxChipY * the wafer y-dimension. * @param chipSpace * the space between chips. */ public WaferMapDataset(final int maxChipX, final int maxChipY, final Number chipSpace) { this.maxValue = new Double(Double.NEGATIVE_INFINITY); this.minValue = new Double(Double.POSITIVE_INFINITY); this.data = new DefaultKeyedValues2D(); this.maxChipX = maxChipX; this.maxChipY = maxChipY; if (chipSpace == null) { this.chipSpace = DEFAULT_CHIP_SPACE; } else { this.chipSpace = chipSpace.doubleValue(); } }
From source file:de.cebitec.readXplorer.plotting.CreatePlots.java
public synchronized static ChartPanel createInfPlot(Map<PersistentFeature, Pair<Double, Double>> data, String xName, String yName, XYToolTipGenerator toolTip) { XYSeriesCollection normal = new XYSeriesCollection(); XYSeriesCollection posInf = new XYSeriesCollection(); XYSeriesCollection negInf = new XYSeriesCollection(); XYSeries nor = new XYSeries("Normal"); XYSeries pos = new XYSeries("Positive Infinite"); XYSeries neg = new XYSeries("Negative Infinite"); for (Iterator<PersistentFeature> it = data.keySet().iterator(); it.hasNext();) { PersistentFeature key = it.next(); Pair<Double, Double> pair = data.get(key); Double X = pair.getFirst(); Double Y = pair.getSecond(); if (Y == Double.POSITIVE_INFINITY) { Y = 0d;/*from w ww .j a v a 2 s .c om*/ pos.add(new PlotDataItem(key, X, Y)); } if (Y == Double.NEGATIVE_INFINITY) { Y = 0d; neg.add(new PlotDataItem(key, X, Y)); } if (!Y.isInfinite() && !X.isInfinite()) { nor.add(new PlotDataItem(key, X, Y)); } } normal.addSeries(nor); posInf.addSeries(pos); negInf.addSeries(neg); JFreeChart chart = createCombinedChart(normal, posInf, negInf, xName, yName, toolTip); chart.removeLegend(); ChartPanel panel = new ChartPanel(chart, true, false, true, true, true); panel.setInitialDelay(0); panel.setMaximumDrawHeight(1080); panel.setMaximumDrawWidth(1920); panel.setMouseWheelEnabled(true); panel.setMouseZoomable(true); MouseActions mouseAction = new MouseActions(); panel.addChartMouseListener(mouseAction); ChartPanelOverlay overlay = new ChartPanelOverlay(mouseAction); panel.addOverlay(overlay); return panel; }
From source file:etomica.potential.P2HSDipole.java
public double energy(IMoleculeList pair) { IMolecule molecule1 = pair.getMolecule(0); IMolecule molecule2 = pair.getMolecule(1); IAtomList atomList1 = molecule1.getChildList(); IAtomList atomList2 = molecule2.getChildList(); IAtomOriented atom1 = (IAtomOriented) atomList1.getAtom(0); IAtomOriented atom2 = (IAtomOriented) atomList2.getAtom(0); // dr is a r1-r2 dr.Ev1Mv2(atom1.getPosition(), atom2.getPosition()); boundary.nearestImage(dr);//from www . j av a2 s . co m double r2 = dr.squared(); if (r2 > rCut * rCut) { return 0; } if (r2 < sigma2) { // hard core return Double.POSITIVE_INFINITY; } // normalize dr, the vector between the molecules dr.normalize(); // v1 (unit vector) is the orientation of molecule 1: dipole1 direction IVector v1 = atom1.getOrientation().getDirection(); // v2 (unit vector) is the orientation of molecule 2: dipole1 direction IVector v2 = atom2.getOrientation().getDirection(); // cos(dipole 1 and dipole 2)=cos(v1 and v2) double cos_D1_D2 = v1.dot(v2); //cos(dipole 1 and r12) double cos_D1_r = v1.dot(dr); //cos(r12 and dipole 2) double cos_r_D2 = dr.dot(v2); double r12Magnitude = Math.sqrt(r2); double ener = dipole * dipole * (cos_D1_D2 - 3.0 * cos_D1_r * cos_r_D2); ener = ener / r12Magnitude / r2; return ener; }
From source file:eu.udig.tools.jgrass.profile.ProfileView.java
public void clearSeries() { max = Double.NEGATIVE_INFINITY; min = Double.POSITIVE_INFINITY; series.clear(); }
From source file:edu.jhuapl.bsp.detector.OpenMath.java
public static double min(double[] in) { if (in != null) { double minvalue = Double.POSITIVE_INFINITY; for (int i = 0; i < in.length; i++) { minvalue = Math.min(in[i], minvalue); }/* w w w. ja v a2 s . com*/ return minvalue; } return Double.NEGATIVE_INFINITY; }
From source file:org.jfree.data.general.WaferMapDataset.java
/** * Creates a new dataset./*from ww w.j a va2s . co m*/ * * @param maxChipX the wafer x-dimension. * @param maxChipY the wafer y-dimension. * @param chipSpace the space between chips. */ public WaferMapDataset(int maxChipX, int maxChipY, Number chipSpace) { this.maxValue = new Double(Double.NEGATIVE_INFINITY); this.minValue = new Double(Double.POSITIVE_INFINITY); this.data = new DefaultKeyedValues2D(); this.maxChipX = maxChipX; this.maxChipY = maxChipY; if (chipSpace == null) { this.chipSpace = DEFAULT_CHIP_SPACE; } else { this.chipSpace = chipSpace.doubleValue(); } }
From source file:com.clust4j.algo.BoruvkaAlgorithm.java
protected static double kdTreeMinRDistDual(DistanceMetric metric, int node1, int node2, double[][][] nodeBounds, int n) {/*from w ww. j a v a2 s. com*/ double d, d1, d2, rdist = 0.0; boolean inf = metric.getP() == Double.POSITIVE_INFINITY; int j; for (j = 0; j < n; j++) { d1 = nodeBounds[0][node1][j] - nodeBounds[1][node2][j]; d2 = nodeBounds[0][node2][j] - nodeBounds[1][node1][j]; d = (d1 + FastMath.abs(d1)) + (d2 + FastMath.abs(d2)); rdist = inf ? FastMath.max(rdist, 0.5 * d) : rdist + FastMath.pow(0.5 * d, metric.getP()); } return rdist; }
From source file:it.unibo.alchemist.utils.MathUtils.java
/** * This is a chached version of the factorial. It means it is slow for the * first call, but extremely fast after that. It relies on the idea that * normally inside Alchemist a factorial is called often with the same * numbers (e.g. for the rate contribution computation of chemical reactions * which involve more molecules of the same compound). Due to limited * precision of double, you may experience precision loss with high numbers. * This method returns meaningful results up to 170!. Over this limit, you * get Double.POSITIVE_INFINITY./* w w w .j a v a 2 s .com*/ * * @param n * the number to compute * @return n! */ public static double factDouble(final int n) { if (n == 0) { return 1; } if (n > MAXFACTDOUBLE) { return Double.POSITIVE_INFINITY; } if (VFACTD[n] != 0d) { return VFACTD[n]; } final double res = factDouble(n - 1) * n; VFACTD[n] = res; return res; }