Example usage for java.lang Double POSITIVE_INFINITY

List of usage examples for java.lang Double POSITIVE_INFINITY

Introduction

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

Prototype

double POSITIVE_INFINITY

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

Click Source Link

Document

A constant holding the positive infinity of type double .

Usage

From source file:edu.oregonstate.eecs.mcplan.bandit.PolicyRolloutEvaluator.java

/**
 * @param sim//from  ww  w . ja v  a2  s  .c o m
 * @param s0 *Not* owned by PolicyRolloutEvaluator
 * @param depth_limit
 */
public PolicyRolloutEvaluator(final TrajectorySimulator<S, A> sim, final S s0, final int depth_limit) {
    this(sim, s0, depth_limit, Double.POSITIVE_INFINITY);
}

From source file:mulavito.gui.components.LayerViewer.java

public static void autoZoomViewer(VisualizationViewer<?, ?> vv, LayerViewer<?, ?> home, Directions direction) {
    if (vv == null || home == null)
        return;/*from w ww .j a  va 2 s  .c  o  m*/

    // reset transforms
    MutableTransformer layoutTrans = vv.getRenderContext().getMultiLayerTransformer()
            .getTransformer(edu.uci.ics.jung.visualization.Layer.LAYOUT);
    layoutTrans.setToIdentity();
    MutableTransformer viewTrans = vv.getRenderContext().getMultiLayerTransformer()
            .getTransformer(edu.uci.ics.jung.visualization.Layer.VIEW);
    viewTrans.setToIdentity();

    Dimension dim = vv.getSize();
    Rectangle2D.Double graphBounds = home.getGraphBoundsCache();

    CrossoverScalingControl scaler = new CrossoverScalingControl();

    // Scale using crossover scaler, so vertices will not grow
    // larger than they are in original
    double factor = Double.POSITIVE_INFINITY;

    if (direction == Directions.HORIZONTAL || direction == Directions.BOTH)
        factor = dim.getWidth() / graphBounds.width;
    if (direction == Directions.VERTICAL || direction == Directions.BOTH || Double.isInfinite(factor))
        factor = Math.min(factor, dim.getHeight() / graphBounds.height);
    scaler.scale(vv, (float) factor, vv.getCenter());

    // Translate center of graph to center of vv.
    Point2D lvc = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(vv.getCenter());
    double dx = (lvc.getX() - graphBounds.getCenterX());
    double dy = (lvc.getY() - graphBounds.getCenterY());
    layoutTrans.translate(dx, dy);
}

From source file:ffx.numerics.ModifiedBessel.java

/**
 * Returns Double.MAX_VALUE in place of Double.POSITIVE_INFINITY; Returns
 * Double.MIN_VALUE in place of Double.NEGATIVE_INFINITY
 *
 * @param x input parameter//from   w  w w.  jav  a  2 s  .  c  om
 * @return exp(x)
 */
private static double eToThe(double x) {
    double res = exp(x);
    if (res == Double.POSITIVE_INFINITY) {
        return Double.MAX_VALUE;
    } else if (res == Double.NEGATIVE_INFINITY) {
        return Double.MIN_VALUE;
    }
    return res;
}

From source file:com.analog.lyric.dimple.factorfunctions.Gamma.java

@Override
public final double evalEnergy(Value[] arguments) {
    int index = 0;
    if (!_parametersConstant) {
        _alpha = arguments[index++].getDouble(); // First input is alpha parameter (must be non-negative)
        if (_alpha <= 0)
            return Double.POSITIVE_INFINITY;
        _beta = arguments[index++].getDouble(); // Second input is beta parameter (must be non-negative)
        if (_beta <= 0)
            return Double.POSITIVE_INFINITY;
        _logBeta = Math.log(_beta);
    }//  w  w w. j ava  2s . c  o m
    final int length = arguments.length;
    final int N = length - index; // Number of non-parameter variables
    double sum = 0;
    if (_alpha == 1) {
        for (; index < length; index++) {
            double x = arguments[index].getDouble(); // Remaining inputs are Gamma variables
            if (x < 0)
                return Double.POSITIVE_INFINITY;
            else
                sum += x;
        }
        return sum * _beta - N * _logBeta;
    } else {
        if (!_parametersConstant) {
            _alphaMinusOne = _alpha - 1;
            _logGammaAlphaMinusAlphaLogBeta = org.apache.commons.math3.special.Gamma.logGamma(_alpha)
                    - _alpha * _logBeta;
        }
        for (; index < length; index++) {
            final double x = arguments[index].getDouble(); // Remaining inputs are Gamma variables
            if (x < 0)
                return Double.POSITIVE_INFINITY;
            else
                sum += x * _beta - Math.log(x) * _alphaMinusOne;
        }
        return sum + N * _logGammaAlphaMinusAlphaLogBeta;
    }
}

From source file:jurls.core.approximation.WeightedInterpolationFunction.java

