Example usage for java.lang Double POSITIVE_INFINITY

List of usage examples for java.lang Double POSITIVE_INFINITY

Introduction

In this page you can find the example usage for java.lang Double POSITIVE_INFINITY.

Prototype

double POSITIVE_INFINITY

To view the source code for java.lang Double POSITIVE_INFINITY.

Click Source Link

Document

A constant holding the positive infinity of type double .

Usage

From source file:de.bund.bfr.knime.pmmlite.views.chart.ChartCreator.java

public JFreeChart getChart(List<String> idsToPaint) throws ParseException, UnitException {
    if (varX == null || varY == null || varX.getName() == null || varY.getName() == null) {
        return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, new XYPlot(), showLegend);
    }/*from   www .  j  ava 2 s  .  co m*/

    NumberAxis xAxis = new NumberAxis(varX.getDisplayString());
    NumberAxis yAxis = new NumberAxis(varY.getDisplayString());
    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    double usedMinX = Double.POSITIVE_INFINITY;
    double usedMaxX = Double.NEGATIVE_INFINITY;
    int index = 0;
    List<Color> defaultColors = ChartUtils.createColorList(idsToPaint.size());
    List<NamedShape> defaultShapes = ChartUtils.createShapeList(idsToPaint.size());

    for (String id : idsToPaint) {
        Plotable plotable = plotables.get(id);

        if (plotable == null) {
            continue;
        }

        if (plotable.getType() == Plotable.Type.BOTH || plotable.getType() == Plotable.Type.BOTH_MANY
                || plotable.getType() == Plotable.Type.FUNCTION
                || plotable.getType() == Plotable.Type.FUNCTION_SAMPLE) {
            double minArg = varX.to(MathUtils.nullToNan(plotable.getMinValues().get(varX.getName())),
                    plotable.getUnits().get(varX.getName()));
            double maxArg = varX.to(MathUtils.nullToNan(plotable.getMaxValues().get(varX.getName())),
                    plotable.getUnits().get(varX.getName()));

            if (Double.isFinite(minArg)) {
                usedMinX = Math.min(usedMinX, minArg);
            }

            if (Double.isFinite(maxArg)) {
                usedMaxX = Math.max(usedMaxX, maxArg);
            }
        }

        if (plotable.getType() == Plotable.Type.BOTH || plotable.getType() == Plotable.Type.BOTH_MANY) {
            for (Map<String, Integer> choice : plotable.getAllChoices(varX.getName())) {
                double[][] points = plotable.getPoints(varX, varY, choice);

                if (points != null) {
                    for (int i = 0; i < points[0].length; i++) {
                        usedMinX = Math.min(usedMinX, points[0][i]);
                        usedMaxX = Math.max(usedMaxX, points[0][i]);
                    }
                }
            }
        }

        if (plotable.getType() == Plotable.Type.DATASET || plotable.getType() == Plotable.Type.DATASET_MANY) {
            double[][] points = plotable.getPoints(varX, varY);

            if (points != null) {
                for (int i = 0; i < points[0].length; i++) {
                    usedMinX = Math.min(usedMinX, points[0][i]);
                    usedMaxX = Math.max(usedMaxX, points[0][i]);
                }
            }
        }

        if (plotable.getType() == Plotable.Type.FUNCTION_SAMPLE) {
            for (Double x : plotable.getSamples()) {
                if (x != null && Double.isFinite(x)) {
                    usedMinX = Math.min(usedMinX, x);
                    usedMaxX = Math.max(usedMaxX, x);
                }
            }
        }
    }

    if (Double.isInfinite(usedMinX)) {
        usedMinX = 0.0;
    }

    if (Double.isInfinite(usedMaxX)) {
        usedMaxX = 100.0;
    }

    if (varX.getName().equals(PmmUtils.TIME) || varX.getName().equals(PmmUtils.CONCENTRATION)) {
        usedMinX = Math.min(usedMinX, 0.0);
        xAxis.setAutoRangeIncludesZero(true);
    } else {
        xAxis.setAutoRangeIncludesZero(false);
    }

    if (varY.getName().equals(PmmUtils.TIME) || varY.getName().equals(PmmUtils.CONCENTRATION)) {
        yAxis.setAutoRangeIncludesZero(true);
    } else {
        yAxis.setAutoRangeIncludesZero(false);
    }

    if (usedMinX == usedMaxX) {
        usedMinX -= 1.0;
        usedMaxX += 1.0;
    }

    if (useManualRange && minX < maxX && minY < maxY) {
        usedMinX = minX;
        usedMaxX = maxX;
        xAxis.setRange(new Range(minX, maxX));
        yAxis.setRange(new Range(minY, maxY));
    }

    for (String id : idsToPaint) {
        Plotable plotable = plotables.get(id);

        if (plotable == null) {
            continue;
        }

        plotable.setFunctionSteps(resolution);

        switch (plotable.getType()) {
        case DATASET:
            plotDataSet(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index));
            break;
        case DATASET_MANY:
            plotDataSetStrict(plot, plotable, id);
            break;
        case FUNCTION:
            plotFunction(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX,
                    usedMaxX);
            break;
        case FUNCTION_SAMPLE:
            plotFunctionSample(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX,
                    usedMaxX);
            break;
        case BOTH:
            plotBoth(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX,
                    usedMaxX);
            break;
        case BOTH_MANY:
            plotBothStrict(plot, plotable, id, usedMinX, usedMaxX);
            break;
        default:
            throw new RuntimeException("Unknown type of plotable: " + plotable.getType());
        }

        index++;
    }

    return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend);
}

