Example usage for java.lang Double MIN_VALUE

List of usage examples for java.lang Double MIN_VALUE

Introduction

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

Prototype

double MIN_VALUE

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

Click Source Link

Document

A constant holding the smallest positive nonzero value of type double , 2-1074.

Usage

From source file:org.fhcrc.cpl.toolbox.statistics.BasicStatistics.java

public static double max(double[] values) {
    double maxValue = Double.MIN_VALUE;
    for (double value : values)
        if (value > maxValue)
            maxValue = value;/*from w ww.ja  v  a 2 s  .  c o  m*/
    return maxValue;
}

From source file:org.bdval.modelconditions.RestatMode.java

@Override
public void processSeries(final ProcessModelConditionsOptions options, final String modelId) {

    // group together models that are in the same series?
    final String seriesID = options.modelConditions.get(modelId).get("id-parameter-scan-series");

    if (!(series.contains(seriesID))) { // This series has not been processed before.

        final ArrayList<String> models = extractSeriesModelIds(options, seriesID);

        // for all models in a series get accuracy measures for each fold,
        for (final String modelInSeries : models) {
            processOneModelIdPassOne(options, modelInSeries);
        }/*from   ww  w. j  a  v  a 2s . com*/

        // across the series, record accuracy obtained by model with maximum accuracy for each fold/repeat element.

        final Map<String, double[]> foldMins = new HashMap<String, double[]>();
        final double[] accuracyArray = new double[numberOfFolds * numberOfRepeats];
        Arrays.fill(accuracyArray, Double.MIN_VALUE);

        for (final String modelInSeries : models) {
            final double[] modelAccuracies = acrossAllFoldsMap.get(modelInSeries);
            if (modelAccuracies == null) {
                // could not load prediction file  for this model.
                continue;
            }
            int index = 0; // maintain s the index in the model accuracies array

            for (int r = 0; r < numberOfRepeats; r++) {
                for (int c = 0; c < numberOfFolds; c++) {
                    if (index >= accuracyArray.length || index >= modelAccuracies.length) {
                        break;
                    }
                    accuracyArray[index] = Math.max(modelAccuracies[index], accuracyArray[index]);
                    ++index;
                }
            }
        }
        foldMins.put(seriesID, accuracyArray);

        // now calculate bias for this  series
        evaluateSeriesBias(options, seriesID, models, acrossAllFoldsMap, foldMins);

        // record that the series has already been processed:
        series.add(seriesID);
    }
}

From source file:edu.stanford.slac.archiverappliance.PB.data.StatusSeverityTest.java

