Examples of Multiplication


Examples of jmathexpr.arithmetic.op.Multiplication

                p = (NaturalNumber) n.add(i);
               
                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

Examples of jmathexpr.arithmetic.op.Multiplication

    public Polynomial multiply(Expression multiplier) {
        if (multiplier.isConstant()) {
            NavigableMap<NaturalNumber, Expression> multiplied = new TreeMap();
           
            for (NaturalNumber n : coeffs.keySet()) {
                multiplied.put(n, new Multiplication(coeffs.get(n), multiplier).evaluate());
            }

            return new Polynomial(multiplied, x);
        } else
            throw new UnsupportedOperationException("Missing implementation: " + multiplier);
View Full Code Here

Examples of jmathexpr.arithmetic.op.Multiplication

   
    private static Polynomial toPolynomial(Multiplication term, Variable x) {
        NavigableMap<NaturalNumber, Expression> coeffs = new TreeMap();
        TerminationPattern c = Numbers.constant("c");
        TerminationPattern n = Numbers.constant("n");
        ExpressionPattern cxn = new Multiplication(c, new Exponentiation(x, n));

        if (cxn.matches(term)) {
            coeffs.put((NaturalNumber) n.hit(), c.hit());
        } else {
            throw new IllegalArgumentException("Illegal polynomial term: " + term);
        }
       
View Full Code Here

Examples of jmathexpr.arithmetic.op.Multiplication

    private Expression sqrt(Multiplication product) {
        Expression l = new Sqrt(product.lhs()).evaluate();
        Expression r = new Sqrt(product.rhs()).evaluate();

        if (!(l instanceof Sqrt && r instanceof Sqrt)) {
            return new Multiplication(l, r).evaluate();
        } else {
            return new Sqrt(product);
        }
    }
View Full Code Here

Examples of jmathexpr.arithmetic.op.Multiplication

        @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

Examples of jmathexpr.arithmetic.op.Multiplication

            return new Sqrt(arg).matches(a);
        }

        @Override
        public Expression apply() {
            return new Equality(new Multiplication(p, new Sqrt(arg.hit())), Naturals.zero());
        }
View Full Code Here

Examples of jmathexpr.arithmetic.op.Multiplication

     */
    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.Multiplication

            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.Multiplication

     */
    private class LeftSubtraction extends SubRule {

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

Examples of jmathexpr.arithmetic.op.Multiplication

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

        @Override
        public Expression apply() {
            return new Subtraction(new Multiplication(a.hit(), b.hit()),
                    new Multiplication(a.hit(), c.hit()));
        }
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.