@Override
public void learn(double[] xs, double y) {
    adjustBorders(xs);/*from   w w  w  .  j av  a  2 s .c  om*/

    ArrayRealVector xs3 = new ArrayRealVector(xs);

    double min = Double.POSITIVE_INFINITY;
    Point nearest = null;

    for (Point p : points) {
        double d = p.xs.getL1Distance(xs3);
        if (d < min) {
            min = d;
            nearest = p;
        }
    }

    nearest.xs.setSubVector(0, xs3);
    nearest.y = y;

    //move the points away from each other to get a homogenous distribution
    for (Point a : points) {
        for (Point b : points) {
            if (a != b) {
                ArrayRealVector d = b.xs.subtract(a.xs);
                double l = d.getL1Norm();
                if (l == 0) {
                    l = 1;
                }
                d.mapMultiplyToSelf(gravity / l / l / l);
                b.velocity.setSubVector(0, b.velocity.add(d));
            }
        }
    }

    for (Point p : points) {
        p.velocity.mapMultiplyToSelf(decay);
        p.xs.setSubVector(0, p.xs.add(p.velocity));

        for (int i = 0; i < numberOfInputs(); ++i) {
            if (p.xs.getEntry(i) > maxInput.getEntry(i)) {
                p.xs.setEntry(i, maxInput.getEntry(i));
                p.velocity.setEntry(i, 0);
            }
            if (p.xs.getEntry(i) < minInput.getEntry(i)) {
                p.xs.setEntry(i, minInput.getEntry(i));
                p.velocity.setEntry(i, 0);
            }
        }

        p.y = value(p.xs.getDataRef());
    }
}

From source file:com.clust4j.data.TestDataSet.java

@Test(expected = IllegalStateException.class)
public void testIris() {
    final int len = IRIS.getDataRef().getRowDimension();
    DataSet shuffled = IRIS.shuffle();//from   w w w.  j  a  v  a 2 s .  c om
    assertTrue(shuffled.getDataRef().getRowDimension() == len);

    // Test that no reference carried over...
    shuffled.getHeaderRef()[0] = "TESTING!";
    assertTrue(!IRIS.getHeaderRef()[0].equals(shuffled.getHeaderRef()[0]));

    shuffled.setColumn("TESTING!", VecUtils.rep(Double.POSITIVE_INFINITY, shuffled.numRows()));
    assertTrue(VecUtils.unique(shuffled.getColumn("TESTING!")).size() == 1);

    // Test piecewise col drops
    shuffled.dropCol("TESTING!");
    assertTrue(shuffled.numCols() == 3);

    shuffled.dropCol("Sepal Width");
    assertTrue(shuffled.numCols() == 2);

    shuffled.dropCol("Petal Length");
    assertTrue(shuffled.numCols() == 1);

    // Prepare for the throw...
    shuffled.dropCol("Petal Width"); // BOOM!
}

From source file:at.pcgamingfreaks.Utils.java

/**
 * Checks if two players are within a certain range from each other.
 *
 * @param player1 The first player.//from   w w  w.j  av a 2  s.co m
 * @param player2 The second player.
 * @param maxDistance The max distance between the two players. Negative values will always return true.
 * @return True if the players are within the given range, false if not.
 */
public static boolean inRange(@NotNull Player player1, @NotNull Player player2, double maxDistance) {
    if (maxDistance < 0)
        return true;
    double distance = getDistance(player1, player2);
    return (maxDistance == 0 && distance != Double.POSITIVE_INFINITY) || distance <= maxDistance;
}

From source file:org.jfree.experimental.chart.renderer.xy.VectorRenderer.java

/**
 * Returns the lower and upper bounds (range) of the x-values in the 
 * specified dataset./*  w w w  .  j  a  v  a 2 s.  c om*/
 * 
 * @param dataset  the dataset (<code>null</code> permitted).
 * 
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 */
public Range findDomainBounds(XYDataset dataset) {
    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();
    double lvalue;
    double uvalue;
    if (dataset instanceof VectorXYDataset) {
        VectorXYDataset vdataset = (VectorXYDataset) dataset;
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {
                double delta = vdataset.getDeltaXValue(series, item);
                if (delta < 0.0) {
                    uvalue = vdataset.getXValue(series, item);
                    lvalue = uvalue + delta;
                } else {
                    lvalue = vdataset.getXValue(series, item);
                    uvalue = lvalue + delta;
                }
                minimum = Math.min(minimum, lvalue);
                maximum = Math.max(maximum, uvalue);
            }
        }
    } else {
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {
                lvalue = dataset.getXValue(series, item);
                uvalue = lvalue;
                minimum = Math.min(minimum, lvalue);
                maximum = Math.max(maximum, uvalue);
            }
        }
    }
    if (minimum > maximum) {
        return null;
    } else {
        return new Range(minimum, maximum);
    }
}

From source file:com.facebook.presto.operator.aggregation.ApproximateUtils.java

private static double conservativeError(double error, double p, double samples) {
    // Heuristic to determine that the sample is too small
    if (p < 0.01 && samples < 100) {
        return Double.POSITIVE_INFINITY;
    }/*from   w  w  w  . j av a 2s.  co m*/
    return error;
}

From source file:visualizer.graph.scalar.DistanceScalar.java

public Scalar scalarFromPointsFile(String filename, Dissimilarity measure, Vertex vertex) throws IOException {
    Matrix matrix = MatrixFactory.getInstance(filename);

    //defining the index
    int index = -1;
    for (int i = 0; i < matrix.getRowCount(); i++) {
        if (matrix.getRow(i).getId().equals(vertex.getUrl())) {
            index = i;/* ww  w.java2s.  c o  m*/
            break;
        }
    }

    if (index == -1) {
        throw new IOException("Query data instance not found on the points file.");
    }

    //creating the scalar values
    double[] scalar = new double[matrix.getRowCount()];

    double min = Double.POSITIVE_INFINITY;
    for (int i = 0; i < scalar.length; i++) {
        scalar[i] = measure.calculate(matrix.getRow(i), matrix.getRow(index));

        if (min > scalar[i] && i != index) {
            min = scalar[i];
        }
    }

    scalar[index] = min;

    ArrayList<String> ids = new ArrayList<String>();
    for (int i = 0; i < matrix.getRowCount(); i++) {
        ids.add(matrix.getRow(i).getId());
    }

    return this.createScalar(scalar, ids, vertex);
}