private DBR getJCASampleValue(ArchDBRTypes type, int value, int severity, int status) {
    switch (type) {
    case DBR_SCALAR_STRING:
        DBR_TIME_String retvalss = new DBR_TIME_String(new String[] { Integer.toString(value) });
        retvalss.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retvalss.setSeverity(severity);/*  w  w w . j  av a2s. co m*/
        retvalss.setStatus(status);
        return retvalss;
    case DBR_SCALAR_SHORT:
        DBR_TIME_Short retvalsh;
        if (0 <= value && value < 1000) {
            // Check for some numbers around the minimum value
            retvalsh = new DBR_TIME_Short(new short[] { (short) (Short.MIN_VALUE + value) });
        } else if (1000 <= value && value < 2000) {
            // Check for some numbers around the maximum value
            retvalsh = new DBR_TIME_Short(new short[] { (short) (Short.MAX_VALUE - (value - 1000)) });
        } else {
            // Check for some numbers around 0
            retvalsh = new DBR_TIME_Short(new short[] { (short) (value - 2000) });
        }
        retvalsh.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retvalsh.setSeverity(severity);
        retvalsh.setStatus(status);
        return retvalsh;
    case DBR_SCALAR_FLOAT:
        DBR_TIME_Float retvalfl;
        if (0 <= value && value < 1000) {
            // Check for some numbers around the minimum value
            retvalfl = new DBR_TIME_Float(new float[] { Float.MIN_VALUE + value });
        } else if (1000 <= value && value < 2000) {
            // Check for some numbers around the maximum value
            retvalfl = new DBR_TIME_Float(new float[] { Float.MAX_VALUE - (value - 1000) });
        } else {
            // Check for some numbers around 0. Divide by a large number to make sure we cater to the number of precision digits
            retvalfl = new DBR_TIME_Float(new float[] { (value - 2000.0f) / value });
        }
        retvalfl.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retvalfl.setSeverity(severity);
        retvalfl.setStatus(status);
        return retvalfl;
    case DBR_SCALAR_ENUM:
        DBR_TIME_Enum retvalen;
        retvalen = new DBR_TIME_Enum(new short[] { (short) (value) });
        retvalen.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retvalen.setSeverity(severity);
        retvalen.setStatus(status);
        return retvalen;
    case DBR_SCALAR_BYTE:
        DBR_TIME_Byte retvalby;
        retvalby = new DBR_TIME_Byte(new byte[] { ((byte) (value % 255)) });
        retvalby.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retvalby.setSeverity(severity);
        retvalby.setStatus(status);
        return retvalby;
    case DBR_SCALAR_INT:
        DBR_TIME_Int retvalint;
        if (0 <= value && value < 1000) {
            // Check for some numbers around the minimum value
            retvalint = new DBR_TIME_Int(new int[] { Integer.MIN_VALUE + value });
        } else if (1000 <= value && value < 2000) {
            // Check for some numbers around the maximum value
            retvalint = new DBR_TIME_Int(new int[] { Integer.MAX_VALUE - (value - 1000) });
        } else {
            // Check for some numbers around 0
            retvalint = new DBR_TIME_Int(new int[] { (value - 2000) });
        }
        retvalint.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retvalint.setSeverity(severity);
        retvalint.setStatus(status);
        return retvalint;
    case DBR_SCALAR_DOUBLE:
        DBR_TIME_Double retvaldb;
        if (0 <= value && value < 1000) {
            // Check for some numbers around the minimum value
            retvaldb = new DBR_TIME_Double(new double[] { (Double.MIN_VALUE + value) });
        } else if (1000 <= value && value < 2000) {
            // Check for some numbers around the maximum value
            retvaldb = new DBR_TIME_Double(new double[] { (Double.MAX_VALUE - (value - 1000)) });
        } else {
            // Check for some numbers around 0. Divide by a large number to make sure we cater to the number of precision digits
            retvaldb = new DBR_TIME_Double(new double[] { ((value - 2000.0) / (value * 1000000)) });
        }
        retvaldb.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retvaldb.setSeverity(severity);
        retvaldb.setStatus(status);
        return retvaldb;
    case DBR_WAVEFORM_STRING:
        DBR_TIME_String retvst;
        // Varying number of copies of a typical value
        retvst = new DBR_TIME_String(
                Collections.nCopies(value, Integer.toString(value)).toArray(new String[0]));
        retvst.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retvst.setSeverity(severity);
        retvst.setStatus(status);
        return retvst;
    case DBR_WAVEFORM_SHORT:
        DBR_TIME_Short retvsh;
        retvsh = new DBR_TIME_Short(
                ArrayUtils.toPrimitive(Collections.nCopies(1, (short) value).toArray(new Short[0])));
        retvsh.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retvsh.setSeverity(severity);
        retvsh.setStatus(status);
        return retvsh;
    case DBR_WAVEFORM_FLOAT:
        DBR_TIME_Float retvf;
        // Varying number of copies of a typical value
        retvf = new DBR_TIME_Float(ArrayUtils.toPrimitive(
                Collections.nCopies(value, (float) Math.cos(value * Math.PI / 3600)).toArray(new Float[0])));
        retvf.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retvf.setSeverity(severity);
        retvf.setStatus(status);
        return retvf;
    case DBR_WAVEFORM_ENUM:
        DBR_TIME_Enum retven;
        retven = new DBR_TIME_Enum(
                ArrayUtils.toPrimitive(Collections.nCopies(1024, (short) value).toArray(new Short[0])));
        retven.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retven.setSeverity(severity);
        retven.setStatus(status);
        return retven;
    case DBR_WAVEFORM_BYTE:
        DBR_TIME_Byte retvb;
        // Large number of elements in the array
        retvb = new DBR_TIME_Byte(ArrayUtils
                .toPrimitive(Collections.nCopies(65536 * value, ((byte) (value % 255))).toArray(new Byte[0])));
        retvb.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retvb.setSeverity(severity);
        retvb.setStatus(status);
        return retvb;
    case DBR_WAVEFORM_INT:
        DBR_TIME_Int retvint;
        // Varying number of copies of a typical value
        retvint = new DBR_TIME_Int(
                ArrayUtils.toPrimitive(Collections.nCopies(value, value * value).toArray(new Integer[0])));
        retvint.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retvint.setSeverity(severity);
        retvint.setStatus(status);
        return retvint;
    case DBR_WAVEFORM_DOUBLE:
        DBR_TIME_Double retvd;
        // Varying number of copies of a typical value
        retvd = new DBR_TIME_Double(ArrayUtils.toPrimitive(
                Collections.nCopies(value, Math.sin(value * Math.PI / 3600)).toArray(new Double[0])));
        retvd.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value));
        retvd.setSeverity(severity);
        retvd.setStatus(status);
        return retvd;
    case DBR_V4_GENERIC_BYTES:
        throw new RuntimeException("Currently don't support " + type + " when generating sample data");
    default:
        throw new RuntimeException("We seemed to have missed a DBR type when generating sample data");
    }
}

