Example usage for java.lang Double NaN

List of usage examples for java.lang Double NaN

Introduction

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

Prototype

double NaN

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

Click Source Link

Document

A constant holding a Not-a-Number (NaN) value of type double .

Usage

From source file:etomica.models.co2.PNGCPM.java

/**
 * This returns the pairwise-additive portion of the GCPM potential for a
 * pair of atoms (dispersion + fixed-charge electrostatics)
 *//*from w ww .j a  v a2 s  .  c  o m*/
public double getNonPolarizationEnergy(IMoleculeList molecules) {
    IAtomList atoms1 = molecules.getMolecule(0).getChildList();
    IAtomList atoms2 = molecules.getMolecule(1).getChildList();

    IVectorMutable C1r = atoms1.getAtom(0).getPosition();
    IVectorMutable C2r = atoms2.getAtom(0).getPosition();

    work.Ev1Mv2(C1r, C2r);
    shift.Ea1Tv1(-1, work);
    boundary.nearestImage(work);
    shift.PE(work);
    final boolean zeroShift = shift.squared() < 0.1;

    double r2 = work.squared();

    double sum = 0;
    if (zeroShift) {
        for (int i = 0; i < atoms1.getAtomCount(); i++) {
            for (int j = 0; j < atoms2.getAtomCount(); j++) {
                GCPMAgent pairAgent = getPairAgent(atoms1.getAtom(i).getType(), atoms2.getAtom(j).getType());
                double epsilon = pairAgent.epsilon;
                double r = Double.NaN;
                if (epsilon > 0) {
                    double sigma = pairAgent.sigma;
                    double gamma = pairAgent.gamma;
                    r2 = atoms1.getAtom(i).getPosition().Mv1Squared(atoms2.getAtom(j).getPosition());
                    r = Math.sqrt(r2);
                    double rOverSigma = r / sigma;
                    double sigma2OverR2 = 1 / (rOverSigma * rOverSigma);
                    if (1 / sigma2OverR2 < coreFac)
                        return Double.POSITIVE_INFINITY;
                    double sixOverGamma = 6 / gamma;
                    sum += epsilon / (1 - sixOverGamma) * (sixOverGamma * Math.exp(gamma * (1 - rOverSigma))
                            - sigma2OverR2 * sigma2OverR2 * sigma2OverR2);
                }

                double charge2 = pairAgent.charge2;
                if (charge2 != 0) {
                    double tau = pairAgent.tau;
                    if (Double.isNaN(r)) {
                        r2 = atoms1.getAtom(i).getPosition().Mv1Squared(atoms2.getAtom(j).getPosition());
                        r = Math.sqrt(r2);
                    }
                    sum += charge2 / r
                            * (1 - org.apache.commons.math3.special.Erf.erfc(Math.sqrt(r2) / (2 * tau)));
                }
            }
        }
    } else {
        for (int i = 0; i < atoms1.getAtomCount(); i++) {
            for (int j = 0; j < atoms2.getAtomCount(); j++) {
                GCPMAgent pairAgent = getPairAgent(atoms1.getAtom(i).getType(), atoms2.getAtom(j).getType());
                double epsilon = pairAgent.epsilon;
                double r = Double.NaN;
                if (epsilon > 0) {

                    double sigma = pairAgent.sigma;
                    IVector r1 = atoms1.getAtom(i).getPosition();
                    shift.PE(r1);
                    r2 = atoms2.getAtom(j).getPosition().Mv1Squared(shift);
                    shift.ME(r1);
                    r = Math.sqrt(r2);

                    double gamma = pairAgent.gamma;

                    double rOverSigma = r / sigma;
                    double sigma2OverR2 = 1 / (rOverSigma * rOverSigma);
                    if (1 / sigma2OverR2 < coreFac)
                        return Double.POSITIVE_INFINITY;
                    double sixOverGamma = 6 / gamma;

                    sum += epsilon / (1 - sixOverGamma) * (sixOverGamma * Math.exp(gamma * (1 - rOverSigma))
                            - sigma2OverR2 * sigma2OverR2 * sigma2OverR2);//exp-6 potential(Udisp)
                }

                double charge2 = pairAgent.charge2;
                if (charge2 != 0) {
                    double tau = pairAgent.tau;
                    if (Double.isNaN(r)) {
                        IVector r1 = atoms1.getAtom(i).getPosition();
                        shift.PE(r1);
                        r2 = atoms2.getAtom(j).getPosition().Mv1Squared(shift);
                        shift.ME(r1);
                        r = Math.sqrt(r2);
                    }
                    sum += charge2 / r
                            * (1 - org.apache.commons.math3.special.Erf.erfc(Math.sqrt(r2) / (2 * tau)));
                }
            }
        }
    }

    return sum;
}

From source file:ch.epfl.lsir.xin.algorithm.core.ItemBasedCF.java

/**
 * This function calculates the similarity matrix for items
 * *//*w  w  w  .j a va2 s .  co  m*/
