Example usage for java.lang Double MIN_VALUE

List of usage examples for java.lang Double MIN_VALUE

Introduction

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

Prototype

double MIN_VALUE

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

Click Source Link

Document

A constant holding the smallest positive nonzero value of type double , 2-1074.

Usage

From source file:ubic.pubmedgate.mallet.mergers.BestSumOrFirstMerge.java

@Override
protected Sequence doMerge(List<SequencePairAlignment<Object, Object>> aResult,
        List<SequencePairAlignment<Object, Object>> bResult) {
    double bestWeight = Double.MIN_VALUE;
    Sequence best = null;/*from   w  w  w.ja  v  a  2s.  co m*/
    int matches = 0;

    for (SequencePairAlignment a : aResult) {
        for (SequencePairAlignment b : bResult) {
            // if they have the same output

            // for some reason the equals on the sequences doesnt work, so use a manual one
            if (BidirectionalMerge.equalSequences(a.output(), b.output())) {
                matches++;
                // add them up
                double weight = a.getWeight() + b.getWeight();
                // if it's the highest then keep it
                if (weight > bestWeight) {
                    bestWeight = weight;
                    best = b.output();
                }
            }
        }
    }
    // log.info( "Matches:" + matches + " biggest=" + bestWeight );
    total++;
    if (best != null) {
        return best;
    } else {
        didFirst++;
        return first.doMerge(aResult, bResult);
    }
}

From source file:ffx.numerics.fft.RowMajorComplex3DCuda.java

/**
 * <p>/*ww  w  .  j  av  a  2s . com*/
 * main</p>
 *
 * @param args an array of {@link java.lang.String} objects.
 * @throws java.lang.Exception if any.
 */
