List of usage examples for java.lang Float MIN_VALUE
float MIN_VALUE
To view the source code for java.lang Float MIN_VALUE.
Click Source Link
From source file:Main.java
public static void getTop(float[] array, ArrayList<Integer> rankList, ArrayList<Float> rankProbs, int i) { // clear/*from ww w . j a v a 2s . c o m*/ rankList.clear(); rankProbs.clear(); // int index = 0; int count = 0; HashSet<Integer> scanned = new HashSet<Integer>(); float max = Float.MIN_VALUE; for (int m = 0; m < i && m < array.length; m++) { boolean flag = false; max = Float.MIN_VALUE; for (int no = 0; no < array.length; no++) { if (array[no] >= max && !scanned.contains(no)) { index = no; max = array[no]; flag = true; } } if (flag) { // found value scanned.add(index); rankList.add(index); rankProbs.add(array[index]); } //System.out.println(m + "\t" + index); } }
From source file:Main.java
public static void getTop(float[] array, ArrayList<Integer> rankList, ArrayList<Float> rankProbs, int i) { // clear//from ww w .j a v a 2 s .c om rankList.clear(); rankProbs.clear(); // int index = 0; HashSet<Integer> scanned = new HashSet<Integer>(); float max = Float.MIN_VALUE; for (int m = 0; m < i && m < array.length; m++) { boolean flag = false; max = Float.MIN_VALUE; for (int no = 0; no < array.length; no++) { if (array[no] >= max && !scanned.contains(no)) { index = no; max = array[no]; flag = true; } } if (flag) { // found value scanned.add(index); rankList.add(index); rankProbs.add(array[index]); } // System.out.println(m + "\t" + index); } }
From source file:pl.edu.icm.coansys.disambiguation.clustering.strategies.TestHelper.java
public static float[][] readResourceToFloatArray(String path) throws IOException { InputStream is = CompleteLinkageHACStrategy_StateOfTheArtTest.class.getClassLoader() .getResourceAsStream(path);//from ww w . j a v a2 s . co m String indata = IOUtils.toString(is); float maxFloat = Float.MIN_VALUE; String[] testLines = indata.split("\n"); for (String s : testLines) { String[] numbers = s.split(","); for (String n : numbers) { float f = Float.parseFloat(n); maxFloat = Math.max(maxFloat, f); } } // System.out.println("============ "+maxFloat); String[] lines = indata.split("\n"); float[][] in = new float[lines.length][]; for (int i = 0; i < lines.length; i++) { String line = lines[i]; String[] values = line.split(","); float[] distLine = new float[i]; for (int j = 0; j < i; j++) { distLine[j] = /* maxFloat- */Float.parseFloat(values[j]); } in[i] = distLine; } return in; }
From source file:qtiscoringengine.AreaMapping.java
static AreaMapping fromXML(Element node, XmlNamespaceManager nsmgr, ValidationLog log) throws Exception { if (node == null) return null; String defVal = node.getAttributeValue("defaultValue"); // required! String upper = node.getAttributeValue("upperBound"); String lower = node.getAttributeValue("lowerBound"); _Ref<Float> fDefault = new _Ref<>(Float.MIN_VALUE); _Ref<Float> fUpper = new _Ref<>(Float.MAX_VALUE); _Ref<Float> fLower = new _Ref<>(Float.MIN_VALUE); if (!JavaPrimitiveUtils.floatTryParse(defVal, fDefault)) { // this is // required log.addMessage(node, "Could not parse float value for defaultValue. Value attempted: '" + defVal + "'"); fDefault.set(Float.MIN_VALUE); }// w w w . j a v a 2 s .com if (!StringUtils.isEmpty(upper)) if (!JavaPrimitiveUtils.floatTryParse(upper, fUpper)) log.addMessage(node, "Could not parse float value for upperBound. Value attempted: '" + upper + "'"); if (!StringUtils.isEmpty(lower)) if (!JavaPrimitiveUtils.floatTryParse(lower, fLower)) log.addMessage(node, "Could not parse float value for lowerBound. Value attempted: '" + lower + "'"); List<Element> entries = new XmlElement(node).selectNodes(QTIXmlConstants.AreaMapEntry, nsmgr); List<AreaMapEntry> entryList = new ArrayList<AreaMapEntry>(); for (Element me : entries) { AreaMapEntry e = AreaMapEntry.fromXML(me, nsmgr, log); if (e != null) entryList.add(e); } return new AreaMapping(entryList, fDefault.get(), fUpper.get(), fLower.get(), node); }
From source file:Main.java
public static final double[] realSymetricMatrix2x2(final double ixx, final double iyy, final double ixy) { // Matrix: [ Ixx Ixy ; Ixy Iyy ]; final double term = Math.sqrt((ixx - iyy) * (ixx - iyy) + 4 * ixy * ixy); final double mu_1 = 0.5 * (ixx + iyy + term); final double mu_2 = 0.5 * (ixx + iyy - term); if (Math.abs(iyy) > Float.MIN_VALUE) { final double cos = 2 * ixy; final double sin = iyy - ixx + term; final double norm = Math.sqrt(cos * cos + sin * sin); if (norm > Float.MIN_VALUE) { return new double[] { mu_1, mu_2, cos / norm, sin / norm }; }//from w w w. j a v a2 s. co m } // Edge case logic // NB BDZ - cosAlpha and sinAlpha edge cases determined by comparing // Float.MIN_VALUE cases to values near it to see trend lines. double cosAlpha; double sinAlpha; // default cosAlpha and sinAlpha if (ixx < 0) { cosAlpha = 0; sinAlpha = 1; } else if (iyy >= 0) { if (ixy >= 0) { cosAlpha = 1; sinAlpha = 0; } else { // ixy < 0 cosAlpha = -1; sinAlpha = 0; } } else { // iyy < 0 if (ixy >= 0) { cosAlpha = 1; sinAlpha = 0; } else { // ixy < 0 cosAlpha = -1; sinAlpha = 0; } } return new double[] { mu_1, mu_2, cosAlpha, sinAlpha }; }
From source file:Main.java
public static void getTop(float[] array, ArrayList<Integer> rankList, int i) { int index = 0; int count = 0; HashSet<Integer> scanned = new HashSet<Integer>(); float max = Float.MIN_VALUE; for (int m = 0; m < i && m < array.length; m++) { max = Float.MIN_VALUE;//from ww w . j a v a2 s.co m for (int no = 0; no < array.length; no++) { if (array[no] >= max && !scanned.contains(no)) { index = no; max = array[no]; } } scanned.add(index); rankList.add(index); //System.out.println(m + "\t" + index); } }
From source file:qtiscoringengine.VariableMapping.java
static VariableMapping fromXML(Element node, BaseType bt, XmlNamespaceManager nsmgr, ValidationLog log) { if (node == null) return null; String defVal = node.getAttributeValue("defaultValue"); // required! String upper = node.getAttributeValue("upperBound"); String lower = node.getAttributeValue("lowerBound"); _Ref<Float> fDefault = new _Ref<>(Float.MIN_VALUE); _Ref<Float> fUpper = new _Ref<>(Float.MAX_VALUE); _Ref<Float> fLower = new _Ref<>(Float.MIN_VALUE); if (!JavaPrimitiveUtils.floatTryParse(defVal, fDefault))// this is required // so return null // if it fails {//w w w. j av a 2s . c o m log.addMessage(node, "Could not parse float value for defaultValue. Value attempted: '" + defVal + "'"); fDefault.set(Float.MIN_VALUE); } if (!StringUtils.isEmpty(upper)) if (!JavaPrimitiveUtils.floatTryParse(upper, fUpper)) log.addMessage(node, "Could not parse float value for upperBound. Value attempted: '" + upper + "'"); if (!StringUtils.isEmpty(lower)) if (!JavaPrimitiveUtils.floatTryParse(lower, fLower)) log.addMessage(node, "Could not parse float value for lowerBound. Value attempted: '" + lower + "'"); // XmlNodeList entries = node.SelectNodes("qti:mapEntry",nsmgr); List<Element> entries = new XmlElement(node).selectNodes("qti:mapEntry", nsmgr); List<VariableMapEntry> entryList = new ArrayList<VariableMapEntry>(); for (Element me : entries) { VariableMapEntry e = VariableMapEntry.FromXML(me, bt, log); if (e != null) entryList.add(e); } return new VariableMapping(entryList, fDefault.get(), fUpper.get(), fLower.get(), node); }
From source file:com.opengamma.maths.lowlevelapi.functions.utilities.Max.java
/** * Returns the maximum value in data//from w ww . j a v a 2s. com * @param data the data to search * @return max, the maximum */ public static float value(float... data) { Validate.notNull(data); float max = Float.MIN_VALUE; final int n = data.length; for (int i = 0; i < n; i++) { if (data[i] > max) { max = data[i]; } } return max; }
From source file:fr.immotronic.ubikit.pems.enocean.impl.item.data.EEP0702xxDataImpl.java
public static EEP0702xxDataImpl constructDataFromRecord(JSONObject lastKnownData) { if (lastKnownData == null) return new EEP0702xxDataImpl(Float.MIN_VALUE, null); try {/*from w w w.ja v a 2 s. co m*/ float temperature = (float) lastKnownData.getDouble("temperature"); Date date = new Date(lastKnownData.getLong("date")); return new EEP0702xxDataImpl(temperature, date); } catch (JSONException e) { Logger.error(LC.gi(), null, "constructDataFromRecord(): An exception while building a sensorData from a JSONObject SHOULD never happen. Check the code !", e); return new EEP0702xxDataImpl(Float.MIN_VALUE, null); } }
From source file:Main.java
/** * Fills the array with random floats. Values will be between min (inclusive) and * max (inclusive)./* w ww. ja va 2s . c o m*/ */ public static void genRandomFloats(long seed, float min, float max, float array[], boolean includeExtremes) { Random r = new Random(seed); int minExponent = Math.min(Math.getExponent(min), 0); int maxExponent = Math.max(Math.getExponent(max), 0); if (minExponent < -6 || maxExponent > 6) { // Use an exponential distribution int exponentDiff = maxExponent - minExponent; for (int i = 0; i < array.length; i++) { float mantissa = r.nextFloat(); int exponent = minExponent + r.nextInt(maxExponent - minExponent); int sign = (min >= 0) ? 1 : 1 - r.nextInt(2) * 2; // -1 or 1 float rand = sign * mantissa * (float) Math.pow(2.0, exponent); if (rand < min || rand > max) { continue; } array[i] = rand; } } else { // Use a linear distribution for (int i = 0; i < array.length; i++) { float rand = r.nextFloat(); array[i] = min + rand * (max - min); } } // Seed a few special numbers we want to be sure to test. for (int i = 0; i < sInterestingDoubles.length; i++) { float f = (float) sInterestingDoubles[i]; if (min <= f && f <= max) { array[r.nextInt(array.length)] = f; } } array[r.nextInt(array.length)] = min; array[r.nextInt(array.length)] = max; if (includeExtremes) { array[r.nextInt(array.length)] = Float.NaN; array[r.nextInt(array.length)] = Float.POSITIVE_INFINITY; array[r.nextInt(array.length)] = Float.NEGATIVE_INFINITY; array[r.nextInt(array.length)] = Float.MIN_VALUE; array[r.nextInt(array.length)] = Float.MIN_NORMAL; array[r.nextInt(array.length)] = Float.MAX_VALUE; array[r.nextInt(array.length)] = -Float.MIN_VALUE; array[r.nextInt(array.length)] = -Float.MIN_NORMAL; array[r.nextInt(array.length)] = -Float.MAX_VALUE; } }