public void similarityMatrixCalculation() {
    for (int i = 0; i < this.ratingMatrix.getColumn(); i++) {
        for (int j = i; j < this.ratingMatrix.getColumn(); j++) {
            if (i == j) //the similarity with herself is 1 
            {
                this.similarityMatrix[i][j] = 1;
            } else {
                ArrayList<Double> commonRatings1 = new ArrayList<Double>();
                ArrayList<Double> commonRatings2 = new ArrayList<Double>();
                //find common ratings for the two items
                for (int i1 = 0; i1 < this.ratingMatrix.getRow(); i1++) {
                    if (this.ratingMatrix.getRatingMatrix().get(i1).get(i) != null
                            && this.ratingMatrix.getRatingMatrix().get(i1).get(j) != null) {
                        commonRatings1.add(this.ratingMatrix.getRatingMatrix().get(i1).get(i));
                        commonRatings2.add(this.ratingMatrix.getRatingMatrix().get(i1).get(j));
                    }
                }
                double similarity = Double.NaN;
                if (this.similarityCalculation.equals("pcc")) {
                    similarity = SimilarityCalculator.getSimilarityPCC(commonRatings1, commonRatings2,
                            this.config.getInt("SHRINKAGE"));
                } else if (this.similarityCalculation.equals("cosine")) {
                    similarity = SimilarityCalculator.getSimilarityCosine(commonRatings1, commonRatings2,
                            this.config.getInt("SHRINKAGE"));
                } else {
                    logger.append("Cannot determine which similarity calculation method is used for. \n");
                    return;
                }

                if (Double.isNaN(similarity)) {
                    similarity = 0;
                }
                this.similarityMatrix[i][j] = similarity;
                this.similarityMatrix[j][i] = similarity;
            }
        }
    }
}

From source file:org.powertac.auctioneer.AuctionService.java

public boolean validateOrder(Order order) {
    if (order.getMWh().equals(Double.NaN) || order.getMWh().equals(Double.POSITIVE_INFINITY)
            || order.getMWh().equals(Double.NEGATIVE_INFINITY)) {
        log.warn("Order from " + order.getBroker().getUsername() + " with invalid quantity " + order.getMWh());
        return false;
    }// w  w w .  j  ava 2 s.  c o m

    double minQuantity = Competition.currentCompetition().getMinimumOrderQuantity();
    if (Math.abs(order.getMWh()) < minQuantity) {
        log.warn("Order from " + order.getBroker().getUsername() + " with quantity " + order.getMWh()
                + " < minimum quantity " + minQuantity);
        return false;
    }

    if (!timeslotRepo.isTimeslotEnabled(order.getTimeslot())) {
        OrderStatus status = new OrderStatus(order.getBroker(), order.getId());
        brokerProxyService.sendMessage(order.getBroker(), status);
        log.warn("Order from " + order.getBroker().getUsername() + " for disabled timeslot "
                + order.getTimeslot());
        return false;
    }
    return true;
}

From source file:com.joptimizer.optimizers.LPPresolverNetlibTest.java

public void doTesting(String problemName) throws Exception {
    doTesting(problemName, true, Double.NaN);
}

From source file:com.ironiacorp.statistics.r.type.LinearModelSummary.java

/**
 * @param factorName//w  ww  .ja v a  2 s. c om
 * @return
 * @see ubic.basecode.util.r.type.GenericAnovaResult#getMainEffectP(java.lang.String)
 */
public Double getMainEffectP(String factorName) {
    if (anovaResult == null)
        return Double.NaN;
    return anovaResult.getMainEffectP(factorName);
}

From source file:ar.edu.famaf.nlp.alusivo.GraphAlgorithm.java

public ReferringExpression resolve(URI referent, List<URI> confusors, RepositoryConnection repo)
        throws ReferringExpressionException, RepositoryException {

    Map<String, Integer> mappedOrder = new HashMap<String, Integer>();
    Set<String> ignored = new HashSet<String>();
    if (this.priorities != null) {
        List<String> priorities = null;
        RepositoryResult<Statement> types = repo.getStatements(referent, RDF.TYPE, null, true);

        if (!types.hasNext())
            throw new ReferringExpressionException("Unknwon type for referent '" + referent + "'");

        StringBuilder typeNames = new StringBuilder();
        String type = null;//from  www . j ava  2 s .  c o m
        while (types.hasNext()) {
            Statement typeStmt = types.next();
            type = typeStmt.getObject().stringValue();
            typeNames.append(' ').append(type);
            priorities = this.priorities.get(type);
            if (priorities != null) {
                if (this.ignored != null && this.ignored.containsKey(type))
                    ignored.addAll(this.ignored.get(type));
                break;
            }
        }

        if (priorities == null)
            throw new ReferringExpressionException(
                    "No priorities for referent with types [" + typeNames + " ]");

        mappedOrder = new HashMap<String, Integer>();
        for (int i = 0; i < priorities.size(); i++)
            mappedOrder.put(priorities.get(i), i);
    }

    URI[] uris = new URI[confusors.size() + 1];
    confusors.toArray(uris);
    uris[uris.length - 1] = referent;
    DirectedPseudograph<Resource, Edge> graph = buildGraph(repo, uris, ignored);
    DirectedPseudograph<Resource, Edge> bestGraph = null;
    DirectedPseudograph<Resource, Edge> candidate = new DirectedPseudograph<Resource, Edge>(Edge.class);
    candidate.addVertex(referent);

    DirectedPseudograph<Resource, Edge> finalGraph = findGraph(referent, graph, bestGraph, Double.NaN,
            candidate, System.currentTimeMillis(), mappedOrder).getLeft();

    if (finalGraph == null)
        throw new ReferringExpressionException("No graph found");

    // read out properties from final graph
    ReferringExpression result = new ReferringExpression(referent);
    for (Edge e : finalGraph.edgeSet())
        result.addPositive(finalGraph.getEdgeSource(e), e.getURI(),
                e.isRelation() ? finalGraph.getEdgeTarget(e) : e.getValue());

    return result;
}

