List of usage examples for java.lang Float MAX_VALUE
float MAX_VALUE
To view the source code for java.lang Float MAX_VALUE.
Click Source Link
From source file:org.broadinstitute.sting.utils.codecs.bcf2.BCF2EncoderDecoderUnitTest.java
@BeforeSuite public void before() { basicTypes.add(new BCF2TypedValue(1, BCF2Type.INT8)); basicTypes.add(new BCF2TypedValue(1000, BCF2Type.INT16)); basicTypes.add(new BCF2TypedValue(1000000, BCF2Type.INT32)); basicTypes.add(new BCF2TypedValue(1.2345e6, BCF2Type.FLOAT)); basicTypes.add(new BCF2TypedValue("A", BCF2Type.CHAR)); // small ints primitives.add(new BCF2TypedValue(0, BCF2Type.INT8)); primitives.add(new BCF2TypedValue(10, BCF2Type.INT8)); primitives.add(new BCF2TypedValue(-1, BCF2Type.INT8)); primitives.add(new BCF2TypedValue(100, BCF2Type.INT8)); primitives.add(new BCF2TypedValue(-100, BCF2Type.INT8)); primitives.add(new BCF2TypedValue(-127, BCF2Type.INT8)); // last value in range primitives.add(new BCF2TypedValue(127, BCF2Type.INT8)); // last value in range // medium ints primitives.add(new BCF2TypedValue(-1000, BCF2Type.INT16)); primitives.add(new BCF2TypedValue(1000, BCF2Type.INT16)); primitives.add(new BCF2TypedValue(-128, BCF2Type.INT16)); // first value in range primitives.add(new BCF2TypedValue(128, BCF2Type.INT16)); // first value in range primitives.add(new BCF2TypedValue(-32767, BCF2Type.INT16)); // last value in range primitives.add(new BCF2TypedValue(32767, BCF2Type.INT16)); // last value in range // larger ints primitives.add(new BCF2TypedValue(-32768, BCF2Type.INT32)); // first value in range primitives.add(new BCF2TypedValue(32768, BCF2Type.INT32)); // first value in range primitives.add(new BCF2TypedValue(-100000, BCF2Type.INT32)); primitives.add(new BCF2TypedValue(100000, BCF2Type.INT32)); primitives.add(new BCF2TypedValue(-2147483647, BCF2Type.INT32)); primitives.add(new BCF2TypedValue(2147483647, BCF2Type.INT32)); // floats//w ww . j a va 2 s. co m primitives.add(new BCF2TypedValue(0.0, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-0.0, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.0, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.0, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.1, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.1, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(5.0 / 3.0, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-5.0 / 3.0, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.23e3, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.23e6, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.23e9, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.23e12, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(1.23e15, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.23e3, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.23e6, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.23e9, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.23e12, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(-1.23e15, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(Float.MIN_VALUE, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(Float.MAX_VALUE, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(Double.NEGATIVE_INFINITY, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(Double.POSITIVE_INFINITY, BCF2Type.FLOAT)); primitives.add(new BCF2TypedValue(Double.NaN, BCF2Type.FLOAT)); // strings //primitives.add(new BCF2TypedValue("", BCFType.CHAR)); <- will be null (which is right) primitives.add(new BCF2TypedValue("S", BCF2Type.CHAR)); primitives.add(new BCF2TypedValue("S2", BCF2Type.CHAR)); primitives.add(new BCF2TypedValue("12345678910", BCF2Type.CHAR)); primitives.add(new BCF2TypedValue("ABCDEFGHIJKLMNOPQRSTUVWXYZ", BCF2Type.CHAR)); primitives.add(new BCF2TypedValue( "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", BCF2Type.CHAR)); // missing values for (BCF2Type type : BCF2Type.values()) { primitives.add(new BCF2TypedValue(null, type)); } forCombinations.add(new BCF2TypedValue(10, BCF2Type.INT8)); forCombinations.add(new BCF2TypedValue(100, BCF2Type.INT8)); forCombinations.add(new BCF2TypedValue(-100, BCF2Type.INT8)); forCombinations.add(new BCF2TypedValue(-128, BCF2Type.INT16)); // first value in range forCombinations.add(new BCF2TypedValue(128, BCF2Type.INT16)); // first value in range forCombinations.add(new BCF2TypedValue(-100000, BCF2Type.INT32)); forCombinations.add(new BCF2TypedValue(100000, BCF2Type.INT32)); forCombinations.add(new BCF2TypedValue(0.0, BCF2Type.FLOAT)); forCombinations.add(new BCF2TypedValue(1.23e6, BCF2Type.FLOAT)); forCombinations.add(new BCF2TypedValue(-1.23e6, BCF2Type.FLOAT)); forCombinations.add(new BCF2TypedValue("S", BCF2Type.CHAR)); forCombinations.add(new BCF2TypedValue("ABCDEFGHIJKLMNOPQRSTUVWXYZ", BCF2Type.CHAR)); forCombinations.add(new BCF2TypedValue( "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", BCF2Type.CHAR)); // missing values for (BCF2Type type : BCF2Type.values()) { forCombinations.add(new BCF2TypedValue(null, type)); } }
From source file:com.alibaba.simpleimage.util.ImageUtils.java
public static final float clampFloat(double in) { return (in > Float.MAX_VALUE ? Float.MAX_VALUE : (in >= FLOAT_MIN ? (float) in : FLOAT_MIN)); }
From source file:edu.snu.leader.hidden.builder.PersonalityDistributionAndDirIndividualBuilder.java
/** * Creates the preferred direction for an individual * * @return The preferred direction/*from w w w .j a v a2s. com*/ * @see edu.snu.leader.hidden.builder.PersonalityDistributionIndividualBuilder#createPreferredDir() */ @Override protected float createPreferredDir() { // Random number generator MersenneTwisterFast random = _simState.getRandom(); int tries = 0; float direction = Float.MAX_VALUE; while (((_minDirection > direction) || (_maxDirection < direction)) && (_maxTries > tries)) { direction = _directionMean + ((float) random.nextGaussian() * _directionStdDev); // Apply either a positive or negative delta float delta = _dirDelta; if (random.nextFloat() > _positiveDeltaProbability) { delta *= -1.0f; } direction += delta; tries++; } if (_maxDirection < direction) { direction = _maxDirection; } else if (_minDirection > direction) { direction = _minDirection; } _LOG.debug("Created direction [" + direction + "]"); return direction; }
From source file:org.stockchart.series.LinearSeries.java
@Override protected void preDraw() { fDistanceBetweenPoints = 0f; minY = Float.MAX_VALUE; fLinePath.reset(); fFillPath.reset(); fPoints.clear(); }
From source file:hivemall.knn.lsh.MinHashUDTF.java
private void computeAndForwardSignatures(List<FeatureValue> features, Object[] forwardObjs) throws HiveException { final PriorityQueue<Integer> minhashes = new PriorityQueue<Integer>(); // Compute N sets K minhash values for (int i = 0; i < num_hashes; i++) { float weightedMinHashValues = Float.MAX_VALUE; for (FeatureValue fv : features) { Object f = fv.getFeature(); int hashIndex = Math.abs(hashFuncs[i].hash(f)); float w = fv.getValueAsFloat(); float hashValue = calcWeightedHashValue(hashIndex, w); if (hashValue < weightedMinHashValues) { weightedMinHashValues = hashValue; minhashes.offer(hashIndex); }/*w w w. ja va2 s . c om*/ } forwardObjs[0] = getSignature(minhashes, num_keygroups); forward(forwardObjs); minhashes.clear(); } }
From source file:hivemall.knn.lsh.MinHashUDTF.java
/** * For a larger w, hash value tends to be smaller and tends to be selected as minhash. *//*from w w w .ja v a 2s. co m*/ private static float calcWeightedHashValue(final int hashIndex, final float w) throws HiveException { if (w < 0.f) { throw new HiveException("Non-negative value is not accepted for a feature weight"); } if (w == 0.f) { return Float.MAX_VALUE; } else { return hashIndex / w; } }
From source file:HelloUniverse.java
public void init() { // These are the string arguments given to the VirtualInputDevice // constructor. These are settable parameters. Look in the // VirtualInputDevice constructor for a complete list. String[] args = new String[10]; args[0] = "printvalues"; args[1] = "true"; args[2] = "yscreeninitloc"; args[3] = "50"; args[4] = null;//from w ww. j a v a 2s . c o m InputDevice device = new VirtualInputDevice(args); // now create the HelloUniverse Canvas setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); add("Center", c); // Create a simple scene and attach it to the virtual universe BranchGroup scene = createSceneGraph(); u = new SimpleUniverse(c); // The InputDevice must be initialized before registering it // with the PhysicalEnvironment object. device.initialize(); // Register the VirtualInputDevice with Java 3D u.getViewer().getPhysicalEnvironment().addInputDevice(device); TransformGroup viewTrans = u.getViewingPlatform().getViewPlatformTransform(); SensorBehavior s = new SensorBehavior(viewTrans, device.getSensor(0)); s.setSchedulingBounds(new BoundingSphere(new Point3d(0.0, 0.0, 0.0), Float.MAX_VALUE)); scene.addChild(s); u.addBranchGraph(scene); }
From source file:com.opensymphony.xwork2.conversion.impl.NumberConverterTest.java
public void testStringToFloatConversionPL() throws Exception { // given/* w w w.ja va 2s . c om*/ NumberConverter converter = new NumberConverter(); Map<String, Object> context = new HashMap<>(); context.put(ActionContext.LOCALE, new Locale("pl", "PL")); // when has max fraction digits Object value = converter.convertValue(context, null, null, null, "0," + StringUtils.repeat('0', 44) + "1401298464324817", Float.class); // then does not lose fraction digits assertEquals(Float.MIN_VALUE, value); // when has max integer digits value = converter.convertValue(context, null, null, null, "34028234663852886" + StringUtils.repeat('0', 22) + ",0", Float.class); // then does not lose integer digits assertEquals(Float.MAX_VALUE, value); }
From source file:com.taobao.weex.devtools.json.ObjectMapperTest.java
@Test public void testObjectToPrimitive() throws JSONException { ArrayOfPrimitivesContainer container = new ArrayOfPrimitivesContainer(); ArrayList<Object> primitives = container.primitives; primitives.add(Long.MIN_VALUE); primitives.add(Long.MAX_VALUE); primitives.add(Integer.MIN_VALUE); primitives.add(Integer.MAX_VALUE); primitives.add(Float.MIN_VALUE); primitives.add(Float.MAX_VALUE); primitives.add(Double.MIN_VALUE); primitives.add(Double.MAX_VALUE); String json = mObjectMapper.convertValue(container, JSONObject.class).toString(); JSONObject obj = new JSONObject(json); JSONArray array = obj.getJSONArray("primitives"); ArrayList<Object> actual = new ArrayList<>(); for (int i = 0, N = array.length(); i < N; i++) { actual.add(array.get(i));// ww w . j ava 2 s .c o m } assertEquals(primitives.toString(), actual.toString()); }
From source file:rrlFramework.RRLExperiment.java
/** * Compiles the performance files together into a single file, detailing the * average, min and max performances./*from w w w.ja v a2 s . c o m*/ * * @param runEnd * The last run. * @param byEpisode * If the performances are being combined by episode (in * intervals) or by regular CE interval. */ private long combineTempFiles(File performanceFile, int runEnd, long experimentStart) throws Exception { List<List<Float[]>> performances = new ArrayList<List<Float[]>>(); float min = Float.MAX_VALUE; int minRun = -1; float max = -Float.MAX_VALUE; int maxRun = -1; double[] episodeLengths = new double[runEnd]; double[] numSlots = new double[runEnd]; long averageRunTime = 0; File combinedPerfFile = performanceFile; if (Config.getInstance().getGeneratorFile() != null) { combinedPerfFile = new File(performanceFile.getAbsolutePath() + "greedy"); ProgramArgument.PERFORMANCE_EPISODE_GAP .setDoubleValue(ProgramArgument.PERFORMANCE_TESTING_SIZE.intValue() * ProgramArgument.POLICY_REPEATS.intValue()); } if (!combinedPerfFile.exists()) combinedPerfFile.createNewFile(); // For every performance file for (int i = 0; i < runEnd; i++) { File tempPerf = new File(Config.TEMP_FOLDER + "/" + performanceFile + i); if (!Performance.readRawPerformanceFile(tempPerf, true)) { System.err.println("Error reading performance file."); return 0; } List<Float[]> thisRunPerformances = new ArrayList<Float[]>(); performances.add(thisRunPerformances); // Run through the performances and place them in the matrix SortedMap<Integer, Float[]> runPerformances = Performance.getPerformanceArray(); averageRunTime += Performance.getRunTime(); Iterator<Integer> iter = runPerformances.keySet().iterator(); Integer current = iter.next(); Integer previous = null; int currentKeyframeEpisode = ProgramArgument.PERFORMANCE_EPISODE_GAP.intValue(); // Run through the performances, using linear interpolation to // get estimates of the performance at a given interval. do { // If the current segment is further along than the current // value, advance to the next value. while (currentKeyframeEpisode > current) { previous = current; if (iter.hasNext()) current = iter.next(); else break; } // If the keyframe isn't up to the first episode, just use // the current value Float[] episodePerformance = runPerformances.get(current); if (previous == null) { // Add to the previous value. thisRunPerformances.add(episodePerformance); } else { // Interpolate from the previous value to the current // one. Float[] interpolatedPerformance = new Float[episodePerformance.length]; if (previous == current) { interpolatedPerformance = episodePerformance; } else { Float[] prevPerformance = runPerformances.get(previous); for (int j = 0; j < episodePerformance.length; j++) { Float currPerf = episodePerformance[j]; Float prevPerf = prevPerformance[j]; // Adjust for null elites if (j == PerformanceDetails.ELITEMAX.ordinal() || j == PerformanceDetails.ELITEMEAN.ordinal()) { if (currPerf == null) currPerf = episodePerformance[PerformanceDetails.MEAN.ordinal()]; if (prevPerf == null) prevPerf = prevPerformance[PerformanceDetails.MEAN.ordinal()]; } if (currPerf == null || prevPerf == null) interpolatedPerformance[j] = null; else interpolatedPerformance[j] = (currPerf - prevPerf) * (1f * (currentKeyframeEpisode - previous) / (current - previous)) + prevPerf; } } // Add to the performances thisRunPerformances.add(interpolatedPerformance); } // To the next increment currentKeyframeEpisode += ProgramArgument.PERFORMANCE_EPISODE_GAP.intValue(); } while (currentKeyframeEpisode <= runPerformances.lastKey()); Float[] lastPerf = runPerformances.get(runPerformances.lastKey()); thisRunPerformances.add(lastPerf); System.out.println(runPerformances.get(runPerformances.lastKey())[PerformanceDetails.MEAN.ordinal()]); // Find min or max runs float runVal = runPerformances.get(runPerformances.lastKey())[PerformanceDetails.MEAN.ordinal()]; if (runVal < min) { min = runVal; minRun = i; } if (runVal > max) { max = runVal; maxRun = i; } episodeLengths[i] = runPerformances.lastKey(); } // Calculate the average and print out the stats FileWriter writer = new FileWriter(combinedPerfFile); BufferedWriter buf = new BufferedWriter(writer); Config.writeFileHeader(buf, Config.getInstance().getGoal()); buf.write( "Episode\tAverage\tSD\tMin\tMax\tElite-Average\tElite-SD\tNumSlots\tSlots-SD\tNumRules\tRules-SD\n"); boolean moreEpisodes = true; int index = 0; Mean mean = new Mean(); StandardDeviation sd = new StandardDeviation(); while (moreEpisodes) { moreEpisodes = false; // Compile the array of performances for the given index double[][] performanceArray = new double[PerformanceDetails.values().length][performances.size()]; double maxVal = 0; double minVal = 0; for (int run = 0; run < performances.size(); run++) { List<Float[]> runPerformanceList = performances.get(run); int thisIndex = Math.min(index, runPerformanceList.size() - 1); if (index < runPerformanceList.size() - 1) moreEpisodes = true; Float[] performanceDetails = runPerformanceList.get(thisIndex); for (int j = 0; j < performanceDetails.length; j++) { if (performanceDetails[j] != null) performanceArray[j][run] = performanceDetails[j]; } // Max and min if (run == minRun) minVal = performanceArray[PerformanceDetails.MEAN.ordinal()][run]; if (run == maxRun) maxVal = performanceArray[PerformanceDetails.MEAN.ordinal()][run]; } // Find the statistics int episodeNum = (index + 1) * ProgramArgument.PERFORMANCE_EPISODE_GAP.intValue(); buf.write(episodeNum + "\t" + mean.evaluate(performanceArray[PerformanceDetails.MEAN.ordinal()]) + "\t" + sd.evaluate(performanceArray[PerformanceDetails.MEAN.ordinal()]) + "\t" + minVal + "\t" + maxVal + "\t" + mean.evaluate(performanceArray[PerformanceDetails.ELITEMEAN.ordinal()]) + "\t" + sd.evaluate(performanceArray[PerformanceDetails.ELITEMEAN.ordinal()]) + "\t" + mean.evaluate(performanceArray[PerformanceDetails.NUMSLOTS.ordinal()]) + "\t" + sd.evaluate(performanceArray[PerformanceDetails.NUMSLOTS.ordinal()]) + "\t" + mean.evaluate(performanceArray[PerformanceDetails.NUMRULES.ordinal()]) + "\t" + sd.evaluate(performanceArray[PerformanceDetails.NUMRULES.ordinal()]) + "\n"); index++; } averageRunTime /= runEnd; buf.write("Average Run Time: " + toTimeFormat(averageRunTime) + "\n"); // Write the average episode length buf.write("\nAverage episode length: " + mean.evaluate(episodeLengths) + " +- " + sd.evaluate(episodeLengths) + "\n"); buf.write("\nAverage num slots: " + mean.evaluate(numSlots) + " +- " + sd.evaluate(numSlots) + "\n"); buf.close(); writer.close(); return averageRunTime; }