List of usage examples for java.lang Double NEGATIVE_INFINITY
double NEGATIVE_INFINITY
To view the source code for java.lang Double NEGATIVE_INFINITY.
Click Source Link
From source file:aprofplot.jfreechart.SamplingXYLineAndShapeRenderer.java
/** * Draws the visual representation of a series as lines. * * @param g2 the graphics device./*from www . ja v a 2 s . co m*/ * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param crosshairState crosshair information for the plot * (<code>null</code> permitted). * @param pass the pass index. */ protected void drawVerticalSeriesLine(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, CrosshairState crosshairState, int pass) { State s = (State) state; RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double lowestVisibleX = domainAxis.getLowerBound(); double highestVisibleX = domainAxis.getUpperBound(); double width = dataArea.getWidth(); double dX = (highestVisibleX - lowestVisibleX) / width * lineWidth; double lowestVisibleY = rangeAxis.getLowerBound(); double highestVisibleY = rangeAxis.getUpperBound(); double lastX = Double.NEGATIVE_INFINITY; double lastY = 0.0; double highY = 0.0; double lowY = 0.0; double openY = 0.0; double closeY = 0.0; boolean lastIntervalDone = false; boolean currentPointVisible = false; boolean lastPointVisible = false; boolean lastPointGood = false; boolean lastPointInInterval = false; boolean pathStarted = false; for (int itemIndex = state.getFirstItemIndex(); itemIndex <= state.getLastItemIndex(); itemIndex++) { double x = dataset.getXValue(series, itemIndex); double y = dataset.getYValue(series, itemIndex); if (!Double.isNaN(x) && !Double.isNaN(y)) { //System.out.println ("Breakpoint 736: pathStarted " + pathStarted); if (!pathStarted) { float startX = (float) domainAxis.valueToJava2D(x, dataArea, xAxisLocation); float startY = (float) rangeAxis.valueToJava2D(y, dataArea, yAxisLocation); s.seriesPath.moveTo(startX, startY); pathStarted = true; } if ((Math.abs(x - lastX) > dX)) { //System.out.println ("Breakpoint 744: leaving interval "); //in any case, add the interval that we are about to leave to the intervalPath float intervalPathX = 0.0f; float intervalPathStartY = 0.0f; float intervalPathEndY = 0.0f; float seriesPathCurrentX = 0.0f; float seriesPathCurrentY = 0.0f; float seriesPathLastX = 0.0f; float seriesPathLastY = 0.0f; //first set some variables intervalPathX = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation); intervalPathStartY = (float) rangeAxis.valueToJava2D(lowY, dataArea, yAxisLocation); intervalPathEndY = (float) rangeAxis.valueToJava2D(highY, dataArea, yAxisLocation); seriesPathCurrentX = (float) domainAxis.valueToJava2D(x, dataArea, xAxisLocation); seriesPathLastX = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation); seriesPathCurrentY = (float) rangeAxis.valueToJava2D(y, dataArea, yAxisLocation); seriesPathLastY = (float) rangeAxis.valueToJava2D(closeY, dataArea, yAxisLocation); /*if((lowY - highY) < 1){ lastPointInInterval = false; }*/ //Double[] values = new Double[]{new Double(openY), new Double(closeY), new Double(highY), new Double(lowY), new Double(lastX)}; /*MessageFormat mf = new MessageFormat("openY {0,number, integer}," + " closeY {1,number, integer}" + " highY {2,number, integer}" + " lowY {3,number, integer}" + "lastX {4,number, integer}");*/ //String text = mf.format(values); //System.out.println("Breakpoint 772" + text); boolean drawInterval = false; if (openY >= closeY) { if (highY > openY || lowY < closeY) { drawInterval = true; } } if (openY < closeY) { if (lowY < openY || highY > closeY) { drawInterval = true; } } //System.out.println("Breakpoint 784, drawInterval " + drawInterval); if (drawInterval) { s.intervalPath.moveTo(intervalPathX, intervalPathStartY); s.intervalPath.lineTo(intervalPathX, intervalPathEndY); } lastIntervalDone = true; //now the series path currentPointVisible = ((x >= lowestVisibleX) && (x <= highestVisibleX) && (y >= lowestVisibleY) && (y <= highestVisibleY)); if (!lastPointGood && !lastPointInInterval) {//last point not valid -- if (currentPointVisible) {//--> if the current position is visible move seriesPath cursor to the current position s.seriesPath.moveTo(seriesPathCurrentX, seriesPathCurrentY); } } else {//last point valid //if the last point was visible and not part of an interval, //we have already moved the seriesPath cursor to the last point, either with or without drawingh a line //thus we only need to draw a line to the current position if (lastPointInInterval && lastPointGood) { s.seriesPath.lineTo(seriesPathLastX, seriesPathLastY); s.seriesPath.lineTo(seriesPathCurrentX, seriesPathCurrentY); } //if the last point was not visible or part of an interval, we have just stored the y values of the last point //and not yet moved the seriesPath cursor. Thus, we need to move the cursor to the last point without drawing //and draw a line to the current position. else { s.seriesPath.lineTo(seriesPathCurrentX, seriesPathCurrentY); } } lastPointVisible = currentPointVisible; lastX = x; lastY = y; highY = y; lowY = y; openY = y; closeY = y; lastPointInInterval = false; } else { lastIntervalDone = false; lastPointInInterval = true; highY = Math.max(highY, y); lowY = Math.min(lowY, y); closeY = y; } lastPointGood = true; } else { lastPointGood = false; } } // if this is the last item, draw the path ... // draw path, but first check whether we need to complete an interval if (!lastIntervalDone) { if (lowY < highY) { float intervalX = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation); float intervalStartY = (float) rangeAxis.valueToJava2D(lowY, dataArea, yAxisLocation); float intervalEndY = (float) rangeAxis.valueToJava2D(highY, dataArea, yAxisLocation); s.intervalPath.moveTo(intervalX, intervalStartY); s.intervalPath.lineTo(intervalX, intervalEndY); } } PathIterator pi = s.seriesPath.getPathIterator(null); g2.setStroke(getItemStroke(series, 0)); g2.setPaint(getItemPaint(series, 0)); g2.draw(s.seriesPath); g2.draw(s.intervalPath); }
From source file:org.jfree.data.general.DatasetUtilities.java
/** * Iterates over the items in an {@link XYDataset} to find * the range of x-values./*from w w w. ja va2s.co m*/ * * @param dataset the dataset (<code>null</code> not permitted). * @param includeInterval a flag that determines, for an * {@link IntervalXYDataset}, whether the x-interval or just the * x-value is used to determine the overall range. * * @return The range (possibly <code>null</code>). */ public static Range iterateDomainBounds(XYDataset dataset, boolean includeInterval) { ParamChecks.nullNotPermitted(dataset, "dataset"); double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); double lvalue, uvalue; if (includeInterval && dataset instanceof IntervalXYDataset) { IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset; for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double value = intervalXYData.getXValue(series, item); lvalue = intervalXYData.getStartXValue(series, item); uvalue = intervalXYData.getEndXValue(series, item); if (!Double.isNaN(value)) { minimum = Math.min(minimum, value); maximum = Math.max(maximum, value); } if (!Double.isNaN(lvalue)) { minimum = Math.min(minimum, lvalue); maximum = Math.max(maximum, lvalue); } if (!Double.isNaN(uvalue)) { minimum = Math.min(minimum, uvalue); maximum = Math.max(maximum, uvalue); } } } } else { for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { lvalue = dataset.getXValue(series, item); uvalue = lvalue; if (!Double.isNaN(lvalue)) { minimum = Math.min(minimum, lvalue); maximum = Math.max(maximum, uvalue); } } } } if (minimum > maximum) { return null; } else { return new Range(minimum, maximum); } }
From source file:com.facebook.presto.tests.AbstractTestQueries.java
@Test public void testSpecialFloatingPointValues() throws Exception { MaterializedResult actual = computeActual("SELECT nan(), infinity(), -infinity()"); MaterializedRow row = Iterables.getOnlyElement(actual.getMaterializedRows()); assertEquals(row.getField(0), Double.NaN); assertEquals(row.getField(1), Double.POSITIVE_INFINITY); assertEquals(row.getField(2), Double.NEGATIVE_INFINITY); }
From source file:com.androzic.MapFragment.java
private void onUpdateNavigationStatus() { if (!application.isNavigating()) return;/* w w w . j a v a 2 s.co m*/ long now = System.currentTimeMillis(); double distance = application.navigationService.navDistance; double bearing = application.navigationService.navBearing; long turn = application.navigationService.navTurn; double vmg = application.navigationService.navVMG; int ete = application.navigationService.navETE; String[] dist = StringFormatter.distanceC(distance, StringFormatter.precisionFormat); String eteString = (ete == Integer.MAX_VALUE) ? getString(R.string.never) : (String) DateUtils.getRelativeTimeSpanString(now + (ete + 1) * 60000, now, DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); String extra = StringFormatter.speedH(vmg) + " | " + eteString; String trnsym = ""; if (turn > 0) { trnsym = "R"; } else if (turn < 0) { trnsym = "L"; turn = -turn; } bearing = application.fixDeclination(bearing); distanceValue.setText(dist[0]); distanceUnit.setText(dist[1]); bearingValue.setText(StringFormatter.angleC(bearing)); turnValue.setText(StringFormatter.angleC(turn) + trnsym); waypointExtra.setText(extra); if (application.navigationService.isNavigatingViaRoute()) { View rootView = getView(); boolean hasNext = application.navigationService.hasNextRouteWaypoint(); if (distance < application.navigationService.navProximity * 3 && !animationSet) { AnimationSet animation = new AnimationSet(true); animation.addAnimation(new AlphaAnimation(1.0f, 0.3f)); animation.addAnimation(new AlphaAnimation(0.3f, 1.0f)); animation.setDuration(500); animation.setRepeatCount(10); rootView.findViewById(R.id.waypointinfo).startAnimation(animation); if (!hasNext) { rootView.findViewById(R.id.routeinfo).startAnimation(animation); } animationSet = true; } else if (animationSet) { rootView.findViewById(R.id.waypointinfo).setAnimation(null); if (!hasNext) { rootView.findViewById(R.id.routeinfo).setAnimation(null); } animationSet = false; } if (application.navigationService.navXTK == Double.NEGATIVE_INFINITY) { xtkValue.setText("--"); xtkUnit.setText("--"); } else { String xtksym = application.navigationService.navXTK == 0 ? "" : application.navigationService.navXTK > 0 ? "R" : "L"; String[] xtks = StringFormatter.distanceC(Math.abs(application.navigationService.navXTK)); xtkValue.setText(xtks[0] + xtksym); xtkUnit.setText(xtks[1]); } double navDistance = application.navigationService.navRouteDistanceLeft(); int eta = application.navigationService.navRouteETE(navDistance); if (eta < Integer.MAX_VALUE) eta += application.navigationService.navETE; String etaString = (eta == Integer.MAX_VALUE) ? getString(R.string.never) : (String) DateUtils.getRelativeTimeSpanString(now + (eta + 1) * 60000, now, DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); extra = StringFormatter.distanceH(navDistance + distance, 1000) + " | " + etaString; routeExtra.setText(extra); } }
From source file:ml.shifu.shifu.core.ConfusionMatrix.java
public void computeConfusionMatixForMultipleClassification(long records) throws IOException { SourceType sourceType = evalConfig.getDataSet().getSource(); List<Scanner> scanners = ShifuFileUtils.getDataScanners(pathFinder.getEvalScorePath(evalConfig, sourceType), sourceType);//from w w w . ja v a2 s. c o m boolean isDir = ShifuFileUtils.isDir(pathFinder.getEvalScorePath(evalConfig, sourceType), sourceType); Set<String> tagSet = new HashSet<String>( modelConfig.getFlattenTags(modelConfig.getPosTags(evalConfig), modelConfig.getNegTags(evalConfig))); List<Set<String>> tags = modelConfig.getSetTags(modelConfig.getPosTags(evalConfig), modelConfig.getNegTags(evalConfig)); int classes = tags.size(); long cnt = 0, invalidTargetCnt = 0; ColumnConfig targetColumn = CommonUtils.findTargetColumn(columnConfigList); List<Integer> binCountNeg = targetColumn.getBinCountNeg(); List<Integer> binCountPos = targetColumn.getBinCountPos(); long[] binCount = new long[classes]; double[] binRatio = new double[classes]; long sumCnt = 0L; for (int i = 0; i < binCount.length; i++) { binCount[i] = binCountNeg.get(i) + binCountPos.get(i); sumCnt += binCount[i]; } for (int i = 0; i < binCount.length; i++) { binRatio[i] = (binCount[i] * 1d) / sumCnt; } long[][] confusionMatrix = new long[classes][classes]; for (Scanner scanner : scanners) { while (scanner.hasNext()) { if ((++cnt) % 100000 == 0) { LOG.info("Loaded " + cnt + " records."); } if (!isDir && cnt == 1) { // if the evaluation score file is the local file, skip the first line since we add header in continue; } // score is separated by default delimiter in our pig output format String[] raw = scanner.nextLine().split(Constants.DEFAULT_ESCAPE_DELIMITER); String tag = raw[targetColumnIndex]; if (StringUtils.isBlank(tag) || !tagSet.contains(tag)) { invalidTargetCnt += 1; continue; } double[] scores = new double[classes]; int predictIndex = -1; double maxScore = Double.NEGATIVE_INFINITY; if (CommonUtils.isTreeModel(modelConfig.getAlgorithm()) && !modelConfig.getTrain().isOneVsAll()) { // for RF native classification double[] tagCounts = new double[tags.size()]; for (int i = this.multiClassScore1Index; i < (raw.length - this.metaColumns); i++) { double dd = NumberFormatUtils.getDouble(raw[i], 0d); tagCounts[(int) dd] += 1d; } double maxVotes = -1d; for (int i = 0; i < tagCounts.length; i++) { if (tagCounts[i] > maxVotes) { predictIndex = i; maxScore = maxVotes = tagCounts[i]; } } } else if ((CommonUtils.isTreeModel(modelConfig.getAlgorithm()) || NNConstants.NN_ALG_NAME.equalsIgnoreCase(modelConfig.getAlgorithm())) && modelConfig.getTrain().isOneVsAll()) { // for RF, GBT & NN OneVsAll classification if (classes == 2) { // for binary classification, only one model is needed. for (int i = this.multiClassScore1Index; i < (1 + this.multiClassScore1Index); i++) { double dd = NumberFormatUtils.getDouble(raw[i], 0d); if (dd > ((1d - binRatio[i - this.multiClassScore1Index]) * scoreScale)) { predictIndex = 0; } else { predictIndex = 1; } } } else { // logic is here, per each onevsrest, it may be im-banlanced. for example, class a, b, c, first // is a(1) vs b and c(0), ratio is 10:1, then to compare score, if score > 1/11 it is positive, // check other models to see if still positive in b or c, take the largest one with ratio for // final prediction int[] predClasses = new int[classes]; double[] scoress = new double[classes]; double[] threhs = new double[classes]; for (int i = this.multiClassScore1Index; i < (classes + this.multiClassScore1Index); i++) { double dd = NumberFormatUtils.getDouble(raw[i], 0d); scoress[i - this.multiClassScore1Index] = dd; threhs[i - this.multiClassScore1Index] = (1d - binRatio[i - this.multiClassScore1Index]) * scoreScale; if (dd > ((1d - binRatio[i - this.multiClassScore1Index]) * scoreScale)) { predClasses[i - this.multiClassScore1Index] = 1; } } double maxRatio = -1d; double maxPositiveRatio = -1d; int maxRatioIndex = -1; for (int i = 0; i < binCount.length; i++) { if (binRatio[i] > maxRatio) { maxRatio = binRatio[i]; maxRatioIndex = i; } // if has positive, choose one with highest ratio if (predClasses[i] == 1) { if (binRatio[i] > maxPositiveRatio) { maxPositiveRatio = binRatio[i]; predictIndex = i; } } } // no any positive, take the largest one if (maxPositiveRatio < 0d) { predictIndex = maxRatioIndex; } } } else { if (classes == 2) { // for binary classification, only one model is needed. for (int i = this.multiClassScore1Index; i < (1 + this.multiClassScore1Index); i++) { double dd = NumberFormatUtils.getDouble(raw[i], 0d); if (dd > ((1d - binRatio[i - this.multiClassScore1Index]) * scoreScale)) { predictIndex = 0; } else { predictIndex = 1; } } } else { // only for NN & Native Multiple classification // 1,2,3 4,5,6: 1,2,3 is model 0, 4,5,6 is model 1 for (int i = 0; i < classes; i++) { for (int j = 0; j < multiClassModelCnt; j++) { double dd = NumberFormatUtils .getDouble(raw[this.multiClassScore1Index + j * classes + i], 0d); scores[i] += dd; } scores[i] /= multiClassModelCnt; if (scores[i] > maxScore) { predictIndex = i; maxScore = scores[i]; } } } } int tagIndex = -1; for (int i = 0; i < tags.size(); i++) { if (tags.get(i).contains(tag)) { tagIndex = i; break; } } confusionMatrix[tagIndex][predictIndex] += 1L; } scanner.close(); } LOG.info("Totally loading {} records with invalid target records {} in eval {}.", cnt, invalidTargetCnt, evalConfig.getName()); writeToConfMatrixFile(tags, confusionMatrix); // print conf matrix LOG.info("Multiple classification confustion matrix:"); LOG.info(String.format("%15s: %20s", " ", tags.toString())); for (int i = 0; i < confusionMatrix.length; i++) { LOG.info(String.format("%15s: %20s", tags.get(i), Arrays.toString(confusionMatrix[i]))); } }
From source file:com.clust4j.algo.NearestNeighborHeapSearch.java
public static int findNodeSplitDim(double[][] data, int[] idcs) { // Gets the difference between the vector of column // maxes and the vector of column mins, then finds the // arg max.//from w w w . j ava 2s. c o m // computes equivalent of (sklearn): // j_max = np.argmax(np.max(data, 0) - np.min(data, 0)) int n = data[0].length, idx, argMax = -1; double[] maxVec = VecUtils.rep(Double.NEGATIVE_INFINITY, n), minVec = VecUtils.rep(Double.POSITIVE_INFINITY, n), current; double diff, maxDiff = Double.NEGATIVE_INFINITY; // Optimized to one KxN pass for (int i = 0; i < idcs.length; i++) { idx = idcs[i]; current = data[idx]; for (int j = 0; j < n; j++) { if (current[j] > maxVec[j]) maxVec[j] = current[j]; if (current[j] < minVec[j]) minVec[j] = current[j]; // If the last iter, we can calc difference right now if (i == idcs.length - 1) { diff = maxVec[j] - minVec[j]; if (diff > maxDiff) { maxDiff = diff; argMax = j; } } } } return argMax; }
From source file:edu.cmu.tetrad.bayes.MlBayesIm.java
private void randomizeTable4(int nodeIndex) { for (int rowIndex = 0; rowIndex < getNumRows(nodeIndex); rowIndex++) { randomizeRow(nodeIndex, rowIndex); }//w w w .j a v a 2 s.c om double[][] saved = new double[getNumRows(nodeIndex)][getNumColumns(nodeIndex)]; double max = Double.NEGATIVE_INFINITY; for (int i = 0; i < 1000; i++) { for (int rowIndex = 0; rowIndex < getNumRows(nodeIndex); rowIndex++) { // randomizeRow(nodeIndex, rowIndex); randomizeRow2(nodeIndex, rowIndex, probs[nodeIndex][rowIndex]); } double score = score(nodeIndex); if (score > max) { max = score; copy(probs[nodeIndex], saved); } // if (score == getNumParents(nodeIndex)) { // break; // } } for (int rowIndex = 0; rowIndex < getNumRows(nodeIndex); rowIndex++) { copy(saved, probs[nodeIndex]); } }
From source file:com.microsoft.windowsazure.storage.table.TableParser.java
/** * Reserved for internal use. Writes an entity to the specified <code>JsonGenerator</code> as an JSON resource * //w w w . ja va2s. co m * @param generator * The <code>JsonGenerator</code> to write the entity to. * @param format * The {@link TablePayloadFormat} to use for parsing. * @param entity * The instance implementing {@link TableEntity} to write to the output stream. * @param isTableEntry * A flag indicating the entity is a reference to a table at the top level of the storage service when * <code>true<code> and a reference to an entity within a table when <code>false</code>. * @param opContext * An {@link OperationContext} object used to track the execution of the operation. * * @throws StorageException * if a Storage service error occurs. * @throws IOException * if an error occurs while accessing the stream. */ private static void writeJsonEntity(final JsonGenerator generator, TablePayloadFormat format, final TableEntity entity, final boolean isTableEntry, final OperationContext opContext) throws StorageException, IOException { HashMap<String, EntityProperty> properties = entity.writeEntity(opContext); if (properties == null) { properties = new HashMap<String, EntityProperty>(); } // start object generator.writeStartObject(); if (!isTableEntry) { Utility.assertNotNull(TableConstants.PARTITION_KEY, entity.getPartitionKey()); Utility.assertNotNull(TableConstants.ROW_KEY, entity.getRowKey()); Utility.assertNotNull(TableConstants.TIMESTAMP, entity.getTimestamp()); // PartitionKey generator.writeStringField(TableConstants.PARTITION_KEY, entity.getPartitionKey()); // RowKey generator.writeStringField(TableConstants.ROW_KEY, entity.getRowKey()); // Timestamp generator.writeStringField(TableConstants.TIMESTAMP, Utility .getTimeByZoneAndFormat(entity.getTimestamp(), Utility.UTC_ZONE, Utility.ISO8061_LONG_PATTERN)); } for (final Entry<String, EntityProperty> ent : properties.entrySet()) { if (ent.getKey().equals(TableConstants.PARTITION_KEY) || ent.getKey().equals(TableConstants.ROW_KEY) || ent.getKey().equals(TableConstants.TIMESTAMP) || ent.getKey().equals("Etag")) { continue; } EntityProperty currProp = ent.getValue(); if (currProp.getEdmType().mustAnnotateType()) { final String edmTypeString = currProp.getEdmType().toString(); // property type generator.writeStringField(ent.getKey() + ODataConstants.ODATA_TYPE_SUFFIX, edmTypeString); // property key and value generator.writeStringField(ent.getKey(), ent.getValue().getValueAsString()); } else if (currProp.getEdmType() == EdmType.DOUBLE && currProp.getIsNull() == false) { final String edmTypeString = currProp.getEdmType().toString(); final Double value = currProp.getValueAsDouble(); // property type, if needed if (value.equals(Double.POSITIVE_INFINITY) || value.equals(Double.NEGATIVE_INFINITY) || value.equals(Double.NaN)) { generator.writeStringField(ent.getKey() + ODataConstants.ODATA_TYPE_SUFFIX, edmTypeString); // property key and value generator.writeStringField(ent.getKey(), ent.getValue().getValueAsString()); } else { writeJsonProperty(generator, ent); } } else { writeJsonProperty(generator, ent); } } // end object generator.writeEndObject(); }
From source file:mondrian.olap.fun.FunUtil.java
/** * Compares double-precision values according to MDX semantics. * * <p>MDX requires a total order://from www .j a va 2 s . com * <blockquote> * -inf < NULL < ... < -1 < ... < 0 < ... < NaN < * +inf * </blockquote> * but this is different than Java semantics, specifically with regard * to {@link Double#NaN}. */ public static int compareValues(double d1, double d2) { if (Double.isNaN(d1)) { if (d2 == Double.POSITIVE_INFINITY) { return -1; } else if (Double.isNaN(d2)) { return 0; } else { return 1; } } else if (Double.isNaN(d2)) { if (d1 == Double.POSITIVE_INFINITY) { return 1; } else { return -1; } } else if (d1 == d2) { return 0; } else if (d1 == FunUtil.DoubleNull) { if (d2 == Double.NEGATIVE_INFINITY) { return 1; } else { return -1; } } else if (d2 == FunUtil.DoubleNull) { if (d1 == Double.NEGATIVE_INFINITY) { return -1; } else { return 1; } } else if (d1 < d2) { return -1; } else { return 1; } }
From source file:desmoj.core.statistic.Histogram.java
/** * Returns the lower limit of the given cell. If the given cell is negative, * <code>UNDEFINED</code> (-1) will be returned. * * @return double : The lower limit of the given cell. * @param cell//from w w w . j av a2 s.co m * int : The cell for which we want to know its lower limit. * Should be zero or positive. */ public double getLowerLimit(int cell) { if (cell < 0 || cell > this.getCells() + 1) { sendWarning("Attempt to get a lower limit of a not known cell. " + "UNDEFINED (-1) will be returned!", "Histogram: " + this.getName() + " Method: getLowerLimit( int cell ).", "The passed int: cell in this method is negative or greater than " + "the largest cell number.", "Make sure to ask the lower limit only for valid cell numbers."); return UNDEFINED; // return UNDEFINED (-1) } if (cell == 0) { return Double.NEGATIVE_INFINITY; } else { return StatisticObject.round(this._range[cell - 1]); } }