Example usage for java.lang Double MAX_VALUE

List of usage examples for java.lang Double MAX_VALUE

Introduction

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

Prototype

double MAX_VALUE

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

Click Source Link

Document

A constant holding the largest positive finite value of type double , (2-2-52)·21023.

Usage

From source file:gov.va.isaac.gui.listview.operations.ParentRetire.java

@Override
public void init(ObservableList<SimpleDisplayConcept> conceptList) {
    super.init(conceptList);
    root_.add(new Label("Retire as parent"), 0, 0);
    retireAsParent_.setPromptText("-Populate the Concepts List-");
    Node n = ErrorMarkerUtils.setupErrorMarker(retireAsParent_, replaceOptionsInvalidString_);
    root_.add(n, 1, 0);//from  ww w.  j a v a  2s  . c o m

    ComboBoxSetupTool.setupComboBox(retireAsParent_);
    // TODO populate retireAsParentCombo

    retireAsParent_.setMaxWidth(Double.MAX_VALUE);
    GridPane.setHgrow(n, Priority.ALWAYS);
    FxUtils.preventColCollapse(root_, 0);

    retireAsParent_.getItems().addListener(new ListChangeListener<SimpleDisplayConcept>() {
        @Override
        public void onChanged(javafx.collections.ListChangeListener.Change<? extends SimpleDisplayConcept> c) {
            if (retireAsParent_.getItems().size() > 0) {
                replaceOptionsInvalidString_.set(null);
                if (retireAsParent_.getSelectionModel().getSelectedItem() == null) {
                    retireAsParent_.getSelectionModel().selectFirst();
                }
            } else {
                replaceOptionsInvalidString_.set("A concept must be selected from this drop down");
                retireAsParent_.getSelectionModel().clearSelection();
                retireAsParent_.setValue(null);
                retireAsParent_.setPromptText("-Populate the Concepts List-");
            }
        }
    });

    allValid_ = new BooleanBinding() {
        {
            super.bind(replaceOptionsInvalidString_);
        }

        @Override
        protected boolean computeValue() {
            return StringUtils.isBlank(replaceOptionsInvalidString_.get());
        }
    };

}

From source file:classif.PrototyperEUC.java

@Override
public double evalErrorRate(ClassedSequence[] testSequences) {

    int nbCorrectlyClassified = 0;
    for (int s = 0; s < testSequences.length; s++) {
        Sequence seq = testSequences[s].sequence;
        double minD = Double.MAX_VALUE;
        String classValue = null;

        for (ClassedSequence proto : prototypes) {
            double tmpD = seq.distanceEuc(proto.sequence);
            if (tmpD < minD) {
                minD = tmpD;//from   w  w w  .  j  av a 2  s  . com
                classValue = proto.classValue;
            }
        }

        if (classValue.equals(testSequences[s].classValue)) {
            nbCorrectlyClassified++;
        }

    }

    return 1.0 - 1.0 * nbCorrectlyClassified / (testSequences.length);
}

From source file:com.joptimizer.algebra.Matrix1NornRescaler.java

/**
 * Scaling factors for not singular matrices.
 * @see Daniel Ruiz, "A scaling algorithm to equilibrate both rows and columns norms in matrices"
 * @see Philip A. Knight, Daniel Ruiz, Bora Ucar "A Symmetry Preserving Algorithm for Matrix Scaling"
 *///from   w  w  w  . j  a v  a 2  s  .c  o m
