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:com.genentech.chemistry.openEye.apps.QTorsionProfileGenerator.java

public static void main(String... args) throws IOException { // create command line Options object
    Options options = new Options();
    Option opt = new Option(OPT_INFILE, true,
            "input file oe-supported Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);/*from   w w  w.  ja v a2 s.co  m*/
    options.addOption(opt);

    opt = new Option(OPT_SDFFILE, true,
            "file to write onformers for debugging (oe-supported Use .sdf|.smi to specify the file type).");
    options.addOption(opt);

    opt = new Option(OPT_WORKDIR, true, "Write files into this directory!");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_OUTPREFIX, true, "Prefix for output file.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_OUTNAMETAG, true,
            "TagName of field containing outFilePrefix. (Use TITLE for mol title).");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_TEMPLATE, true,
            "Template file for quantum program containing #XYZ# place holder line. A #FName# placeholder can be used fro chk files and the like.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_SPIN_MULTIPLICITY, true, "Spin Multiplicity of the input molecules (default 1)");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_NCPU, true, "Overwrite nprocshared parameter in guassian input file if given");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_MEM, true, "Memory for gaussian default='10GB' replaces #mem# in tempalte");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_MINIMIZE, false, "minimize conformer at each step using MMFFs");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_CONSTRIANT, true,
            "one of strong (90),medium (45), weak(20), none or a floating point number"
                    + " specifying the strength of tethered constrains for -doMinimize (def=strong)");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_BONDFILE, true, "Structure file containing 4 atoms defining the torsion. "
            + "In each input molecule the atoms colses these atoms are used to define the torsion.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_STARTTorsion, true,
            "The torsion in your inMol will be rotated by this value for the first job");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_TORSIONIncrement, true, "Incremnt each subsequent conformation by this step size");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_NSTEPS, true, "Number of conformations to create");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_MAXCONFS_PER_STEP, true,
            "While holding the torsion fixed, maximum number of conformations of free atoms to generate.  default=1");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_COREFILE, true, "Outputfile to store guessed core.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_DEBUG, false, "Produce more debug output.");
    opt.setRequired(false);
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }
    args = cmd.getArgs();
    if (args.length != 0) {
        System.err.println("Unknown arguments" + args);
        exitWithHelp(options);
    }

    if (cmd.hasOption("d")) {
        System.err.println("Start debugger and press return:");
        new BufferedReader(new InputStreamReader(System.in)).readLine();
    }

    String inFile = cmd.getOptionValue(OPT_INFILE);
    String sdfFile = cmd.getOptionValue(OPT_SDFFILE);
    String outPrefix = cmd.getOptionValue(OPT_OUTPREFIX);
    String outNameTag = cmd.getOptionValue(OPT_OUTNAMETAG);
    String workDir = cmd.getOptionValue(OPT_WORKDIR);
    String coreFile = cmd.getOptionValue(OPT_COREFILE);
    String tempalte = cmd.getOptionValue(OPT_TEMPLATE);
    String bondFile = cmd.getOptionValue(OPT_BONDFILE);
    String nCPU = cmd.getOptionValue(OPT_NCPU);
    String memStr = cmd.getOptionValue(OPT_MEM);
    String maxConfsStr = cmd.getOptionValue(OPT_MAXCONFS_PER_STEP);
    String spinMult = cmd.getOptionValue(OPT_SPIN_MULTIPLICITY);

    boolean doMinimize = cmd.hasOption(OPT_MINIMIZE);
    String constraintStrength = cmd.getOptionValue(OPT_CONSTRIANT);
    int nStep = Integer.parseInt(cmd.getOptionValue(OPT_NSTEPS));

    if (memStr == null || memStr.length() == 0)
        memStr = "10GB";

    if (spinMult == null || spinMult.length() == 0)
        spinMult = "1";

    if ((outPrefix == null && outNameTag == null) || (outPrefix != null && outNameTag != null)) {
        System.err.println("Exactly one of -outPrefix or outNameTag must be given!");
        exitWithHelp(options);
    }

    if (workDir == null || workDir.trim().length() == 0)
        workDir = ".";

    double startTorsion = Double.NaN;
    if (cmd.hasOption(OPT_STARTTorsion))
        startTorsion = Double.parseDouble(cmd.getOptionValue(OPT_STARTTorsion));

    double torInc = Double.parseDouble(cmd.getOptionValue(OPT_TORSIONIncrement));
    int maxStepConfs = maxConfsStr == null ? 1 : Integer.parseInt(maxConfsStr);

    QTorsionProfileGenerator calculator = new QTorsionProfileGenerator(tempalte, workDir, outPrefix, outNameTag,
            bondFile, spinMult, startTorsion, torInc, nStep, maxStepConfs, doMinimize, constraintStrength,
            cmd.hasOption(OPT_DEBUG));

    calculator.run(inFile, sdfFile, coreFile, nCPU, memStr);
}

