Example usage for java.lang Double NEGATIVE_INFINITY

List of usage examples for java.lang Double NEGATIVE_INFINITY

Introduction

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

Prototype

double NEGATIVE_INFINITY

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

Click Source Link

Document

A constant holding the negative infinity of type double .

Usage

From source file:com.rapidminer.operator.preprocessing.discretization.UserBasedDiscretization.java

@Override
public List<ParameterType> getParameterTypes() {
    List<ParameterType> types = super.getParameterTypes();

    ParameterType classType = new ParameterTypeString(PARAMETER_CLASS_NAME, "The name of this range.");
    ParameterType threshold = new ParameterTypeDouble(PARAMETER_UPPER_LIMIT, "The upper limit.",
            Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    List<String[]> defaultList = new LinkedList<String[]>();

    defaultList.add(new String[] { "first", Double.NEGATIVE_INFINITY + "" });
    defaultList.add(new String[] { "last", Double.POSITIVE_INFINITY + "" });

    ParameterType type = new ParameterTypeList(PARAMETER_RANGE_NAMES,
            "Defines the classes and the upper limits of each class.", classType, threshold, defaultList);
    type.setExpert(false);//from w  w w.j a v  a 2s.  c  om
    types.add(type);

    return types;
}

From source file:ffx.crystal.CCP4MapWriter.java

/**
 * write data to file, does not normalize
 *
 * @param data map data to write out/*from  w  w w. j a va  2s . c  om*/
 * @param norm should the data be normalized by mean/sd?
 */
public void write(double data[], boolean norm) {
    ByteOrder b = ByteOrder.nativeOrder();
    FileOutputStream fos;
    DataOutputStream dos;

    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    double mean = 0.0;
    double sd = 0.0;

    int n = 0;
    for (int k = 0; k < extz; k++) {
        for (int j = 0; j < exty; j++) {
            for (int i = 0; i < extx; i++) {
                int index = stride * (i + extx * (j + exty * k));
                // int index = k * (exty * (extx + 2)) + j * (extx + 2) + i;
                n++;
                if (data[index] < min) {
                    min = data[index];
                }
                if (data[index] > max) {
                    max = data[index];
                }
                mean += (data[index] - mean) / n;
            }
        }
    }

    n = 0;
    for (int k = 0; k < extz; k++) {
        for (int j = 0; j < exty; j++) {
            for (int i = 0; i < extx; i++) {
                int index = stride * (i + extx * (j + exty * k));
                // int index = k * (exty * (extx + 2)) + j * (extx + 2) + i;
                sd += pow(data[index] - mean, 2.0);
                n++;
            }
        }
    }
    sd = sqrt(sd / n);

    if (norm) {
        for (int k = 0; k < extz; k++) {
            for (int j = 0; j < exty; j++) {
                for (int i = 0; i < extx; i++) {
                    int index = stride * (i + extx * (j + exty * k));
                    data[index] = (data[index] - mean) / sd;
                }
            }
        }
        // recurse
        write(data, false);
    }

    try {
        if (logger.isLoggable(Level.INFO)) {
            StringBuilder sb = new StringBuilder();
            sb.append(String.format("\nwriting CCP4 map file: \"%s\"\n", filename));
            sb.append(String.format("map min: %g max: %g mean: %g standard dev.: %g", min, max, mean, sd));
            logger.info(sb.toString());
        }

        fos = new FileOutputStream(filename);
        dos = new DataOutputStream(fos);

        byte bytes[] = new byte[2048];
        int offset = 0;

        int imapdata;
        float fmapdata;
        String mapstr;

        // header
        ByteBuffer bb = ByteBuffer.wrap(bytes);
        bb.order(b).putInt(extx);
        bb.order(b).putInt(exty);
        bb.order(b).putInt(extz);

        // mode (2 = reals, only one we accept)
        bb.order(b).putInt(2);

        bb.order(b).putInt(orix);
        bb.order(b).putInt(oriy);
        bb.order(b).putInt(oriz);
        bb.order(b).putInt(nx);
        bb.order(b).putInt(ny);
        bb.order(b).putInt(nz);

        bb.order(b).putFloat((float) crystal.a);
        bb.order(b).putFloat((float) crystal.b);
        bb.order(b).putFloat((float) crystal.c);
        bb.order(b).putFloat((float) crystal.alpha);
        bb.order(b).putFloat((float) crystal.beta);
        bb.order(b).putFloat((float) crystal.gamma);

        bb.order(b).putInt(1);
        bb.order(b).putInt(2);
        bb.order(b).putInt(3);

        bb.order(b).putFloat((float) min);
        bb.order(b).putFloat((float) max);
        bb.order(b).putFloat((float) mean);

        bb.order(b).putInt(crystal.spaceGroup.number);
        // bb.order(b).putInt(1);

        // symmetry bytes - should set this up at some point
        // imapdata = swap ? ByteSwap.swap(320) : 320;
        bb.order(b).putInt(80);

        bb.order(b).putInt(0);

        for (int i = 0; i < 12; i++) {
            bb.order(b).putFloat(0.0f);
        }

        for (int i = 0; i < 15; i++) {
            bb.order(b).putInt(0);
        }
        dos.write(bytes, offset, 208);
        bb.rewind();

        mapstr = "MAP ";
        dos.writeBytes(mapstr);

        // machine code: double, float, int, uchar
        // 0x4441 for LE, 0x1111 for BE
        if (ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) {
            imapdata = 0x4441;
        } else {
            imapdata = 0x1111;
        }
        bb.order(b).putInt(imapdata);

        bb.order(b).putFloat((float) sd);

        bb.order(b).putInt(1);
        dos.write(bytes, offset, 12);

        StringBuilder sb = new StringBuilder();
        sb.append("map data from ffx");
        while (sb.length() < 80) {
            sb.append(" ");
        }
        dos.writeBytes(sb.toString());

        sb = new StringBuilder();
        while (sb.length() < 80) {
            sb.append(" ");
        }
        for (int i = 0; i < 9; i++) {
            dos.writeBytes(sb.toString());
        }

        sb = new StringBuilder();
        sb.append("x,y,z");
        while (sb.length() < 80) {
            sb.append(" ");
        }
        dos.writeBytes(sb.toString());

        bb.rewind();
        for (int k = 0; k < extz; k++) {
            for (int j = 0; j < exty; j++) {
                for (int i = 0; i < extx; i++) {
                    int index = stride * (i + extx * (j + exty * k));
                    // int index = k * (exty * (extx + 2)) + j * (extx + 2) + i;
                    fmapdata = (float) data[index];
                    bb.order(b).putFloat(fmapdata);
                    if (!bb.hasRemaining()) {
                        dos.write(bytes);
                        bb.rewind();
                    }
                }
            }
        }
        if (bb.position() > 0) {
            dos.write(bytes);
            bb.rewind();
        }

        dos.close();
    } catch (Exception e) {
        String message = "Fatal exception evaluating structure factors.\n";
        logger.log(Level.SEVERE, message, e);
        System.exit(-1);
    }
}

From source file:lirmm.inria.fr.math.BigSparseRealMatrixTest.java

@Test
public void testMath870() {
    // Caveat: This implementation assumes that, for any {@code x},
    // the equality {@code x * 0d == 0d} holds. But it is is not true for
    // {@code NaN}. Moreover, zero entries will lose their sign.
    // Some operations (that involve {@code NaN} and/or infinities) may
    // thus give incorrect results.
    BigSparseRealMatrix a = new BigSparseRealMatrix(3, 3);
    BigSparseRealMatrix x = new BigSparseRealMatrix(3, 1);
    x.setEntry(0, 0, Double.NaN);
    x.setEntry(2, 0, Double.NEGATIVE_INFINITY);
    BigSparseRealMatrix b = a.multiply(x);
    for (int i = 0; i < b.getRowDimension(); ++i) {
        for (int j = 0; j < b.getColumnDimension(); ++j) {
            // NaNs and infinities have disappeared, this is a limitation of our implementation
            Assert.assertEquals(0.0, b.getEntry(i, j), 1.0e-20);
        }//from w  ww . j  a v a2s  .co  m
    }
}

From source file:org.jfree.experimental.chart.renderer.xy.VectorRenderer.java

/**
 * Returns the range of values the renderer requires to display all the 
 * items from the specified dataset.//  w ww. j a va2s.c om
 * 
 * @param dataset  the dataset (<code>null</code> permitted).
 * 
 * @return The range (<code>null</code> if the dataset is <code>null</code> 
 *         or empty).
 */
public Range findRangeBounds(XYDataset dataset) {
    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();
    double lvalue;
    double uvalue;
    if (dataset instanceof VectorXYDataset) {
        VectorXYDataset vdataset = (VectorXYDataset) dataset;
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {
                double delta = vdataset.getDeltaYValue(series, item);
                if (delta < 0.0) {
                    uvalue = vdataset.getYValue(series, item);
                    lvalue = uvalue + delta;
                } else {
                    lvalue = vdataset.getYValue(series, item);
                    uvalue = lvalue + delta;
                }
                minimum = Math.min(minimum, lvalue);
                maximum = Math.max(maximum, uvalue);
            }
        }
    } else {
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {
                lvalue = dataset.getYValue(series, item);
                uvalue = lvalue;
                minimum = Math.min(minimum, lvalue);
                maximum = Math.max(maximum, uvalue);
            }
        }
    }
    if (minimum > maximum) {
        return null;
    } else {
        return new Range(minimum, maximum);
    }
}