@Override
public DoubleMatrix1D[] getMatrixScalingFactors(DoubleMatrix2D A) {
    DoubleFactory1D F1 = DoubleFactory1D.dense;
    Algebra ALG = Algebra.DEFAULT;
    int r = A.rows();
    int c = A.columns();
    DoubleMatrix1D D1 = F1.make(r, 1);
    DoubleMatrix1D D2 = F1.make(c, 1);
    DoubleMatrix2D AK = A.copy();
    DoubleMatrix1D DR = F1.make(r, 1);
    DoubleMatrix1D DC = F1.make(c, 1);
    DoubleMatrix1D DRInv = F1.make(r);
    DoubleMatrix1D DCInv = F1.make(c);
    log.debug("eps  : " + eps);
    int maxIteration = 50;
    for (int k = 0; k <= maxIteration; k++) {
        double normR = -Double.MAX_VALUE;
        double normC = -Double.MAX_VALUE;
        for (int i = 0; i < r; i++) {
            double dri = ALG.normInfinity(AK.viewRow(i));
            DR.setQuick(i, Math.sqrt(dri));
            DRInv.setQuick(i, 1. / Math.sqrt(dri));
            normR = Math.max(normR, Math.abs(1 - dri));
        }
        for (int j = 0; j < c; j++) {
            double dci = ALG.normInfinity(AK.viewColumn(j));
            DC.setQuick(j, Math.sqrt(dci));
            DCInv.setQuick(j, 1. / Math.sqrt(dci));
            normC = Math.max(normC, Math.abs(1 - dci));
        }

        log.debug("normR: " + normR);
        log.debug("normC: " + normC);
        if (normR < eps && normC < eps) {
            break;
        }

        //D1 = ALG.mult(D1, DRInv);
        for (int i = 0; i < r; i++) {
            double prevD1I = D1.getQuick(i);
            double newD1I = prevD1I * DRInv.getQuick(i);
            D1.setQuick(i, newD1I);
        }
        //D2 = ALG.mult(D2, DCInv);
        for (int j = 0; j < c; j++) {
            double prevD2J = D2.getQuick(j);
            double newD2J = prevD2J * DCInv.getQuick(j);
            D2.setQuick(j, newD2J);
        }
        //log.debug("D1: " + ArrayUtils.toString(D1.toArray()));
        //log.debug("D2: " + ArrayUtils.toString(D2.toArray()));

        if (k == maxIteration) {
            log.warn("max iteration reached");
        }

        //AK = ALG.mult(DRInv, ALG.mult(AK, DCInv));
        AK = ColtUtils.diagonalMatrixMult(DRInv, AK, DCInv);
    }

    return new DoubleMatrix1D[] { D1, D2 };
}

From source file:lirmm.inria.fr.peersim.dpmf.MainSite.java

public MainSite(long ID) throws IOException {
    super(ID);//from   w w  w  .ja  v  a2s.  c  o m
    latentDimension = Configuration.getInt(parameter_latentDimension);
    lambdaU = Configuration.getDouble(parameter_u);
    lambdaV = Configuration.getDouble(parameter_v);
    lambdaR = Configuration.getDouble(parameter_r);
    J = Double.MAX_VALUE;
    String file = Configuration.getString(parameter_datasource);
    R = DataMatrix.createDataMatrix(file);
    U = BigSparseRealMatrix.randomGenerateMatrix(latentDimension, R.getRowDimension());
    V = BigSparseRealMatrix.randomGenerateMatrix(latentDimension, R.getColumnDimension());
    R.cutDataSet(Configuration.getDouble(parameter_testsetrate), 0);
    System.err.println("R=[" + R.getRowDimension() + "," + R.getColumnDimension() + "]= " + R.getDataSize()
            + " (Rate = " + Configuration.getDouble(parameter_testsetrate) + "%)");
    //        double[][] uData = {{0.04459, 0.06017, 0.09179, 0.04057, 0.08069, 0.06254, 0.07317, 0.02529, 0.0926, 0.04346},
    //        {0.06973, 0.049, 0.06391, 0.01254, 0.05567, 0.05333, 0.08618, 0.05368, 0.01709, 0.06473},
    //        {0.08956, 0.09606, 0.06459, 0.09891, 0.04529, 0.04609, 0.08478, 0.05972, 0.01564, 0.06002}};
    //        
    //        double[][] vData = {{0.06608, 0.02523, 0.0624, 0.0897, 0.03538, 0.05164, 0.06457, 0.07063, 0.09929, 0.08286},
    //        {0.05791, 0.09987, 0.05437, 0.03309, 0.04333, 0.02943, 0.01195, 0.01118, 0.03416, 0.01022},
    //        {0.00973, 0.08802, 0.05382, 0.06729, 0.07961, 0.03695, 0.02192, 0.06149, 0.00978, 0.04965}};
    //        U = new BigSparseRealMatrix(uData);
    //        V = new BigSparseRealMatrix(vData);
}

