Example usage for java.lang Double equals

List of usage examples for java.lang Double equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object against the specified object.

Usage

From source file:com.leonarduk.finance.chart.PieChartFactory.java

public PieChartFactory add(final String name, final Double double1) {
    if (double1.equals(Double.NaN)) {
        return this;
    }/* www .  j a  v a  2  s.  com*/
    if (this.dataset.getKeys().contains(name)) {
        final Double value = this.dataset.getValue(name).doubleValue();
        this.put(name, double1 + value);
    } else {
        this.put(name, double1);
    }
    return this;
}

From source file:com.whizzosoftware.hobson.rest.v1.resource.device.DeviceTelemetryResource.java

/**
 * @api {get} /api/v1/users/:userId/hubs/:hubId/plugins/:pluginId/devices/:deviceId/telemetry Get device variable telemetry
 * @apiVersion 0.1.8//from w  w  w.  j  a v a 2  s. co  m
 * @apiName GetDeviceTelemetry
 * @apiDescription Retrieves telemetry for a specific device variable.
 * @apiGroup Devices
 * @apiSuccessExample {json} Success Response:
 * {
 *   "tempF": {
 *     "1408390215763": 72.0
 *   }
 * },
 * {
 *   "targetTempF": {
 *     "1408390215763": 73.0
 *   }
 * }
 */
@Override
protected Representation get() {
    HobsonRestContext ctx = HobsonRestContext.createContext(this, getRequest());
    String pluginId = getAttribute("pluginId");
    String deviceId = getAttribute("deviceId");
    long endTime = System.currentTimeMillis() / 1000; // TODO: should be pulled from request
    TelemetryInterval interval = TelemetryInterval.HOURS_24; // TODO: should be pulled from request

    Map<String, Collection<TemporalValue>> telemetry = deviceManager.getDeviceTelemetry(ctx.getUserId(),
            ctx.getHubId(), pluginId, deviceId, endTime, interval);

    JSONObject results = new JSONObject();

    for (String varName : telemetry.keySet()) {
        Collection<TemporalValue> varTm = telemetry.get(varName);

        JSONObject seriesJSON = new JSONObject();
        results.put(varName, seriesJSON);

        for (TemporalValue value : varTm) {
            Double d = (Double) value.getValue();
            if (d != null && !d.equals(Double.NaN)) {
                seriesJSON.put(Long.toString(value.getTime()), d);
            }
        }
    }

    return new JsonRepresentation(results);
}

From source file:Test.utile_functions.java

public LinkedHashMap<Integer, Double> sortHashMapByValues(HashMap<Integer, Double> passedMap) {
    List<Integer> id_tasks = new ArrayList<>(passedMap.keySet());
    List<Double> utilities = new ArrayList<>(passedMap.values());
    Collections.sort(id_tasks);/*from w w w .ja  v  a 2 s  . c  o  m*/
    Collections.sort(utilities);

    LinkedHashMap<Integer, Double> sortedMap = new LinkedHashMap<>();

    Iterator<Double> valueIt = utilities.iterator();
    while (valueIt.hasNext()) {
        Double val = valueIt.next();
        Iterator<Integer> keyIt = id_tasks.iterator();

        while (keyIt.hasNext()) {
            Integer key = keyIt.next();
            Double comp1 = passedMap.get(key);
            Double comp2 = val;

            if (comp1.equals(comp2)) {
                keyIt.remove();
                sortedMap.put(key, val);
                break;
            }
        }
    }
    return sortedMap;
}

From source file:no.imr.stox.functions.processdata.DefineAgeErrorMatrix.java

/**
 * define temporal covariates// ww  w .  jav a 2s  . c om
 *
 * @param input contains Polygon file name DataTypeDescription.txt
 * @return
 */
@Override
public Object perform(Map<String, Object> input) {
    ProcessDataBO pd = (ProcessDataBO) input.get(Functions.PM_DEFINEAGEERRORMATRIX_PROCESSDATA);
    MatrixBO ageError = pd.getMatrix(AbndEstProcessDataUtil.TABLE_AGEERROR);
    String defMethod = (String) input.get(Functions.PM_DEFINEAGEERRORMATRIX_DEFINITIONMETHOD);
    ILogger logger = (ILogger) input.get(Functions.PM_LOGGER);
    if (defMethod == null || defMethod.equals(Functions.DEFINITIONMETHOD_USEPROCESSDATA)) {
        // Use existing, do not read from file.
        return pd;
    }
    String fileName = ProjectUtils.resolveParameterFileName(
            (String) input.get(Functions.PM_DEFINEAGEERRORMATRIX_FILENAME),
            (String) input.get(Functions.PM_PROJECTFOLDER));
    if (fileName == null) {
        return pd;
    }
    List<String> lines;
    try {
        lines = FileUtils.readLines(new File(fileName));
        // Loop through the lines
        if (lines.isEmpty()) {
            return pd;
        }
        String[] realAges = lines.get(0).split("\t");
        if (lines.size() != realAges.length) {
            return null; // equal dimension size on real and read ages
        }
        lines.remove(0); // Remove header
        for (String line : lines) {
            if (line.startsWith("#")) {
                continue;
            }
            String[] elements = line.split("\t");
            if (elements.length != realAges.length) {
                return null;
            }
            String readAge = elements[0];
            for (int iRealAge = 1; iRealAge < elements.length; iRealAge++) {
                String realAge = realAges[iRealAge];
                Double p = Conversion.safeStringtoDoubleNULL(elements[iRealAge]);
                if (p == null || p.equals(0d)) {
                    continue;
                }
                ageError.setRowColValue(realAge, readAge, p);
            }
        }
    } catch (IOException ex) {
        throw new UncheckedIOException(ex);
    }
    return pd;
}

