Example usage for java.lang Double doubleValue

List of usage examples for java.lang Double doubleValue

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public double doubleValue() 

Source Link

Document

Returns the double value of this Double object.

Usage

From source file:com.clican.pluto.dataprocess.dpl.function.impl.TrackError.java

/**
 * @param rowSet//from   w ww .j  a v a  2s.co  m
 *            List
 * @see com.clican.pluto.dataprocess.dpl.function.MultiRowFunction#calculate(java.util.List)
 */

public Object calculate(List<Map<String, Object>> rowSet)
        throws CalculationException, PrefixAndSuffixException {
    if (rowSet == null || rowSet.size() == 0) {
        throw new CalculationException("??");
    }

    double[] values = new double[rowSet.size()];
    double sum = 0;
    for (int i = 0; i < rowSet.size(); i++) {
        Map<String, Object> row = rowSet.get(i);
        Double fundValue = fundNavList.getValue(row);
        Double indexValue = indexList.getValue(row);
        double value = fundValue.doubleValue() - indexValue.doubleValue();
        values[i] = value;
        sum += value;
    }
    double avg = sum / (rowSet.size());

    Variance var = new Variance(false);
    Double result = Math.sqrt(var.evaluate(values, avg));

    return result;
}

From source file:edu.jhuapl.bsp.detector.OpenMath.java

public static double median(double[] in) {
    if (in != null) {
        if (in.length > 0) {
            double[] d = new double[in.length];
            for (int i = 0; i < in.length; i++) {
                d[i] = in[i];//from w ww . j a  v a 2 s .c  om
            }
            Arrays.sort(d);
            Double median = null;
            int index = (int) Math.ceil(d.length / 2);
            if ((d.length & 1) == 1) {
                median = new Double(d[index]);
            } else {
                median = new Double((d[index] + d[index - 1]) / 2.0);
            }
            if (median.isNaN() || median.isInfinite()) {
                return 0.0;
            } else {
                return median.doubleValue();
            }
        } else {
            return 0.0;
        }
    }
    return 0.0;
}

From source file:com.cloudmine.api.CMGeoPoint.java

private double getValueFromKey(SimpleCMObject object, String[] keys) {
    for (String key : keys) {
        Double keyValue = object.getDouble(key);
        if (keyValue != null)
            return keyValue.doubleValue();
    }//from w  w w  .  jav a 2s.c o  m
    LOG.error("No value found for keys, using 0.0");
    return 0;
}

From source file:de.unidue.ltl.flextag.features.ngram.LuceneNgramUnitTest.java

private void evaluateExtractedFeatures(File output) throws Exception {
    Gson gson = new Gson();
    FeatureStore fs = gson.fromJson(FileUtils.readFileToString(new File(output, JsonDataWriter.JSON_FILE_NAME)),
            DenseFeatureStore.class);

    assertEquals(6, fs.getNumberOfInstances());
    Iterator<Instance> iterator = fs.getInstances().iterator();
    List<Feature> setFeats = new ArrayList<Feature>();
    while (iterator.hasNext()) {
        Instance next = iterator.next();
        List<Feature> arrayList = new ArrayList<Feature>(next.getFeatures());
        for (Feature f : arrayList) {
            Double d = Double.valueOf(f.getValue().toString());
            if (d.doubleValue() > 0) {
                setFeats.add(f);/*from  w w  w . j  a  va  2 s  .c  o  m*/
            }
        }
    }

    assertEquals(5, setFeats.size());

}

From source file:org.eclipse.jubula.client.ui.controllers.propertysources.MonitoringValuePropertySource.java

/**
 * @return displays the value of the given object id, default is "empty"
 * @param id//w  w w. j  a  v  a 2s  .  c om
 *            the id
 */
public Object getPropertyValue(Object id) {

    IMonitoringValue m = m_monitoringValueMap.get(id);
    if (m.getType().equals(MonitoringConstants.PERCENT_VALUE)) {
        DecimalFormat n = new DecimalFormat("0.0#%"); //$NON-NLS-1$
        Double doubleValue = Double.valueOf(m.getValue());
        return StringUtils.defaultString(n.format(doubleValue.doubleValue()));
    }
    return m.getValue();

}

From source file:com.insightml.math.distributions.DiscreteDistribution.java

public double get(final T key, final double defaultValue) {
    final Double value = map.get(key);
    return value == null ? defaultValue : value.doubleValue();
}

From source file:com.acc.validator.ReviewDataValidator.java

protected void validateRating(final Errors errors) {
    Assert.notNull(errors, "Errors object must not be null");
    final Double rating = (Double) errors.getFieldValue(RATING);

    if (rating == null) {
        errors.rejectValue(RATING, "field.required");
    } else {/*from  w  w w. jav a  2s.  c  om*/
        if (rating.doubleValue() < RATING_MIN || rating.doubleValue() > RATING_MAX) {
            errors.rejectValue(RATING, "review.rating.invalid");
        }
    }
}

From source file:de.hybris.platform.acceleratorservices.config.impl.AbstractConfigLookup.java

@Override
public double getDouble(final String key, final double defaultValue) {
    final String property = getProperty(key);
    if (property != null && !property.isEmpty()) {
        try {//from w  ww.ja v a  2 s . c om
            final Double doubleValue = Double.valueOf(property);
            if (doubleValue != null) {
                return doubleValue.doubleValue();
            }
        } catch (final NumberFormatException ex) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Failed to parse double property value for key [" + key + "] value was [" + property
                        + "]", ex);
            }
        }
    }
    return defaultValue;
}

From source file:kmi.taa.core.SmallSetAnalyser.java

public double mean(HashMap<Integer, Double> map) {
    double sum = 0;
    for (Double v : map.values()) {
        sum += v.doubleValue();
    }//w  w  w. j  av  a2s  .c  om
    return sum / map.size();
}

From source file:org.openmrs.module.sync.SyncDrugOrderTest.java

@Test
@NotTransactional/*  ww  w.j  a v  a2s .c o m*/
public void shouldUpdateDrugOrder() throws Exception {

    if (TestUtil.isOpenmrsVersionAtLeast("1.10")) {
        log.warn("NOT RUNNING DRUG ORDER TESTS AGAINST 1.10.  TODO.");
        return;
    }

    runSyncTest(new SyncTestHelper() {

        OrderService orderService = Context.getOrderService();

        public void runOnChild() throws Exception {
            DrugOrder order = (DrugOrder) OrderService.class.getMethod("getOrder", Integer.class, Class.class)
                    .invoke(orderService, 1, DrugOrder.class);
            Double d = (Double) DrugOrder.class.getMethod("getDose").invoke(order);
            Assert.assertFalse(d.doubleValue() == 10.0);
            DrugOrder.class.getMethod("setDose", Double.class).invoke(order, 10.0);
            OrderService.class.getMethod("saveOrder", Order.class).invoke(orderService, order);
            d = (Double) DrugOrder.class.getMethod("getDose").invoke(order);
            Assert.assertEquals(10.0, d.doubleValue());
        }

        public void runOnParent() throws Exception {
            DrugOrder order = (DrugOrder) OrderService.class.getMethod("getOrder", Integer.class, Class.class)
                    .invoke(orderService, 1, DrugOrder.class);
            Double d = (Double) DrugOrder.class.getMethod("getDose").invoke(order);
            Assert.assertEquals(10.0, d.doubleValue());
        }
    });
}