From source file:com.analog.lyric.dimple.solvers.core.parameterizedMessages.MultivariateNormalParameters.java

private final void set(double[] meanOrInfo, double[] varianceOrPrecision, boolean informationForm) {
    final int n = _size = meanOrInfo.length;

    final double[] infoOrMean = new double[n];
    final double[] precisionOrVariance = new double[n];

    if (ArrayUtil.onlyContains(varianceOrPrecision, 0.0)) {
        // All zero => inverse is infinite
        Arrays.fill(precisionOrVariance, Double.POSITIVE_INFINITY);
        Arrays.fill(infoOrMean, Double.POSITIVE_INFINITY);
    } else if (ArrayUtil.onlyContains(varianceOrPrecision, Double.POSITIVE_INFINITY)) {
        // Infinite => inverse is zero
    } else {/*ww w  .jav a2s .c  om*/
        // Except for the all zero/infinite case, condition eigenvalues to not be too small/large FIXME hacky
        for (int i = 0; i < _size; ++i) {
            double x = varianceOrPrecision[i], inv = 1 / x;
            if (x < MIN_EIGENVALUE) {
                varianceOrPrecision[i] = MIN_EIGENVALUE;
                inv = 1 / MIN_EIGENVALUE;
            } else if (inv < MIN_EIGENVALUE) {
                varianceOrPrecision[i] = 1 / MIN_EIGENVALUE;
                inv = MIN_EIGENVALUE;
            }

            precisionOrVariance[i] = inv;
            infoOrMean[i] = meanOrInfo[i] * inv;
        }
    }

    if (informationForm) {
        _infoVector = meanOrInfo;
        _mean = infoOrMean;
        _precision = varianceOrPrecision;
        _variance = precisionOrVariance;
    } else {
        _mean = meanOrInfo;
        _infoVector = infoOrMean;
        _variance = varianceOrPrecision;
        _precision = precisionOrVariance;
    }

    _matrix = ArrayUtil.EMPTY_DOUBLE_ARRAY_ARRAY;
    _isInInformationForm = informationForm;
    _isDiagonal = true;
    _isDiagonalComputed = true;
    forgetNormalizationEnergy();
}

From source file:com.facebook.presto.AbstractTestQueries.java

@Test
void testSpecialFloatingPointValues() throws Exception {
    MaterializedResult actual = computeActual("SELECT nan(), infinity(), -infinity()");
    MaterializedTuple tuple = Iterables.getOnlyElement(actual.getMaterializedTuples());
    assertEquals(tuple.getField(0), Double.NaN);
    assertEquals(tuple.getField(1), Double.POSITIVE_INFINITY);
    assertEquals(tuple.getField(2), Double.NEGATIVE_INFINITY);
}

From source file:master.utilities.PopulationFunctionFromJSON.java

