List of usage examples for java.lang Double MAX_VALUE
double MAX_VALUE
To view the source code for java.lang Double MAX_VALUE.
Click Source Link
From source file:msi.gama.util.path.GamaSpatialPath.java
protected double zVal(final GamaPoint point, final IShape edge) { double z = 0.0; final int nbSp = getPointsOf(edge).length; final Coordinate[] temp = new Coordinate[2]; final Point pointGeom = (Point) point.getInnerGeometry(); double distanceS = Double.MAX_VALUE; final GamaPoint[] edgePoints = GeometryUtils.getPointsOf(edge); for (int i = 0; i < nbSp - 1; i++) { temp[0] = edgePoints[i];//w ww.ja va2 s .c o m temp[1] = edgePoints[i + 1]; final LineString segment = GeometryUtils.GEOMETRY_FACTORY.createLineString(temp); final double distS = segment.distance(pointGeom); if (distS < distanceS) { distanceS = distS; final GamaPoint pt0 = new GamaPoint(temp[0]); final GamaPoint pt1 = new GamaPoint(temp[1]); z = pt0.z + (pt1.z - pt0.z) * point.distance(pt0) / segment.getLength(); } } return z; }
From source file:edu.umn.cs.spatialHadoop.core.GridRecordWriter.java
/** * Creates a new GridRecordWriter that will write all data files to the * given directory/*from w ww.j a va 2 s.c om*/ * @param outDir The directory in which all files will be stored * @param job The MapReduce job associated with this output * @param prefix A unique prefix to be associated with files of this writer * @param cells Cells to partition the file * @throws IOException */ public GridRecordWriter(Path outDir, JobConf job, String prefix, CellInfo[] cells) throws IOException { if (job != null) { this.sindex = job.get("sindex", "heap"); this.pack = PackedIndexes.contains(sindex); this.expand = ExpandedIndexes.contains(sindex); } this.prefix = prefix; this.fileSystem = outDir == null ? FileOutputFormat.getOutputPath(job).getFileSystem(job) : outDir.getFileSystem(job != null ? job : new Configuration()); this.outDir = outDir; this.jobConf = job; if (cells != null) { // Make sure cellIndex maps to array index. This is necessary for calls that // call directly write(int, Text) int highest_index = 0; for (CellInfo cell : cells) { if (cell.cellId > highest_index) highest_index = (int) cell.cellId; } // Create a master file that contains meta information about partitions masterFile = fileSystem.create(getMasterFilePath()); this.cells = new CellInfo[highest_index + 1]; for (CellInfo cell : cells) this.cells[(int) cell.cellId] = cell; // Prepare arrays that hold cells information intermediateCellStreams = new OutputStream[this.cells.length]; intermediateCellPath = new Path[this.cells.length]; cellsMbr = new Rectangle[this.cells.length]; // Initialize the counters for each cell intermediateCellRecordCount = new int[this.cells.length]; intermediateCellSize = new int[this.cells.length]; } else { intermediateCellStreams = new OutputStream[1]; intermediateCellPath = new Path[1]; cellsMbr = new Rectangle[1]; intermediateCellSize = new int[1]; intermediateCellRecordCount = new int[1]; } for (int i = 0; i < cellsMbr.length; i++) { cellsMbr[i] = new Rectangle(Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE); } this.blockSize = fileSystem.getDefaultBlockSize(outDir); closingThreads = new ArrayList<Thread>(); text = new Text(); }
From source file:ffx.potential.parsers.PDBFileMatcher.java
private double calculateRMSD(FileFilePair matchFile, Structure sourceStructure, StructurePairAligner aligner) throws StructureException { Structure matchStructure = matchFile.getStructure(); if (superpose) { double rmsd = Double.MAX_VALUE; aligner.align(matchStructure, matchStructure); AlternativeAlignment[] alignments = aligner.getAlignments(); for (AlternativeAlignment alignment : alignments) { double alignRMSD = alignment.getRmsd(); rmsd = alignRMSD < rmsd ? alignRMSD : rmsd; }//from w w w.j a va2 s .c om return rmsd; } Atom[] matchArray; Atom[] sourceArray; switch (atomsUsed) { case 1: String[] atomNames = { "CA", "N1", "N9" }; matchArray = StructureTools.getAtomArray(matchStructure, atomNames); sourceArray = StructureTools.getAtomArray(sourceStructure, atomNames); break; case 2: List<Atom> matchAtoms = new ArrayList<>(); List<Chain> matchChains = matchStructure.getChains(); for (Chain chain : matchChains) { List<Group> matchGroups = chain.getAtomGroups(GroupType.AMINOACID); matchGroups.addAll(chain.getAtomGroups(GroupType.NUCLEOTIDE)); for (Group group : matchGroups) { matchAtoms.addAll(group.getAtoms()); } } matchArray = matchAtoms.toArray(new Atom[matchAtoms.size()]); List<Atom> sourceAtoms = new ArrayList<>(); List<Chain> sourceChains = sourceStructure.getChains(); for (Chain chain : sourceChains) { List<Group> sourceGroups = chain.getAtomGroups(GroupType.AMINOACID); sourceGroups.addAll(chain.getAtomGroups(GroupType.NUCLEOTIDE)); for (Group group : sourceGroups) { sourceAtoms.addAll(group.getAtoms()); } } sourceArray = sourceAtoms.toArray(new Atom[sourceAtoms.size()]); break; case 3: matchAtoms = new ArrayList<>(); matchChains = matchStructure.getChains(); for (Chain chain : matchChains) { List<Group> matchGroups = chain.getAtomGroups(); for (Group group : matchGroups) { if (!group.isWater()) { matchAtoms.addAll(group.getAtoms()); } } } matchArray = matchAtoms.toArray(new Atom[matchAtoms.size()]); sourceAtoms = new ArrayList<>(); sourceChains = sourceStructure.getChains(); for (Chain chain : sourceChains) { List<Group> matchGroups = chain.getAtomGroups(); for (Group group : matchGroups) { if (!group.isWater()) { sourceAtoms.addAll(group.getAtoms()); } } } sourceArray = sourceAtoms.toArray(new Atom[sourceAtoms.size()]); break; case 4: matchArray = StructureTools.getAllAtomArray(matchStructure); sourceArray = StructureTools.getAllAtomArray(sourceStructure); break; default: throw new IllegalArgumentException( "atomsUsed is not 1-4: this has not been properly checked at an earlier stage."); } // Returns simpleRMSD(matchArray, sourceArray) below old code. /*List<Atom> matchAtoms = new ArrayList<>(); Structure matchStructure = matchFile.getStructure(); List<Chain> matchChains = matchStructure.getChains(); if (atomsUsed == 4) { matchAtoms = StructureTools.getAllAtomArray(matchStructure); } for (Chain chain : matchChains) { List<Group> matchGroups = chain.getSeqResGroups(); for (Group group : matchGroups) { String groupType = group.getType(); if (groupType.equalsIgnoreCase("HETATOM")) { if (atomsUsed < 3) { continue; } else if (atomsUsed < 4 && group.isWater()) { continue; } } if (atomsUsed != 1) { matchAtoms.addAll(group.getAtoms()); } else { try { matchAtoms.add(getReferenceAtom(group)); } catch (StructureException ex) { String refAtomType = (groupType.equalsIgnoreCase("AminoAcid") ? "CA" : "N1/9"); // refAtomType should be binary between amino acid and nucleic acid, as HETATOM is eliminated. logger.info(String.format(" Reference atom %s could not be found for group %s", refAtomType, group.toString())); } } } } Atom[] match = new Atom[matchAtoms.size()]; matchAtoms.toArray(match); matchAtoms.clear(); List<Atom> sourceAtoms = new ArrayList<>(); List<Chain> sourceChains = sourceStructure.getChains(); for (Chain chain : sourceChains) { List<Group> sourceGroups = chain.getSeqResGroups(); for (Group group : sourceGroups) { String groupType = group.getType(); if (groupType.equalsIgnoreCase("HETATOM")) { if (atomsUsed < 3) { continue; } else if (atomsUsed < 4 && group.isWater()) { continue; } } if (atomsUsed != 1) { sourceAtoms.addAll(group.getAtoms()); } else { try { sourceAtoms.add(getReferenceAtom(group)); } catch (StructureException ex) { logger.info(String.format(" Reference atom could not be found for group %s", group.toString())); } } } } Atom[] sourceArray = new Atom[sourceAtoms.size()]; sourceAtoms.toArray(sourceArray); sourceAtoms.clear();*/ return simpleRMSD(sourceArray, matchArray); }
From source file:distributions.Beta.java
public double findmin(int i) { double min = Double.MAX_VALUE; for (double[] data1 : data) { if (min > data1[i]) { min = data1[i];/* ww w . j a v a 2 s .c om*/ } } return min; }
From source file:br.fapesp.myutils.MyUtils.java
private static double internalHausdorffAlg(double[][] x, double[][] y) { double h = 0; double dij, shortest; for (int i = 0; i < x.length; i++) { shortest = Double.MAX_VALUE; for (int j = 0; j < y.length; j++) { dij = squaredEuclideanDistance(x[i], y[j]); if (dij < shortest) shortest = dij;/*from w ww.j ava2s . co m*/ } if (shortest > h) h = shortest; } return Math.sqrt(h); }
From source file:ch.aonyx.broker.ib.api.order.PlaceOrderRequest.java
private void checkScaleOrdersSupport() { final double scalePriceIncrement = order.getScalePriceIncrement(); if ((scalePriceIncrement > 0) && (scalePriceIncrement != Double.MAX_VALUE)) { if ((order.getScalePriceAdjustValue() != Double.MAX_VALUE) || (order.getScalePriceAdjustInterval() != Integer.MAX_VALUE) || (order.getScaleProfitOffset() != Double.MAX_VALUE) || order.isScaleAutoReset() || (order.getScaleInitPosition() != Integer.MAX_VALUE) || (order.getScaleInitFillQuantity() != Integer.MAX_VALUE) || order.isScaleRandomPercent()) { if (!Feature.SCALE_ORDERS.isSupportedByVersion(getServerCurrentVersion())) { throw new RequestException(ClientMessageCode.UPDATE_TWS, "It does not support Scale order parameters: PriceAdjustValue, PriceAdjustInterval, " + "ProfitOffset, AutoReset, InitPosition, InitFillQty and RandomPercent.", this); }/*w ww. j a v a 2 s . c o m*/ } } }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java
@Test public void testConfigurationPropertiesWithDoubleList() { ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); Double doubleValue = config.doubleList.get(0); assertEquals(Double.class, doubleValue.getClass()); assertEquals(Double.MAX_VALUE, doubleValue.doubleValue(), 1); assertEquals(3, config.doubleList.size()); }
From source file:edu.stanford.cfuller.colocalization3d.correction.PositionCorrector.java
/** * Creates a correction from a set of objects whose positions should be the same in each channel. * * @param imageObjects A Vector containing all the ImageObjects to be used for the correction * or in the order it appears in a multiwavelength image file. * @return A Correction object that can be used to correct the positions of other objects based upon the standards provided. *//*from ww w.ja v a 2s .co m*/ public Correction getCorrection(java.util.List<ImageObject> imageObjects) { int referenceChannel = this.parameters.getIntValueForKey(REF_CH_PARAM); int channelToCorrect = this.parameters.getIntValueForKey(CORR_CH_PARAM); if (!this.parameters.hasKeyAndTrue(DET_CORR_PARAM)) { try { return Correction.readFromDisk(FileUtils.getCorrectionFilename(this.parameters)); } catch (java.io.IOException e) { java.util.logging.Logger .getLogger(edu.stanford.cfuller.colocalization3d.Colocalization3DMain.LOGGER_NAME) .severe("Exception encountered while reading correction from disk: "); e.printStackTrace(); } catch (ClassNotFoundException e) { java.util.logging.Logger .getLogger(edu.stanford.cfuller.colocalization3d.Colocalization3DMain.LOGGER_NAME) .severe("Exception encountered while reading correction from disk: "); e.printStackTrace(); } return null; } int numberOfPointsToFit = this.parameters.getIntValueForKey(NUM_POINT_PARAM); RealMatrix correctionX = new Array2DRowRealMatrix(imageObjects.size(), numberOfCorrectionParameters); RealMatrix correctionY = new Array2DRowRealMatrix(imageObjects.size(), numberOfCorrectionParameters); RealMatrix correctionZ = new Array2DRowRealMatrix(imageObjects.size(), numberOfCorrectionParameters); RealVector distanceCutoffs = new ArrayRealVector(imageObjects.size(), 0.0); RealVector ones = new ArrayRealVector(numberOfPointsToFit, 1.0); RealVector distancesToObjects = new ArrayRealVector(imageObjects.size(), 0.0); RealMatrix allCorrectionParametersMatrix = new Array2DRowRealMatrix(numberOfPointsToFit, numberOfCorrectionParameters); for (int i = 0; i < imageObjects.size(); i++) { RealVector ithPos = imageObjects.get(i).getPositionForChannel(referenceChannel); for (int j = 0; j < imageObjects.size(); j++) { double d = imageObjects.get(j).getPositionForChannel(referenceChannel).subtract(ithPos).getNorm(); distancesToObjects.setEntry(j, d); } //the sorting becomes a bottleneck once the number of points gets large //reverse comparator so we can use the priority queue and get the max element at the head Comparator<Double> cdReverse = new Comparator<Double>() { public int compare(Double o1, Double o2) { if (o1.equals(o2)) return 0; if (o1 > o2) return -1; return 1; } }; PriorityQueue<Double> pq = new PriorityQueue<Double>(numberOfPointsToFit + 2, cdReverse); double maxElement = Double.MAX_VALUE; for (int p = 0; p < numberOfPointsToFit + 1; p++) { pq.add(distancesToObjects.getEntry(p)); } maxElement = pq.peek(); for (int p = numberOfPointsToFit + 1; p < distancesToObjects.getDimension(); p++) { double value = distancesToObjects.getEntry(p); if (value < maxElement) { pq.poll(); pq.add(value); maxElement = pq.peek(); } } double firstExclude = pq.poll(); double lastDist = pq.poll(); double distanceCutoff = (lastDist + firstExclude) / 2.0; distanceCutoffs.setEntry(i, distanceCutoff); RealVector xPositionsToFit = new ArrayRealVector(numberOfPointsToFit, 0.0); RealVector yPositionsToFit = new ArrayRealVector(numberOfPointsToFit, 0.0); RealVector zPositionsToFit = new ArrayRealVector(numberOfPointsToFit, 0.0); RealMatrix differencesToFit = new Array2DRowRealMatrix(numberOfPointsToFit, imageObjects.get(0).getPositionForChannel(referenceChannel).getDimension()); int toFitCounter = 0; for (int j = 0; j < imageObjects.size(); j++) { if (distancesToObjects.getEntry(j) < distanceCutoff) { xPositionsToFit.setEntry(toFitCounter, imageObjects.get(j).getPositionForChannel(referenceChannel).getEntry(0)); yPositionsToFit.setEntry(toFitCounter, imageObjects.get(j).getPositionForChannel(referenceChannel).getEntry(1)); zPositionsToFit.setEntry(toFitCounter, imageObjects.get(j).getPositionForChannel(referenceChannel).getEntry(2)); differencesToFit.setRowVector(toFitCounter, imageObjects.get(j) .getVectorDifferenceBetweenChannels(referenceChannel, channelToCorrect)); toFitCounter++; } } RealVector x = xPositionsToFit.mapSubtractToSelf(ithPos.getEntry(0)); RealVector y = yPositionsToFit.mapSubtractToSelf(ithPos.getEntry(1)); allCorrectionParametersMatrix.setColumnVector(0, ones); allCorrectionParametersMatrix.setColumnVector(1, x); allCorrectionParametersMatrix.setColumnVector(2, y); allCorrectionParametersMatrix.setColumnVector(3, x.map(new Power(2))); allCorrectionParametersMatrix.setColumnVector(4, y.map(new Power(2))); allCorrectionParametersMatrix.setColumnVector(5, x.ebeMultiply(y)); DecompositionSolver solver = (new QRDecomposition(allCorrectionParametersMatrix)).getSolver(); RealVector cX = solver.solve(differencesToFit.getColumnVector(0)); RealVector cY = solver.solve(differencesToFit.getColumnVector(1)); RealVector cZ = solver.solve(differencesToFit.getColumnVector(2)); correctionX.setRowVector(i, cX); correctionY.setRowVector(i, cY); correctionZ.setRowVector(i, cZ); } Correction c = new Correction(correctionX, correctionY, correctionZ, distanceCutoffs, imageObjects, referenceChannel, channelToCorrect); return c; }
From source file:fs.MainWindow.java
public MainWindow() { initComponents();/*from w w w . j av a 2s .co m*/ //inicializacao do modelo numerido usado na definicao dos parametros. jS_QuantizationValue.setModel(new SpinnerNumberModel(2, 1, Integer.MAX_VALUE, 1)); jS_MaxResultListSE.setModel(new SpinnerNumberModel(3, 1, Integer.MAX_VALUE, 1)); jS_MaxSetSizeSE.setModel(new SpinnerNumberModel(3, 1, Integer.MAX_VALUE, 1)); jS_MaxSetSizeCV.setModel(new SpinnerNumberModel(3, 1, Integer.MAX_VALUE, 1)); jS_NrExecutionsCV.setModel(new SpinnerNumberModel(10, 1, Integer.MAX_VALUE, 1)); jS_ThresholdEntropy.setModel(new SpinnerNumberModel(0.3, 0, 1, 0.05)); jS_QEntropyCV.setModel(new SpinnerNumberModel(1d, 0.1d, Double.MAX_VALUE, 0.1d)); jS_AlphaCV.setModel(new SpinnerNumberModel(1d, 0d, Double.MAX_VALUE, 0.1d)); jS_QEntropySE.setModel(new SpinnerNumberModel(1d, 0.1d, Double.MAX_VALUE, 0.1d)); jS_AlphaSE.setModel(new SpinnerNumberModel(1d, 0d, Double.MAX_VALUE, 0.1d)); //captura teclas pressionadas, se for F1 aciona o JFrame Help. KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F1 && e.getID() == KeyEvent.KEY_PRESSED) { if (help != null) { help.setVisible(false); help.dispose(); } if (jTabbedPane1.getSelectedIndex() == 0) { help = new HelpInput(); } else if (jTabbedPane1.getSelectedIndex() == 1) { help = new HelpQuantization(); } else if (jTabbedPane1.getSelectedIndex() == 2) { help = new HelpFS(); } else if (jTabbedPane1.getSelectedIndex() == 3) { help = new HelpCV(); } help.setVisible(true); return true; } return false; } }); }
From source file:emlab.role.market.SelectLongTermElectricityContractsRole.java
public double determineVolumeForContractType(LongTermContractType type, Zone zone) { // calculate minimum load of the segments in this contract type double minimumLoadInSegmentsOfContractType = Double.MAX_VALUE; for (Segment segment : type.getSegments()) { double loadOfSegment = reps.marketRepository .findSegmentLoadForElectricitySpotMarketForZone(zone, segment).getBaseLoad() * reps.marketRepository.findElectricitySpotMarketForZone(zone).getDemandGrowthTrend() .getValue(getCurrentTick()); if (loadOfSegment < minimumLoadInSegmentsOfContractType) { minimumLoadInSegmentsOfContractType = loadOfSegment; }/* ww w. j a v a 2 s. co m*/ } logger.info("For ltc type {}, the lowest load of the segments covered is {}", type, minimumLoadInSegmentsOfContractType); return minimumLoadInSegmentsOfContractType; }