From source file:sbu.srl.rolextract.SBURolePredict.java

public static Object getBestArgument(ParseResult parseResult, String targetText) {
    List<Predicate> predicates = parseResult.getPredicates();
    List<Argument> arguments = new ArrayList<Argument>();

    for (Predicate predicate : predicates) {
        arguments.addAll(predicate.getArguments());
    }/*from  w w w  .  j  a v  a  2  s .c o m*/
    ArrayList<Object> overlappedSpans = new ArrayList<>();
    int minimumDistance = Integer.MAX_VALUE;
    boolean overlapping = false;
    for (Predicate predicate : predicates) {
        if (isOverlapping(predicate.getText(), targetText)) {
            minimumDistance = Math.min(minimumDistance,
                    StringUtils.getLevenshteinDistance(targetText, predicate.getText()));
            overlapping = true;
        }
    }
    for (Argument argument : arguments) {
        if (isOverlapping(targetText, argument.getText())) {
            minimumDistance = Math.min(minimumDistance,
                    StringUtils.getLevenshteinDistance(targetText, argument.getText()));
            overlapping = true;
        }
    }
    if (!overlapping) {
        return null; // NONE
    }
    for (Predicate predicate : predicates) {
        if (StringUtils.getLevenshteinDistance(targetText, predicate.getText()) == minimumDistance) {
            overlappedSpans.add(predicate);
        }
    }
    for (Argument argument : arguments) {
        if (StringUtils.getLevenshteinDistance(targetText, argument.getText()) == minimumDistance) {
            overlappedSpans.add(argument);
        }
    }
    if (overlappedSpans.size() > 1) {
        double maxScore = Double.MIN_VALUE;
        Object bestSpan = null;
        for (Object obj : overlappedSpans) {
            if (obj instanceof Predicate) {
                if (((Predicate) obj).getScore() > maxScore) {
                    maxScore = ((Predicate) obj).getScore();
                    bestSpan = ((Predicate) obj);
                }
            } else {
                if (((Argument) obj).getArgScore() > maxScore) {
                    maxScore = ((Argument) obj).getArgScore();
                    bestSpan = ((Argument) obj);
                }
            }
        }
        return bestSpan;
    } else {
        return overlappedSpans.get(0);
    }
}

From source file:ome.server.itests.query.pojos.QueryTest.java

private void assertFloatsNotRounded(double dbl) {
    Correction correction = iQuery.findAll(Correction.class, null).get(0);
    Immersion immersion = iQuery.findAll(Immersion.class, null).get(0);

    Objective o = new Objective();
    Instrument instrument = new Instrument();
    o.setCorrection(correction);//from  w w  w  . jav  a 2  s . co m
    o.setImmersion(immersion);
    o.setInstrument(instrument);
    // o.setLensNA(new Float(dbl));
    o.setLensNA(dbl);

    Objective t1 = iUpdate.saveAndReturnObject(o);

    // Test value via jdbc
    String jdbcQuery = "SELECT lensNa FROM Objective WHERE id = :id";
    Float lensNA = (Float) iQuery.projection(jdbcQuery, new Parameters().addId(t1.getId())).get(0)[0];
    assertEquals(dbl, lensNA.floatValue(), 0.01);
    try {
        assertEquals(dbl, lensNA.floatValue(), Float.MIN_VALUE);
    } catch (AssertionFailedError e) {
        // This is what fails!!
    }

    // now test is with double which is our chosen solution
    Double lensNADoubled = (Double) iQuery.projection(jdbcQuery, new Parameters().addId(t1.getId())).get(0)[0];
    assertEquals(dbl, lensNADoubled.doubleValue(), 0.01);
    assertEquals(dbl, lensNADoubled.doubleValue(), Float.MIN_VALUE);
    assertEquals(dbl, lensNADoubled.doubleValue(), Double.MIN_VALUE);

    // Test value return by iUpdate
    // Now changing these to doubleValue() post #1150 fix.
    assertEquals(dbl, t1.getLensNA().doubleValue(), 0.001);
    assertEquals(dbl, t1.getLensNA().doubleValue(), Float.MIN_VALUE);
    assertEquals(dbl, t1.getLensNA().doubleValue());

    // Test via query
    Objective t2 = iQuery.find(Objective.class, o.getId());
    assertEquals(dbl, t2.getLensNA().doubleValue());
}