@Override
public double getIntensity(double t) {

    double tforward = convertTime(t);

    if (tforward > times[times.length - 1]) {
        if (popSizeEndInput.get() > 0.0) {
            return intensities[times.length - 1] + (times[times.length - 1] - tforward) / popSizeEndInput.get();
        } else/*w ww . ja  va 2 s .c  o m*/
            return Double.NEGATIVE_INFINITY;
    }

    if (tforward < 0.0) {
        if (popSizeStartInput.get() > 0.0) {
            return intensities[0] + (-tforward) / popSizeStartInput.get();
        } else
            return Double.POSITIVE_INFINITY;
    }

    int tidx = Arrays.binarySearch(times, tforward);
    if (tidx < 0) {
        tidx = -(tidx + 1); // index of first element greater than key

        // Integrate from different sides depending on location wrt peakIdx
        if (tidx <= peakIdx) {
            return (times[tidx] - tforward) / (popSizes[tidx - 1]) + intensities[tidx];
        } else {
            return intensities[tidx - 1] - (tforward - times[tidx - 1]) / popSizes[tidx - 1];
        }
    } else
        return intensities[tidx]; // Exact match can happen at boundaries.

}

From source file:etomica.models.co2.PNGCPM.java

/**
 * This returns the pairwise-additive portion of the GCPM potential for a
 * pair of atoms (dispersion + fixed-charge electrostatics)
 *///w w w  .  j  av a 2 s . c  om
public double getNonPolarizationEnergy(IMoleculeList molecules) {
    IAtomList atoms1 = molecules.getMolecule(0).getChildList();
    IAtomList atoms2 = molecules.getMolecule(1).getChildList();

    IVectorMutable C1r = atoms1.getAtom(0).getPosition();
    IVectorMutable C2r = atoms2.getAtom(0).getPosition();

    work.Ev1Mv2(C1r, C2r);
    shift.Ea1Tv1(-1, work);
    boundary.nearestImage(work);
    shift.PE(work);
    final boolean zeroShift = shift.squared() < 0.1;

    double r2 = work.squared();

    double sum = 0;
    if (zeroShift) {
        for (int i = 0; i < atoms1.getAtomCount(); i++) {
            for (int j = 0; j < atoms2.getAtomCount(); j++) {
                GCPMAgent pairAgent = getPairAgent(atoms1.getAtom(i).getType(), atoms2.getAtom(j).getType());
                double epsilon = pairAgent.epsilon;
                double r = Double.NaN;
                if (epsilon > 0) {
                    double sigma = pairAgent.sigma;
                    double gamma = pairAgent.gamma;
                    r2 = atoms1.getAtom(i).getPosition().Mv1Squared(atoms2.getAtom(j).getPosition());
                    r = Math.sqrt(r2);
                    double rOverSigma = r / sigma;
                    double sigma2OverR2 = 1 / (rOverSigma * rOverSigma);
                    if (1 / sigma2OverR2 < coreFac)
                        return Double.POSITIVE_INFINITY;
                    double sixOverGamma = 6 / gamma;
                    sum += epsilon / (1 - sixOverGamma) * (sixOverGamma * Math.exp(gamma * (1 - rOverSigma))
                            - sigma2OverR2 * sigma2OverR2 * sigma2OverR2);
                }

                double charge2 = pairAgent.charge2;
                if (charge2 != 0) {
                    double tau = pairAgent.tau;
                    if (Double.isNaN(r)) {
                        r2 = atoms1.getAtom(i).getPosition().Mv1Squared(atoms2.getAtom(j).getPosition());
                        r = Math.sqrt(r2);
                    }
                    sum += charge2 / r
                            * (1 - org.apache.commons.math3.special.Erf.erfc(Math.sqrt(r2) / (2 * tau)));
                }
            }
        }
    } else {
        for (int i = 0; i < atoms1.getAtomCount(); i++) {
            for (int j = 0; j < atoms2.getAtomCount(); j++) {
                GCPMAgent pairAgent = getPairAgent(atoms1.getAtom(i).getType(), atoms2.getAtom(j).getType());
                double epsilon = pairAgent.epsilon;
                double r = Double.NaN;
                if (epsilon > 0) {

                    double sigma = pairAgent.sigma;
                    IVector r1 = atoms1.getAtom(i).getPosition();
                    shift.PE(r1);
                    r2 = atoms2.getAtom(j).getPosition().Mv1Squared(shift);
                    shift.ME(r1);
                    r = Math.sqrt(r2);

                    double gamma = pairAgent.gamma;

                    double rOverSigma = r / sigma;
                    double sigma2OverR2 = 1 / (rOverSigma * rOverSigma);
                    if (1 / sigma2OverR2 < coreFac)
                        return Double.POSITIVE_INFINITY;
                    double sixOverGamma = 6 / gamma;

                    sum += epsilon / (1 - sixOverGamma) * (sixOverGamma * Math.exp(gamma * (1 - rOverSigma))
                            - sigma2OverR2 * sigma2OverR2 * sigma2OverR2);//exp-6 potential(Udisp)
                }

                double charge2 = pairAgent.charge2;
                if (charge2 != 0) {
                    double tau = pairAgent.tau;
                    if (Double.isNaN(r)) {
                        IVector r1 = atoms1.getAtom(i).getPosition();
                        shift.PE(r1);
                        r2 = atoms2.getAtom(j).getPosition().Mv1Squared(shift);
                        shift.ME(r1);
                        r = Math.sqrt(r2);
                    }
                    sum += charge2 / r
                            * (1 - org.apache.commons.math3.special.Erf.erfc(Math.sqrt(r2) / (2 * tau)));
                }
            }
        }
    }

    return sum;
}

