Example usage for java.lang Float MAX_VALUE

List of usage examples for java.lang Float MAX_VALUE

Introduction

In this page you can find the example usage for java.lang Float MAX_VALUE.

Prototype

float MAX_VALUE

To view the source code for java.lang Float MAX_VALUE.

Click Source Link

Document

A constant holding the largest positive finite value of type float , (2-2-23)·2127.

Usage

From source file:org.knime.knip.suise.node.boundarymodel.contourdata.ContourDataFromCRF.java

private void compareSelection(double[] grid) {
    PermutohedralLattice lat = new PermutohedralLattice(contourDataGrid().numFeatures(),
            contourDataGrid().totalLength() + 1, contourDataGrid().totalLength());
    double[] value = new double[contourDataGrid().totalLength() + 1];
    double[] tmpPos = new double[contourDataGrid().numFeatures()];
    int i = 0;/*from  ww  w.j a v a 2 s.co m*/
    int numPos = 0;
    for (int g = 0; g < grid.length; g++) {
        if (grid[g] == 1) {
            Arrays.fill(value, 0);
            value[i] = 1;
            value[value.length - 1] = 1;
            double[] vec = contourDataGrid().getVector(g);
            for (int j = 0; j < vec.length; j++) {
                tmpPos[j] = vec[j] / STDEV;
            }
            lat.splat(tmpPos, value);
            i++;
            numPos++;
        }

    }
    lat.blur();
    lat.beginSlice();
    Img<FloatType> img = new ArrayImgFactory<FloatType>().create(new int[] { value.length, value.length },
            new FloatType());
    RandomAccess<FloatType> tmpRA = img.randomAccess();
    for (i = 0; i < numPos; i++) {
        lat.slice(value);
        tmpRA.setPosition(i, 1);

        for (int j = 0; j < value.length - 1; j++) {
            tmpRA.setPosition(j, 0);
            // double val = value[j] / value[value.length - 1];
            double val = value[j];
            // value[value.length - 1] += val;
            tmpRA.get().setReal(val);
        }
        value[value.length - 1] = 0;
        // tmpRA.setPosition(value.length - 1, 0);
        // tmpRA.get().setReal(value[value.length - 1]);

    }
    Pair<FloatType, FloatType> minmax = Operations.compute(new MinMax<FloatType>(), img);
    Operations.<FloatType, FloatType>map(new Normalize<FloatType>(minmax.getA().getRealDouble(),
            minmax.getB().getRealDouble(), -Float.MAX_VALUE, Float.MAX_VALUE)).compute(img, img);
    compareSelection.show(img, 1.0);
}

From source file:cz.cuni.mff.peckam.ais.detection.SummingDetector.java

/**
 * Return the minimal horizontal distance between peaks.
 * /* w w w .  j a  v  a2  s  . com*/
 * @param peaks The peaks array.
 * @return The minimal distance between peaks.
 */
private static float getMinPeakDistance(float[] peaks) {
    float minPeakDistance = Float.MAX_VALUE;
    int prevPeak = -1;
    for (int i = 0; i < peaks.length; i++) {
        if (peaks[i] == 0)
            continue;
        if (prevPeak >= 0) {
            if (i - prevPeak < minPeakDistance)
                minPeakDistance = i - prevPeak;
        }
        prevPeak = i;
    }
    return minPeakDistance;
}

From source file:gr.iti.mklab.reveal.forensics.util.Util.java

public static float minDouble2DArray(float[][] arrayIn) {
    // Calculate the minimum value of a 2D float array
    float min = Float.MAX_VALUE;
    float colMin;
    for (float[] arrayInRow : arrayIn) {
        List b = Arrays.asList(ArrayUtils.toObject(arrayInRow));
        colMin = (float) Collections.min(b);
        if (colMin < min) {
            min = colMin;//  w ww.j a  v a  2s.c o m
        }
    }
    return min;
}

From source file:org.noise_planet.noisecapture.CalibrationLinearityActivity.java