From source file:com.joptimizer.algebra.Matrix1NormRescaler.java

/**
 * Scaling factors for not singular matrices.
 * @see Daniel Ruiz, "A scaling algorithm to equilibrate both rows and columns norms in matrices"
 * @see Philip A. Knight, Daniel Ruiz, Bora Ucar "A Symmetry Preserving Algorithm for Matrix Scaling"
 *///from w  ww.j  av  a  2s .  c  o m
public DoubleMatrix1D[] getMatrixScalingFactors(DoubleMatrix2D A) {
    DoubleFactory1D F1 = DoubleFactory1D.dense;
    DoubleFactory2D F2 = DoubleFactory2D.sparse;
    Algebra ALG = Algebra.DEFAULT;
    int r = A.rows();
    int c = A.columns();
    DoubleMatrix1D D1 = F1.make(r, 1);
    DoubleMatrix1D D2 = F1.make(c, 1);
    DoubleMatrix2D AK = A.copy();
    DoubleMatrix1D DR = F1.make(r, 1);
    DoubleMatrix1D DC = F1.make(c, 1);
    DoubleMatrix1D DRInv = F1.make(r);
    DoubleMatrix1D DCInv = F1.make(c);
    log.debug("eps  : " + eps);
    int maxIteration = 50;
    for (int k = 0; k <= maxIteration; k++) {
        double normR = -Double.MAX_VALUE;
        double normC = -Double.MAX_VALUE;
        for (int i = 0; i < r; i++) {
            double dri = ALG.normInfinity(AK.viewRow(i));
            DR.setQuick(i, Math.sqrt(dri));
            DRInv.setQuick(i, 1. / Math.sqrt(dri));
            normR = Math.max(normR, Math.abs(1 - dri));
        }
        for (int j = 0; j < c; j++) {
            double dci = ALG.normInfinity(AK.viewColumn(j));
            DC.setQuick(j, Math.sqrt(dci));
            DCInv.setQuick(j, 1. / Math.sqrt(dci));
            normC = Math.max(normC, Math.abs(1 - dci));
        }

        log.debug("normR: " + normR);
        log.debug("normC: " + normC);
        if (normR < eps && normC < eps) {
            break;
        }

        //D1 = ALG.mult(D1, DRInv);
        for (int i = 0; i < r; i++) {
            double prevD1I = D1.getQuick(i);
            double newD1I = prevD1I * DRInv.getQuick(i);
            D1.setQuick(i, newD1I);
        }
        //D2 = ALG.mult(D2, DCInv);
        for (int j = 0; j < c; j++) {
            double prevD2J = D2.getQuick(j);
            double newD2J = prevD2J * DCInv.getQuick(j);
            D2.setQuick(j, newD2J);
        }
        //log.debug("D1: " + ArrayUtils.toString(D1.toArray()));
        //log.debug("D2: " + ArrayUtils.toString(D2.toArray()));

        if (k == maxIteration) {
            log.warn("max iteration reached");
        }

        //AK = ALG.mult(DRInv, ALG.mult(AK, DCInv));
        AK = ColtUtils.diagonalMatrixMult(DRInv, AK, DCInv);
    }

    return new DoubleMatrix1D[] { D1, D2 };
}

From source file:de.knowwe.visualization.util.Utils.java