From source file:ffx.xray.parsers.CNSFilter.java

/**
 * {@inheritDoc}/*from   ww w. j  a v  a2 s  .co m*/
 */
@Override
public double getResolution(File cnsFile, Crystal crystal) {
    double res = Double.POSITIVE_INFINITY;

    try {
        BufferedReader br = new BufferedReader(new FileReader(cnsFile));
        HKL hkl = new HKL();
        String string;
        while ((string = br.readLine()) != null) {
            String strArray[] = string.split("\\s+");
            for (int i = 0; i < strArray.length; i++) {
                if (strArray[i].toLowerCase().startsWith("inde")) {
                    if (i < strArray.length - 3) {
                        int ih = parseInt(strArray[i + 1]);
                        int ik = parseInt(strArray[i + 2]);
                        int il = parseInt(strArray[i + 3]);
                        hkl.h(ih);
                        hkl.k(ik);
                        hkl.l(il);
                        res = min(res, Crystal.res(crystal, hkl));
                    }
                }
            }
        }
    } catch (IOException e) {
        String message = " CNS IO Exception.";
        logger.log(Level.WARNING, message, e);
        return -1.0;
    }

    return res;
}

From source file:clus.statistic.RegressionStat.java

public void updateWeighted(DataTuple tuple, double weight) {
    m_NbExamples++;/*from   w w w  . j  av a 2s  . c  om*/
    m_SumWeight += weight;
    for (int i = 0; i < m_NbAttrs; i++) {
        double val = m_Attrs[i].getNumeric(tuple);
        if (val != Double.POSITIVE_INFINITY) {
            m_SumWeights[i] += weight;
            m_SumValues[i] += weight * val;
            m_SumSqValues[i] += weight * val * val;
        }
    }
}

From source file:it.units.malelab.ege.benchmark.mapper.MappingPropertiesFitness.java

@Override
public MultiObjectiveFitness<Double> worstValue() {
    Double[] worstValues = new Double[properties.length];
    for (int i = 0; i < properties.length; i++) {
        worstValues[i] = Double.POSITIVE_INFINITY;
    }/*from   w  w  w  .  jav  a  2 s  .c om*/
    MultiObjectiveFitness<Double> mof = new MultiObjectiveFitness<Double>(worstValues);
    return mof;
}

From source file:com.cinnober.msgcodec.json.JsonValueHandlerTest.java

@Test
public void testFloat64DecodePosInfinity() throws IOException {
    JsonParser p = f.createParser("\"Infinity\"");
    p.nextToken();/*from w w w. ja  v a  2s .  co m*/
    assertTrue(Double.POSITIVE_INFINITY == JsonValueHandler.FLOAT64.readValue(p));
}

From source file:userinterface.graph.AxisSettings.java