From source file:edu.cmu.tetrad.search.IndTestConditionalGaussianLRT.java

/**
 * @return the significance level of the independence test.
 * @throws UnsupportedOperationException if there is no significance level.
 *//*w ww . j  a  va 2  s.  com*/
public double getAlpha() {
    return Double.NaN;
}

From source file:org.jfree.data.general.DefaultHeatMapDatasetTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *///from ww w .  jav a2  s . c  o  m
@Test
public void testSerialization() {
    DefaultHeatMapDataset d1 = new DefaultHeatMapDataset(2, 3, -1.0, 4.0, -2.0, 5.0);
    d1.setZValue(0, 0, 10.0);
    d1.setZValue(0, 1, Double.NEGATIVE_INFINITY);
    d1.setZValue(0, 2, Double.POSITIVE_INFINITY);
    d1.setZValue(1, 0, Double.NaN);
    DefaultHeatMapDataset d2 = (DefaultHeatMapDataset) TestUtilities.serialised(d1);
    assertEquals(d1, d2);
}

From source file:edu.cuny.cat.ui.ClientStatePanel.java

@Override
protected synchronized void processGameStarting(final GameStartingEvent event) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            yAxis.setLowerBound(-1);//from   www.  j a  va2s  .  c o m
            yAxis.setUpperBound(days);

            eventDataset = new DefaultValueListCategoryDataset();
            eventDataset.setAutomaticChangedEvent(false);
            progressDataset = new DefaultIntervalListCategoryDataset();
            progressDataset.setAutomaticChangedEvent(false);

            categoryPlot.setDataset(0, eventDataset);
            categoryPlot.setDataset(1, progressDataset);

            // useful only to keep specialists in the same order in the plot
            final String specialistIds[] = registry.getSpecialistIds();
            for (final String specialistId : specialistIds) {
                eventDataset.add(Double.NaN, event.getClass().getSimpleName(), specialistId);
                progressDataset.setStartValue(Double.NaN, 0, ClientState.getCodeDesc(ClientState.OK),
                        specialistId);
                progressDataset.setEndValue(Double.NaN, 0, ClientState.getCodeDesc(ClientState.OK),
                        specialistId);
            }
        }
    });
}

From source file:ffx.xray.DiffractionRefinementData.java

/**
 * allocate data given a {@link ReflectionList}
 *
 * @param properties configuration properties
 * @param reflectionlist {@link ReflectionList} to use to allocate data
 *//*from   www. ja  va2 s  .c  o  m*/
public DiffractionRefinementData(CompositeConfiguration properties, ReflectionList reflectionlist) {

    int rflag = -1;
    if (properties != null) {
        rflag = properties.getInt("rfreeflag", -1);
        fsigfcutoff = properties.getDouble("fsigfcutoff", -1.0);
    } else {
        fsigfcutoff = -1.0;
    }

    this.n = reflectionlist.hkllist.size();
    this.scale_n = reflectionlist.crystal.scale_n;
    this.rfreeflag = rflag;
    this.nbins = reflectionlist.nbins;
    fsigf = new double[n][2];
    freer = new int[n];
    fc = new double[n][2];
    fs = new double[n][2];
    fctot = new double[n][2];
    fomphi = new double[n][2];
    fofc2 = new double[n][2];
    fofc1 = new double[n][2];
    dfc = new double[n][2];
    dfs = new double[n][2];

    for (int i = 0; i < n; i++) {
        fsigf[i][0] = fsigf[i][1] = Double.NaN;
        fctot[i][0] = fctot[i][1] = Double.NaN;
    }

    spline = new double[nbins * 2];
    sigmaa = new double[nbins];
    sigmaw = new double[nbins];
    fcesq = new double[nbins];
    foesq = new double[nbins];
    for (int i = 0; i < nbins; i++) {
        spline[i] = spline[i + nbins] = sigmaa[i] = fcesq[i] = foesq[i] = 1.0;
        sigmaw[i] = 0.05;
    }

    // initial guess for scaling/bulk solvent correction
    solvent_k = 0.33;
    solvent_ueq = 50.0 / (8.0 * PI * PI);
    model_k = 0.0;
}