Example usage for java.lang Double Double

List of usage examples for java.lang Double Double

Introduction

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

Prototype

@Deprecated(since = "9")
public Double(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Double object that represents the floating-point value of type double represented by the string.

Usage

From source file:bigtweet.model.StudyingBeacons.java

@Override
public void updateMetricsForParametersValues(JSONArray parametersValues, int parametersValuesIndex) {
    DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.US);
    DecimalFormat df = new DecimalFormat("0.000", otherSymbols);

    //get infected array for each seed

    double infected[] = new double[seedAndStates.values().size()];

    for (int i = 0; i < infected.length; i++) {
        //number of infected for each seed            
        //System.out.println(  ((Map<String,Integer>) (seedAndStates.values().toArray()[i])).get("INFECTED"));
        infected[i] = (new Double(
                ((Map<String, Integer>) (seedAndStates.values().toArray()[i])).get("ENDORSER")));
    }/*from   w ww .  j  a  va  2s .c  o m*/

    //get metrics for this experiment and this dataset
    double minInfected = (new Min()).evaluate(infected);
    double mean = (new Mean()).evaluate(infected);
    double sd = (new StandardDeviation()).evaluate(infected);

    //put in metricsForLastExperiment, JSON object
    metricsForLastExperiment = new JSONObject();//create new object for the last experiment    
    metricsForLastExperiment.put("minEndorsers", df.format(minInfected));
    metricsForLastExperiment.put("mean", df.format(mean));
    metricsForLastExperiment.put("sd", df.format(sd));

    JSONObject statesJSON = new JSONObject();
    for (Map.Entry<Long, Map<String, Integer>> entry : seedAndStates.entrySet()) {
        statesJSON.put(entry.getKey().toString(), entry.getValue());
    }

    metricsForLastExperiment.put("randomSeedsAndStates", statesJSON);

    //update metrics for all experiments

    if (mean < this.bestMean) {
        //System.out.println(name + " bestmean " + df.format(bestMean).toString() + " mean " + df.format(mean).toString());
        bestMean = mean;
        experimentWithBestMean = parametersValuesIndex;
        metricsForAllExperiments.put("bestMean", df.format(bestMean));
        metricsForAllExperiments.put("experimentWithBestMean", parametersValuesIndex);
    }
    if (minInfected < this.bestEndorser) {

        bestEndorser = minInfected;
        experimentWithBestEndorser = parametersValuesIndex;
        metricsForAllExperiments.put("bestEndorsers", df.format(minInfected));
        metricsForAllExperiments.put("experimentWithBestEndorsers", parametersValuesIndex);
    }

    generateBatchOuputForChart(parametersValues, parametersValuesIndex, mean);

}

From source file:com.projity.functor.NumberClosure.java

public void setDoubleValue(double d) {
    value = new Double(d);
}

From source file:com.neovisionaries.security.DigestTest.java

@Test
public void test2() {
    List<Number> list = new ArrayList<Number>();
    list.add(new Byte((byte) 1));
    list.add(new Short((short) 2));
    list.add(new Integer(3));
    list.add(new Long(4));
    list.add(new Float(5));
    list.add(new Double(6));

    String digest1 = sha1().update(list).digestAsString();

    String digest2 = sha1().update((byte) 1).update((short) 2).update(3).update((long) 4).update((float) 5)
            .update((double) 6).digestAsString();

    assertEquals(digest1, digest2);/*from   www .j  a  v  a 2 s  . co  m*/
}

From source file:com.adaptris.core.services.jdbc.types.StringColumnTranslatorTest.java

@Test
public void testAsFormattedDoubleTranslator() throws Exception {
    translator.setFormat("%f");
    JdbcResultRow row = new JdbcResultRow();
    row.setFieldValue("testField", new Double(111), Types.VARCHAR);
    {//from   ww  w .  j  a  v a 2s. co m
        String translated = translator.translate(row, 0);
        assertEquals("111.000000", translated);
    }
    {
        String translated = translator.translate(row, "testField");
        assertEquals("111.000000", translated);
    }
}