public static void main(String[] args) throws Exception {
    int dimNotFinal = 64;
    int reps = 10;
    if (args != null) {
        try {
            dimNotFinal = Integer.parseInt(args[0]);
            if (dimNotFinal < 1) {
                dimNotFinal = 64;
            }
            reps = Integer.parseInt(args[2]);
            if (reps < 1) {
                reps = 5;
            }
        } catch (Exception e) {
        }
    }
    final int dim = dimNotFinal;

    System.out.println(String.format(
            " Initializing a %d cubed grid.\n" + " The best timing out of %d repititions will be used.", dim,
            reps));

    final int dimCubed = dim * dim * dim;

    /**
     * Create an array to save the initial input and result.
     */
    double orig[] = new double[dimCubed];
    double answer[] = new double[dimCubed];

    double data[] = new double[dimCubed * 2];
    double recip[] = new double[dimCubed];

    Random random = new Random(1);
    for (int x = 0; x < dim; x++) {
        for (int y = 0; y < dim; y++) {
            for (int z = 0; z < dim; z++) {
                int index = RowMajorComplex3D.iComplex3D(x, y, z, dim, dim);
                orig[index / 2] = random.nextDouble();
                recip[index / 2] = orig[index / 2];
            }
        }
    }

    RowMajorComplex3D complex3D = new RowMajorComplex3D(dim, dim, dim);
    RowMajorComplex3DParallel complex3DParallel = new RowMajorComplex3DParallel(dim, dim, dim,
            new ParallelTeam(), IntegerSchedule.fixed());
    RowMajorComplex3DCuda complex3DCUDA = new RowMajorComplex3DCuda(dim, dim, dim, data, recip);
    Thread cudaThread = new Thread(complex3DCUDA);

    cudaThread.setPriority(Thread.MAX_PRIORITY);
    cudaThread.start();

    double toSeconds = 0.000000001;
    long parTime = Long.MAX_VALUE;
    long seqTime = Long.MAX_VALUE;
    long clTime = Long.MAX_VALUE;

    complex3D.setRecip(recip);
    for (int i = 0; i < reps; i++) {
        for (int j = 0; j < dimCubed; j++) {
            data[j * 2] = orig[j];
            data[j * 2 + 1] = 0.0;
        }
        long time = System.nanoTime();
        complex3D.convolution(data);
        time = (System.nanoTime() - time);
        System.out.println(String.format(" %2d Sequential: %8.3f", i + 1, toSeconds * time));
        if (time < seqTime) {
            seqTime = time;
        }
    }

    for (int j = 0; j < dimCubed; j++) {
        answer[j] = data[j * 2];
    }

    complex3DParallel.setRecip(recip);
    for (int i = 0; i < reps; i++) {
        for (int j = 0; j < dimCubed; j++) {
            data[j * 2] = orig[j];
            data[j * 2 + 1] = 0.0;
        }
        long time = System.nanoTime();
        complex3DParallel.convolution(data);
        time = (System.nanoTime() - time);
        System.out.println(String.format(" %2d Parallel:   %8.3f", i + 1, toSeconds * time));
        if (time < parTime) {
            parTime = time;
        }
    }

    double maxError = Double.MIN_VALUE;
    double rmse = 0.0;
    for (int i = 0; i < dimCubed; i++) {
        double error = Math.abs(answer[i] - data[2 * i]);
        if (error > maxError) {
            maxError = error;
        }
        rmse += error * error;
    }
    rmse /= dimCubed;
    rmse = Math.sqrt(rmse);
    logger.info(String.format(" Parallel RMSE:   %12.10f, Max: %12.10f", rmse, maxError));
    for (int i = 0; i < reps; i++) {
        for (int j = 0; j < dimCubed; j++) {
            data[j * 2] = orig[j];
            data[j * 2 + 1] = 0.0;
        }
        long time = System.nanoTime();
        complex3DCUDA.convolution(data);
        time = (System.nanoTime() - time);
        System.out.println(String.format(" %2d CUDA:     %8.3f", i + 1, toSeconds * time));
        if (time < clTime) {
            clTime = time;
        }
    }

    maxError = Double.MIN_VALUE;
    double avg = 0.0;
    rmse = 0.0;
    for (int i = 0; i < dimCubed; i++) {
        double error = Math.abs((answer[i] - data[2 * i]) / dimCubed);
        avg += error;
        if (error > maxError) {
            maxError = error;
        }
        rmse += error * error;
    }
    rmse /= dimCubed;
    avg /= dimCubed;
    rmse = Math.sqrt(rmse);
    logger.info(String.format(" CUDA RMSE:   %12.10f, Max: %12.10f, Avg: %12.10f", rmse, maxError, avg));

    complex3DCUDA.free();
    complex3DCUDA = null;

    System.out.println(String.format(" Best Sequential Time:  %8.3f", toSeconds * seqTime));
    System.out.println(String.format(" Best Parallel Time:    %8.3f", toSeconds * parTime));
    System.out.println(String.format(" Best CUDA Time:        %8.3f", toSeconds * clTime));
    System.out.println(String.format(" Parallel Speedup: %15.5f", (double) seqTime / parTime));
    System.out.println(String.format(" CUDA Speedup:     %15.5f", (double) seqTime / clTime));
}

From source file:com.itemanalysis.psychometrics.irt.estimation.ItemParamPriorBeta.java

public double logDensity(double x) {
    if (x < 0)
        return Double.MIN_VALUE;
    if (x > 1)
        return Double.MIN_VALUE;
    return betaDistribution.logDensity(x);
}

From source file:com.basetechnology.s0.agentserver.field.FloatField.java

public FloatField(SymbolTable symbolTable, String name) {
    this.symbol = new Symbol(symbolTable, name, IntegerTypeNode.one);
    this.label = name;
    minValue = Double.MIN_VALUE;
    maxValue = Double.MAX_VALUE;/*from w ww .j  a va  2  s .  c o m*/
}

From source file:Main.java