From source file:com.itemanalysis.psychometrics.kernel.LeastSquaresCrossValidation.java

public double value() {
    BrentOptimizer brent = new BrentOptimizer(1e-10, 1e-14);
    UnivariatePointValuePair pair;/*w w  w .ja  v  a 2s . c  o m*/
    try {
        pair = brent.optimize(400, this, GoalType.MINIMIZE, 0.01, sd);
    } catch (Exception ex) {
        return Double.NaN;
    }
    return pair.getPoint();
}

From source file:edu.cornell.med.icb.learning.weka.WekaClassifier.java

public double predict(final ClassificationModel trainingModel, final ClassificationProblem problem,
        final int instanceIndex, final double[] probabilities) {
    assert trainingModel instanceof WekaModel : "Model must be a weka model.";
    final double[] probs;
    try {//from w w  w  .  ja  v  a 2  s . c  o m
        probs = getWekaClassifier(this)
                .distributionForInstance(getWekaProblem(problem).instance(instanceIndex));
    } catch (Exception e) {
        LOG.error("Weka classifier has thrown exception.", e);
        return Double.NaN;
    }

    System.arraycopy(probs, 0, probabilities, 0, probs.length);
    if (LOG.isDebugEnabled()) {
        LOG.debug("decision values: " + ArrayUtils.toString(probabilities));
    }

    double maxProb = Double.NEGATIVE_INFINITY;
    int maxIndex = -1;
    for (int labelIndex = 0; labelIndex < probabilities.length; labelIndex++) {
        if (probabilities[labelIndex] > maxProb) {
            maxProb = probabilities[labelIndex];
            maxIndex = labelIndex;
        }
    }

    final double decision;
    if (maxIndex == -1) {
        decision = Double.NaN;
    } else {
        decision = labelIndex2LabelValue[maxIndex];
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("decision: " + decision);
    }

    return decision;
}

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

/**
 * Some tests for the equals() method.//w  w w .j  av a  2 s .co  m
 */
@Test
public void testEquals() {
    DefaultHeatMapDataset d1 = new DefaultHeatMapDataset(5, 10, 1.0, 2.0, 3.0, 4.0);
    DefaultHeatMapDataset d2 = new DefaultHeatMapDataset(5, 10, 1.0, 2.0, 3.0, 4.0);
    assertEquals(d1, d2);

    d1 = new DefaultHeatMapDataset(6, 10, 1.0, 2.0, 3.0, 4.0);
    assertFalse(d1.equals(d2));
    d2 = new DefaultHeatMapDataset(6, 10, 1.0, 2.0, 3.0, 4.0);
    assertTrue(d1.equals(d2));

    d1 = new DefaultHeatMapDataset(6, 11, 1.0, 2.0, 3.0, 4.0);
    assertFalse(d1.equals(d2));
    d2 = new DefaultHeatMapDataset(6, 11, 1.0, 2.0, 3.0, 4.0);
    assertTrue(d1.equals(d2));

    d1 = new DefaultHeatMapDataset(6, 11, 2.0, 2.0, 3.0, 4.0);
    assertFalse(d1.equals(d2));
    d2 = new DefaultHeatMapDataset(6, 11, 2.0, 2.0, 3.0, 4.0);
    assertTrue(d1.equals(d2));

    d1 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 3.0, 4.0);
    assertFalse(d1.equals(d2));
    d2 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 3.0, 4.0);
    assertTrue(d1.equals(d2));

    d1 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 4.0);
    assertFalse(d1.equals(d2));
    d2 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 4.0);
    assertTrue(d1.equals(d2));

    d1 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 5.0);
    assertFalse(d1.equals(d2));
    d2 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 5.0);
    assertTrue(d1.equals(d2));

    d1.setZValue(1, 2, 3.0);
    assertFalse(d1.equals(d2));
    d2.setZValue(1, 2, 3.0);
    assertTrue(d1.equals(d2));

    d1.setZValue(0, 0, Double.NEGATIVE_INFINITY);
    assertFalse(d1.equals(d2));
    d2.setZValue(0, 0, Double.NEGATIVE_INFINITY);
    assertTrue(d1.equals(d2));

    d1.setZValue(0, 1, Double.POSITIVE_INFINITY);
    assertFalse(d1.equals(d2));
    d2.setZValue(0, 1, Double.POSITIVE_INFINITY);
    assertTrue(d1.equals(d2));

    d1.setZValue(0, 2, Double.NaN);
    assertFalse(d1.equals(d2));
    d2.setZValue(0, 2, Double.NaN);
    assertTrue(d1.equals(d2));
}

From source file:net.femtoparsec.jnlmin.AbstractTokenTask.java

