Package jmathexpr.arithmetic.op

Examples of jmathexpr.arithmetic.op.Division


       
        evaluated = zeroTest.evaluate();
        System.out.printf("%s : %s%n", zeroTest, evaluated);
        assertEquals(evaluated, TruthValue.True);
       
        Division division = new Division(R.create(10.0), R.create(2.0));
        System.out.printf("Division domain: %s%n", division.domain());
       
        ExpressionParser parser = new ExpressionParser();
        Expression fraction = parser.parse("(6 sqrt(249) + 130) / 16");
        evaluated = fraction.evaluate();
        System.out.printf("%s : %s%n", fraction, evaluated);
View Full Code Here


       
        @Override
        public Expression apply() {
            Expression coef = a.hit();

            return new Equality(new Division(((Equality) target).lhs(), coef),
                    new Division(((Equality) target).rhs(), coef));
        }
View Full Code Here

       
        q.put(ZERO, ZERO);
        r.putAll(this.coeffs);
       
        while (!isZero(r) && bdeg.le(r.lastKey())) {
            c = new Division(r.lastEntry().getValue(), bc).evaluate();
            n = (NaturalNumber) r.lastKey().subtract(bdeg);
           
            q.put(n, c);
           
            for (NaturalNumber i : b.coeffs.descendingKeySet()) {
View Full Code Here

        Expression c;
       
        for (NaturalNumber n : coeffs.keySet()) {
            c = coeffs.get(n);
           
            map.put(n, new Division(c, expr).evaluate());
        }
       
        return new Polynomial(map, x);
    }
View Full Code Here

    private Expression sqrt(RationalNumber r) {
        Expression sqrtn = Naturals.sqrt(r.numerator().toNatural());
        Expression sqrtd = Naturals.sqrt(r.denominator());

        if (sqrtn instanceof NaturalNumber || sqrtd instanceof NaturalNumber) {
            return new Division(sqrtn, sqrtd).evaluate();
        } else {
            return new Sqrt(r);
        }       
    }
View Full Code Here

        @Override
        public Expression apply() {
            Expression sqrt = new Sqrt(arg.hit());
           
            return new Division(new Multiplication(fraction.numerator(), sqrt),
                       new Multiplication(fraction.denominator(), sqrt));
        }
View Full Code Here

                } else if (!((ANumber) c).isNegative()) {
                    return new EmptySet();
                }
            }
           
            Expression x1 = new Sqrt(new Division(new Negation(c), a));
            Expression x2 = new Negation(x1);
           
            ExpressionContext.getInstance().addExpression(new Equality(Numbers.variable("x", 1), x1));
            ExpressionContext.getInstance().addExpression(new Equality(Numbers.variable("x", 2), x2));
           
View Full Code Here

                ANumber d = (ANumber) dd;
               
                if (d.isNegative()) {
                    return new EmptySet();
                } else if (d.isZero()) {
                    return new FiniteSet(new Division(new Negation(b),
                            new Multiplication(two, a)).evaluate());
                }
            }
           
            Expression sd = new Sqrt(dd);
            Expression x1 = new Division(
                    new Addition(new Negation(b), sd),
                    new Multiplication(two, a));
            Expression x2 = new Division(
                    new Subtraction(new Negation(b), sd),
                    new Multiplication(two, a));
           
            ExpressionContext.getInstance().addExpression(new Equality(Numbers.variable("x", 1), x1));
            ExpressionContext.getInstance().addExpression(new Equality(Numbers.variable("x", 2), x2));
           
            x1 = x1.evaluate();
            x2 = x2.evaluate();
           
            ExpressionContext.getInstance().addExpression(new Equality(Numbers.variable("x", 1), x1));
            ExpressionContext.getInstance().addExpression(new Equality(Numbers.variable("x", 2), x2));
           
            return new FiniteSet(x1, x2);
View Full Code Here

            if (ax.matches(expr) && matchesPower(f.hit())) { // P = ax^n
                return true;
            }
           
            Constant c = Numbers.constant("c");
            Division xc = new Division(f, c);
           
            if (xc.matches(expr) && matchesPower(f.hit())) { // P = x^n/c
                return coeff.matches(new Division(Naturals.one(), c.hit()).evaluate());
            }
        }
       
        value = null;
       
View Full Code Here

    public void exitDivision(ExpressionsParser.DivisionContext ctx) {
        Expression rhs = stack.pop();
        Expression lhs = stack.pop();
       
        if (lhs instanceof IntegerNumber && rhs instanceof NaturalNumber) {
            stack.push(new Division(lhs, rhs).evaluate());
        } else {
            stack.push(new Division(lhs, rhs));
        }
    }
View Full Code Here

TOP

Related Classes of jmathexpr.arithmetic.op.Division

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.