List of usage examples for java.lang Float NEGATIVE_INFINITY
float NEGATIVE_INFINITY
To view the source code for java.lang Float NEGATIVE_INFINITY.
Click Source Link
From source file:au.org.ala.delta.intkey.ui.CharacterImageDialog.java
public FloatRange getInputRealValues() { FloatRange retRange = null;//from w w w . j av a 2s .co m String inputText = _multipleImageViewer.getVisibleViewer().getInputText(); if (!StringUtils.isEmpty(inputText)) { // Use value supplied in input field retRange = ParsingUtils.parseRealCharacterValue(inputText); } else { // Use values for selected value fields if (!_selectedValues.isEmpty()) { Set<Float> boundsSet = new HashSet<Float>(); for (Pair<String, String> selectedValue : _selectedValues) { float minVal = Float.parseFloat(selectedValue.getFirst()); boundsSet.add(minVal); // Second value in the pair will be null if the value field // represents a // single real value rather than a range. if (selectedValue.getSecond() != null) { float maxVal = Float.parseFloat(selectedValue.getSecond()); boundsSet.add(maxVal); } } float overallMin = Collections.min(boundsSet); float overallMax = Collections.max(boundsSet); retRange = new FloatRange(overallMin, overallMax); } } // if the range is still null, return a float range with negative // infinity. This represents "no values selected". if (retRange == null) { retRange = new FloatRange(Float.NEGATIVE_INFINITY); } return retRange; }
From source file:sourcefiles.RunPageRankBasic.java
private float phase1(int i, int j, String basePath, int numNodes) throws Exception { Job job = Job.getInstance(getConf()); job.setJobName("PageRank:Basic:iteration" + j + ":Phase1"); job.setJarByClass(RunPageRankBasic.class); String in = basePath + "/iter" + formatter.format(i); String out = basePath + "/iter" + formatter.format(j) + "t"; String outm = out + "-mass"; // We need to actually count the number of part files to get the number of partitions (because // the directory might contain _log). int numPartitions = 0; for (FileStatus s : FileSystem.get(getConf()).listStatus(new Path(in))) { if (s.getPath().getName().contains("part-")) numPartitions++;/*from www .j a v a 2s .c o m*/ } LOG.info("PageRank: iteration " + j + ": Phase1"); LOG.info(" - input: " + in); LOG.info(" - output: " + out); LOG.info(" - nodeCnt: " + numNodes); LOG.info("computed number of partitions: " + numPartitions); int numReduceTasks = numPartitions; job.getConfiguration().setInt("NodeCount", numNodes); job.getConfiguration().setBoolean("mapred.map.tasks.speculative.execution", false); job.getConfiguration().setBoolean("mapred.reduce.tasks.speculative.execution", false); //job.getConfiguration().set("mapred.child.java.opts", "-Xmx2048m"); job.getConfiguration().set("PageRankMassPath", outm); job.setNumReduceTasks(numReduceTasks); FileInputFormat.setInputPaths(job, new Path(in)); FileOutputFormat.setOutputPath(job, new Path(out)); job.setInputFormatClass(NonSplitableSequenceFileInputFormat.class); job.setOutputFormatClass(SequenceFileOutputFormat.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(PageRankNode.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(PageRankNode.class); job.setMapperClass(MapClass.class); job.setCombinerClass(CombineClass.class); job.setReducerClass(ReduceClass.class); FileSystem.get(getConf()).delete(new Path(out), true); FileSystem.get(getConf()).delete(new Path(outm), true); long startTime = System.currentTimeMillis(); job.waitForCompletion(true); System.out.println("Job Finished in " + (System.currentTimeMillis() - startTime) / 1000.0 + " seconds"); float mass = Float.NEGATIVE_INFINITY; FileSystem fs = FileSystem.get(getConf()); for (FileStatus f : fs.listStatus(new Path(outm))) { FSDataInputStream fin = fs.open(f.getPath()); mass = sumLogProbs(mass, fin.readFloat()); fin.close(); } return mass; }
From source file:gdsc.smlm.ij.plugins.DensityImage.java
/** * Draw an image of the density for each localisation. Optionally filter results below a threshold. * /*from ww w . j a v a2s . c o m*/ * @param results * @param density * @param scoreCalculator * @return */ private int plotResults(MemoryPeakResults results, float[] density, ScoreCalculator scoreCalculator) { // Filter results using 5x higher than average density of the sample in a 150nm radius: // Annibale, et al (2011). Identification of clustering artifacts in photoactivated localization microscopy. // Nature Methods, 8, pp527-528 MemoryPeakResults newResults = null; float densityThreshold = Float.NEGATIVE_INFINITY; // No filtering if (filterLocalisations) { densityThreshold = scoreCalculator.getThreshold(); newResults = new MemoryPeakResults(); newResults.copySettings(results); newResults.setName(results.getName() + " Density Filter"); } // Draw an image - Use error so that a floating point value can be used on a single pixel List<PeakResult> peakResults = results.getResults(); IJImagePeakResults image = ImagePeakResultsFactory.createPeakResultsImage(ResultsImage.ERROR, false, false, results.getName() + " Density", results.getBounds(), results.getNmPerPixel(), results.getGain(), imageScale, 0, (cumulativeImage) ? ResultsMode.ADD : ResultsMode.MAX); image.setDisplayFlags(image.getDisplayFlags() | IJImagePeakResults.DISPLAY_NEGATIVES); image.setLutName("grays"); image.begin(); for (int i = 0; i < density.length; i++) { if (density[i] < densityThreshold) continue; PeakResult r = peakResults.get(i); image.add(0, 0, 0, 0, density[i], 0, r.params, null); if (newResults != null) newResults.add(r); } image.end(); // Add to memory if (newResults != null && newResults.size() > 0) MemoryPeakResults.addResults(newResults); return image.size(); }
From source file:gov.nih.nci.caarray.util.CaArrayUtils.java
private static String toXmlString(float value) { if (Float.isNaN(value)) { return "NaN"; } else if (value == Float.POSITIVE_INFINITY) { return "INF"; } else if (value == Float.NEGATIVE_INFINITY) { return "-INF"; } else {/*from ww w . java 2 s . com*/ return Float.toString(value); } }
From source file:byps.test.TestSerializePrimitiveTypes.java
@Test public void testSerializeFloat() throws BException { log.info("testSerializeFloat("); internalTestSerializeFloat(Float.NaN); internalTestSerializeFloat(Float.NEGATIVE_INFINITY); internalTestSerializeFloat(Float.POSITIVE_INFINITY); internalTestSerializeFloat(0.0f);// w w w .j av a2 s .c om internalTestSerializeFloat(1.0f); internalTestSerializeFloat(-1.0f); internalTestSerializeFloat(1.0e7f); internalTestSerializeFloat(1.0e-7f); internalTestSerializeFloat(2.0E5f); log.info(")testSerializeFloat"); }
From source file:edu.harvard.iq.dataverse.dataaccess.TabularSubsetGenerator.java
public static Float[] subsetFloatVector(InputStream in, int column, int numCases) { Float[] retVector = new Float[numCases]; Scanner scanner = new Scanner(in); scanner.useDelimiter("\\n"); for (int caseIndex = 0; caseIndex < numCases; caseIndex++) { if (scanner.hasNext()) { String[] line = (scanner.next()).split("\t", -1); // Verified: new Float("nan") works correctly, // resulting in Float.NaN; // Float("[+-]Inf") doesn't work however; // (the constructor appears to be expecting it // to be spelled as "Infinity", "-Infinity", etc. if ("inf".equalsIgnoreCase(line[column]) || "+inf".equalsIgnoreCase(line[column])) { retVector[caseIndex] = java.lang.Float.POSITIVE_INFINITY; } else if ("-inf".equalsIgnoreCase(line[column])) { retVector[caseIndex] = java.lang.Float.NEGATIVE_INFINITY; } else if (line[column] == null || line[column].equals("")) { // missing value: retVector[caseIndex] = null; } else { try { retVector[caseIndex] = new Float(line[column]); } catch (NumberFormatException ex) { retVector[caseIndex] = null; // missing value }//from ww w .j av a 2 s.c o m } } else { scanner.close(); throw new RuntimeException("Tab file has fewer rows than the stored number of cases!"); } } int tailIndex = numCases; while (scanner.hasNext()) { String nextLine = scanner.next(); if (!"".equals(nextLine)) { scanner.close(); throw new RuntimeException( "Column " + column + ": tab file has more nonempty rows than the stored number of cases (" + numCases + ")! current index: " + tailIndex + ", line: " + nextLine); } tailIndex++; } scanner.close(); return retVector; }
From source file:gov.nih.nci.caarray.util.CaArrayUtils.java
private static float xmlStringToFloat(String value) { if ("NaN".equals(value)) { return Float.NaN; } else if ("INF".equals(value)) { return Float.POSITIVE_INFINITY; } else if ("-INF".equals(value)) { return Float.NEGATIVE_INFINITY; } else {/*from w w w.ja v a 2s. c om*/ return Float.parseFloat(value); } }
From source file:nl.uva.illc.dataselection.InvitationModel.java
public static float calculateProb(final int ssent[], final int tsent[], final TranslationTable ttable) { float prob = 0; for (int t = 1; t < tsent.length; t++) { int tw = tsent[t]; float sum = Float.NEGATIVE_INFINITY; for (int s = 0; s < ssent.length; s++) { int sw = ssent[s]; sum = logAdd(sum, ttable.get(tw, sw, p)); }//from ww w. j av a 2 s.co m prob += sum; } return prob - (float) Math.log(Math.pow(ssent.length, tsent.length - 1)); }
From source file:net.myrrix.online.ServerRecommender.java
private List<RecommendedItem> multithreadedTopN(final float[][] userFeatures, final FastIDSet userKnownItemIDs, final FastIDSet userTagIDs, final IDRescorer rescorer, final int howMany, CandidateFilter candidateFilter) { Collection<Iterator<FastByIDMap.MapEntry<float[]>>> candidateIterators = candidateFilter .getCandidateIterator(userFeatures); int numIterators = candidateIterators.size(); int parallelism = FastMath.min(numCores, numIterators); final Queue<MutableRecommendedItem> topN = TopN.initialQueue(howMany); if (parallelism > 1) { ExecutorService executorService = executor.get(); final Iterator<Iterator<FastByIDMap.MapEntry<float[]>>> candidateIteratorsIterator = candidateIterators .iterator();/*from w w w. j a va 2 s . c o m*/ Collection<Future<?>> futures = Lists.newArrayList(); for (int i = 0; i < numCores; i++) { futures.add(executorService.submit(new Callable<Void>() { @Override public Void call() { float[] queueLeastValue = { Float.NEGATIVE_INFINITY }; while (true) { Iterator<FastByIDMap.MapEntry<float[]>> candidateIterator; synchronized (candidateIteratorsIterator) { if (!candidateIteratorsIterator.hasNext()) { break; } candidateIterator = candidateIteratorsIterator.next(); } Iterator<RecommendedItem> partialIterator = new RecommendIterator(userFeatures, candidateIterator, userKnownItemIDs, userTagIDs, rescorer); TopN.selectTopNIntoQueueMultithreaded(topN, queueLeastValue, partialIterator, howMany); } return null; } })); } for (Future<?> future : futures) { try { future.get(); } catch (InterruptedException e) { throw new IllegalStateException(e); } catch (ExecutionException e) { throw new IllegalStateException(e.getCause()); } } } else { for (Iterator<FastByIDMap.MapEntry<float[]>> candidateIterator : candidateIterators) { Iterator<RecommendedItem> partialIterator = new RecommendIterator(userFeatures, candidateIterator, userKnownItemIDs, userTagIDs, rescorer); TopN.selectTopNIntoQueue(topN, partialIterator, howMany); } } return TopN.selectTopNFromQueue(topN, howMany); }
From source file:it.uniroma2.sag.kelp.learningalgorithm.classification.passiveaggressive.BudgetedPassiveAggressiveClassification.java
private void computeNearestNeighbors() { if (this.nearestNeighbors == null) { this.nearestNeighbors = new int[budget]; this.nearestNeighborsSimilarity = new float[budget]; }/*from w w w . j a v a 2 s .c om*/ int svIndex = 0; for (SupportVector sv : this.getPredictionFunction().getModel().getSupportVectors()) { int nn = -1; float maxSimilarity = Float.NEGATIVE_INFINITY; int svIndex2 = 0; for (SupportVector sv2 : this.getPredictionFunction().getModel().getSupportVectors()) { if (sv != sv2) { float currentSimilarity = kernel.innerProduct(sv.getInstance(), sv2.getInstance()); if (currentSimilarity > maxSimilarity) { maxSimilarity = currentSimilarity; nn = svIndex2; } } svIndex2++; } this.nearestNeighbors[svIndex] = nn; this.nearestNeighborsSimilarity[svIndex] = maxSimilarity; } this.areNnComputed = true; }