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


Java Precision.SAFE_MIN属性代码示例

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


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

示例1: computeGeometricalProperties

/** {@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,代码行数:25,代码来源:ArcsSet.java

示例2: computeGeometricalProperties

/** {@inheritDoc} */
@Override
protected void computeGeometricalProperties() {
    if (getTree(false).getCut() == null) {
        setBarycenter((Point<Euclidean1D>) Vector1D.NaN);
        setSize(((Boolean) getTree(false).getAttribute()) ? Double.POSITIVE_INFINITY : 0);
    } else {
        double size = 0.0;
        double sum = 0.0;
        for (final Interval interval : asList()) {
            size += interval.getSize();
            sum  += interval.getSize() * interval.getBarycenter();
        }
        setSize(size);
        if (Double.isInfinite(size)) {
            setBarycenter((Point<Euclidean1D>) Vector1D.NaN);
        } else if (size >= Precision.SAFE_MIN) {
            setBarycenter((Point<Euclidean1D>) new Vector1D(sum / size));
        } else {
            setBarycenter((Point<Euclidean1D>) ((OrientedPoint) getTree(false).getCut().getHyperplane()).getLocation());
        }
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:23,代码来源:IntervalsSet.java

示例3: distance

/** Compute the shortest distance between the instance and another line.
 * @param line line to check against the instance
 * @return shortest distance between the instance and the line
 */
public double distance(final Line line) {

    final Vector3D normal = Vector3D.crossProduct(direction, line.direction);
    final double n = normal.getNorm();
    if (n < Precision.SAFE_MIN) {
        // lines are parallel
        return distance(line.zero);
    }

    // signed separation of the two parallel planes that contains the lines
    final double offset = line.zero.subtract(zero).dotProduct(normal) / n;

    return FastMath.abs(offset);

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

示例4: SmoothingPolynomialBicubicSplineInterpolator

/**
 * @param xDegree Degree of the polynomial fitting functions along the
 * x-dimension.
 * @param yDegree Degree of the polynomial fitting functions along the
 * y-dimension.
 * @exception NotPositiveException if degrees are not positive
 */
public SmoothingPolynomialBicubicSplineInterpolator(int xDegree, int yDegree)
    throws NotPositiveException {
    if (xDegree < 0) {
        throw new NotPositiveException(xDegree);
    }
    if (yDegree < 0) {
        throw new NotPositiveException(yDegree);
    }
    this.xDegree = xDegree;
    this.yDegree = yDegree;

    final double safeFactor = 1e2;
    final SimpleVectorValueChecker checker
        = new SimpleVectorValueChecker(safeFactor * Precision.EPSILON,
                                       safeFactor * Precision.SAFE_MIN);
    xFitter = new PolynomialFitter(new GaussNewtonOptimizer(false, checker));
    yFitter = new PolynomialFitter(new GaussNewtonOptimizer(false, checker));
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:25,代码来源:SmoothingPolynomialBicubicSplineInterpolator.java

示例5: solveLowerTriangularSystem

/**Solve  a  system of composed of a Lower Triangular Matrix
 * {@link RealMatrix}.
 * <p>
 * This method is called to solve systems of equations which are
 * of the lower triangular form. The matrix {@link RealMatrix}
 * is assumed, though not checked, to be in lower triangular form.
 * The vector {@link RealVector} is overwritten with the solution.
 * The matrix is checked that it is square and its dimensions match
 * the length of the vector.
 * </p>
 * @param rm RealMatrix which is lower triangular
 * @param b  RealVector this is overwritten
 * @throws DimensionMismatchException if the matrix and vector are not
 * conformable
 * @throws NonSquareMatrixException if the matrix {@code rm} is not square
 * @throws MathArithmeticException if the absolute value of one of the diagonal
 * coefficient of {@code rm} is lower than {@link Precision#SAFE_MIN}
 */
public static void solveLowerTriangularSystem(RealMatrix rm, RealVector b)
    throws DimensionMismatchException, MathArithmeticException,
    NonSquareMatrixException {
    if ((rm == null) || (b == null) || ( rm.getRowDimension() != b.getDimension())) {
        throw new DimensionMismatchException(
                (rm == null) ? 0 : rm.getRowDimension(),
                (b == null) ? 0 : b.getDimension());
    }
    if( rm.getColumnDimension() != rm.getRowDimension() ){
        throw new NonSquareMatrixException(rm.getRowDimension(),
                                           rm.getColumnDimension());
    }
    int rows = rm.getRowDimension();
    for( int i = 0 ; i < rows ; i++ ){
        double diag = rm.getEntry(i, i);
        if( FastMath.abs(diag) < Precision.SAFE_MIN ){
            throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
        }
        double bi = b.getEntry(i)/diag;
        b.setEntry(i,  bi );
        for( int j = i+1; j< rows; j++ ){
            b.setEntry(j, b.getEntry(j)-bi*rm.getEntry(j,i)  );
        }
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:43,代码来源:MatrixUtils.java

示例6: solveUpperTriangularSystem

/** Solver a  system composed  of an Upper Triangular Matrix
 * {@link RealMatrix}.
 * <p>
 * This method is called to solve systems of equations which are
 * of the lower triangular form. The matrix {@link RealMatrix}
 * is assumed, though not checked, to be in upper triangular form.
 * The vector {@link RealVector} is overwritten with the solution.
 * The matrix is checked that it is square and its dimensions match
 * the length of the vector.
 * </p>
 * @param rm RealMatrix which is upper triangular
 * @param b  RealVector this is overwritten
 * @throws DimensionMismatchException if the matrix and vector are not
 * conformable
 * @throws NonSquareMatrixException if the matrix {@code rm} is not
 * square
 * @throws MathArithmeticException if the absolute value of one of the diagonal
 * coefficient of {@code rm} is lower than {@link Precision#SAFE_MIN}
 */
public static void solveUpperTriangularSystem(RealMatrix rm, RealVector b)
    throws DimensionMismatchException, MathArithmeticException,
    NonSquareMatrixException {
    if ((rm == null) || (b == null) || ( rm.getRowDimension() != b.getDimension())) {
        throw new DimensionMismatchException(
                (rm == null) ? 0 : rm.getRowDimension(),
                (b == null) ? 0 : b.getDimension());
    }
    if( rm.getColumnDimension() != rm.getRowDimension() ){
        throw new NonSquareMatrixException(rm.getRowDimension(),
                                           rm.getColumnDimension());
    }
    int rows = rm.getRowDimension();
    for( int i = rows-1 ; i >-1 ; i-- ){
        double diag = rm.getEntry(i, i);
        if( FastMath.abs(diag) < Precision.SAFE_MIN ){
            throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
        }
        double bi = b.getEntry(i)/diag;
        b.setEntry(i,  bi );
        for( int j = i-1; j>-1; j-- ){
            b.setEntry(j, b.getEntry(j)-bi*rm.getEntry(j,i)  );
        }
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:44,代码来源:MatrixUtils.java

示例7: solveLowerTriangularSystem

/**Solve  a  system of composed of a Lower Triangular Matrix
 * {@link RealMatrix}.
 * <p>
 * This method is called to solve systems of equations which are
 * of the lower triangular form. The matrix {@link RealMatrix}
 * is assumed, though not checked, to be in lower triangular form.
 * The vector {@link RealVector} is overwritten with the solution.
 * The matrix is checked that it is square and its dimensions match
 * the length of the vector.
 * </p>
 * @param rm RealMatrix which is lower triangular
 * @param b  RealVector this is overwritten
 * @exception IllegalArgumentException if the matrix and vector are not conformable
 * @exception ArithmeticException there is a zero or near zero on the diagonal of rm
 */
public static void solveLowerTriangularSystem( RealMatrix rm, RealVector b){
    if ((rm == null) || (b == null) || ( rm.getRowDimension() != b.getDimension())) {
        throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
                (rm == null) ? 0 : rm.getRowDimension(),
                (b == null) ? 0 : b.getDimension());
    }
    if( rm.getColumnDimension() != rm.getRowDimension() ){
        throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
                rm.getRowDimension(),rm.getRowDimension(),
                rm.getRowDimension(),rm.getColumnDimension());
    }
    int rows = rm.getRowDimension();
    for( int i = 0 ; i < rows ; i++ ){
        double diag = rm.getEntry(i, i);
        if( FastMath.abs(diag) < Precision.SAFE_MIN ){
            throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
        }
        double bi = b.getEntry(i)/diag;
        b.setEntry(i,  bi );
        for( int j = i+1; j< rows; j++ ){
            b.setEntry(j, b.getEntry(j)-bi*rm.getEntry(j,i)  );
        }
    }
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:39,代码来源:MatrixUtils.java

示例8: solveUpperTriangularSystem

/** Solver a  system composed  of an Upper Triangular Matrix
 * {@link RealMatrix}.
 * <p>
 * This method is called to solve systems of equations which are
 * of the lower triangular form. The matrix {@link RealMatrix}
 * is assumed, though not checked, to be in upper triangular form.
 * The vector {@link RealVector} is overwritten with the solution.
 * The matrix is checked that it is square and its dimensions match
 * the length of the vector.
 * </p>
 * @param rm RealMatrix which is upper triangular
 * @param b  RealVector this is overwritten
 * @exception IllegalArgumentException if the matrix and vector are not conformable
 * @exception ArithmeticException there is a zero or near zero on the diagonal of rm
 */
public static void solveUpperTriangularSystem( RealMatrix rm, RealVector b){
    if ((rm == null) || (b == null) || ( rm.getRowDimension() != b.getDimension())) {
        throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
                (rm == null) ? 0 : rm.getRowDimension(),
                (b == null) ? 0 : b.getDimension());
    }
    if( rm.getColumnDimension() != rm.getRowDimension() ){
        throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
                rm.getRowDimension(),rm.getRowDimension(),
                rm.getRowDimension(),rm.getColumnDimension());
    }
    int rows = rm.getRowDimension();
    for( int i = rows-1 ; i >-1 ; i-- ){
        double diag = rm.getEntry(i, i);
        if( FastMath.abs(diag) < Precision.SAFE_MIN ){
            throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
        }
        double bi = b.getEntry(i)/diag;
        b.setEntry(i,  bi );
        for( int j = i-1; j>-1; j-- ){
            b.setEntry(j, b.getEntry(j)-bi*rm.getEntry(j,i)  );
        }
    }
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:39,代码来源:MatrixUtils.java

示例9: normalize

/**
 * Computes the normalized quaternion (the versor of the instance).
 * The norm of the quaternion must not be zero.
 *
 * @return a normalized quaternion.
 * @throws ZeroException if the norm of the quaternion is zero.
 */
public Quaternion normalize() {
    final double norm = getNorm();

    if (norm < Precision.SAFE_MIN) {
        throw new ZeroException(LocalizedFormats.NORM, norm);
    }

    return new Quaternion(q0 / norm,
                          q1 / norm,
                          q2 / norm,
                          q3 / norm);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:19,代码来源:Quaternion.java

示例10: getInverse

/**
 * Returns the inverse of this instance.
 * The norm of the quaternion must not be zero.
 *
 * @return the inverse.
 * @throws ZeroException if the norm (squared) of the quaternion is zero.
 */
public Quaternion getInverse() {
    final double squareNorm = q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3;
    if (squareNorm < Precision.SAFE_MIN) {
        throw new ZeroException(LocalizedFormats.NORM, squareNorm);
    }

    return new Quaternion(q0 / squareNorm,
                          -q1 / squareNorm,
                          -q2 / squareNorm,
                          -q3 / squareNorm);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:18,代码来源:Quaternion.java

示例11: testTiny

@Test
public void testTiny() {
    ArcsSet tiny = new ArcsSet(0.0, Precision.SAFE_MIN / 2, 1.0e-10);
    Assert.assertEquals(1.0e-10, tiny.getTolerance(), 1.0e-20);
    Assert.assertEquals(Precision.SAFE_MIN / 2, tiny.getSize(), 1.0e-10);
    Assert.assertEquals(1, tiny.asList().size());
    Assert.assertEquals(0.0, tiny.asList().get(0).getInf(), 1.0e-10);
    Assert.assertEquals(Precision.SAFE_MIN / 2, tiny.asList().get(0).getSup(), 1.0e-10);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:9,代码来源:ArcsSetTest.java

示例12: value

/** {@inheritDoc}
 * @since 3.1
 */
public DerivativeStructure value(final DerivativeStructure t)
    throws DimensionMismatchException {

    final double u = is * (t.getValue() - mean);
    double[] f = new double[t.getOrder() + 1];

    // the nth order derivative of the Gaussian has the form:
    // dn(g(x)/dxn = (norm / s^n) P_n(u) exp(-u^2/2) with u=(x-m)/s
    // where P_n(u) is a degree n polynomial with same parity as n
    // P_0(u) = 1, P_1(u) = -u, P_2(u) = u^2 - 1, P_3(u) = -u^3 + 3 u...
    // the general recurrence relation for P_n is:
    // P_n(u) = P_(n-1)'(u) - u P_(n-1)(u)
    // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array
    final double[] p = new double[f.length];
    p[0] = 1;
    final double u2 = u * u;
    double coeff = norm * FastMath.exp(-0.5 * u2);
    if (coeff <= Precision.SAFE_MIN) {
        Arrays.fill(f, 0.0);
    } else {
        f[0] = coeff;
        for (int n = 1; n < f.length; ++n) {

            // update and evaluate polynomial P_n(x)
            double v = 0;
            p[n] = -p[n - 1];
            for (int k = n; k >= 0; k -= 2) {
                v = v * u2 + p[k];
                if (k > 2) {
                    p[k - 2] = (k - 1) * p[k - 1] - p[k - 3];
                } else if (k == 2) {
                    p[0] = p[1];
                }
            }
            if ((n & 0x1) == 1) {
                v *= u;
            }

            coeff *= is;
            f[n] = coeff * v;

        }
    }

    return t.compose(f);

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

示例13: LevenbergMarquardtOptimizer

/**
 * Build an optimizer for least squares problems with default values
 * for some of the tuning parameters (see the {@link
 * #LevenbergMarquardtOptimizer(double,double,double,double,double)
 * other contructor}.
 * The default values for the algorithm settings are:
 * <ul>
 *  <li>Initial step bound factor}: 100</li>
 *  <li>QR ranking threshold}: {@link Precision#SAFE_MIN}</li>
 * </ul>
 *
 * @param costRelativeTolerance Desired relative error in the sum of
 * squares.
 * @param parRelativeTolerance Desired relative error in the approximate
 * solution parameters.
 * @param orthoTolerance Desired max cosine on the orthogonality between
 * the function vector and the columns of the Jacobian.
 */
public LevenbergMarquardtOptimizer(double costRelativeTolerance,
                                   double parRelativeTolerance,
                                   double orthoTolerance) {
    this(100,
         costRelativeTolerance, parRelativeTolerance, orthoTolerance,
         Precision.SAFE_MIN);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:25,代码来源:LevenbergMarquardtOptimizer.java

示例14: LevenbergMarquardtOptimizer

/** Default constructor.
 * <p>
 * The default values for the algorithm settings are:
 * <ul>
 *  <li>Initial step bound factor: 100</li>
 *  <li>Cost relative tolerance: 1e-10</li>
 *  <li>Parameters relative tolerance: 1e-10</li>
 *  <li>Orthogonality tolerance: 1e-10</li>
 *  <li>QR ranking threshold: {@link Precision#SAFE_MIN}</li>
 * </ul>
 **/
public LevenbergMarquardtOptimizer() {
    this(100, 1e-10, 1e-10, 1e-10, Precision.SAFE_MIN);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:14,代码来源:LevenbergMarquardtOptimizer.java

示例15: LevenbergMarquardtOptimizer

/**
 * Build an optimizer for least squares problems with default values
 * for all the tuning parameters (see the {@link
 * #LevenbergMarquardtOptimizer(double,double,double,double,double)
 * other contructor}.
 * The default values for the algorithm settings are:
 * <ul>
 *  <li>Initial step bound factor: 100</li>
 *  <li>Cost relative tolerance: 1e-10</li>
 *  <li>Parameters relative tolerance: 1e-10</li>
 *  <li>Orthogonality tolerance: 1e-10</li>
 *  <li>QR ranking threshold: {@link Precision#SAFE_MIN}</li>
 * </ul>
 */
public LevenbergMarquardtOptimizer() {
    this(100, 1e-10, 1e-10, 1e-10, Precision.SAFE_MIN);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:17,代码来源:LevenbergMarquardtOptimizer.java


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