From source file:com.fay.statics.SummaryStat.java

public void clear() {
    valSum = sumSquare = 0.0d;
    numObs = 0;
    weightSum = 0.0d;
    min = Double.POSITIVE_INFINITY;
    max = Double.NEGATIVE_INFINITY;
}

From source file:com.rapidminer.gui.plotter.charts.BubbleChartPlotter.java

private void prepareNumericalData() {
    DataTable dataTable = getDataTable();
    this.nominal = false;
    xyzDataSet = new DefaultXYZDataset();

    if (axis[X_AXIS] >= 0 && axis[Y_AXIS] >= 0 && axis[BUBBLE_SIZE_AXIS] >= 0) {

        this.bubbleSizeMin = Double.POSITIVE_INFINITY;
        this.bubbleSizeMax = Double.NEGATIVE_INFINITY;
        this.xAxisMin = Double.POSITIVE_INFINITY;
        this.xAxisMax = Double.NEGATIVE_INFINITY;
        this.yAxisMin = Double.POSITIVE_INFINITY;
        this.yAxisMax = Double.NEGATIVE_INFINITY;
        this.minColor = Double.POSITIVE_INFINITY;
        this.maxColor = Double.NEGATIVE_INFINITY;

        List<double[]> dataList = new LinkedList<>();
        synchronized (dataTable) {
            Iterator<DataTableRow> i = dataTable.iterator();
            while (i.hasNext()) {
                DataTableRow row = i.next();

                double xValue = row.getValue(axis[X_AXIS]);
                double yValue = row.getValue(axis[Y_AXIS]);
                double bubbleSizeValue = row.getValue(axis[BUBBLE_SIZE_AXIS]);

                double colorValue = Double.NaN;
                if (colorColumn >= 0) {
                    colorValue = row.getValue(colorColumn);
                }/*from   ww w  .j  a va2s  . c o m*/

                if (!Double.isNaN(xValue) && !Double.isNaN(yValue) && !Double.isNaN(bubbleSizeValue)) {
                    double[] data = new double[4];
                    data[X_AXIS] = xValue;
                    data[Y_AXIS] = yValue;
                    data[BUBBLE_SIZE_AXIS] = bubbleSizeValue;
                    data[3] = colorValue;

                    this.bubbleSizeMin = MathFunctions.robustMin(this.bubbleSizeMin, bubbleSizeValue);
                    this.bubbleSizeMax = MathFunctions.robustMax(this.bubbleSizeMax, bubbleSizeValue);
                    this.xAxisMin = MathFunctions.robustMin(this.xAxisMin, xValue);
                    this.yAxisMin = MathFunctions.robustMin(this.yAxisMin, yValue);
                    this.xAxisMax = MathFunctions.robustMax(this.xAxisMax, xValue);
                    this.yAxisMax = MathFunctions.robustMax(this.yAxisMax, yValue);
                    this.minColor = MathFunctions.robustMin(this.minColor, colorValue);
                    this.maxColor = MathFunctions.robustMax(this.maxColor, colorValue);

                    dataList.add(data);
                }
            }
        }

        double[][] data = new double[3][dataList.size()];
        this.colors = new double[dataList.size()];

        int index = 0;
        double scaleFactor = Math.min(this.xAxisMax - this.xAxisMin, this.yAxisMax - this.yAxisMin) / 4.0d;
        for (double[] d : dataList) {
            data[X_AXIS][index] = d[X_AXIS];
            data[Y_AXIS][index] = d[Y_AXIS];
            data[BUBBLE_SIZE_AXIS][index] = ((d[BUBBLE_SIZE_AXIS] - bubbleSizeMin)
                    / (bubbleSizeMax - bubbleSizeMin) + 0.1) * scaleFactor;
            this.colors[index] = d[3];
            index++;
        }

        xyzDataSet.addSeries("All", data);
    }
}

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

