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.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest.java

@Test
@LoadGraphWith(MODERN)// w ww  .  ja va  2s .c  o  m
public void g_V_hasLabelXpersonX_programXpageRank_rankX_order_byXrank_decrX_valueMapXname_rankX() {
    final Traversal<Vertex, Map<String, List<Object>>> traversal = get_g_V_hasLabelXpersonX_programXpageRank_rankX_order_byXrank_incrX_valueMapXname_rankX();
    printTraversalForm(traversal);
    int counter = 0;
    double lastRank = Double.MIN_VALUE;
    while (traversal.hasNext()) {
        final Map<String, List<Object>> map = traversal.next();
        assertEquals(2, map.size());
        assertEquals(1, map.get("name").size());
        assertEquals(1, map.get("rank").size());
        String name = (String) map.get("name").get(0);
        double rank = (Double) map.get("rank").get(0);
        assertTrue(rank >= lastRank);
        lastRank = rank;
        assertFalse(name.equals("lop") || name.equals("ripple"));
        counter++;
    }
    assertEquals(4, counter);
}

From source file:Questao3.java

/**
 * Metodo que retorna o maior valor da matriz
 * @param matriz//from w  w  w .  j ava 2 s .c  om
 * @return double max
 */
public double maxValue(double[][] matriz) {
    double max = Double.MIN_VALUE;
    for (double[] linha : matriz) {
        for (double d : linha) {
            if (d > max) {
                max = d;
            }
        }
    }
    return max;
}

From source file:ubic.BAMSandAllen.RankedGeneListLoader.java

public String writeEndSetGenes(boolean keepSign) throws Exception {
    List<String> topGenes = new LinkedList<String>();
    final int correlation_column = 1;
    final int gene_column = 2;
    String resultFilename = getResultFilename();
    CSVReader reader = new CSVReader(new FileReader(resultFilename));
    List<String[]> correlationLines = reader.readAll();
    double firstBaseLine = Double.parseDouble(correlationLines.get(0)[correlation_column]);

    boolean increase = firstBaseLine > 0;
    if (!keepSign)
        increase = !increase;//from  w w  w  . j av a2 s  . com

    List<String> rowsInFile = new LinkedList<String>();

    double apexCorrelation;

    if (increase)
        apexCorrelation = Double.MIN_VALUE;
    else
        apexCorrelation = Double.MAX_VALUE;

    // find the apex
    for (String[] line : correlationLines) {
        double correlation = Double.parseDouble(line[correlation_column]);
        if (increase && (apexCorrelation < correlation)) {
            apexCorrelation = correlation;
        }
        if (!increase && (apexCorrelation > correlation))
            apexCorrelation = correlation;
    }
    log.info("Peak correlation:" + apexCorrelation);

    int count = 0;
    boolean reachedApex = false;
    // get genes after the apex, could use index instead
    for (String[] line : correlationLines) {
        count++;
        String row = line[gene_column];
        rowsInFile.add(row);
        double correlation = Double.parseDouble(line[correlation_column]);

        if (correlation == apexCorrelation)
            reachedApex = true;

        if (reachedApex) {
            topGenes.add(row);
        }
    }

    // the results file maybe missing genes at the end, add them in
    List<String> addToEnd = new LinkedList<String>(lines);
    addToEnd.removeAll(rowsInFile);
    log.info("adding " + addToEnd.size() + " genes to end");
    topGenes.addAll(addToEnd);

    threshold = ((double) topGenes.size()) / lines.size();
    // round to 5 decimals
    threshold = Double.parseDouble(String.format("%.5g%n", threshold));

    String outFileName = filename + "." + topGenes.size() + "." + threshold + ".topGenes.txt";
    FileTools.stringsToFile(topGenes, new File(outFileName));
    log.info("Wrote file: " + outFileName);

    return outFileName;
}

From source file:org.apache.drill.exec.physical.impl.orderedpartitioner.TestOrderedPartitionExchange.java