From source file:com.school.exam.rest.MakeExmRestController.java

/**
 * ???// ww  w  .j  a v  a2  s .c  o m
 * @param examId
 * @return
 */
@RequestMapping(value = "/order/{examId}", method = RequestMethod.GET, produces = MediaTypes.JSON_UTF_8)
public void orderByResult(@PathVariable(value = "examId") Long examId) {
    if (null != examId) {
        List<TeExamPaperResultVO> resutlist = resultService.getListOrderbySumScore(examId);
        ///.sort(resutlist,Comparators.getComparator());
        //logger.warn("sort:{}",resutlist.get(0).getSumScore());
        //logger.warn("sort:{}",resutlist.get(1).getSumScore());
        Collections.sort(resutlist);
        //logger.warn("sort1:{}",resutlist.get(0).getSumScore());
        //logger.warn("sort1:{}",resutlist.get(1).getSumScore());
        int No = 1;
        Double score = -0.0;
        for (TeExamPaperResultVO vo : resutlist) {
            if (score != -0.0 && !score.equals(vo.getSumScore())) {
                ++No;
            }
            vo.setExamOrder(No);
            vo.setState(2);
            score = vo.getSumScore();
        }
        resultService.updateOrder(resutlist, examId);
    } else {
        throw new RestException(HttpStatus.NOT_FOUND, "??");
    }
}

From source file:com.opengamma.analytics.math.integration.GaussHermiteQuadratureIntegrator1D.java

/**
 * {@inheritDoc}//from   ww  w .j av a 2  s.c o m
 * The function $f(x)$ that is to be integrated is transformed into a form
 * suitable for this quadrature method using:
 * $$
 * \begin{align*}
 * \int_{-\infty}^{\infty} f(x) dx
 * &= \int_{-\infty}^{\infty} f(x) e^{x^2} e^{-x^2} dx\\
 * &= \int_{-\infty}^{\infty} g(x) e^{-x^2} dx
 * \end{align*} 
 * $$
 * @throws UnsupportedOperationException If the lower limit is not $-\infty$ or the upper limit is not $\infty$
 */
@Override
public Function1D<Double, Double> getIntegralFunction(final Function1D<Double, Double> function,
        final Double lower, final Double upper) {
    Validate.notNull(function, "function");
    Validate.notNull(lower, "lower");
    Validate.notNull(upper, "upper");
    if (lower.equals(LIMITS[0]) && upper.equals(LIMITS[1])) {
        return new Function1D<Double, Double>() {

            @Override
            public Double evaluate(final Double x) {
                return Math.exp(x * x) * function.evaluate(x);
            }

        };
    }
    throw new UnsupportedOperationException("Limits for this integration method are +/-infinity");
}

From source file:ubic.gemma.web.controller.visualization.GeneExpressionProfile.java

/**
 * @param vector/*from w  w w . j  av a 2s.  c  om*/
 * @param genes
 * @param color
 * @param factor
 * @param pValue
 * @param standardize
 */
public GeneExpressionProfile(DoubleVectorValueObject vector, Collection<GeneValueObject> genes, String color,
        Integer factor, Double pValue, boolean standardize) {
    this.genes = genes;
    this.probe = vector.getDesignElement();
    this.probe.setArrayDesign(null);
    this.factor = factor;
    this.pValue = pValue;
    this.rank = vector.getRank();

    if (color != null) {
        this.color = color;
    }

    this.standardized = standardize;

    if (this.standardized) {
        this.profile = vector.standardize();
    } else {
        this.profile = vector.getData();
    }

    // Also test to make sure all the data isn't NAN
    for (Double d : this.profile) {
        if (!d.equals(Double.NaN)) {
            this.allMissing = false;
            break;
        }
    }

}

From source file:org.gitools.analysis.stats.mtc.BenjaminiHochbergFdrMtcFunction.java

@Override
public void onBeforeIterate(IMatrixIterable<Double> parentIterable) {

    ranks = new HashMap<>((int) parentIterable.size());

    n = 0;/*from   ww w. j a  v a  2  s  .  c o m*/
    int rank = 0;
    Double lastValue = -1.0;

    IMatrixIterable<Double> sortedIterable = parentIterable.filter(new NotNullPredicate<Double>()).sort();

    for (Double value : sortedIterable) {
        n++;

        if (!lastValue.equals(value)) {
            rank++;
        }

        String hash = hashKey(sortedIterable.getPosition());

        ranks.put(hash, rank);
        lastValue = value;
    }

}

From source file:gov.nih.nci.ncicb.cadsr.bulkloader.util.BulkLoaderUnclassifier.java

private Double getCSVersion(UnloadProperties unloadProperties) {
    Double csVersion = new Double(unloadProperties.getCsVersion());

    if (csVersion.equals(new Double(0.0))) {
        csVersion = getLatestCSVersion(unloadProperties);
    }// w  ww.  j  a v a 2s .c  om

    return csVersion;
}

From source file:gov.nih.nci.ncicb.cadsr.bulkloader.util.BulkLoaderUnclassifier.java

private Double getCSIVersion(UnloadProperties unloadProperties) {
    Double csiVersion = new Double(unloadProperties.getCsiVersion());

    if (csiVersion.equals(new Double(0.0))) {
        csiVersion = getLatestCSIVersion(unloadProperties);
    }//  w w  w  .ja va2s.  c  om

    return csiVersion;
}