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


Java Precision.EPSILON属性代码示例

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


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

示例1: closestPoint

/** Compute the point of the instance closest to another line.
 * @param line line to check against the instance
 * @return point of the instance closest to another line
 */
public Vector3D closestPoint(final Line line) {

    final double cos = direction.dotProduct(line.direction);
    final double n = 1 - cos * cos;
    if (n < Precision.EPSILON) {
        // the lines are parallel
        return zero;
    }

    final Vector3D delta0 = line.zero.subtract(zero);
    final double a        = delta0.dotProduct(direction);
    final double b        = delta0.dotProduct(line.direction);

    return new Vector3D(1, zero, (a - b * cos) / n, direction);

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

示例2: 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

示例3: isSymmetric

/**
 * Check if a matrix is symmetric.
 *
 * @param matrix Matrix to check.
 * @param raiseException If {@code true}, the method will throw an
 * exception if {@code matrix} is not symmetric.
 * @return {@code true} if {@code matrix} is symmetric.
 * @throws NonSymmetricMatrixException if the matrix is not symmetric and
 * {@code raiseException} is {@code true}.
 */
private boolean isSymmetric(final RealMatrix matrix,
                            boolean raiseException) {
    final int rows = matrix.getRowDimension();
    final int columns = matrix.getColumnDimension();
    final double eps = 10 * rows * columns * Precision.EPSILON;
    for (int i = 0; i < rows; ++i) {
        for (int j = i + 1; j < columns; ++j) {
            final double mij = matrix.getEntry(i, j);
            final double mji = matrix.getEntry(j, i);
            if (FastMath.abs(mij - mji) >
                (FastMath.max(FastMath.abs(mij), FastMath.abs(mji)) * eps)) {
                if (raiseException) {
                    throw new NonSymmetricMatrixException(i, j, eps);
                }
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:30,代码来源:EigenDecomposition.java

示例4: eig

/**
 * Takes a square symmetric real matrix [M] and finds an orthogonal transformation [U] such that
 * [U]^T [M] [U] is diagonal, and diagonal entries are sorted in descending order.
 *
 * @param matrix a symmetric matrix
 * @param symmetrize enforce symmetry
 * @param logger a logger instance
 * @return [U]
 */
public static ImmutablePair<double[], RealMatrix> eig(@Nonnull final RealMatrix matrix,
                                                      final boolean symmetrize,
                                                      @Nonnull final Logger logger) {
    if (matrix.getRowDimension() != matrix.getColumnDimension()) {
        throw new IllegalArgumentException("The input matrix must be square");
    }
    final RealMatrix finalMatrix;
    final double symTol = 10 * matrix.getRowDimension() * matrix.getColumnDimension() * Precision.EPSILON;
    if (symmetrize && !MatrixUtils.isSymmetric(matrix, symTol)) {
        logger.info("The input matrix is not symmetric -- enforcing symmetrization");
        finalMatrix = matrix.add(matrix.transpose()).scalarMultiply(0.5);
    } else {
        finalMatrix = matrix;
    }
    final EigenDecomposition decomposer = new EigenDecomposition(finalMatrix);
    final double[] eigs = decomposer.getRealEigenvalues();
    final RealMatrix V = decomposer.getV();
    return ImmutablePair.of(eigs, V);
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:28,代码来源:CoverageModelEMWorkspaceMathUtils.java

示例5: EigenDecomposition

/**
 * Calculates the eigen decomposition of the given real matrix.
 * <p>
 * Supports decomposition of a general matrix since 3.1.
 *
 * @param matrix Matrix to decompose.
 * @throws MaxCountExceededException if the algorithm fails to converge.
 * @throws MathArithmeticException if the decomposition of a general matrix
 * results in a matrix with zero norm
 * @since 3.1
 */
public EigenDecomposition(final RealMatrix matrix)
    throws MathArithmeticException {
    final double symTol = 10 * matrix.getRowDimension() * matrix.getColumnDimension() * Precision.EPSILON;
    isSymmetric = MatrixUtils.isSymmetric(matrix, symTol);
    if (isSymmetric) {
        transformToTridiagonal(matrix);
        findEigenVectors(transformer.getQ().getData());
    } else {
        final SchurTransformer t = transformToSchur(matrix);
        findEigenVectorsFromSchur(t);
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:23,代码来源:EigenDecomposition.java

示例6: testHash

@Test
public void testHash() {
    Assert.assertEquals(new Vector1D(Double.NaN).hashCode(), new Vector1D(Double.NaN).hashCode());
    Vector1D u = new Vector1D(1);
    Vector1D v = new Vector1D(1 + 10 * Precision.EPSILON);
    Assert.assertTrue(u.hashCode() != v.hashCode());
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:7,代码来源:Vector1DTest.java

示例7: testHash

@Test
public void testHash() {
    Assert.assertEquals(new Vector3D(0, Double.NaN, 0).hashCode(), new Vector3D(0, 0, Double.NaN).hashCode());
    Vector3D u = new Vector3D(1, 2, 3);
    Vector3D v = new Vector3D(1, 2, 3 + 10 * Precision.EPSILON);
    Assert.assertTrue(u.hashCode() != v.hashCode());
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:7,代码来源:Vector3DTest.java

示例8: include

/**
 * The include method is where the QR decomposition occurs. This statement forms all
 * intermediate data which will be used for all derivative measures.
 * According to the miller paper, note that in the original implementation the x vector
 * is overwritten. In this implementation, the include method is passed a copy of the
 * original data vector so that there is no contamination of the data. Additionally,
 * this method differs slightly from Gentleman's method, in that the assumption is
 * of dense design matrices, there is some advantage in using the original gentleman algorithm
 * on sparse matrices.
 *
 * @param x observations on the regressors
 * @param wi weight of the this observation (-1,1)
 * @param yi observation on the regressand
 */
private void include(final double[] x, final double wi, final double yi) {
    int nextr = 0;
    double w = wi;
    double y = yi;
    double xi;
    double di;
    double wxi;
    double dpi;
    double xk;
    double _w;
    this.rss_set = false;
    sumy = smartAdd(yi, sumy);
    sumsqy = smartAdd(sumsqy, yi * yi);
    for (int i = 0; i < x.length; i++) {
        if (w == 0.0) {
            return;
        }
        xi = x[i];

        if (xi == 0.0) {
            nextr += nvars - i - 1;
            continue;
        }
        di = d[i];
        wxi = w * xi;
        _w = w;
        if (di != 0.0) {
            dpi = smartAdd(di, wxi * xi);
            final double tmp = wxi * xi / di;
            if (FastMath.abs(tmp) > Precision.EPSILON) {
                w = (di * w) / dpi;
            }
        } else {
            dpi = wxi * xi;
            w = 0.0;
        }
        d[i] = dpi;
        for (int k = i + 1; k < nvars; k++) {
            xk = x[k];
            x[k] = smartAdd(xk, -xi * r[nextr]);
            if (di != 0.0) {
                r[nextr] = smartAdd(di * r[nextr], (_w * xi) * xk) / dpi;
            } else {
                r[nextr] = xk / xi;
            }
            ++nextr;
        }
        xk = y;
        y = smartAdd(xk, -xi * rhs[i]);
        if (di != 0.0) {
            rhs[i] = smartAdd(di * rhs[i], wxi * xk) / dpi;
        } else {
            rhs[i] = xk / xi;
        }
    }
    sserr = smartAdd(sserr, w * y * y);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:71,代码来源:MillerUpdatingRegression.java

示例9: testSmall

@Test
public void testSmall() {
    Arc arc = new Arc(1.0, FastMath.nextAfter(1.0, Double.POSITIVE_INFINITY), Precision.EPSILON);
    Assert.assertEquals(2 * Precision.EPSILON, arc.getSize(), Precision.SAFE_MIN);
    Assert.assertEquals(1.0, arc.getBarycenter(), Precision.EPSILON);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:6,代码来源:ArcTest.java

示例10: MillerUpdatingRegression

/**
 * Primary constructor for the MillerUpdatingRegression.
 *
 * @param numberOfVariables maximum number of potential regressors
 * @param includeConstant include a constant automatically
 * @throws ModelSpecificationException if {@code numberOfVariables is less than 1}
 */
public MillerUpdatingRegression(int numberOfVariables, boolean includeConstant)
throws ModelSpecificationException {
    this(numberOfVariables, includeConstant, Precision.EPSILON);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:11,代码来源:MillerUpdatingRegression.java


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