当前位置: 首页>>代码示例>>Java>>正文


Java Precision.equals方法代码示例

本文整理汇总了Java中org.apache.commons.math3.util.Precision.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Precision.equals方法的具体用法?Java Precision.equals怎么用?Java Precision.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.util.Precision的用法示例。


在下文中一共展示了Precision.equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isNonSingular

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Checks whether the decomposed matrix is non-singular.
 *
 * @return true if the decomposed matrix is non-singular.
 */
public boolean isNonSingular() {
    double largestEigenvalueNorm = 0.0;
    // Looping over all values (in case they are not sorted in decreasing
    // order of their norm).
    for (int i = 0; i < realEigenvalues.length; ++i) {
        largestEigenvalueNorm = FastMath.max(largestEigenvalueNorm, eigenvalueNorm(i));
    }
    // Corner case: zero matrix, all exactly 0 eigenvalues
    if (largestEigenvalueNorm == 0.0) {
        return false;
    }
    for (int i = 0; i < realEigenvalues.length; ++i) {
        // Looking for eigenvalues that are 0, where we consider anything much much smaller
        // than the largest eigenvalue to be effectively 0.
        if (Precision.equals(eigenvalueNorm(i) / largestEigenvalueNorm, 0, EPSILON)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:26,代码来源:EigenDecomposition.java

示例2: Arc

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/** Simple constructor.
 * <p>
 * If either {@code lower} is equals to {@code upper} or
 * the interval exceeds \( 2 \pi \), the arc is considered
 * to be the full circle and its initial defining boundaries
 * will be forgotten. {@code lower} is not allowed to be
 * greater than {@code upper} (an exception is thrown in this case).
 * {@code lower} will be canonicalized between 0 and \( 2 \pi \), and
 * upper shifted accordingly, so the {@link #getInf()} and {@link #getSup()}
 * may not return the value used at instance construction.
 * </p>
 * @param lower lower angular bound of the arc
 * @param upper upper angular bound of the arc
 * @param tolerance tolerance below which angles are considered identical
 * @exception NumberIsTooLargeException if lower is greater than upper
 */
public Arc(final double lower, final double upper, final double tolerance)
    throws NumberIsTooLargeException {
    this.tolerance = tolerance;
    if (Precision.equals(lower, upper, 0) || (upper - lower) >= MathUtils.TWO_PI) {
        // the arc must cover the whole circle
        this.lower  = 0;
        this.upper  = MathUtils.TWO_PI;
        this.middle = FastMath.PI;
    } else  if (lower <= upper) {
        this.lower  = MathUtils.normalizeAngle(lower, FastMath.PI);
        this.upper  = this.lower + (upper - lower);
        this.middle = 0.5 * (this.lower + this.upper);
    } else {
        throw new NumberIsTooLargeException(LocalizedFormats.ENDPOINTS_NOT_AN_INTERVAL,
                                            lower, upper, true);
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:34,代码来源:Arc.java

示例3: computeGeometricalProperties

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void computeGeometricalProperties() {
    if (getTree(false).getCut() == null) {
        setBarycenter(S1Point.NaN);
        setSize(((Boolean) getTree(false).getAttribute()) ? MathUtils.TWO_PI : 0);
    } else {
        double size = 0.0;
        double sum  = 0.0;
        for (final double[] a : this) {
            final double length = a[1] - a[0];
            size += length;
            sum  += length * (a[0] + a[1]);
        }
        setSize(size);
        if (Precision.equals(size, MathUtils.TWO_PI, 0)) {
            setBarycenter(S1Point.NaN);
        } else if (size >= Precision.SAFE_MIN) {
            setBarycenter(new S1Point(sum / (2 * size)));
        } else {
            final LimitAngle limit = (LimitAngle) getTree(false).getCut().getHyperplane();
            setBarycenter(limit.getLocation());
        }
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:26,代码来源:ArcsSet.java

示例4: solvePhase1

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Solves Phase 1 of the Simplex method.
 * @param tableau simple tableau for the problem
 * @throws MaxCountExceededException if the maximal iteration count has been exceeded
 * @throws UnboundedSolutionException if the model is found not to have a bounded solution
 * @throws NoFeasibleSolutionException if there is no feasible solution
 */
protected void solvePhase1(final SimplexTableau tableau)
    throws MaxCountExceededException, UnboundedSolutionException, NoFeasibleSolutionException {

    // make sure we're in Phase 1
    if (tableau.getNumArtificialVariables() == 0) {
        return;
    }

    while (!tableau.isOptimal()) {
        doIteration(tableau);
    }

    // if W is not zero then we have no feasible solution
    if (!Precision.equals(tableau.getEntry(0, tableau.getRhsOffset()), 0d, epsilon)) {
        throw new NoFeasibleSolutionException();
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:25,代码来源:SimplexSolver.java

示例5: solvePhase1

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Solves Phase 1 of the Simplex method.
 *
 * @param tableau Simple tableau for the problem.
 * @throws TooManyIterationsException if the allowed number of iterations has been exhausted.
 * @throws UnboundedSolutionException if the model is found not to have a bounded solution.
 * @throws NoFeasibleSolutionException if there is no feasible solution?
 */
protected void solvePhase1(final SimplexTableau tableau)
    throws TooManyIterationsException,
           UnboundedSolutionException,
           NoFeasibleSolutionException {

    // make sure we're in Phase 1
    if (tableau.getNumArtificialVariables() == 0) {
        return;
    }

    while (!tableau.isOptimal()) {
        doIteration(tableau);
    }

    // if W is not zero then we have no feasible solution
    if (!Precision.equals(tableau.getEntry(0, tableau.getRhsOffset()), 0d, epsilon)) {
        throw new NoFeasibleSolutionException();
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:28,代码来源:SimplexSolver.java

示例6: lastElementIsSame

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Checks that the contents of the last element is equal to the
 * contents of {@code p}.
 *
 * @param store Container.
 * @param point Observation.
 * @return {@code true} if both elements have the same contents.
 */
private boolean lastElementIsSame(WeightedObservedPoints store,
                                  WeightedObservedPoint point) {
    final List<WeightedObservedPoint> list = store.toList();
    final WeightedObservedPoint lastPoint = list.get(list.size() - 1);

    if (!Precision.equals(lastPoint.getX(), point.getX())) {
        return false;
    }
    if (!Precision.equals(lastPoint.getY(), point.getY())) {
        return false;
    }
    if (!Precision.equals(lastPoint.getWeight(), point.getWeight())) {
        return false;
    }

    return true;
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:26,代码来源:WeightedObservedPointsTest.java

示例7: containSameValues

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Checks whether the contents of both arrays is the same.
 *
 * @param current Current values.
 * @param expect Expected values.
 * @throws DimensionMismatchException if the length of {@code expected}
 * is not the same as specified in the {@link #Neuron(long,double[])
 * constructor}.
 * @return {@code true} if the arrays contain the same values.
 */
private boolean containSameValues(double[] current,
                                  double[] expect) {
    if (expect.length != size) {
        throw new DimensionMismatchException(expect.length, size);
    }

    for (int i = 0; i < size; i++) {
        if (!Precision.equals(current[i], expect[i])) {
            return false;
        }
    }
    return true;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:24,代码来源:Neuron.java

示例8: filterSpuriousVertices

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/** Filter out spurious vertices on straight lines (at machine precision).
 * @param loop segments loop to filter (will be modified in-place)
 */
private void filterSpuriousVertices(final List<Segment> loop) {
    for (int i = 0; i < loop.size(); ++i) {
        final Segment previous = loop.get(i);
        int j = (i + 1) % loop.size();
        final Segment next = loop.get(j);
        if (next != null &&
            Precision.equals(previous.getLine().getAngle(), next.getLine().getAngle(), Precision.EPSILON)) {
            // the vertex between the two edges is a spurious one
            // replace the two segments by a single one
            loop.set(j, new Segment(previous.getStart(), next.getEnd(), previous.getLine()));
            loop.remove(i--);
        }
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:18,代码来源:PolygonsSet.java

示例9: getBasicRow

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Checks whether the given column is basic.
 * @param col index of the column to check
 * @return the row that the variable is basic in.  null if the column is not basic
 */
protected Integer getBasicRow(final int col) {
    Integer row = null;
    for (int i = 0; i < getHeight(); i++) {
        final double entry = getEntry(i, col);
        if (Precision.equals(entry, 1d, maxUlps) && (row == null)) {
            row = i;
        } else if (!Precision.equals(entry, 0d, maxUlps)) {
            return null;
        }
    }
    return row;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:18,代码来源:SimplexTableau.java

示例10: equals

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Test for the equality of two sparse gradients.
 * <p>
 * Sparse gradients are considered equal if they have the same value
 * and the same derivatives.
 * </p>
 * @param other Object to test for equality to this
 * @return true if two sparse gradients are equal
 */
@Override
public boolean equals(Object other) {

    if (this == other) {
        return true;
    }

    if (other instanceof SparseGradient) {
        final SparseGradient rhs = (SparseGradient)other;
        if (!Precision.equals(value, rhs.value, 1)) {
            return false;
        }
        if (derivatives.size() != rhs.derivatives.size()) {
            return false;
        }
        for (final Map.Entry<Integer, Double> entry : derivatives.entrySet()) {
            if (!rhs.derivatives.containsKey(entry.getKey())) {
                return false;
            }
            if (!Precision.equals(entry.getValue(), rhs.derivatives.get(entry.getKey()), 1)) {
                return false;
            }
        }
        return true;
    }

    return false;

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:39,代码来源:SparseGradient.java

示例11: findBasicRow

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Returns the row in which the given column is basic.
 * @param col index of the column
 * @return the row that the variable is basic in, or {@code null} if the variable is not basic.
 */
private Integer findBasicRow(final int col) {
    Integer row = null;
    for (int i = 0; i < getHeight(); i++) {
        final double entry = getEntry(i, col);
        if (Precision.equals(entry, 1d, maxUlps) && (row == null)) {
            row = i;
        } else if (!Precision.equals(entry, 0d, maxUlps)) {
            return null;
        }
    }
    return row;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:18,代码来源:SimplexTableau.java

示例12: isSingular

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/** Returns whether this diagonal matrix is singular, i.e. any diagonal entry
 * is equal to {@code 0} within the given threshold.
 *
 * @param threshold Singularity threshold.
 * @return {@code true} if the matrix is singular, {@code false} otherwise
 * @since 3.3
 */
public boolean isSingular(double threshold) {
    for (int i = 0; i < data.length; i++) {
        if (Precision.equals(data[i], 0.0, threshold)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:16,代码来源:DiagonalMatrix.java

示例13: equals

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }
    if (!(o instanceof MeanSlopePair)) {
        return false;
    } else {
        MeanSlopePair msp = (MeanSlopePair) o;
        return Precision.equals(getFirst(), msp.getMean(), TimeSeriesPrecision.EPSILON) &&
                Precision.equals(getSecond(), msp.getSlope(), TimeSeriesPrecision.EPSILON);
    }
}
 
开发者ID:octavian-h,项目名称:time-series-math,代码行数:17,代码来源:MeanSlopePair.java

示例14: assertContains

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Fails iff values does not contain a number within epsilon of z.
 *
 * @param msg  message to return with failure
 * @param values complex array to search
 * @param z  value sought
 * @param epsilon  tolerance
 */
public static void assertContains(String msg, Complex[] values,
                                  Complex z, double epsilon) {
    for (Complex value : values) {
        if (Precision.equals(value.getReal(), z.getReal(), epsilon) &&
            Precision.equals(value.getImaginary(), z.getImaginary(), epsilon)) {
            return;
        }
    }
    Assert.fail(msg + " Unable to find " + (new ComplexFormat()).format(z));
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:19,代码来源:TestUtils.java

示例15: equals

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }
    if (!(o instanceof MeanLastPair)) {
        return false;
    } else {
        MeanLastPair mlp = (MeanLastPair) o;
        return Precision.equals(getFirst(), mlp.getMean(), TimeSeriesPrecision.EPSILON) &&
                getSecond() == mlp.getLast();
    }
}
 
开发者ID:octavian-h,项目名称:time-series-math,代码行数:17,代码来源:MeanLastPair.java


注:本文中的org.apache.commons.math3.util.Precision.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。