private void dispatchStarting() {
    if (this.listeners.isEmpty()) {
        return;/*ww w.ja  v a  2  s  .c  o  m*/
    }
    MinimizerEventImpl event = new MinimizerEventImpl();
    event.setMinimizerStatus(MinimizerStatus.STARTING);
    event.setNbEvaluations(0);
    event.setNbIterations(0);
    event.setParameters(this.getFirstGuess());
    event.setPenalty(Double.NaN);
    this.dispatchEvent(event);
}

From source file:it.unifi.rcl.chess.traceanalysis.Trace.java

public double getBound(double coverage) {

    double ret = 0;
    forbidSystemExitCall();/* w ww .ja v a 2s  . c  om*/
    try {
        ret = MonitoringService.getBound(data, coverage, data.size());
    } catch (MonitoringServiceException e) {
        System.out.println(e);
    } catch (ExitTrappedException e) {
        ret = Double.NaN;
        System.out.println(e);
    } finally {
        enableSystemExitCall();
    }
    return ret;
}

From source file:geogebra.kernel.cas.AlgoIntegralDefinite.java

protected final void compute() {
    if (!f.isDefined() || !ageo.isDefined() || !bgeo.isDefined()) {
        n.setUndefined();/*from  w  w  w. j av a2s  .co m*/
        return;
    }

    // check for equal bounds
    double lowerLimit = a.getDouble();
    double upperLimit = b.getDouble();
    if (Kernel.isEqual(lowerLimit, upperLimit)) {
        n.setValue(0);
        return;
    }

    // check if f(a) and f(b) are defined
    double fa = f.evaluate(lowerLimit);
    double fb = f.evaluate(upperLimit);
    if (Double.isNaN(fa) || Double.isInfinite(fa) || Double.isNaN(fb) || Double.isInfinite(fb)) {
        n.setUndefined();
        return;
    }

    // return if it should not be evaluated (i.e. is shade-only)
    if (evaluateOnly()) {
        n.setValue(Double.NaN);
        return;
    }

    /* 
     * Try to use symbolic integral
     *
     * We only do this for functions that do NOT include divisions by their variable.
     * Otherwise there might be problems like:
     * Integral[ 1/x, -2, -1 ] would be undefined (log(-1) - log(-2))
     * Integral[ 1/x^2, -1, 1 ] would be defined (-2)
     */
    if (symbIntegral != null && symbIntegral.isDefined() && !f.includesDivisionByVar()) {
        double val = symbIntegral.evaluate(upperLimit) - symbIntegral.evaluate(lowerLimit);
        n.setValue(val);
        if (n.isDefined())
            return;
    }

    // numerical integration
    // max_error = ACCURACY; // current maximum error
    //maxstep = 0;           

    double integral = numericIntegration(f, lowerLimit, upperLimit);
    n.setValue(integral);

    /*
    Application.debug("***\nsteps: " + maxstep);                   
    Application.debug("max_error: " + max_error);
    */
}

From source file:org.jfree.data.statistics.DefaultStatisticalCategoryDataset.java

/**
 * Creates a new dataset.//from w ww . ja  va 2  s . com
 */
public DefaultStatisticalCategoryDataset() {
    this.data = new KeyedObjects2D();
    this.minimumRangeValue = Double.NaN;
    this.minimumRangeValueRow = -1;
    this.minimumRangeValueColumn = -1;
    this.maximumRangeValue = Double.NaN;
    this.maximumRangeValueRow = -1;
    this.maximumRangeValueColumn = -1;
    this.minimumRangeValueIncStdDev = Double.NaN;
    this.minimumRangeValueIncStdDevRow = -1;
    this.minimumRangeValueIncStdDevColumn = -1;
    this.maximumRangeValueIncStdDev = Double.NaN;
    this.maximumRangeValueIncStdDevRow = -1;
    this.maximumRangeValueIncStdDevColumn = -1;
}

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

/**
 * Compare two files and update the result.
 *//* w  ww . j  a va  2  s  .c  o m*/
@Override
public void run() {
    try {
        handler.onStarted();
        Similarity compare = compare(file1, file2);
        job.updateSimilarityValue(pairwiseComparison.getId(), compare.getValue());
        if (handler != null) {
            handler.onDone(compare.getValue());
        }
        log.debug("Done computing similarity between " + file1 + " and " + file2 + " = " + compare.getValue());
    } catch (Throwable e1) {
        // TODO need status in comparison
        job.updateSimilarityValue(pairwiseComparison.getId(), Double.NaN);
        if (handler != null) {
            handler.onFailed("Error computing similarity", e1);
        }
        job.setStatus(pairwiseComparison.getId(), ComparisonStatus.FAILED);
        log.error("Error computing similarity between " + file1 + " and " + file2 + " ["
                + pairwiseComparison.getId() + "]", e1);
    }
}