/**
 * Starts two drillbits and runs a physical plan with a Mock scan, project, OrderedParititionExchange, Union Exchange,
 * and sort. The final sort is done first on the partition column, and verifies that the partitions are correct, in that
 * all rows in partition 0 should come in the sort order before any row in partition 1, etc. Also verifies that the standard
 * deviation of the size of the partitions is less than one tenth the mean size of the partitions, because we expect all
 * the partitions to be roughly equal in size.
 * @throws Exception//ww w.  ja v  a 2 s  .  co m
 */
@Test
public void twoBitTwoExchangeRun() throws Exception {
    RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();

    try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
            Drillbit bit2 = new Drillbit(CONFIG, serviceSet);
            DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) {

        bit1.run();
        bit2.run();
        client.connect();
        List<QueryDataBatch> results = client.runQuery(
                org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL,
                Files.toString(FileUtils.getResourceAsFile("/sender/ordered_exchange.json"), Charsets.UTF_8));
        int count = 0;
        List<Integer> partitionRecordCounts = Lists.newArrayList();
        for (QueryDataBatch b : results) {
            if (b.getData() != null) {
                int rows = b.getHeader().getRowCount();
                count += rows;
                RecordBatchLoader loader = new RecordBatchLoader(
                        new BootStrapContext(DrillConfig.create()).getAllocator());
                loader.load(b.getHeader().getDef(), b.getData());
                BigIntVector vv1 = (BigIntVector) loader.getValueAccessorById(BigIntVector.class, loader
                        .getValueVectorId(new SchemaPath("col1", ExpressionPosition.UNKNOWN)).getFieldIds())
                        .getValueVector();
                Float8Vector vv2 = (Float8Vector) loader.getValueAccessorById(Float8Vector.class, loader
                        .getValueVectorId(new SchemaPath("col2", ExpressionPosition.UNKNOWN)).getFieldIds())
                        .getValueVector();
                IntVector pVector = (IntVector) loader.getValueAccessorById(IntVector.class,
                        loader.getValueVectorId(new SchemaPath("partition", ExpressionPosition.UNKNOWN))
                                .getFieldIds())
                        .getValueVector();
                long previous1 = Long.MIN_VALUE;
                double previous2 = Double.MIN_VALUE;
                int partPrevious = -1;
                long current1 = Long.MIN_VALUE;
                double current2 = Double.MIN_VALUE;
                int partCurrent = -1;
                int partitionRecordCount = 0;
                for (int i = 0; i < rows; i++) {
                    previous1 = current1;
                    previous2 = current2;
                    partPrevious = partCurrent;
                    current1 = vv1.getAccessor().get(i);
                    current2 = vv2.getAccessor().get(i);
                    partCurrent = pVector.getAccessor().get(i);
                    Assert.assertTrue(current1 >= previous1);
                    if (current1 == previous1) {
                        Assert.assertTrue(current2 <= previous2);
                    }
                    if (partCurrent == partPrevious || partPrevious == -1) {
                        partitionRecordCount++;
                    } else {
                        partitionRecordCounts.add(partitionRecordCount);
                        partitionRecordCount = 0;
                    }
                }
                partitionRecordCounts.add(partitionRecordCount);
                loader.clear();
            }

            b.release();
        }
        double[] values = new double[partitionRecordCounts.size()];
        int i = 0;
        for (Integer rc : partitionRecordCounts) {
            values[i++] = rc.doubleValue();
        }
        StandardDeviation stdDev = new StandardDeviation();
        Mean mean = new Mean();
        double std = stdDev.evaluate(values);
        double m = mean.evaluate(values);
        System.out.println("mean: " + m + " std dev: " + std);
        //Assert.assertTrue(std < 0.1 * m);
        assertEquals(31000, count);
    }
}

From source file:android.support.test.espresso.web.model.ModelCodecTest.java

