Package jmathexpr.arithmetic.pattern

Examples of jmathexpr.arithmetic.pattern.PolynomialTermPattern.matches()


    }
   
    public static boolean isLinear(Expression expr, Variable x) {
        ExpressionPattern pattern = new PolynomialTermPattern(x, 1);
       
        if (pattern.matches(expr)) {
            return true;
        } else if (expr instanceof Negation) {
            return isLinear(((Negation) expr).getChild(), x);
        } else if (expr instanceof Division) {
            Expression lhs = ((Division) expr).lhs();
View Full Code Here


        PolynomialTermPattern pt = new PolynomialTermPattern(x);
        NaturalNumber n;
        Expression c, c0;
       
        for (Expression t : terms) {
            if (pt.matches(t)) {
                n = pt.exponent();
                c = pt.coefficient();
            } else {
                throw new IllegalArgumentException(
                        String.format("Illegal polynomial term: %s (%s)", t, t.getClass()));
View Full Code Here

   
    private static boolean isQuadratic(Expression expr, Variable x) {
        NaturalNumber two = Naturals.getInstance().create(2);
        ExpressionPattern pattern = new PolynomialTermPattern(x, 2);
       
        if (pattern.matches(expr)) {
            return true;
        } else if (expr instanceof Negation) {
            return isQuadratic(((Negation) expr).getChild(), x);
        } else if (expr instanceof Division) {
            Expression lhs = ((Division) expr).lhs();
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.