From source file:edu.illinois.ncsa.versus.engine.impl.ComprehensiveEngine.java

/**
 * Compute all comparisons and then linearly combine the results based on
 * weights.// ww  w  . jav a  2 s.  c  o m
 * 
 * @param comparisons
 * @param weights
 * @return
 */
public Double compute(List<PairwiseComparison> comparisons, List<Double> weights) {
    log.debug("Submitting all comparisons");
    List<Future<Proximity>> results = new ArrayList<Future<Proximity>>(comparisons.size());
    for (int i = 0; i < comparisons.size(); i++) {
        ComputeCallable computeCallable = new ComputeCallable(comparisons.get(i));
        Future<Proximity> result = newFixedThreadPool.submit(computeCallable);
        results.add(result);
    }
    log.debug("Submission of comparisons done");
    Double sum = new Double(0);
    log.debug("Computing linear combination");
    for (int i = 0; i < results.size(); i++) {
        try {
            double value = results.get(i).get().getValue();
            double weight = weights.get(i);
            sum += value * weight;
            log.debug("Added proximity " + value + " with weight " + weight);
        } catch (InterruptedException e) {
            log.error("Error retrieving result of comparison", e);
        } catch (ExecutionException e) {
            log.error("Error retrieving result of comparison", e);
        }
    }
    log.debug("Linear combintation finished. Result is " + sum);
    return sum;
}

From source file:nz.co.senanque.validationengine.ConvertUtils.java

public static Object convertToObject(Class<?> clazz) {
    if (clazz.isPrimitive()) {
        if (clazz.equals(Long.TYPE)) {
            return new Long(0L);
        } else if (clazz.equals(Integer.TYPE)) {
            return new Integer(0);
        } else if (clazz.equals(Float.TYPE)) {
            return new Float(0F);
        } else if (clazz.equals(Double.TYPE)) {
            return new Double(0D);
        } else if (clazz.equals(Boolean.TYPE)) {
            return new Boolean(false);
        }/*w ww . j av  a 2s . com*/
    }
    return null;

}

From source file:com.ebay.jetstream.event.processor.esper.ESPTest.java

private JetstreamEvent generateESPAggregationTestEvent(int id) {
    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("field_id", id);
    map.put("field", new Double(id));
    return new JetstreamEvent("ESPAggregationTestEvent", null, map);
}

From source file:com.devoteam.srit.xmlloader.core.report.derived.DerivedCounter.java

public DerivedCounter(long endTimestamp, long zeroTimestamp, StatCounter counter) throws ParsingException {
    this.counter = counter.clone();
    mean = std_dv = new Double(0);
    this.reportEndTimestamp = endTimestamp;
    this.reportZeroTimestamp = zeroTimestamp;
    this.createCharts = Config.getConfigByName("tester.properties")
            .getBoolean("stats.GENERATE_CHARTS_PICTURES");
    this.createCSVs = Config.getConfigByName("tester.properties").getBoolean("stats.GENERATE_CHARTS_CSVS");
    this.csvSeparator = ';';
}

From source file:org.jfree.data.category.DefaultCategoryDatasetTest.java

/**
 * Some checks for the incrementValue() method.
 *//*w w w . j a  v a 2s.  c  o m*/
public void testIncrementValue() {
    DefaultCategoryDataset d = new DefaultCategoryDataset();
    d.addValue(1.0, "R1", "C1");
    d.incrementValue(2.0, "R1", "C1");
    assertEquals(new Double(3.0), d.getValue("R1", "C1"));

    // increment a null value
    d.addValue(null, "R2", "C1");
    d.incrementValue(2.0, "R2", "C1");
    assertEquals(new Double(2.0), d.getValue("R2", "C1"));

    // increment an unknown row
    boolean pass = false;
    try {
        d.incrementValue(1.0, "XX", "C1");
    } catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);

    // increment an unknown column
    pass = false;
    try {
        d.incrementValue(1.0, "R1", "XX");
    } catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);
}