From source file:javalibs.CSVDataNormalizer.java

private Pair getMaxMinFromLinkedColumns(String columnName) {
    List<String> cols = this.columnsWithLinkings.get(columnName);
    // Also need to look at the primary column name
    cols.add(columnName);/*w w w  .  j  a  va2 s  . c  o  m*/
    double max = Double.MIN_VALUE;
    double min = Double.MAX_VALUE;

    for (String col : cols) {
        Pair<Double, Double> maxMin = getMaxMinFromCol(col);
        if (maxMin.left() > max)
            max = maxMin.left();
        if (maxMin.right() < min)
            min = maxMin.right();
    }

    return new Pair(max, min);
}

From source file:de.tuberlin.uebb.jdae.simulation.PendulumTest.java

@Test
public void testLongSimulationVariableStep() {

    dae.data[1][0] = 0.1;/*from   w ww.  j  a va  2s .  c  o m*/
    dae.initialize();

    runtime.simulateVariableStep(dae, SIM_TEST_STOP_TIME, Double.MIN_VALUE, Double.MAX_VALUE, 1e-6, 1e-6);

    assertEquals(SIM_TEST_STOP_TIME, dae.data[0][0], 1e-8);
    assertThat(runtime.lastResults().results.size(), is(greaterThan(1)));
}

From source file:org.apache.sysml.runtime.controlprogram.parfor.opt.CostEstimator.java

protected double getMaxEstimate(TestMeasure measure, ArrayList<OptNode> nodes, ExecType et)
        throws DMLRuntimeException {
    double max = Double.MIN_VALUE; //smallest positive value
    for (OptNode n : nodes) {
        double tmp = getEstimate(measure, n, et);
        if (tmp > max)
            max = tmp;/*from  w  w w  . jav  a2 s .c o  m*/
    }
    return max;
}

From source file:com.streamsets.pipeline.stage.origin.jdbc.table.AllTypesIT.java