public JFreeChart createChart() throws ParseException {
    if (varX == null || varY == null) {
        return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, new XYPlot(), showLegend);
    }// w  ww .j  av  a 2 s. c  om

    List<String> idsToPaint;

    if (selectAll) {
        idsToPaint = new ArrayList<>(plotables.keySet());
    } else {
        idsToPaint = selectedIds;
    }

    NumberAxis xAxis = new NumberAxis(transformX.getName(varX));
    NumberAxis yAxis = new NumberAxis(transformY.getName(varY));
    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.isDataType()) {
            double[][] points = plotable.getDataPoints(varX, varY, transformX, transformY);

            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.isParamType()) {
            double minArg = transformX.to(MathUtils.nullToNan(plotable.getMinValues().get(varX)));
            double maxArg = transformX.to(MathUtils.nullToNan(plotable.getMaxValues().get(varX)));

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

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

    if (!Double.isFinite(usedMinX)) {
        usedMinX = 0.0;
    }

    if (!Double.isFinite(usedMaxX)) {
        usedMaxX = 100.0;
    }

    xAxis.setAutoRangeIncludesZero(false);
    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);
        plotable.setInterpolator(interpolator);

        switch (plotable.getType()) {
        case DATA:
            plotData(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index));
            break;
        case FUNCTION:
            plotFunction(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX,
                    usedMaxX);
            break;
        case DATA_FUNCTION:
            plotDataFunction(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX,
                    usedMaxX);
            break;
        case DIFF:
            plotDiff(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX,
                    usedMaxX);
            break;
        case DATA_DIFF:
            plotDataDiff(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX,
                    usedMaxX);
            break;
        default:
            throw new RuntimeException("Unknown type of plotable: " + plotable.getType());
        }

        index++;
    }

    if (minToZero && !useManualRange) {
        Range xRange = xAxis.getRange();
        Range yRange = yAxis.getRange();

        if (xRange.getUpperBound() <= 0.0 || yRange.getUpperBound() <= 0.0) {
            return null;
        }

        xAxis.setRange(new Range(0.0, xRange.getUpperBound()));
        yAxis.setRange(new Range(0.0, yRange.getUpperBound()));
    }

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

