Package org.apache.commons.math3.exception

Examples of org.apache.commons.math3.exception.MathArithmeticException


    /** {@inheritDoc} */
    public Vector2D normalize() {
        double s = getNorm();
        if (s == 0) {
            throw new MathArithmeticException(LocalizedFormats.CANNOT_NORMALIZE_A_ZERO_NORM_VECTOR);
        }
        return scalarMultiply(1 / s);
    }
View Full Code Here


            }
            break;
        }
        case BigDecimal.ROUND_UNNECESSARY :
            if (unscaled != FastMath.floor(unscaled)) {
                throw new MathArithmeticException();
            }
            break;
        case BigDecimal.ROUND_UP :
            unscaled = FastMath.ceil(FastMath.nextAfter(unscaled,  Double.POSITIVE_INFINITY));
            break;
View Full Code Here

     * @exception MathArithmeticException if the normal norm is too small
     */
    private void setNormal(final Vector3D normal) {
        final double norm = normal.getNorm();
        if (norm < 1.0e-10) {
            throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
        }
        w = new Vector3D(1.0 / norm, normal);
    }
View Full Code Here

    public BigReal divide(BigReal a) {
        try {
            return new BigReal(d.divide(a.d, scale, roundingMode));
        } catch (ArithmeticException e) {
            // Division by zero has occured
            throw new MathArithmeticException(LocalizedFormats.ZERO_NOT_ALLOWED);
        }
    }
View Full Code Here

    public BigReal reciprocal() {
        try {
            return new BigReal(BigDecimal.ONE.divide(d, scale, roundingMode));
        } catch (ArithmeticException e) {
            // Division by zero has occured
            throw new MathArithmeticException(LocalizedFormats.ZERO_NOT_ALLOWED);
        }
    }
View Full Code Here

             if (!Double.isNaN(values[i])) {
                 sum += values[i];
             }
         }
         if (sum == 0) {
             throw new MathArithmeticException(LocalizedFormats.ARRAY_SUMS_TO_ZERO);
         }
         for (int i = 0; i < len; i++) {
             if (Double.isNaN(values[i])) {
                 out[i] = Double.NaN;
             } else {
View Full Code Here

    /** {@inheritDoc} */
    public Vector3D normalize() {
        double s = getNorm();
        if (s == 0) {
            throw new MathArithmeticException(LocalizedFormats.CANNOT_NORMALIZE_A_ZERO_NORM_VECTOR);
        }
        return scalarMultiply(1 / s);
    }
View Full Code Here

     */
    public Vector3D orthogonal() {

        double threshold = 0.6 * getNorm();
        if (threshold == 0) {
            throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
        }

        if ((x >= -threshold) && (x <= threshold)) {
            double inverse  = 1 / FastMath.sqrt(y * y + z * z);
            return new Vector3D(0, inverse * z, -inverse * y);
 
View Full Code Here

     */
    public static double angle(Vector3D v1, Vector3D v2) {

        double normProduct = v1.getNorm() * v2.getNorm();
        if (normProduct == 0) {
            throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
        }

        double dot = v1.dotProduct(v2);
        double threshold = normProduct * 0.9999;
        if ((dot < -threshold) || (dot > threshold)) {
View Full Code Here

        if ((magnitude >= 0 && sign >= 0) ||
            (magnitude < 0 && sign < 0)) { // Sign is OK.
            return magnitude;
        } else if (sign >= 0 &&
                   magnitude == Byte.MIN_VALUE) {
            throw new MathArithmeticException(LocalizedFormats.OVERFLOW);
        } else {
            return (byte) -magnitude; // Flip sign.
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.math3.exception.MathArithmeticException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.