public void testEncodeDecode_map() {
    Map<String, Object> adhoc = Maps.newHashMap();
    adhoc.put("yellow", 1234);
    adhoc.put("bar", "frog");
    adhoc.put("int_max", Integer.MAX_VALUE);
    adhoc.put("int_min", Integer.MIN_VALUE);
    adhoc.put("double_min", Double.MIN_VALUE);
    adhoc.put("double_max", Double.MAX_VALUE);
    adhoc.put("sudz", Lists.newArrayList("goodbye"));
    assertEquals(adhoc, ModelCodec.decode(ModelCodec.encode(adhoc)));
}

From source file:edu.uci.ics.jung.algorithms.scoring.AbstractIterativeScorer.java

/**
 * Initializes the internal state for this instance.
 *//* www .j a v  a  2 s .c  om*/
protected void initialize() {
    this.total_iterations = 0;
    this.max_delta = Double.MIN_VALUE;
    this.output_reversed = true;
    this.current_values = new HashMap<V, T>();
    this.output = new HashMap<V, T>();
}

From source file:com.google.android.apps.forscience.whistlepunk.GraphPopulator.java

/**
 * If the graphStatus shows that there are still values that need to be fetched to fill the
 * currently-displayed graph, this method will begin fetching them.
 * <p/>/* w w w.  ja  v a  2 s  .c  o  m*/
 * Call only on the UI thread.
 */
public void requestObservations(final GraphStatus graphStatus, final DataController dataController,
        final FailureListener failureListener, final int resolutionTier, final String sensorId) {
    if (mRequestInFlight) {
        return;
    }
    final TimeRange r = getRequestRange(graphStatus);
    if (r == null) {
        mObservationDisplay.onFinish(mRequestId);
    } else {
        mRequestInFlight = true;
        dataController.getScalarReadings(sensorId, resolutionTier, r, MAX_DATAPOINTS_PER_SENSOR_LOAD,
                MaybeConsumers.chainFailure(failureListener, new FallibleConsumer<ScalarReadingList>() {
                    @Override
                    public void take(ScalarReadingList observations) {
                        mRequestInFlight = false;
                        if (graphStatus.graphIsStillValid()) {
                            final Pair<Range<Long>, Range<Double>> received = addObservationsToDisplay(
                                    observations);
                            if (received.first != null) {
                                mObservationDisplay.addRange(observations, received.second, mRequestId);
                            }
                            addToRequestedTimes(getEffectiveAddedRange(r, received.first));
                            requestObservations(graphStatus, dataController, failureListener, resolutionTier,
                                    sensorId);
                        }
                    }

                    public void addToRequestedTimes(Range<Long> effectiveAdded) {
                        mRequestedTimes = Ranges.span(mRequestedTimes, effectiveAdded);
                    }

                    public Pair<Range<Long>, Range<Double>> addObservationsToDisplay(
                            ScalarReadingList observations) {
                        List<ScalarReading> points = ScalarReading.slurp(observations);
                        long xMin = Long.MAX_VALUE;
                        long xMax = Long.MIN_VALUE;
                        double yMin = Double.MAX_VALUE;
                        double yMax = Double.MIN_VALUE;
                        Range<Long> timeRange = null;
                        Range<Double> valueRange = null;
                        for (ScalarReading point : points) {
                            if (point.getCollectedTimeMillis() < xMin) {
                                xMin = point.getCollectedTimeMillis();
                            }
                            if (point.getCollectedTimeMillis() > xMax) {
                                xMax = point.getCollectedTimeMillis();
                            }
                            if (point.getValue() < yMin) {
                                yMin = point.getValue();
                            }
                            if (point.getValue() > yMax) {
                                yMax = point.getValue();
                            }
                        }
                        if (xMin <= xMax) {
                            timeRange = Range.closed(xMin, xMax);
                        }
                        if (yMin <= yMax) {
                            valueRange = Range.closed(yMin, yMax);
                        }
                        return new Pair<>(timeRange, valueRange);
                    }
                }));
    }
    return;
}

