Package jmathexpr

Examples of jmathexpr.Constant


     *
     * @param name the name of the constant
     * @return a new Constant instance
     */
    public static Constant constant(String name) {
        return new Constant(name, Reals.getInstance());
    }
View Full Code Here


    }
   
    private Map<Expression, List<ANumber>> selectConstants(List<Expression> evaluated) {
        Map<Expression, List<ANumber>> selected = new HashMap(); // ai*c -> a1, a2, ... an
        NumberPattern a = new NumberPattern();
        TerminationPattern c = new Constant();
        ExpressionPattern p = new Multiplication(a, c);
       
        for (Expression e : evaluated) {
            if (e.isConstant()) {
                if (e instanceof ANumber) { // 1 -> numbers
                    addToSelectionMap(selected, Naturals.one(), (ANumber) e);
                } else if (p.matches(e)) {
                    addToSelectionMap(selected, c.hit(), a.hit());
                } else {
                    addToSelectionMap(selected, e, Naturals.one());
                }
            }
        }
View Full Code Here

        return selected;
    }
   
    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

           
            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

TOP

Related Classes of jmathexpr.Constant

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.