private void updateBarChart() {
    BarChart barChart = getBarChart();/*from  w  w w  .j  a v a  2s  .  com*/
    if (barChart == null) {
        return;
    }
    if (freqLeqStats.size() <= 2) {
        return;
    }
    double[] pearsons = computePearson();
    if (pearsons == null) {
        return;
    }

    float YMin = Float.MAX_VALUE;
    float YMax = Float.MIN_VALUE;

    ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();

    // Read all white noise values for indexing before usage
    ArrayList<BarEntry> yMeasure = new ArrayList<BarEntry>();
    int idfreq = 0;
    for (double value : pearsons) {
        YMax = Math.max(YMax, (float) value);
        YMin = Math.min(YMin, (float) value);
        yMeasure.add(new BarEntry((float) value, idfreq++));
    }
    BarDataSet freqSet = new BarDataSet(yMeasure, "Pearson's correlation");
    freqSet.setColor(ColorTemplate.COLORFUL_COLORS[0]);
    freqSet.setValueTextColor(Color.WHITE);
    freqSet.setDrawValues(true);
    dataSets.add(freqSet);

    ArrayList<String> xVals = new ArrayList<String>();
    double[] freqs = FFTSignalProcessing
            .computeFFTCenterFrequency(AudioProcess.REALTIME_SAMPLE_RATE_LIMITATION);
    for (double freqValue : freqs) {
        xVals.add(Spectrogram.formatFrequency((int) freqValue));
    }

    // create a data object with the datasets
    BarData data = new BarData(xVals, dataSets);
    barChart.setData(data);
    YAxis yl = barChart.getAxisLeft();
    yl.setAxisMinValue(YMin - 0.1f);
    yl.setAxisMaxValue(YMax + 0.1f);

    barChart.invalidate();
}

From source file:org.dcm4che2.tool.dcmwado.DcmWado.java

public final void setWindow(String[] window) {
    if (window.length != 2)
        throw new IllegalArgumentException("Illegal argument for -voi");
    parseFloat(window[0], "Illegal argument for -voi", Float.MIN_VALUE, Float.MAX_VALUE);
    parseFloat(window[1], "Illegal argument for -voi", 0, Float.MAX_VALUE);
    this.window = window;
}

From source file:com.waz.zclient.pages.main.conversation.LocationFragment.java

@Override
public void onLocationChanged(Location location) {
    Timber.i("onLocationChanged, lat=%f, lon=%f, accuracy=%f, distanceToCurrent=%f", location.getLatitude(),
            location.getLongitude(), location.getAccuracy(),
            (currentLocation == null) ? 0 : location.distanceTo(currentLocation));

    float distanceFromCenterOfScreen = Float.MAX_VALUE;
    if (currentLatLng != null) {
        float[] distance = new float[1];
        Location.distanceBetween(currentLatLng.latitude, currentLatLng.longitude, location.getLatitude(),
                location.getLongitude(), distance);
        distanceFromCenterOfScreen = distance[0];
        Timber.i("current location distance from map center %f", distance[0]);
    }/*  w w w.java 2  s  .com*/

    currentLocation = location;
    if (map != null) {
        map.clear();
        LatLng position = new LatLng(location.getLatitude(), location.getLongitude());
        map.addMarker(new MarkerOptions().position(position)
                .icon(BitmapDescriptorFactory.fromBitmap(getMarker())).anchor(0.5f, 0.5f));
        if (animateTocurrentLocation && distanceFromCenterOfScreen > DEFAULT_MIMIMUM_CAMERA_MOVEMENT) {
            if (zoom || animating) {
                map.animateCamera(CameraUpdateFactory.newLatLngZoom(
                        new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()),
                        DEFAULT_MAP_ZOOM_LEVEL));
                animating = true;
                zoom = false;
            } else {
                map.animateCamera(CameraUpdateFactory
                        .newLatLng(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude())));
            }
        }
    }
}

From source file:voldemort.VoldemortClientShell.java

@SuppressWarnings("unchecked")
protected static Object tightenNumericTypes(Object o) {
    if (o == null) {
        return null;
    } else if (o instanceof List) {
        List l = (List) o;
        for (int i = 0; i < l.size(); i++)
            l.set(i, tightenNumericTypes(l.get(i)));
        return l;
    } else if (o instanceof Map) {
        Map m = (Map) o;/*w  w  w .  j  a  v  a 2 s .  c  o  m*/
        for (Map.Entry entry : (Set<Map.Entry>) m.entrySet())
            m.put(entry.getKey(), tightenNumericTypes(entry.getValue()));
        return m;
    } else if (o instanceof Number) {
        Number n = (Number) o;
        if (o instanceof Integer) {
            if (n.intValue() < Byte.MAX_VALUE)
                return n.byteValue();
            else if (n.intValue() < Short.MAX_VALUE)
                return n.shortValue();
            else
                return n;
        } else if (o instanceof Double) {
            if (n.doubleValue() < Float.MAX_VALUE)
                return n.floatValue();
            else
                return n;
        } else {
            throw new RuntimeException("Unsupported numeric type: " + o.getClass());
        }
    } else {
        return o;
    }
}

