Package jmathexpr.arithmetic.op

Examples of jmathexpr.arithmetic.op.Negation


                return new Abs(f).matches(expr);
            }

            @Override
            public Expression apply() {
                return new Negation(f.hit());
            }
View Full Code Here


               
                rp = r.get(p);
                bi = b.coeffs.get(i);
               
                rp = rp != null ? new Subtraction(rp, new Multiplication(c, bi)).evaluate()
                        : new Negation(new Multiplication(c, bi)).evaluate();

                if (rp instanceof ANumber && ((ANumber) rp).isZero() && !p.isZero()) {
                    r.remove(p);
                } else {
                    r.put(p, rp);
View Full Code Here

            minuend = coeffs.get(n);
           
            if (minuend != null) {
                c = new Subtraction(minuend, subtrahend.coeffs.get(n)).evaluate();
            } else {
                c = new Negation(subtrahend.coeffs.get(n)).evaluate();
            }
           
            if (c instanceof ANumber && ((ANumber) c).isZero()) {
                map.remove(n);
            } else {
View Full Code Here

            c = coeffs.get(n);
           
            if (c instanceof ANumber) {
                map.put(n, ((ANumber) c).negate());
            } else {
                map.put(n, new Negation(c));
            }
        }
       
        return new Polynomial(map, x);
    }
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));
           
            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

                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));
           
View Full Code Here

            return n.matches(Naturals.zero());
        } else if (matchesPower(expr)) { // P = x or x^n
            return coeff.matches(Naturals.one());
        } else if (expr instanceof Negation) { // P = -(Q)
            if (matches(((Negation) expr).getChild())) {
                return coeff.matches(new Negation(coeff.hit()).evaluate());
            }
        } else {
            FunctionPattern f = new FunctionPattern(x);
            Negation nf = new Negation(f);
           
            if (nf.matches(expr) && matchesPower(f.hit())) {
                return coeff.matches(Integers.getInstance().create(-1));
            }
           
            Multiplication ax = new Multiplication(coeff, f);
           
View Full Code Here

        Expression arg = stack.pop();
       
        if (arg instanceof ANumber) {
            stack.push(((ANumber) arg).negate());
        } else {
            stack.push(new Negation(arg));
        }
    }
View Full Code Here

TOP

Related Classes of jmathexpr.arithmetic.op.Negation

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.