Examples of Addition


Examples of eas.users.lukas.tnt.arithmetic.Addition

   
    @SuppressWarnings(value = { "all" })
    public static void main(String[] args) throws CloneNotSupportedException {
        Variable a = new Variable(0), b = new Variable(1), c = new Variable(2);
        Variable d = new Variable(3), e = new Variable(4), f = new Variable(5);
        Statement s1 = new Negation(new Exists(new Exists(new Exists(new Equality(new Multiplication(new Multiplication(a, a), a), new Addition(new Multiplication(new Multiplication(new Addition(b, new Number(1)), new Addition(b, new Number(1))), new Addition(b, new Number(1))), new Multiplication(new Multiplication(new Addition(c, new Number(1)), new Addition(c, new Number(1))), new Addition(c, new Number(1))))), c), b), a));
        Statement s2 = s1.clone();
        s1 = new Disjunction(new Conjunction(s1.clone(), s1.clone()), s1.clone());
        Statement s3 = s2.clone();
        renameVarConsistently(s3, a.clone(), d.clone());
        renameVarConsistently(s3, b.clone(), e.clone());
View Full Code Here

Examples of jmathexpr.arithmetic.op.Addition

    @Test(dependsOnMethods = { "testVariables" })
    public void testRationalExpressions() {
        Expression evaluated;
        RationalNumber oneHalf = new LongRationalNumber(1, 2);
        RationalNumber oneThird = new LongRationalNumber(1, 3);
        Expression sum = new Addition(oneHalf, oneThird);
       
        evaluated = sum.evaluate();
        System.out.printf("%s = %s%n", sum, evaluated);
        assertEquals(evaluated, new LongRationalNumber(5, 6));
       
        Expression difference = new Subtraction(oneHalf, oneThird);
        evaluated = difference.evaluate();
View Full Code Here

Examples of jmathexpr.arithmetic.op.Addition

    @Test
    public void testNaturalExpressions() {
        Expression evaluated;
        NaturalNumber five = N.create(5);
        NaturalNumber two = N.create(2);
        Addition seven = new Addition(five, two);
        NaturalNumber six = N.create("6");
        Expression naturalExpr = new Multiplication(six, seven);
       
        evaluated = naturalExpr.evaluate();
        System.out.printf("%s = %s%n", naturalExpr, evaluated);       
View Full Code Here

Examples of jmathexpr.arithmetic.op.Addition

         */
        private class AdditionC extends SubRule {

            @Override
            public boolean matches(Expression expr) {
                return new Equality(new Addition(ax, b), c).matches(expr);
            }
View Full Code Here

Examples of jmathexpr.arithmetic.op.Addition

            }
           
            c0 = map.get(n);
           
            if (c0 != null) {
                c = new Addition(c0, c).evaluate();
            }
           
            map.put(n, c);
        }
       
View Full Code Here

Examples of jmathexpr.arithmetic.op.Addition

     */
    private class LeftAddition extends SubRule {

        @Override
        public boolean matches(Expression expr) {
            boolean matches = new Multiplication(a, new Addition(b, c)).matches(expr);
           
            return matches && !(a.hit() instanceof ANumber && ((ANumber) a.hit()).isOne());
        }
View Full Code Here

Examples of jmathexpr.arithmetic.op.Addition

            return matches && !(a.hit() instanceof ANumber && ((ANumber) a.hit()).isOne());
        }

        @Override
        public Expression apply() {
            return new Addition(new Multiplication(a.hit(), b.hit()),
                    new Multiplication(a.hit(), c.hit()));
        }
View Full Code Here

Examples of jmathexpr.arithmetic.op.Addition

     */
    private class RightAddition extends SubRule {

        @Override
        public boolean matches(Expression expr) {
            boolean matches = new Multiplication(new Addition(a, b), c).matches(expr);
           
            return matches && !(c.hit() instanceof ANumber && ((ANumber) c.hit()).isOne());
        }
View Full Code Here

Examples of jmathexpr.arithmetic.op.Addition

            return matches && !(c.hit() instanceof ANumber && ((ANumber) c.hit()).isOne());
        }

        @Override
        public Expression apply() {
            return new Addition(new Multiplication(a.hit(), b.hit()),
                    new Multiplication(a.hit(), c.hit()));
        }
View Full Code Here

Examples of jmathexpr.arithmetic.op.Addition

     */
    private class AdditionAddition extends SubRule {

        @Override
        public boolean matches(Expression expr) {
            Addition apb = new Addition(a, b);
            Addition bpc = new Addition(b, c);
           
            return new Addition(apb, c).matches(expr) ||
                   new Addition(a, bpc).matches(expr);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.