@Nonnull public static IAST quarticSolveN(IExpr a, IExpr b, IExpr c, IExpr d, IExpr e) { return (IAST) F.evaln(quarticSolve(a, b, c, d, e)); }
public IExpr apply(final IExpr firstArg) { return F.evaln(F.subst(fFunction, F.Rule(fVariable, firstArg))); }
public COMPARE_RESULT prepareCompare(final IExpr o0, final IExpr o1) { // don't compare strings IExpr a0 = o0; IExpr a1 = o1; if (!(a0.isSignedNumber()) && NumericQ.CONST.apply(a0)) { a0 = F.evaln(a0); } if (!(a1.isSignedNumber()) && NumericQ.CONST.apply(a1)) { a1 = F.evaln(a1); } if (a0.isNumeric() && a1.isRational()) { a1 = F.evaln(a1); } if (a1.isNumeric() && a0.isRational()) { a0 = F.evaln(a0); } return compare(a0, a1); }
/** {@inheritDoc} */ @Override public boolean isPositive() { if (isNumericFunction()) { IExpr temp = F.evaln(this); if (temp.isReal() && temp.isPositive()) { return true; } } return false; }
/** {@inheritDoc} */ @Override public boolean isNegative() { if (isNumericFunction()) { IExpr temp = F.evaln(this); if (temp.isReal() && temp.isNegative()) { return true; } } return false; }
/** {@inheritDoc} */ @Override public boolean isNegative() { if (isNumericFunction()) { IExpr temp = F.evaln(this); if (temp.isReal() && temp.isNegative()) { return true; } } return false; }
/** {@inheritDoc} */ @Override public boolean isPositive() { if (isNumericFunction()) { IExpr temp = F.evaln(this); if (temp.isReal() && temp.isPositive()) { return true; } } return false; }
public IExpr apply(final IExpr firstArg, final IExpr secondArg) { return F.evaln(F.subst(fun,F.List(F.Rule(variable1, firstArg), F.Rule(variable2, secondArg)) )); }
public static double evalSymbol(final ISymbol symbol) { if (symbol.hasLocalVariableStack()) { return ((ISignedNumber) symbol.get()).doubleValue(); } final IEvaluator module = symbol.getEvaluator(); if (module instanceof INumericConstant) { // fast evaluation path return ((INumericConstant) module).evalReal(); } // slow evaluation path final IExpr result = F.evaln(symbol); if (result instanceof Num) { return ((Num) result).doubleValue(); } throw new UnsupportedOperationException("EvalDouble#evalSymbol() - no value assigned for symbol: "+symbol); } }
/** {@inheritDoc} */ @Override public final INumber evalNumber() { if (isNumericFunction()) { IExpr result = F.evaln(this); if (result.isNumber()) { return (INumber) result; } } else if (hasLocalVariableStack()) { IExpr temp = get(); if (temp != null && temp.isNumericFunction()) { IExpr result = F.evaln(this); if (result.isNumber()) { return (INumber) result; } } } else { IExpr temp = evalDownRule(EvalEngine.get(), this); if (temp.isPresent() && temp.isNumericFunction()) { IExpr result = F.evaln(this); if (result.isNumber()) { return (INumber) result; } } } return null; }
/** {@inheritDoc} */ @Override public final ISignedNumber evalReal() { if (isNumericFunction()) { IExpr result = F.evaln(this); if (result.isReal()) { return (ISignedNumber) result; } } else if (hasLocalVariableStack()) { IExpr temp = get(); if (temp != null && temp.isNumericFunction()) { IExpr result = F.evaln(this); if (result.isReal()) { return (ISignedNumber) result; } } } else { IExpr temp = evalDownRule(EvalEngine.get(), this); if (temp.isPresent() && temp.isNumericFunction()) { IExpr result = F.evaln(this); if (result.isReal()) { return (ISignedNumber) result; } } } return null; }
/** {@inheritDoc} */ @Override public final ISignedNumber evalReal() { if (isNumericFunction()) { IExpr result = F.evaln(this); if (result.isReal()) { return (ISignedNumber) result; } } else if (hasLocalVariableStack()) { IExpr temp = get(); if (temp != null && temp.isNumericFunction()) { IExpr result = F.evaln(this); if (result.isReal()) { return (ISignedNumber) result; } } } else { IExpr temp = evalDownRule(EvalEngine.get(), this); if (temp.isPresent() && temp.isNumericFunction()) { IExpr result = F.evaln(this); if (result.isReal()) { return (ISignedNumber) result; } } } return null; }
/** {@inheritDoc} */ @Override public final INumber evalNumber() { if (isNumericFunction()) { IExpr result = F.evaln(this); if (result.isNumber()) { return (INumber) result; } } else if (hasLocalVariableStack()) { IExpr temp = get(); if (temp != null && temp.isNumericFunction()) { IExpr result = F.evaln(this); if (result.isNumber()) { return (INumber) result; } } } else { IExpr temp = evalDownRule(EvalEngine.get(), this); if (temp.isPresent() && temp.isNumericFunction()) { IExpr result = F.evaln(this); if (result.isNumber()) { return (INumber) result; } } } return null; }
@Override public IExpr evaluate(final IAST ast) { if (ast.size() != 2) { return null; } IExpr temp = roots(ast, true); if (temp == null || !temp.isList()) { return null; } IAST list = (IAST)temp; IAST result = F.List(); for (int i = 1; i < list.size(); i++) { result.add(F.evaln(list.get(i))); } return result; }
public static double evalSymbol(final ISymbol symbol) { if (symbol.hasLocalVariableStack()) { return ((ISignedNumber) symbol.get()).doubleValue(); } if (symbol.isRealConstant()) { // fast evaluation path return ((ISignedNumberConstant) ((IBuiltInSymbol) symbol).getEvaluator()).evalReal(); } // slow evaluation path final IExpr result = F.evaln(symbol); if (result.isReal()) { return ((ISignedNumber) result).doubleValue(); } if (result.isInfinity()) { return Double.POSITIVE_INFINITY; } if (result.isNegativeInfinity()) { return Double.NEGATIVE_INFINITY; } if (result.isIndeterminate()) { return Double.NaN; } throw new UnsupportedOperationException("EvalDouble#evalSymbol() - no value assigned for symbol: " + symbol); }
public static double evalAST(double[] stack, final int top, final IAST ast) { final ISymbol symbol = (ISymbol) ast.get(0); final IEvaluator module = symbol.getEvaluator(); if (module instanceof INumeric) { int newTop = top; // fast evaluation path if (top + ast.size() >= stack.length) { Alloc alloc = Alloc.get(); stack = alloc.vector(ast.size() + 50); } for (int i = 1; i < ast.size(); i++) { ++newTop; stack[newTop] = eval(stack, newTop, ast.get(i)); } return ((INumeric) module).evalReal(stack, newTop, ast.size() - 1); } // slow evaluation path final IExpr result = F.evaln(ast); if (result instanceof Num) { return ((Num) result).doubleValue(); } throw new UnsupportedOperationException("EvalDouble#evalAST(): "+ast); }
public static double evalAST(double[] stack, final int top, final IAST ast) { if (ast.head().isBuiltInSymbol()) { final IBuiltInSymbol symbol = (IBuiltInSymbol) ast.head(); final IEvaluator module = ((IBuiltInSymbol) symbol).getEvaluator(); if (module instanceof INumeric) { int newTop = top; // fast evaluation path if (top + ast.size() >= stack.length) { stack = new double[ast.size() + 50]; } for (int i = 1; i < ast.size(); i++) { ++newTop; stack[newTop] = DoubleStackEvaluator.eval(stack, newTop, ast.get(i)); } return ((INumeric) module).evalReal(stack, newTop, ast.argSize()); } } // slow evaluation path final IExpr result = F.evaln(ast); if (result.isReal()) { return ((ISignedNumber) result).doubleValue(); } throw new UnsupportedOperationException("EvalDouble#evalAST(): " + ast); }
@Override public double evaluate(DoubleEvaluator doubleEngine, FunctionNode functionNode, double[] args) { ASTNode node = functionNode.getNode(0); if (node instanceof SymbolNode) { AST2Expr ast2Expr = new AST2Expr(); IExpr head = ast2Expr.convert(node); IASTAppendable fun = F.ast(head, args.length, false); fun.appendArgs(0, args.length, i -> F.num(args[i])); // for (int i = 0; i < args.length; i++) { // fun.append(F.num(args[i])); // } final IExpr result = F.evaln(fun); if (result.isReal()) { return ((ISignedNumber) result).doubleValue(); } } else if (node instanceof FunctionNode) { AST2Expr ast2Expr = new AST2Expr(); IExpr head = ast2Expr.convert(node); IASTAppendable fun = F.ast(head); for (int i = 0; i < args.length; i++) { fun.append(F.num(args[i])); } final IExpr result = F.evaln(fun); if (result.isReal()) { return ((ISignedNumber) result).doubleValue(); } } throw new MathException("CoreCallbackFunction#evaluate() not possible for: " + functionNode.toString()); }
final IExpr result = F.evaln(ast); if (result instanceof ComplexNum) { final double[] res = new double[2];
final IExpr result = F.evaln(ast); Alloc alloc = Alloc.get(); if (result instanceof ComplexNum) {