private static void populateRecords() {
    Record record = RecordCreator.create();
    LinkedHashMap<String, Field> fields;
    AtomicInteger id_field = new AtomicInteger(0);

    //CHAR_AND_BINARY
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);/* w w  w . ja v  a  2 s  .  co m*/
    fields.put("char1", Field.create("abcdefghij"));
    fields.put("varchar1", Field.create(UUID.randomUUID().toString()));
    fields.put("clob1", Field.create(UUID.randomUUID().toString()));
    fields.put("varbinary1", Field.create(UUID.randomUUID().toString().getBytes()));
    fields.put("blob1", Field.create(UUID.randomUUID().toString().getBytes()));
    record.set(Field.createListMap(fields));

    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("CHAR_AND_BINARY").getRight().add(record);

    //Date and time
    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    Calendar calendar = Calendar.getInstance();

    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    fields.put("date1", Field.create(Field.Type.DATE, calendar.getTime()));
    calendar.setTimeInMillis(System.currentTimeMillis());

    calendar.set(Calendar.MILLISECOND, 0);
    fields.put("timestamp1", Field.create(Field.Type.DATETIME, calendar.getTime()));
    fields.put("datetime1", Field.create(Field.Type.DATETIME, calendar.getTime()));
    calendar.setTimeInMillis(System.currentTimeMillis());

    calendar.set(Calendar.YEAR, 1970);
    calendar.set(Calendar.MONTH, Calendar.JANUARY);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    calendar.set(Calendar.MILLISECOND, 0);
    fields.put("time1", Field.create(Field.Type.TIME, calendar.getTime()));
    calendar.setTimeInMillis(System.currentTimeMillis());

    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("DATE_AND_TIME").getRight().add(record);

    //DIFFERENT_INTS
    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    fields.put("int1", Field.create(Field.Type.INTEGER, Integer.MIN_VALUE));
    fields.put("int2", Field.create(Field.Type.INTEGER, Integer.MIN_VALUE));
    fields.put("mediumint1", Field.create(Field.Type.INTEGER, Integer.MIN_VALUE));
    fields.put("tinyint1", Field.create(Field.Type.SHORT, -128));
    fields.put("smallint1", Field.create(Field.Type.SHORT, Short.MIN_VALUE));
    fields.put("bigint1", Field.create(Field.Type.LONG, Long.MIN_VALUE));
    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("DIFFERENT_INTS").getRight().add(record);

    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    fields.put("int1", Field.create(Field.Type.INTEGER, Integer.MAX_VALUE));
    fields.put("int2", Field.create(Field.Type.INTEGER, Integer.MAX_VALUE));
    fields.put("mediumint1", Field.create(Field.Type.INTEGER, Integer.MAX_VALUE));
    fields.put("tinyint1", Field.create(Field.Type.SHORT, 127));
    fields.put("smallint1", Field.create(Field.Type.SHORT, Short.MAX_VALUE));
    fields.put("bigint1", Field.create(Field.Type.LONG, Long.MAX_VALUE));
    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("DIFFERENT_INTS").getRight().add(record);

    //FLOATING_PT_INTS
    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    fields.put("decimal1", Field.create(Field.Type.DECIMAL, new BigDecimal("12.345")));
    fields.put("number1", Field.create(Field.Type.DECIMAL, new BigDecimal("0.12345")));
    fields.put("double1", Field.create(Field.Type.DOUBLE, 123.456));
    fields.put("real1", Field.create(Field.Type.FLOAT, 12.34));
    fields.put("floatdouble1", Field.create(Field.Type.DOUBLE, Double.MAX_VALUE));
    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("FLOATING_PT_INTS").getRight().add(record);

    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    fields.put("decimal1", Field.create(Field.Type.DECIMAL, new BigDecimal("-12.345")));
    fields.put("number1", Field.create(Field.Type.DECIMAL, new BigDecimal("-0.12345")));
    fields.put("double1", Field.create(Field.Type.DOUBLE, -123.456));
    fields.put("real1", Field.create(Field.Type.FLOAT, -12.34));
    fields.put("floatdouble1", Field.create(Field.Type.DOUBLE, Double.MIN_VALUE));
    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("FLOATING_PT_INTS").getRight().add(record);

    //OTHER_TYPES
    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    fields.put("boolean1", Field.create(Field.Type.BOOLEAN, true));
    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("OTHER_TYPES").getRight().add(record);

    record = RecordCreator.create();
    fields = new LinkedHashMap<>();
    createIdField(fields, id_field);
    fields.put("boolean1", Field.create(Field.Type.BOOLEAN, false));
    record.set(Field.createListMap(fields));
    TABLE_TO_TEMPLATE_AND_RECORDS_MAP.get("OTHER_TYPES").getRight().add(record);
}

From source file:net.sf.javaml.tools.DatasetTools.java

/**
 * Finds the double[][] array where the first index reflects the attributes
 * and the second index the minimum (index 0) and maximum (index 1) of the
 * attributes.// w  ww  . ja  v  a2  s . c  om
 * 
 * @param data
 *            data set to compute this array for
 * 
 * @return a two-dimensional array with the minimum and maximum values per
 *         attribute
 */
private static double[][] getMinMax(Dataset data) {
    final int noAttributes = data.get(0).noAttributes();
    final int noInstances = data.size();
    final int MIN_INDEX = 0;
    final int MAX_INDEX = 1;

    // second index contains min and max -> therefore size = 2
    double[][] ret = new double[noAttributes][2];

    // reset min and max indices to Double.MAX_VALUE and Double.MIN_VALUE
    // resp;
    for (int a = 0; a < noAttributes; a++) {
        ret[a][MIN_INDEX] = Double.MAX_VALUE;
        ret[a][MAX_INDEX] = Double.MIN_VALUE;
    }

    // find min and max for each attribute
    double attrVal;
    Instance instance = null;
    for (int i = 0; i < noInstances; i++) { // for each instance
        instance = data.get(i);
        for (int a = 0; a < noAttributes; a++) { // for each attribute
            attrVal = instance.value(a);
            if (attrVal < ret[a][MIN_INDEX])
                ret[a][MIN_INDEX] = attrVal;
            if (attrVal > ret[a][MAX_INDEX])
                ret[a][MAX_INDEX] = attrVal;

        }
    }
    return ret;
}