From source file:gr.iti.mklab.reveal.forensics.util.Util.java

public static float maxDouble2DArray(float[][] arrayIn) {
    // Calculate the maximum value of a 2D float array
    float max = -Float.MAX_VALUE;
    float colMax;
    for (float[] arrayInRow : arrayIn) {
        List b = Arrays.asList(ArrayUtils.toObject(arrayInRow));
        colMax = (float) Collections.max(b);
        if (colMax > max) {
            max = colMax;//from   w ww.j ava 2 s.  c  o m
        }
    }
    return max;
}

From source file:org.apache.pdfbox.text.PDFTextStripper.java

/**
 * This will print the text of the processed page to "output". It will estimate, based on the coordinates of the
 * text, where newlines and word spacings should be placed. The text will be sorted only if that feature was
 * enabled./*from ww w  .  j a  va  2s. c o m*/
 *
 * @throws IOException If there is an error writing the text.
 */
protected void writePage() throws IOException {
    float maxYForLine = MAX_Y_FOR_LINE_RESET_VALUE;
    float minYTopForLine = MIN_Y_TOP_FOR_LINE_RESET_VALUE;
    float endOfLastTextX = END_OF_LAST_TEXT_X_RESET_VALUE;
    float lastWordSpacing = LAST_WORD_SPACING_RESET_VALUE;
    float maxHeightForLine = MAX_HEIGHT_FOR_LINE_RESET_VALUE;
    PositionWrapper lastPosition = null;
    PositionWrapper lastLineStartPosition = null;

    boolean startOfPage = true; // flag to indicate start of page
    boolean startOfArticle;
    if (charactersByArticle.size() > 0) {
        writePageStart();
    }

    for (List<TextPosition> textList : charactersByArticle) {
        if (getSortByPosition()) {
            TextPositionComparator comparator = new TextPositionComparator();

            // because the TextPositionComparator is not transitive, but
            // JDK7+ enforces transitivity on comparators, we need to use
            // a custom quicksort implementation (which is slower, unfortunately).
            if (useCustomQuickSort) {
                QuickSort.sort(textList, comparator);
            } else {
                Collections.sort(textList, comparator);
            }
        }

        startArticle();
        startOfArticle = true;

        // Now cycle through to print the text.
        // We queue up a line at a time before we print so that we can convert
        // the line from presentation form to logical form (if needed).
        List<LineItem> line = new ArrayList<LineItem>();

        Iterator<TextPosition> textIter = textList.iterator();
        // PDF files don't always store spaces. We will need to guess where we should add
        // spaces based on the distances between TextPositions. Historically, this was done
        // based on the size of the space character provided by the font. In general, this
        // worked but there were cases where it did not work. Calculating the average character
        // width and using that as a metric works better in some cases but fails in some cases
        // where the spacing worked. So we use both. NOTE: Adobe reader also fails on some of
        // these examples.

        // Keeps track of the previous average character width
        float previousAveCharWidth = -1;
        while (textIter.hasNext()) {
            TextPosition position = textIter.next();
            PositionWrapper current = new PositionWrapper(position);
            String characterValue = position.getUnicode();

            // Resets the average character width when we see a change in font
            // or a change in the font size
            if (lastPosition != null && (position.getFont() != lastPosition.getTextPosition().getFont()
                    || position.getFontSize() != lastPosition.getTextPosition().getFontSize())) {
                previousAveCharWidth = -1;
            }

            float positionX;
            float positionY;
            float positionWidth;
            float positionHeight;

            // If we are sorting, then we need to use the text direction
            // adjusted coordinates, because they were used in the sorting.
            if (getSortByPosition()) {
                positionX = position.getXDirAdj();
                positionY = position.getYDirAdj();
                positionWidth = position.getWidthDirAdj();
                positionHeight = position.getHeightDir();
            } else {
                positionX = position.getX();
                positionY = position.getY();
                positionWidth = position.getWidth();
                positionHeight = position.getHeight();
            }

            // The current amount of characters in a word
            int wordCharCount = position.getIndividualWidths().length;

            // Estimate the expected width of the space based on the
            // space character with some margin.
            float wordSpacing = position.getWidthOfSpace();
            float deltaSpace;
            if (wordSpacing == 0 || Float.isNaN(wordSpacing)) {
                deltaSpace = Float.MAX_VALUE;
            } else {
                if (lastWordSpacing < 0) {
                    deltaSpace = wordSpacing * getSpacingTolerance();
                } else {
                    deltaSpace = (wordSpacing + lastWordSpacing) / 2f * getSpacingTolerance();
                }
            }

            // Estimate the expected width of the space based on the average character width
            // with some margin. This calculation does not make a true average (average of
            // averages) but we found that it gave the best results after numerous experiments.
            // Based on experiments we also found that .3 worked well.
            float averageCharWidth;
            if (previousAveCharWidth < 0) {
                averageCharWidth = positionWidth / wordCharCount;
            } else {
                averageCharWidth = (previousAveCharWidth + positionWidth / wordCharCount) / 2f;
            }
            float deltaCharWidth = averageCharWidth * getAverageCharTolerance();

            // Compares the values obtained by the average method and the wordSpacing method
            // and picks the smaller number.
            float expectedStartOfNextWordX = EXPECTED_START_OF_NEXT_WORD_X_RESET_VALUE;
            if (endOfLastTextX != END_OF_LAST_TEXT_X_RESET_VALUE) {
                if (deltaCharWidth > deltaSpace) {
                    expectedStartOfNextWordX = endOfLastTextX + deltaSpace;
                } else {
                    expectedStartOfNextWordX = endOfLastTextX + deltaCharWidth;
                }
            }

            if (lastPosition != null) {
                if (startOfArticle) {
                    lastPosition.setArticleStart();
                    startOfArticle = false;
                }
                // RDD - Here we determine whether this text object is on the current
                // line. We use the lastBaselineFontSize to handle the superscript
                // case, and the size of the current font to handle the subscript case.
                // Text must overlap with the last rendered baseline text by at least
                // a small amount in order to be considered as being on the same line.

                // XXX BC: In theory, this check should really check if the next char is in
                // full range seen in this line. This is what I tried to do with minYTopForLine,
                // but this caused a lot of regression test failures. So, I'm leaving it be for
                // now
                if (!overlap(positionY, positionHeight, maxYForLine, maxHeightForLine)) {
                    writeLine(normalize(line));
                    line.clear();
                    lastLineStartPosition = handleLineSeparation(current, lastPosition, lastLineStartPosition,
                            maxHeightForLine);
                    expectedStartOfNextWordX = EXPECTED_START_OF_NEXT_WORD_X_RESET_VALUE;
                    maxYForLine = MAX_Y_FOR_LINE_RESET_VALUE;
                    maxHeightForLine = MAX_HEIGHT_FOR_LINE_RESET_VALUE;
                    minYTopForLine = MIN_Y_TOP_FOR_LINE_RESET_VALUE;
                }
                // test if our TextPosition starts after a new word would be expected to start
                if (expectedStartOfNextWordX != EXPECTED_START_OF_NEXT_WORD_X_RESET_VALUE
                        && expectedStartOfNextWordX < positionX &&
                        // only bother adding a space if the last character was not a space
                        lastPosition.getTextPosition().getUnicode() != null
                        && !lastPosition.getTextPosition().getUnicode().endsWith(" ")) {
                    line.add(LineItem.getWordSeparator());
                }
            }
            if (positionY >= maxYForLine) {
                maxYForLine = positionY;
            }
            // RDD - endX is what PDF considers to be the x coordinate of the
            // end position of the text. We use it in computing our metrics below.
            endOfLastTextX = positionX + positionWidth;

            // add it to the list
            if (characterValue != null) {
                if (startOfPage && lastPosition == null) {
                    writeParagraphStart();// not sure this is correct for RTL?
                }
                line.add(new LineItem(position));
            }
            maxHeightForLine = Math.max(maxHeightForLine, positionHeight);
            minYTopForLine = Math.min(minYTopForLine, positionY - positionHeight);
            lastPosition = current;
            if (startOfPage) {
                lastPosition.setParagraphStart();
                lastPosition.setLineStart();
                lastLineStartPosition = lastPosition;
                startOfPage = false;
            }
            lastWordSpacing = wordSpacing;
            previousAveCharWidth = averageCharWidth;
        }
        // print the final line
        if (line.size() > 0) {
            writeLine(normalize(line));
            writeParagraphEnd();
        }
        endArticle();
    }
    writePageEnd();
}

