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:ffx.xray.CCP4MapFilter.java
/** * {@inheritDoc}//from w w w. j a v a 2 s. co m */ @Override public boolean readFile(String filename, RealSpaceRefinementData refinementdata, CompositeConfiguration properties) { int imapdata; double cella, cellb, cellc, cellalpha, cellbeta, cellgamma; String stampstr; ByteOrder b = ByteOrder.nativeOrder(); FileInputStream fis; DataInputStream dis; double min = Double.POSITIVE_INFINITY; double max = Double.NEGATIVE_INFINITY; double mean = 0.0; double sd = 0.0; double rmsd = 0.0; // first determine byte order of file versus system try { fis = new FileInputStream(filename); dis = new DataInputStream(fis); dis.skipBytes(212); byte bytes[] = new byte[4]; dis.read(bytes, 0, 4); ByteBuffer bb = ByteBuffer.wrap(bytes); imapdata = bb.order(ByteOrder.BIG_ENDIAN).getInt(); stampstr = Integer.toHexString(imapdata); // System.out.println("stamp: " + stampstr); switch (stampstr.charAt(0)) { case '1': case '3': if (b.equals(ByteOrder.LITTLE_ENDIAN)) { b = ByteOrder.BIG_ENDIAN; } break; case '4': if (b.equals(ByteOrder.BIG_ENDIAN)) { b = ByteOrder.LITTLE_ENDIAN; } break; } if (logger.isLoggable(Level.INFO)) { StringBuilder sb = new StringBuilder(); sb.append(String.format("\nOpening CCP4 map: %s\n", filename)); sb.append(String.format("file type (machine stamp): %s\n", stampstr)); logger.info(sb.toString()); } fis.close(); } catch (Exception e) { String message = "Fatal exception reading CCP4 map.\n"; logger.log(Level.SEVERE, message, e); System.exit(-1); } try { fis = new FileInputStream(filename); dis = new DataInputStream(fis); byte bytes[] = new byte[2048]; dis.read(bytes, 0, 1024); ByteBuffer bb = ByteBuffer.wrap(bytes); int ext[] = new int[3]; ext[0] = bb.order(b).getInt(); ext[1] = bb.order(b).getInt(); ext[2] = bb.order(b).getInt(); // mode (2 = reals, only one we accept) int mode = bb.order(b).getInt(); int ori[] = new int[3]; ori[0] = bb.order(b).getInt(); ori[1] = bb.order(b).getInt(); ori[2] = bb.order(b).getInt(); int ni[] = new int[3]; ni[0] = bb.order(b).getInt(); ni[1] = bb.order(b).getInt(); ni[2] = bb.order(b).getInt(); cella = bb.order(b).getFloat(); cellb = bb.order(b).getFloat(); cellc = bb.order(b).getFloat(); cellalpha = bb.order(b).getFloat(); cellbeta = bb.order(b).getFloat(); cellgamma = bb.order(b).getFloat(); int axisi[] = new int[3]; for (int i = 0; i < 3; i++) { int axis = bb.order(b).getInt(); switch (axis) { case 1: axisi[0] = i; break; case 2: axisi[1] = i; break; case 3: axisi[2] = i; break; } } min = bb.order(b).getFloat(); max = bb.order(b).getFloat(); mean = bb.order(b).getFloat(); int sg = bb.order(b).getInt(); int nsymb = bb.order(b).getInt(); int skew = bb.order(b).getInt(); for (int i = 0; i < 12; i++) { bb.order(b).getFloat(); } for (int i = 0; i < 15; i++) { bb.order(b).getInt(); } byte word[] = new byte[2048]; bb.order(b).get(word, 0, 4); String mapstr = new String(word); // System.out.println("MAP?: " + mapstr); sd = bb.order(b).getFloat(); rmsd = bb.order(b).getFloat(); /* System.out.println("col: " + ori[0] + " " + ext[0] + " " + ni[0]); System.out.println("row: " + ori[1] + " " + ext[1] + " " + ni[1]); System.out.println("sec: " + ori[2] + " " + ext[2] + " " + ni[2]); System.out.println("order: " + axisi[0] + " " + axisi[1] + " " + axisi[2]); System.out.println("min: " + min + " max: " + max + " mean: " + mean); System.out.println("sd: " + sd + " rmsd: " + rmsd); System.out.println("sg: " + sg); System.out.println("a: " + cella + " b: " + cellb + " c: " + cellc + " alpha: " + cellalpha + " beta: " + cellbeta + " gamma: " + cellgamma); */ if (logger.isLoggable(Level.INFO)) { StringBuilder sb = new StringBuilder(); sb.append(String.format(" column origin: %d extent: %d\n", ori[0], ext[0])); sb.append(String.format(" row origin: %d extent: %d\n", ori[1], ext[1])); sb.append(String.format(" section origin: %d extent: %d\n", ori[2], ext[2])); sb.append(String.format(" axis order: %d %d %d\n", axisi[0], axisi[1], axisi[2])); sb.append(String.format(" number of X, Y, Z columns: %d %d %d\n", ni[0], ni[1], ni[2])); sb.append(String.format(" spacegroup #: %d (name: %s)\n", sg, SpaceGroup.spaceGroupNames[sg - 1])); sb.append(String.format(" cell: %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n", cella, cellb, cellc, cellalpha, cellbeta, cellgamma)); logger.info(sb.toString()); } int nlabel = bb.order(b).getInt(); // System.out.println("nsymb: " + nsymb + " nlabel: " + nlabel); for (int i = 0; i < 10; i++) { bb.order(b).get(word, 0, 80); mapstr = new String(word); // System.out.println("label " + i + " : " + mapstr); } if (nsymb > 0) { bb.rewind(); dis.read(bytes, 0, nsymb); for (int i = 0; i < nsymb / 80; i += 80) { bb.order(b).get(word, 0, 80); mapstr = new String(word); // System.out.println("symm: " + mapstr); } } bb.rewind(); dis.read(bytes, 0, 2048); refinementdata.data = new double[ext[0] * ext[1] * ext[2]]; int ijk[] = new int[3]; int index, x, y, z; refinementdata.ori[0] = ori[axisi[0]]; refinementdata.ori[1] = ori[axisi[1]]; refinementdata.ori[2] = ori[axisi[2]]; int nx = ext[axisi[0]]; int ny = ext[axisi[1]]; int nz = ext[axisi[2]]; refinementdata.ext[0] = nx; refinementdata.ext[1] = ny; refinementdata.ext[2] = nz; refinementdata.ni[0] = ni[0]; refinementdata.ni[1] = ni[1]; refinementdata.ni[2] = ni[2]; for (ijk[2] = 0; ijk[2] < ext[2]; ijk[2]++) { for (ijk[1] = 0; ijk[1] < ext[1]; ijk[1]++) { for (ijk[0] = 0; ijk[0] < ext[0]; ijk[0]++) { x = ijk[axisi[0]]; y = ijk[axisi[1]]; z = ijk[axisi[2]]; index = x + nx * (y + ny * z); refinementdata.data[index] = bb.order(b).getFloat(); if (!bb.hasRemaining()) { bb.rewind(); dis.read(bytes, 0, 2048); } } } } fis.close(); } catch (Exception e) { String message = "Fatal exception reading CCP4 map.\n"; logger.log(Level.SEVERE, message, e); System.exit(-1); } return true; }
From source file:com.rapidminer.operator.preprocessing.filter.InfiniteValueReplenishment.java
@Override public List<ParameterType> getParameterTypes() { List<ParameterType> types = super.getParameterTypes(); ParameterType type = new ParameterTypeCategory(PARAMETER_REPLENISHMENT_WHAT, "Decides if positive or negative infite values will be replaced.", WHAT_NAMES, 0, false); types.add(type);/*ww w. j a v a2 s. co m*/ type = new ParameterTypeDouble(PARAMETER_REPLENISHMENT_VALUE, "This value will be inserted instead of infinity.", Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, true); type.registerDependencyCondition( new EqualTypeCondition(this, PARAMETER_DEFAULT, getFunctionNames(), true, VALUE)); types.add(type); return types; }
From source file:org.jax.bham.test.PhylogenyAssociationTestGraphPanel.java
/** * Gets the index of the interval with the highest value that falls * under the given Java2D coordinates/*from w w w. j av a 2 s .c o m*/ * @param x * the Java2D X coordinate * @param y * the Java2D Y coordinate * @return * the interval index */ private int getMaximalIntervalIndex(int x, int y) { int clickIndex = -1; int[] chromosomes = this.getSelectedChromosomes(); if (chromosomes.length == 1) { List<PhylogenyTestResult> selectedPhyloAssociationTests = this.chromosomeResultsCache .get(chromosomes[0]); if (selectedPhyloAssociationTests != null) { RealValuedBasePairInterval[] selectedValuesList = selectedPhyloAssociationTests .toArray(new RealValuedBasePairInterval[selectedPhyloAssociationTests.size()]); Point2D clickedGraphPoint = JFreeChartUtil.java2DPointToGraphPoint(new Point(x, y), this.chartPanel); // exhaustive search for the maximum clicked index (this could // be a binary search, but this seems to perform OK for now) double graphX = clickedGraphPoint.getX(); int valueCount = selectedValuesList.length; double biggestClickedValue = Double.NEGATIVE_INFINITY; for (int i = 0; i < valueCount; i++) { RealValuedBasePairInterval currValue = selectedValuesList[i]; if (currValue.getStartInBasePairs() < graphX && currValue.getEndInBasePairs() > graphX && currValue.getRealValue() > biggestClickedValue) { biggestClickedValue = currValue.getRealValue(); clickIndex = i; } } // if we didn't click on anything grab the nearest item // (again this could and should be faster) if (clickIndex == -1 && valueCount >= 1) { clickIndex = 0; double nearestDistance = Math.min( Math.abs(selectedValuesList[0].getStartInBasePairs() - graphX), Math.abs(selectedValuesList[0].getEndInBasePairs() - graphX)); for (int i = 1; i < valueCount; i++) { BasePairInterval currValue = selectedValuesList[i]; double currDistance = Math.min(Math.abs(currValue.getStartInBasePairs() - graphX), Math.abs(currValue.getEndInBasePairs() - graphX)); if (currDistance < nearestDistance) { nearestDistance = currDistance; clickIndex = i; } } } } } return clickIndex; }
From source file:org.powertac.auctioneer.AuctionService.java
public boolean validateOrder(Order order) { if (order.getMWh().equals(Double.NaN) || order.getMWh().equals(Double.POSITIVE_INFINITY) || order.getMWh().equals(Double.NEGATIVE_INFINITY)) { log.warn("Order from " + order.getBroker().getUsername() + " with invalid quantity " + order.getMWh()); return false; }/*from w ww . j a v a 2 s. c o m*/ double minQuantity = Competition.currentCompetition().getMinimumOrderQuantity(); if (Math.abs(order.getMWh()) < minQuantity) { log.warn("Order from " + order.getBroker().getUsername() + " with quantity " + order.getMWh() + " < minimum quantity " + minQuantity); return false; } if (!timeslotRepo.isTimeslotEnabled(order.getTimeslot())) { OrderStatus status = new OrderStatus(order.getBroker(), order.getId()); brokerProxyService.sendMessage(order.getBroker(), status); log.warn("Order from " + order.getBroker().getUsername() + " for disabled timeslot " + order.getTimeslot()); return false; } return true; }
From source file:org.jfree.data.general.DefaultHeatMapDatasetTest.java
/** * Serialize an instance, restore it, and check for equality. *//*from w w w . ja v a 2 s .c o m*/ @Test public void testSerialization() { DefaultHeatMapDataset d1 = new DefaultHeatMapDataset(2, 3, -1.0, 4.0, -2.0, 5.0); d1.setZValue(0, 0, 10.0); d1.setZValue(0, 1, Double.NEGATIVE_INFINITY); d1.setZValue(0, 2, Double.POSITIVE_INFINITY); d1.setZValue(1, 0, Double.NaN); DefaultHeatMapDataset d2 = (DefaultHeatMapDataset) TestUtilities.serialised(d1); assertEquals(d1, d2); }
From source file:gedi.util.math.stat.distributions.GeneralizedExtremeValueDistribution.java
@Override public double getSupportLowerBound() { if (shape > 0) return location - scale / shape; return Double.NEGATIVE_INFINITY; }
From source file:com.rapidminer.gui.graphs.SimilarityGraphCreator.java
private void addEdges() { // remove old edges if available Iterator<String> e = edgeLabelMap.keySet().iterator(); while (e.hasNext()) { graph.removeEdge(e.next());/*from w w w. j av a 2s. com*/ } edgeLabelMap.clear(); boolean isDistance = measure.isDistance(); Attribute id = exampleSet.getAttributes().getId(); List<SortableEdge> sortableEdges = new LinkedList<SortableEdge>(); for (int i = 0; i < exampleSet.size(); i++) { Example example = exampleSet.getExample(i); for (int j = i + 1; j < exampleSet.size(); j++) { Example comExample = exampleSet.getExample(j); if (isDistance) { sortableEdges.add(new SortableEdge(example.getValueAsString(id), comExample.getValueAsString(id), null, measure.calculateDistance(example, comExample), SortableEdge.DIRECTION_INCREASE)); } else { sortableEdges.add(new SortableEdge(example.getValueAsString(id), comExample.getValueAsString(id), null, measure.calculateSimilarity(example, comExample), SortableEdge.DIRECTION_DECREASE)); } } } Collections.sort(sortableEdges); int numberOfEdges = distanceSlider.getValue(); int counter = 0; double minStrength = Double.POSITIVE_INFINITY; double maxStrength = Double.NEGATIVE_INFINITY; Map<String, Double> strengthMap = new HashMap<String, Double>(); for (SortableEdge sortableEdge : sortableEdges) { if (counter > numberOfEdges) { break; } String idString = edgeFactory.create(); graph.addEdge(idString, sortableEdge.getFirstVertex(), sortableEdge.getSecondVertex(), EdgeType.UNDIRECTED); edgeLabelMap.put(idString, Tools.formatIntegerIfPossible(sortableEdge.getEdgeValue())); double strength = sortableEdge.getEdgeValue(); minStrength = Math.min(minStrength, strength); maxStrength = Math.max(maxStrength, strength); strengthMap.put(idString, strength); counter++; } for (Entry<String, Double> entry : strengthMap.entrySet()) { edgeStrengthMap.put(entry.getKey(), (entry.getValue() - minStrength) / (maxStrength - minStrength)); } }
From source file:com.rapidminer.operator.preprocessing.NoiseOperator.java
@Override protected ExampleSetMetaData modifyMetaData(ExampleSetMetaData exampleSetMetaData) throws UndefinedParameterError { AttributeMetaData label = exampleSetMetaData.getLabelMetaData(); if (label != null) { if (label.isNumerical() && getParameterAsDouble(PARAMETER_LABEL_NOISE) > 0) { label.setValueSetRelation(SetRelation.SUPERSET); }//from w w w . j a va2s . co m } double defaultNoise = getParameterAsDouble(PARAMETER_DEFAULT_ATTRIBUTE_NOISE); if (defaultNoise > 0) { for (AttributeMetaData amd : exampleSetMetaData.getAllAttributes()) { if (!amd.isSpecial()) { if (amd.isNumerical()) { amd.setValueSetRelation(SetRelation.SUPERSET); } } } } int numberOfRandomAttributes = getParameterAsInt(PARAMETER_RANDOM_ATTRIBUTES); for (int i = 0; i < numberOfRandomAttributes; i++) { AttributeMetaData amd = new AttributeMetaData("random" + ((i == 0) ? "" : i + ""), Ontology.REAL); amd.setValueRange(new Range(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), SetRelation.SUBSET); exampleSetMetaData.addAttribute(amd); } return exampleSetMetaData; }
From source file:com.clust4j.algo.AbstractClusterer.java
final private Array2DRowRealMatrix initData(final RealMatrix data) { final int m = data.getRowDimension(), n = data.getColumnDimension(); final double[][] ref = new double[m][n]; final HashSet<Double> unique = new HashSet<>(); // Used to compute variance on the fly for summaries later... double[] sum = new double[n]; double[] sumSq = new double[n]; double[] maxes = VecUtils.rep(Double.NEGATIVE_INFINITY, n); double[] mins = VecUtils.rep(Double.POSITIVE_INFINITY, n); // This will store summaries for each column + a header ModelSummary summaries = new ModelSummary( new Object[] { "Feature #", "Variance", "Std. Dev", "Mean", "Max", "Min" }); /*/* w w w . jav a 2 s.co m*/ * Internally performs the copy */ double entry; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { entry = data.getEntry(i, j); if (Double.isNaN(entry)) { error(new NaNException("NaN in input data. " + "Select a matrix imputation method for " + "incomplete records")); } else { // copy the entry ref[i][j] = entry; unique.add(entry); // capture stats... sumSq[j] += entry * entry; sum[j] += entry; maxes[j] = FastMath.max(entry, maxes[j]); mins[j] = FastMath.min(entry, mins[j]); // if it's the last row, we can compute these: if (i == m - 1) { double var = (sumSq[j] - (sum[j] * sum[j]) / (double) m) / ((double) m - 1.0); if (var == 0) { warn("zero variance in feature " + j); } summaries.add(new Object[] { j, // feature num var, // var m < 2 ? Double.NaN : FastMath.sqrt(var), // std dev sum[j] / (double) m, // mean maxes[j], // max mins[j] // min }); } } } } // Log the summaries summaryLogger(formatter.format(summaries)); if (unique.size() == 1) this.singular_value = true; /* * Don't need to copy again, because already internally copied... */ return new Array2DRowRealMatrix(ref, false); }
From source file:master.utilities.PopulationFunctionFromJSON.java
@Override public double getIntensity(double t) { double tforward = convertTime(t); if (tforward > times[times.length - 1]) { if (popSizeEndInput.get() > 0.0) { return intensities[times.length - 1] + (times[times.length - 1] - tforward) / popSizeEndInput.get(); } else/*w w w. j a v a 2 s . c o m*/ return Double.NEGATIVE_INFINITY; } if (tforward < 0.0) { if (popSizeStartInput.get() > 0.0) { return intensities[0] + (-tforward) / popSizeStartInput.get(); } else return Double.POSITIVE_INFINITY; } int tidx = Arrays.binarySearch(times, tforward); if (tidx < 0) { tidx = -(tidx + 1); // index of first element greater than key // Integrate from different sides depending on location wrt peakIdx if (tidx <= peakIdx) { return (times[tidx] - tforward) / (popSizes[tidx - 1]) + intensities[tidx]; } else { return intensities[tidx - 1] - (tforward - times[tidx - 1]) / popSizes[tidx - 1]; } } else return intensities[tidx]; // Exact match can happen at boundaries. }