From source file:beast.evomodel.speciation.BirthDeathModel.java

@Override
public double calculateTreeLogLikelihood(Tree tree) {
    if (conditionOnOrigin && tree.getNodeHeight(tree.getRoot()) > originHeightParameter.getValue(0))
        return Double.NEGATIVE_INFINITY;
    return super.calculateTreeLogLikelihood(tree);
}

From source file:com.rapidminer.operator.preprocessing.discretization.MinMaxBinDiscretization.java

@Override
public List<ParameterType> getParameterTypes() {
    List<ParameterType> types = super.getParameterTypes();

    ParameterType type = new ParameterTypeInt(PARAMETER_NUMBER_OF_BINS,
            "Defines the number of bins which should be used for each attribute.", 2, Integer.MAX_VALUE, 2);
    type.setExpert(false);//  w w w. j av a2  s  .co  m
    types.add(type);

    types.add(new ParameterTypeDouble(PARAMETER_MIN_VALUE, "The minimum value for the binning range.",
            Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, false));
    types.add(new ParameterTypeDouble(PARAMETER_MAX_VALUE, "The maximum value for the binning range.",
            Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, false));

    types.add(new ParameterTypeCategory(PARAMETER_RANGE_NAME_TYPE,
            "Indicates if long range names including the limits should be used.",
            DiscretizationModel.RANGE_NAME_TYPES, DiscretizationModel.RANGE_NAME_LONG));

    type = new ParameterTypeBoolean(PARAMETER_AUTOMATIC_NUMBER_OF_DIGITS,
            "Indicates if the number of digits should be automatically determined for the range names.", true);
    type.registerDependencyCondition(new EqualTypeCondition(this, PARAMETER_RANGE_NAME_TYPE,
            DiscretizationModel.RANGE_NAME_TYPES, false, DiscretizationModel.RANGE_NAME_INTERVAL));
    types.add(type);

    type = new ParameterTypeInt(PARAMETER_NUMBER_OF_DIGITS,
            "The minimum number of digits used for the interval names (-1: determine minimal number automatically).",
            -1, Integer.MAX_VALUE, -1);
    type.registerDependencyCondition(
            new BooleanParameterCondition(this, PARAMETER_AUTOMATIC_NUMBER_OF_DIGITS, false, false));
    types.add(type);

    return types;
}

From source file:de.saring.util.gui.jfreechart.StackedRenderer.java

/**
 * Returns the range of values the renderer requires to display all the
 * items from the specified dataset./*from  w  ww  .  j a  v a 2 s .c o m*/
 *
 * @param dataset the dataset (<code>null</code> permitted).
 * @return The range (or <code>null</code> if the dataset is
 *         <code>null</code> or empty).
 */
@Override
public Range findRangeBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    TableXYDataset d = (TableXYDataset) dataset;
    int itemCount = d.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        double[] stackValues = getStackValues((TableXYDataset) dataset, d.getSeriesCount(), i);
        min = Math.min(min, stackValues[0]);
        max = Math.max(max, stackValues[1]);
    }
    if (min == Double.POSITIVE_INFINITY) {
        return null;
    }
    return new Range(min, max);
}