/**
 * Returns the size of an ulp of the argument.  An ulp of a
 * <code>double</code> value is the positive distance between this
 * floating-point value and the <code>double</code> value next
 * larger in magnitude.  Note that for non-NaN <i>x</i>,
 * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
 *
 * <p>Special Cases:/*ww  w  .j  a  v a  2  s .  c o  m*/
 * <ul>
 * <li> If the argument is NaN, then the result is NaN.
 * <li> If the argument is positive or negative infinity, then the
 * result is positive infinity.
 * <li> If the argument is positive or negative zero, then the result is
 * <code>Double.MIN_VALUE</code>.
 * <li> If the argument is &plusmn;<code>Double.MAX_VALUE</code>, then
 * the result is equal to 2<sup>971</sup>.
 * </ul>
 *
 * @param d the floating-point value whose ulp is to be returned
 * @return the size of an ulp of the argument
 * @author Joseph D. Darcy
 * @since 1.5
 */
public static double ulp(double d) {
    int exp = getExponent(d);

    switch (exp) {
    case DoubleConsts.MAX_EXPONENT + 1: // NaN or infinity
        return Math.abs(d);
    // break;

    case DoubleConsts.MIN_EXPONENT - 1: // zero or subnormal
        return Double.MIN_VALUE;
    // break

    default:
        assert exp <= DoubleConsts.MAX_EXPONENT && exp >= DoubleConsts.MIN_EXPONENT;

        // ulp(x) is usually 2^(SIGNIFICAND_WIDTH-1)*(2^ilogb(x))
        exp = exp - (DoubleConsts.SIGNIFICAND_WIDTH - 1);
        if (exp >= DoubleConsts.MIN_EXPONENT) {
            return powerOfTwoD(exp);
        } else {
            // return a subnormal result; left shift integer
            // representation of Double.MIN_VALUE appropriate
            // number of positions
            return Double.longBitsToDouble(
                    1L << (exp - (DoubleConsts.MIN_EXPONENT - (DoubleConsts.SIGNIFICAND_WIDTH - 1))));
        }
        // break
    }
}

From source file:cc.mallet.types.PolyaUrnDirichlet.java

public VSResult nextDistributionWithSparseness(int[] counts) {
    double distribution[] = new double[partition.length];
    TIntArrayList resultingNonZeroIdxs = new TIntArrayList();
    double sum = 0;

    // implements the Poisson Polya Urn
    for (int i = 0; i < distribution.length; i++) {
        // determine whether we land in F_0 or F^_n
        if (counts[i] == 0 || ThreadLocalRandom.current()
                .nextDouble((partition[i] * magnitude) + counts[i]) < partition[i] * magnitude) {
            // sample from F_0
            distribution[i] = (double) nextPoisson(partition[i] * magnitude);
        } else {// w w  w  . ja  v a 2s .  c  o  m
            // sample from F^_n
            distribution[i] = (double) nextPoisson((double) counts[i]);
        }
        sum += distribution[i];
        if (distribution[i] != 0) {
            resultingNonZeroIdxs.add(i);
        }
    }

    for (int i = 0; i < distribution.length; i++) {
        distribution[i] /= sum;
        if (distribution[i] <= 0) {
            distribution[i] = Double.MIN_VALUE;
        }
    }

    return new VSResult(distribution, resultingNonZeroIdxs.toNativeArray());
}

From source file:inflor.core.plots.CategoricalNumberAxis.java

public CategoricalNumberAxis(String name, HashMap<Integer, String> lableMap) {
    super(name);//from  ww  w.  j a va 2s  .  c o m
    this.labelMap = lableMap;

    Integer[] yValues = lableMap.keySet().toArray(new Integer[lableMap.size()]);
    double yMin = Double.MAX_VALUE;
    double yMax = Double.MIN_VALUE;

    for (Integer d : yValues) {
        if (d < yMin) {
            yMin = d;
        }
        if (d > yMax) {
            yMax = d;
        }
    }
    this.setRange(new Range(yMin - 0.5, yMax + 0.5));
    NumberFormat formatter = new CategoryNumberFormat(lableMap);
    this.setNumberFormatOverride(formatter);
    this.setTickMarkOutsideLength(2);
}

From source file:mzmatch.ipeak.align.CowCoda.java

/**
 * /*w w  w.j av  a2  s .c om*/
 * @param peak
 * @return
 * @throws RuntimeException
 */
