Package jmathexpr.util.pattern

Examples of jmathexpr.util.pattern.FunctionPattern


     * @param equality the equality to test
     * @param x the unknown in the equation
     * @return true if the equality is a radical equation
     */
    public static boolean isA(Equality equality, Variable x) {
        return equality.contains(new Sqrt(new FunctionPattern(x)));
    }
View Full Code Here


       
        @Override
        public boolean matches(Expression expr) {
            target = expr;
           
            return expr.contains(new Sqrt(new FunctionPattern(x)));
        }
View Full Code Here

    }
   
    private Map<Expression, List<Expression>> selectLikeTerms(List<Expression> evaluated) {
        Map<Expression, List<Expression>> selected = new HashMap(); // ai*f(x) -> a1, a2, ... an
        TerminationPattern c = new Constant();
        TerminationPattern f = new FunctionPattern(new Variable());
        ExpressionPattern p = new Multiplication(c, f);
       
        for (Expression e : evaluated) {
            if (e.isConstant()) {
                continue;
            } else if (p.matches(e)) {
                addToSelectionMap(selected, f.hit(), c.hit());
            } else {
                addToSelectionMap(selected, e, Naturals.one());
            }
        }

View Full Code Here

        } 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);
           
            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

     * @param equality the equality to test
     * @param x the unknown in the equation
     * @return true if the equality is an absolute value equation
     */
    public static boolean isA(Equality equality, Variable x) {
        return equality.contains(new Abs(new FunctionPattern(x)));
    }
View Full Code Here

TOP

Related Classes of jmathexpr.util.pattern.FunctionPattern

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.