From source file:blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.java

public Set<AbstractConnection> getIndirectEnergyConnections(BlockPos node, World world,
        boolean ignoreIsEnergyOutput) {
    int dimension = world.provider.getDimension();
    if (!ignoreIsEnergyOutput && indirectConnections.containsKey(dimension)
            && indirectConnections.get(dimension).containsKey(node))
        return indirectConnections.get(dimension).get(node);
    else if (ignoreIsEnergyOutput && indirectConnectionsIgnoreOut.containsKey(dimension)
            && indirectConnectionsIgnoreOut.get(dimension).containsKey(node))
        return indirectConnectionsIgnoreOut.get(dimension).get(node);

    PriorityQueue<Pair<IImmersiveConnectable, Float>> queue = new PriorityQueue<>(
            Comparator.comparingDouble(Pair::getRight));
    Set<AbstractConnection> closedList = newSetFromMap(new ConcurrentHashMap<AbstractConnection, Boolean>());
    List<BlockPos> checked = new ArrayList<>();
    HashMap<BlockPos, BlockPos> backtracker = new HashMap<>();

    checked.add(node);//from  ww w  .  ja va2 s  .  c o  m
    Set<Connection> conL = getConnections(world, node);
    if (conL != null)
        for (Connection con : conL) {
            IImmersiveConnectable end = toIIC(con.end, world);
            if (end != null) {
                queue.add(new ImmutablePair<>(end, con.getBaseLoss()));
                backtracker.put(con.end, node);
            }
        }

    IImmersiveConnectable next;
    final int closedListMax = 1200;

    while (closedList.size() < closedListMax && !queue.isEmpty()) {
        Pair<IImmersiveConnectable, Float> pair = queue.poll();
        next = pair.getLeft();
        float loss = pair.getRight();
        BlockPos nextPos = toBlockPos(next);
        if (!checked.contains(nextPos) && queue.stream().noneMatch((p) -> p.getLeft().equals(nextPos))) {
            boolean isOutput = next.isEnergyOutput();
            if (ignoreIsEnergyOutput || isOutput) {
                BlockPos last = toBlockPos(next);
                WireType minimumType = null;
                int distance = 0;
                List<Connection> connectionParts = new ArrayList<>();
                while (last != null) {
                    BlockPos prev = last;
                    last = backtracker.get(last);
                    if (last != null) {

                        Set<Connection> conLB = getConnections(world, last);
                        if (conLB != null)
                            for (Connection conB : conLB)
                                if (conB.end.equals(prev)) {
                                    connectionParts.add(0, conB);
                                    distance += conB.length;
                                    if (minimumType == null
                                            || conB.cableType.getTransferRate() < minimumType.getTransferRate())
                                        minimumType = conB.cableType;
                                    break;
                                }
                    }
                }
                closedList.add(new AbstractConnection(toBlockPos(node), toBlockPos(next), minimumType, distance,
                        isOutput, connectionParts.toArray(new Connection[connectionParts.size()])));
            }

            Set<Connection> conLN = getConnections(world, toBlockPos(next));
            if (conLN != null)
                for (Connection con : conLN)
                    if (next.allowEnergyToPass(con)) {
                        IImmersiveConnectable end = toIIC(con.end, world);

                        Optional<Pair<IImmersiveConnectable, Float>> existing = queue.stream()
                                .filter((p) -> p.getLeft() == end).findAny();
                        float newLoss = con.getBaseLoss() + loss;
                        if (end != null && !checked.contains(con.end)
                                && existing.map(Pair::getRight).orElse(Float.MAX_VALUE) > newLoss) {
                            existing.ifPresent(p1 -> queue.removeIf((p2) -> p1.getLeft() == p2.getLeft()));
                            queue.add(new ImmutablePair<>(end, newLoss));
                            backtracker.put(con.end, toBlockPos(next));
                        }
                    }
            checked.add(toBlockPos(next));
        }
    }
    if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
        if (ignoreIsEnergyOutput) {
            if (!indirectConnectionsIgnoreOut.containsKey(dimension))
                indirectConnectionsIgnoreOut.put(dimension, new ConcurrentHashMap<>());
            Map<BlockPos, Set<AbstractConnection>> conns = indirectConnectionsIgnoreOut.get(dimension);
            if (!conns.containsKey(node))
                conns.put(node, newSetFromMap(new ConcurrentHashMap<>()));
            conns.get(node).addAll(closedList);
        } else {
            if (!indirectConnections.containsKey(dimension))
                indirectConnections.put(dimension, new ConcurrentHashMap<>());
            Map<BlockPos, Set<AbstractConnection>> conns = indirectConnections.get(dimension);
            if (!conns.containsKey(node))
                conns.put(node, newSetFromMap(new ConcurrentHashMap<>()));
            conns.get(node).addAll(closedList);
        }
    }
    return closedList;
}