From source file:net.ymate.platform.configuration.provider.impl.JConfigProvider.java

public double getDouble(String key) {
    return getDouble(key, Double.MIN_VALUE);
}

From source file:edu.scripps.fl.curves.plot.CurvePlot.java

public void addCurveAllPoints(Curve curve, FitFunction fitFunction, String description) {
    double min = Double.MAX_VALUE, max = Double.MIN_VALUE;
    YIntervalSeries validSeries = new YIntervalSeries(description);
    validSeries.setDescription(description);
    YIntervalSeries invalidSeries = new YIntervalSeries("");
    for (int ii = 0; ii < curve.getConcentrations().size(); ii++) {
        Double c = curve.getConcentrations().get(ii);
        Double r = curve.getResponses().get(ii);
        if (curve.getMask().get(ii))
            validSeries.add(c, r, r, r);
        else/*from  w ww  .  ja v  a  2s  . com*/
            invalidSeries.add(c, r, r, r);
        min = Math.min(min, c);
        max = Math.max(max, c);
    }
    addCurve(curve, validSeries, invalidSeries, fitFunction, min, max);
}

From source file:co.turnus.analysis.bottlenecks.AlgorithmicBottlenecks.java

protected HotspotsData find(Table<String, String, Double> ratiosTable) {
    // check if the trace should be initialised
    initTrace();// w ww .  j  a v a  2 s  .  com

    Trace trace = project.getTrace();
    Network network = project.getNetwork();
    HotSpotsDataCollector collector = new HotSpotsDataCollector(network);
    iterationId++;

    Step tStep = null;
    double cpValue = Double.MIN_VALUE;
    for (long stepId = 0; stepId < trace.getLength(); stepId++) {
        Step step = trace.getStep(stepId);

        double es = 0.0;
        for (Dependency in : step.getIncomings()) {
            double tmp = in.getSource().getAttribute(EARLY_FINISH + iterationId);
            es = FastMath.max(tmp, es);
        }

        // evaluate early start and finish time
        double[] cl = getWeight(step, ratiosTable);
        double ef = es + cl[MEAN];
        step.setAttribute(EARLY_START + iterationId, es);
        step.setAttribute(EARLY_FINISH + iterationId, ef);

        if (ef > cpValue) {
            cpValue = ef;
            tStep = step;
        }
    }

    for (long stepId = trace.getLength() - 1; stepId >= 0; stepId--) {
        Step step = trace.getStep(stepId);

        double lf = cpValue;
        for (Dependency out : step.getOutgoings()) {
            double tmp = out.getTarget().getAttribute(LATEST_START + iterationId);
            lf = FastMath.min(tmp, lf);
        }

        double[] cl = getWeight(step, ratiosTable);
        double ls = lf - cl[MEAN];
        step.setAttribute(LATEST_FINISH + iterationId, lf);
        step.setAttribute(LATEST_START + iterationId, ls);

        double ef = step.getAttribute(EARLY_FINISH + iterationId);
        double slack = lf - ef;
        step.setAttribute(SLACK + iterationId, slack);

        // log computational load with the slack
        collector.addExecution(step, cl, slack);
    }

    // Walk back the critical path following the early finish gradient
    Step next = tStep;
    Set<Step> predecessors = new HashSet<>();
    while (next != null) {
        collector.addCriticalExecution(next, getWeight(next, ratiosTable));

        predecessors.clear();
        for (Dependency in : next.getIncomings()) {
            predecessors.add(in.getSource());
        }

        next = null;
        double efMax = Double.MIN_VALUE;
        for (Step s : predecessors) {
            // it's the same as the partial critical path
            double ef = s.getAttribute(EARLY_FINISH + iterationId);
            if (ef > efMax) {
                efMax = ef;
                next = s;
            }
        }
    }

    return collector.getResults();
}