@SuppressWarnings("unchecked")
public static double codaDW(IPeak peak) throws RuntimeException {
    if (peak.getClass().equals(IPeakSet.class)) {
        IPeakSet<IPeak> peakset = (IPeakSet<IPeak>) peak;
        double codadw = Double.MIN_VALUE;
        for (IPeak p : peakset)
            codadw = Math.max(codadw, codaDW(p));
        return codadw;
    } else if (peak.getClass().equals(MassChromatogram.class))
        return ((MassChromatogram<Peak>) peak).codaDW();
    throw new RuntimeException("Only type MassChromatogram or PeakSet are supported");
}

From source file:Main.java

/**
 * Fills the array with random doubles.  Values will be between min (inclusive) and
 * max (inclusive)./*  w ww.j ava 2s .c  om*/
 */
public static void genRandomDoubles(long seed, double min, double max, double array[],
        boolean includeExtremes) {
    Random r = new Random(seed);
    int minExponent = Math.min(Math.getExponent(min), 0);
    int maxExponent = Math.max(Math.getExponent(max), 0);
    if (minExponent < -6 || maxExponent > 6) {
        // Use an exponential distribution
        int exponentDiff = maxExponent - minExponent;
        for (int i = 0; i < array.length; i++) {
            double mantissa = r.nextDouble();
            int exponent = minExponent + r.nextInt(maxExponent - minExponent);
            int sign = (min >= 0) ? 1 : 1 - r.nextInt(2) * 2; // -1 or 1
            double rand = sign * mantissa * Math.pow(2.0, exponent);
            if (rand < min || rand > max) {
                continue;
            }
            array[i] = rand;
        }
    } else {
        // Use a linear distribution
        for (int i = 0; i < array.length; i++) {
            double rand = r.nextDouble();
            array[i] = min + rand * (max - min);
        }
    }
    // Seed a few special numbers we want to be sure to test.
    for (int i = 0; i < sInterestingDoubles.length; i++) {
        double d = sInterestingDoubles[i];
        if (min <= d && d <= max) {
            array[r.nextInt(array.length)] = d;
        }
    }
    array[r.nextInt(array.length)] = min;
    array[r.nextInt(array.length)] = max;
    if (includeExtremes) {
        array[r.nextInt(array.length)] = Double.NaN;
        array[r.nextInt(array.length)] = Double.POSITIVE_INFINITY;
        array[r.nextInt(array.length)] = Double.NEGATIVE_INFINITY;
        array[r.nextInt(array.length)] = Double.MIN_VALUE;
        array[r.nextInt(array.length)] = Double.MIN_NORMAL;
        array[r.nextInt(array.length)] = Double.MAX_VALUE;
        array[r.nextInt(array.length)] = -Double.MIN_VALUE;
        array[r.nextInt(array.length)] = -Double.MIN_NORMAL;
        array[r.nextInt(array.length)] = -Double.MAX_VALUE;
    }
}

From source file:org.clueminer.eval.PBM.java

@Override
public double score(Clustering<E, C> clusters, Props params) {
    double db = Double.MIN_VALUE;
    double tmp, score;
    Instance g = clusters.getCentroid();
    double et = 0.0;
    double ew = 0.0;
    Instance x, y;/*from   ww  w  . j a va 2s  . c  om*/
    Cluster clust;
    for (int i = 0; i < clusters.size(); i++) {
        clust = clusters.get(i);
        x = clust.getCentroid();

        for (int j = 0; j < i; j++) {
            y = clusters.get(j).getCentroid();
            tmp = dm.measure(x, y);
            if (tmp > db) {
                db = tmp;
            }
        }

        //distance of each cluster member to its centroid
        for (int j = 0; j < clust.size(); j++) {
            y = clust.get(j);
            ew += dm.measure(y, x);
            //distance to global centroid
            et += dm.measure(y, g);
        }
    }
    score = (et * db) / (ew * clusters.size());
    return FastMath.pow(score, 2);
}