public AxisSettings(String name, boolean isDomain, Graph graph) {
    this.name = name;
    this.isDomain = isDomain;
    this.graph = graph;
    this.chart = graph.getChart();
    this.plot = chart.getXYPlot();
    this.axis = (isDomain) ? this.plot.getDomainAxis() : this.plot.getRangeAxis();

    this.valuesFormatter = NumberFormat.getInstance(Locale.UK);

    if (this.valuesFormatter instanceof DecimalFormat)
        ((DecimalFormat) this.valuesFormatter)
                .applyPattern("###,###,###,###,###,###,###,###.########################");

    /* Initialise all the settings. */
    heading = new SingleLineStringSetting("heading", name, "The heading for this axis", this, true);
    headingFont = new FontColorSetting("heading font",
            new FontColorPair(new Font("SansSerif", Font.PLAIN, 12), Color.black),
            "The font for this axis' heading.", this, true);
    numberFont = new FontColorSetting("numbering font",
            new FontColorPair(new Font("SansSerif", Font.PLAIN, 12), Color.black),
            "The font used to number the axis.", this, true);

    showGrid = new BooleanSetting("show gridlines", new Boolean(true), "Should the gridlines be visible", this,
            true);/*www .j av  a 2  s. c  o  m*/
    gridColour = new ColorSetting("gridline colour", new Color(204, 204, 204), "The colour of the gridlines",
            this, true);

    String[] logarithmicChoices = { "Normal", "Logarithmic" };
    scaleType = new ChoiceSetting("scale type", logarithmicChoices, logarithmicChoices[0],
            "Should the scale be normal, or logarithmic", this, true);
    autoScale = new BooleanSetting("auto-scale", new Boolean(true),
            "When set to true, all minimum values, maximum values, grid intervals, maximum logarithmic powers and minimum logarithmic powers are automatically set and maintained when the data changes.",
            this, true);
    minValue = new DoubleSetting("minimum value", new Double(0.0), "The minimum value for the axis", this,
            true);
    maxValue = new DoubleSetting("maximum value", new Double(1.0), "The maximum value for the axis", this,
            true);
    gridInterval = new DoubleSetting("gridline interval", new Double(0.2), "The interval between gridlines",
            this, false, new RangeConstraint(0, Double.POSITIVE_INFINITY, false, true));
    logBase = new DoubleSetting("log base", new Double(10), "The base for the logarithmic scale", this, false,
            new RangeConstraint("1,"));

    minimumPower = new DoubleSetting("minimum power", new Double("0.0"),
            "The minimum logarithmic power that should be displayed on the scale", this, true);
    maximumPower = new DoubleSetting("maximum power", new Double("1.0"),
            "The maximum logarithmic power that should be displayed on the scale", this, true);

    String[] logStyleChoices = { "Values", "Base and exponent" };
    logStyle = new ChoiceSetting("logarithmic number style", logStyleChoices, logStyleChoices[1],
            "Should the style of the logarithmic scale show the actual values, or the base with the exponent.",
            this, false);

    /* Add constraints. */
    minValue.addConstraint(new NumericConstraint() {
        public void checkValueDouble(double d) throws SettingException {
            if (activated && d >= maxValue.getDoubleValue())
                throw new SettingException("Minimum value should be < Maximum value");
        }

        public void checkValueInteger(int i) throws SettingException {
            if (activated && i >= maxValue.getDoubleValue())
                throw new SettingException("Minimum value should be < Maximum value");
        }

        public void checkValueLong(long i) throws SettingException {
            if (activated && i >= maxValue.getDoubleValue())
                throw new SettingException("Minimum value should be < Maximum value");
        }
    });
    maxValue.addConstraint(new NumericConstraint() {
        public void checkValueDouble(double d) throws SettingException {
            if (activated && d <= minValue.getDoubleValue())
                throw new SettingException("Maximum value should be > Minimum value");
        }

        public void checkValueInteger(int i) throws SettingException {
            if (activated && i <= minValue.getDoubleValue())
                throw new SettingException("Maximum value should be > Minimum value");
        }

        public void checkValueLong(long i) throws SettingException {
            if (activated && i <= maxValue.getDoubleValue())
                throw new SettingException("Minimum value should be > Maximum value");
        }
    });
    minimumPower.addConstraint(new NumericConstraint() {
        public void checkValueDouble(double d) throws SettingException {
            if (activated && d >= maximumPower.getDoubleValue())
                throw new SettingException("Minimum power should be < Maximum power");
        }

        public void checkValueInteger(int i) throws SettingException {
            if (activated && i >= maximumPower.getDoubleValue())
                throw new SettingException("Minimum power should be < Maximum power");
        }

        public void checkValueLong(long i) throws SettingException {
            if (activated && i >= maximumPower.getDoubleValue())
                throw new SettingException("Minimum power should be < Maximum power");
        }
    });
    maximumPower.addConstraint(new NumericConstraint() {
        public void checkValueDouble(double d) throws SettingException {
            if (activated && d <= minimumPower.getDoubleValue())
                throw new SettingException("Maximum power should be > Minimum power");
        }

        public void checkValueInteger(int i) throws SettingException {
            if (activated && i <= minimumPower.getDoubleValue())
                throw new SettingException("Maximum power should be > Minimum power");
        }

        public void checkValueLong(long i) throws SettingException {
            if (activated && i <= minimumPower.getDoubleValue())
                throw new SettingException("Maximum power should be > Minimum power");
        }
    });

    doEnables();
    display = null;
    activated = true;

    updateAxis();
    setChanged();
    notifyObservers();
}