Search in sources :

Example 1 with HornerScheme

use of org.matheclipse.core.polynomials.HornerScheme in project symja_android_library by axkr.

the class Horner method evaluate.

@Override
@Deprecated
public IExpr evaluate(final IAST ast, EvalEngine engine) {
    Validate.checkSize(ast, 2);
    if (ast.arg1().isAST()) {
        IAST poly = (IAST) ast.arg1();
        VariablesSet eVar = new VariablesSet(ast.arg1());
        IAST variables = eVar.getVarList();
        if (variables.size() >= 2) {
            ISymbol sym = (ISymbol) variables.arg1();
            if (poly.isASTSizeGE(F.Plus, 2)) {
                HornerScheme scheme = new HornerScheme();
                return scheme.generate(engine.isNumericMode(), poly, sym);
            }
        }
    }
    return ast.arg1();
}
Also used : ISymbol(org.matheclipse.core.interfaces.ISymbol) HornerScheme(org.matheclipse.core.polynomials.HornerScheme) IAST(org.matheclipse.core.interfaces.IAST) VariablesSet(org.matheclipse.core.convert.VariablesSet)

Example 2 with HornerScheme

use of org.matheclipse.core.polynomials.HornerScheme in project symja_android_library by axkr.

the class HornerForm method evaluate.

@Override
public IExpr evaluate(final IAST ast, EvalEngine engine) {
    Validate.checkRange(ast, 2, 3);
    IExpr arg1 = ast.arg1();
    if (arg1.isAST()) {
        IAST poly = (IAST) arg1;
        VariablesSet eVar;
        IAST variables;
        if (ast.isAST2()) {
            variables = Validate.checkSymbolOrSymbolList(ast, 2);
        } else {
            eVar = new VariablesSet(ast.arg1());
            variables = eVar.getVarList();
        }
        if (variables.size() >= 2) {
            ISymbol sym = (ISymbol) variables.arg1();
            if (poly.isASTSizeGE(F.Plus, 2)) {
                HornerScheme scheme = new HornerScheme();
                return scheme.generate(engine.isNumericMode(), poly, sym);
            }
        }
    }
    return arg1;
}
Also used : ISymbol(org.matheclipse.core.interfaces.ISymbol) HornerScheme(org.matheclipse.core.polynomials.HornerScheme) IExpr(org.matheclipse.core.interfaces.IExpr) IAST(org.matheclipse.core.interfaces.IAST) VariablesSet(org.matheclipse.core.convert.VariablesSet)

Aggregations

VariablesSet (org.matheclipse.core.convert.VariablesSet)2 IAST (org.matheclipse.core.interfaces.IAST)2 ISymbol (org.matheclipse.core.interfaces.ISymbol)2 HornerScheme (org.matheclipse.core.polynomials.HornerScheme)2 IExpr (org.matheclipse.core.interfaces.IExpr)1