public static String prepareLabel(String string) {
    // if (true) return string;
    String lb = LINE_BREAK;/*from  w  ww  .ja  v  a  2s  .c  om*/

    int length = string.length();
    if (length < 13)
        return clean(string, lb);

    // find possible line break positions
    Set<Integer> possibleLBs = new TreeSet<>();

    // possible line breaks are before the following chars:
    // _ >= <= = . ( [ and white spaces
    Matcher m = Pattern.compile("_|>=|<=|=|\\.|\\([^\\)]{1}|\\[[^\\]]{1}").matcher(string);
    while (m.find()) {
        possibleLBs.add(m.start(0));
    }
    // line breaks at whitespace only if they are not in range of = or > or
    // <
    m = Pattern.compile("(?<=[^=<>]){3}( )(?=[^=<>]{3})").matcher(string);
    while (m.find()) {
        possibleLBs.add(m.start(1));
    }

    if (possibleLBs.isEmpty())
        return clean(string, lb);

    // add the line breaks were it makes sense
    List<Integer> desiredLBs = new LinkedList<>();
    Set<Integer> addedLBs = new TreeSet<>();

    // optimal length is determined by the length of the given String
    double optimalLength = (double) length / Math.sqrt(length / 5);

    for (int i = 1; i < string.length() / optimalLength; i++) {
        // having the line breaks on these position would be optimal
        desiredLBs.add((int) Math.round(i * optimalLength));
    }

    //todo: remove creation of trailing linebreaks

    // try to find those possible line breaks that closest to the optimal
    // line breaks
    int d = 0;
    for (Integer desLB : desiredLBs) {
        int bestCandiadate = 0;
        // to avoid breaks for only a few chars at the end, we make
        // extra efforts for the last line break
        // we get the line break that produces the smallest variance
        // we should actually calculate the best break via variance for
        // all line breaks, but that seems rather complex and not yet
        // justified right now, since the current simple algorithm
        // already produces nice results
        if (d == desiredLBs.size() - 1) {
            double bestVar = Double.MAX_VALUE;
            for (Integer posLB : possibleLBs) {
                Set<Integer> temp = new TreeSet<>(addedLBs);
                temp.add(posLB);
                TreeSet<Integer> varianceCheck = new TreeSet<>(temp);
                varianceCheck.add(length);
                double variance = getVariance(varianceCheck);
                if (variance <= bestVar) {
                    bestVar = variance;
                    bestCandiadate = posLB;
                }
            }
        }
        // for all other breakpoints, just get the one closest to the
        // desired position
        else {
            for (Integer posLB : possibleLBs) {
                if (Math.abs(desLB - posLB) <= Math.abs(desLB - bestCandiadate)) {
                    bestCandiadate = posLB;
                }
            }
        }
        if (bestCandiadate != 0 && bestCandiadate != length) {
            addedLBs.add(bestCandiadate);
        }
        d++;
    }

    // but in the line breaks
    StringBuilder labelBuilder = new StringBuilder();
    List<String> split = new ArrayList<>(addedLBs.size() + 1);
    int last = 0;
    for (Integer addedLB : addedLBs) {
        split.add(string.substring(last, addedLB));
        last = addedLB;
    }
    split.add(string.substring(last, string.length()));
    for (String s : split) {
        // clean the substrings
        labelBuilder.append(clean(s.trim(), lb)).append(lb);
    }

    String label = labelBuilder.toString();
    return label;
}

From source file:com.opengamma.maths.lowlevelapi.functions.utilities.Min.java

/**
 * Returns the index of the minimum value in data
 * @param data the data to search/*  ww  w .jav  a2  s. c om*/
 * @return idx, the index of the minimum value in the data
 */
public static int index(double... data) {
    Validate.notNull(data);
    double min = Double.MAX_VALUE;
    int idx = -1;
    final int n = data.length;
    for (int i = 0; i < n; i++) {
        if (data[i] < min) {
            min = data[i];
            idx = i;
        }
    }
    return idx;
}

From source file:com.l2jfree.gameserver.model.entity.Entity.java

public double getDistanceToZone(int x, int y) {
    if (_zone != null)
        return _zone.getDistanceToZone(x, y);

    _log.error(getClassName() + " has no zone defined");
    return Double.MAX_VALUE;
}

From source file:gsn.reports.scriptlets.StreamScriptlet.java

