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


Java LocalizedFormats.ZERO_DENOMINATOR属性代码示例

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


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

示例1: floorDiv

/** Finds q such that a = q b + r with 0 <= r < b if b > 0 and b < r <= 0 if b < 0.
 * <p>
 * This methods returns the same value as integer division when
 * a and b are same signs, but returns a different value when
 * they are opposite (i.e. q is negative).
 * </p>
 * @param a dividend
 * @param b divisor
 * @return q such that a = q b + r with 0 <= r < b if b > 0 and b < r <= 0 if b < 0
 * @exception MathArithmeticException if b == 0
 * @see #floorMod(int, int)
 * @since 3.4
 */
public static int floorDiv(final int a, final int b) throws MathArithmeticException {

    if (b == 0) {
        throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
    }

    final int m = a % b;
    if ((a ^ b) >= 0 || m == 0) {
        // a an b have same sign, or division is exact
        return a / b;
    } else {
        // a and b have opposite signs and division is not exact
        return (a / b) - 1;
    }

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

示例2: floorMod

/** Finds r such that a = q b + r with 0 <= r < b if b > 0 and b < r <= 0 if b < 0.
 * <p>
 * This methods returns the same value as integer modulo when
 * a and b are same signs, but returns a different value when
 * they are opposite (i.e. q is negative).
 * </p>
 * @param a dividend
 * @param b divisor
 * @return r such that a = q b + r with 0 <= r < b if b > 0 and b < r <= 0 if b < 0
 * @exception MathArithmeticException if b == 0
 * @see #floorDiv(int, int)
 * @since 3.4
 */
public static int floorMod(final int a, final int b) throws MathArithmeticException {

    if (b == 0) {
        throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
    }

    final int m = a % b;
    if ((a ^ b) >= 0 || m == 0) {
        // a an b have same sign, or division is exact
        return m;
    } else {
        // a and b have opposite signs and division is not exact
        return b + m;
    }

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

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

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

示例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
 * @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

示例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
 * @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

示例7: BigFraction

/**
 * Create a {@link BigFraction} given the numerator and denominator as
 * {@code BigInteger}. The {@link BigFraction} is reduced to lowest terms.
 *
 * @param num the numerator, must not be {@code null}.
 * @param den the denominator, must not be {@code null}.
 * @throws ZeroException if the denominator is zero.
 * @throws NullArgumentException if either of the arguments is null
 */
public BigFraction(BigInteger num, BigInteger den) {
    MathUtils.checkNotNull(num, LocalizedFormats.NUMERATOR);
    MathUtils.checkNotNull(den, LocalizedFormats.DENOMINATOR);
    if (den.signum() == 0) {
        throw new ZeroException(LocalizedFormats.ZERO_DENOMINATOR);
    }
    if (num.signum() == 0) {
        numerator   = BigInteger.ZERO;
        denominator = BigInteger.ONE;
    } else {

        // reduce numerator and denominator by greatest common denominator
        final BigInteger gcd = num.gcd(den);
        if (BigInteger.ONE.compareTo(gcd) < 0) {
            num = num.divide(gcd);
            den = den.divide(gcd);
        }

        // move sign to numerator
        if (den.signum() == -1) {
            num = num.negate();
            den = den.negate();
        }

        // store the values in the final fields
        numerator   = num;
        denominator = den;

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

示例8: divide

/**
 * <p>
 * Divide the value of this fraction by the passed {@code BigInteger},
 * ie {@code this * 1 / bg}, returning the result in reduced form.
 * </p>
 *
 * @param bg the {@code BigInteger} to divide by, must not be {@code null}
 * @return a {@link BigFraction} instance with the resulting values
 * @throws NullArgumentException if the {@code BigInteger} is {@code null}
 * @throws MathArithmeticException if the fraction to divide by is zero
 */
public BigFraction divide(final BigInteger bg) {
    if (bg == null) {
        throw new NullArgumentException(LocalizedFormats.FRACTION);
    }
    if (bg.signum() == 0) {
        throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
    }
    if (numerator.signum() == 0) {
        return ZERO;
    }
    return new BigFraction(numerator, denominator.multiply(bg));
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:23,代码来源:BigFraction.java


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