@SuppressWarnings("unchecked")
public void setStatistics() throws JRScriptletException {

    String max = "NA";
    String min = "NA";
    String average = "NA";
    String stdDeviation = "NA";
    String median = "NA";
    String nb = "0";
    String startTime = "NA";
    String endTime = "NA";
    String samplingAverage = "NA";
    //      String samplingAverageUnit      = "NA";
    String nbOfNull = "0";
    String samplingStdDeviation = "NA";
    //      String samplingStdDeviationUnit   = "NA";

    Collection<Data> datas = (Collection<Data>) this.getFieldValue("datas");
    if (datas.size() > 0) {
        Double max_value = Double.MIN_VALUE;
        Double min_value = Double.MAX_VALUE;
        Double average_value = 0.0;
        Double sum_value = 0.0;/* w  ww  .  ja  v  a 2 s . c  o m*/
        Long start_time_value = 0L;
        Long end_time_value = 0L;
        Long sampling_average_value = 0L;
        Integer nb_value = 0;
        Integer nb_of_null = 0;
        Iterator<Data> iter = datas.iterator();
        Data nextData;
        Double nextDataValue;
        while (iter.hasNext()) {
            nextData = iter.next();
            if (nextData.getValue() != null) {
                nextDataValue = (Double) nextData.getValue();
                //
                sum_value += nextDataValue;
                //
                if (nextDataValue < min_value)
                    min_value = nextDataValue;
                if (nextDataValue > max_value)
                    max_value = nextDataValue;
                //               
                if (datas.size() == 1 || nb_value == datas.size() / 2)
                    median = nextDataValue.toString();
                //
                if (!iter.hasNext()) {
                    startTime = sdf.format(new Date((Long) nextData.getP2())).toString();
                    start_time_value = (Long) nextData.getP2();
                }
                if (nb_value == 0) {
                    endTime = sdf.format(new Date((Long) nextData.getP2())).toString();
                    end_time_value = (Long) nextData.getP2();
                }
            } else {
                nb_of_null++;
            }
            nb_value++;
        }
        //
        max = max_value == Double.MIN_VALUE ? "NA" : max_value.toString();
        min = min_value == Double.MAX_VALUE ? "NA" : min_value.toString();
        nb = nb_value.toString();
        average_value = (Double) (sum_value / nb_value);
        average = average_value.toString();
        nbOfNull = nb_of_null.toString();
        //
        if (datas.size() > 1) {
            sampling_average_value = (end_time_value - start_time_value) / (nb_value - 1);
            samplingAverage = Helpers.formatTimePeriod(sampling_average_value);
        }
        //
        iter = datas.iterator();
        Double variance_value = 0.0;
        Double sampling_variance_value = 0.0;
        Long lastDataTime = end_time_value;
        int i = 0;
        while (iter.hasNext()) {
            nextData = iter.next();
            if (nextData.getValue() != null) {
                nextDataValue = (Double) nextData.getValue();
                variance_value += Math.pow((average_value - nextDataValue), 2);
                if (i > 0) {
                    sampling_variance_value += Math
                            .pow((sampling_average_value - ((lastDataTime - (Long) nextData.getP2()))), 2);
                    lastDataTime = (Long) nextData.getP2();
                }
                i++;
            }
        }
        stdDeviation = ((Double) Math.sqrt(variance_value)).toString();
        if (datas.size() > 1) {
            Double sampling_std_deviation = (Double) Math.sqrt(sampling_variance_value);
            samplingStdDeviation = Helpers.formatTimePeriod(sampling_std_deviation.longValue());
        }
    }

    this.setVariableValue("max", max); // ok
    this.setVariableValue("min", min); // ok
    this.setVariableValue("average", average); // ok
    this.setVariableValue("stdDeviation", stdDeviation); // ok
    this.setVariableValue("median", median); // ok
    this.setVariableValue("nb", nb); // ok
    this.setVariableValue("startTime", startTime); // ok
    this.setVariableValue("endTime", endTime); // ok
    this.setVariableValue("samplingAverage", samplingAverage); // ok
    this.setVariableValue("nbOfNull", nbOfNull); // ok
    this.setVariableValue("samplingStdDeviation", samplingStdDeviation); // ok
}

From source file:com.redhat.lightblue.metadata.types.DoubleTypeTest.java

@Test
public void testCastBigDecimal() {
    assertTrue(doubleType.cast(Double.MAX_VALUE) instanceof Double);
}