/** * Define an binary AST with the header <code>head</code>. * * @param head the AST's head expresion */ public BinaryEval(final IExpr head) { fEngine = EvalEngine.get(); fAST = F.ast(head, 1, false); }
/** {@inheritDoc} */ @Override public final IPatternMatcher putDownRule(final PatternMatcherAndInvoker pmEvaluator) { if (fRulesData == null) { fRulesData = new RulesData(EvalEngine.get().getContext()); } return fRulesData.insertMatcher(pmEvaluator); }
public static IComplexNum complexNum(final IInteger value) { final EvalEngine engine = EvalEngine.get(); if (engine.isApfloat()) { return ApcomplexNum.valueOf(value.toBigNumerator(), BigInteger.ONE, BigInteger.ZERO, BigInteger.ONE, engine.getNumericPrecision()); } return complexNum(value.doubleValue(), 0.0d); }
/** * Define an unary AST with the header <code>head</code>. * * @param engine * the evaluation engine * @param head * the AST's head expresion */ public IsUnaryTrue(final EvalEngine engine, final IExpr head) { fEngine = EvalEngine.get(); fAST = F.ast(head, 1, false); }
/** {@inheritDoc} */ @Override public void readRules(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { fSymbolName = stream.readUTF(); fAttributes = stream.read(); boolean hasDownRulesData = stream.readBoolean(); if (hasDownRulesData) { fRulesData = new RulesData(EvalEngine.get().getContext()); fRulesData = (RulesData) stream.readObject(); } }
public static INum num(final IInteger value) { EvalEngine engine = EvalEngine.get(); if (engine.isApfloat()) { return ApfloatNum.valueOf(value.toBigNumerator(), engine.getNumericPrecision()); } return num(value.doubleValue()); }
/** {@inheritDoc} */ @Override public boolean isValue() { return evaluate(EvalEngine.get()) != null; }
/** {@inheritDoc} */ @Override public IExpr of(IExpr... args) { return of(EvalEngine.get(), args); }
/** * Apply <code>ExpandAll()</code> to the given expression if it's an <code>IAST</code>. If expanding wasn't possible * this method returns the given argument. * * @param a * the expression which should be evaluated * @return the evaluated expression * @see EvalEngine#evaluate(IExpr) */ public static IExpr evalExpandAll(IExpr a) { return evalExpandAll(a, EvalEngine.get()); }
/** {@inheritDoc} */ @Override public boolean ofQ(IExpr... args) { return ofQ(EvalEngine.get(), args); }
/** {@inheritDoc} */ @Override public final void pushLocalVariable(final IExpr expression) { EvalEngine.get().localStackCreate(this).push(expression); }
public VisitorReplaceAll(IAST ast, int offset) { super(); this.fFunction = Functors.rules(ast, EvalEngine.get()); this.fOffset = offset; }
/** {@inheritDoc} */ public void setAttributes(final int attributes) { fAttributes = attributes; if (fSymbolName.charAt(0) == '$' && Config.SERVER_MODE) { EvalEngine engine = EvalEngine.get(); engine.addModifiedVariable(this); } }
/** * Method Declaration. * * @see */ public void tearDown() { if (variable != null) { variable.popLocalVariable(); // variable.clearSymbolRule(session, variable); } EvalEngine.get().setNumericMode(fNumericMode); }
/** {@inheritDoc} */ @Override public boolean isValue(IAST ast) { if (ast.head() instanceof ISymbol) { IExpr result = ((ISymbol) ast.head()).evalDownRule(EvalEngine.get(), ast); return result != null; } return false; }
/** {@inheritDoc} */ @Override public final void setAttributes(final int attributes) { fAttributes = attributes; if (isLocked()) { throw new RuleCreationError(this); } EvalEngine engine = EvalEngine.get(); engine.addModifiedVariable(this); }
/** {@inheritDoc} */ public PatternMatcher putDownRule(ISymbol setSymbol, final boolean equalRule, final IExpr leftHandSide, final IExpr rightHandSide, final int priority) { EvalEngine engine = EvalEngine.get(); if (!engine.isPackageMode()) { if (Config.SERVER_MODE && (fSymbolName.charAt(0) != '$')) { throw new RuleCreationError(leftHandSide); } engine.addModifiedVariable(this); } return fRulesData.putDownRule(setSymbol, equalRule, leftHandSide, rightHandSide, priority); }
public IExpr evaluate(final IAST ast) { if (ast.size() == 2) { final long begin = System.currentTimeMillis(); final EvalEngine engine = EvalEngine.get(); final IExpr result = engine.evaluate(ast.get(1)); return List(Times(FractionSym.valueOf((System .currentTimeMillis() - begin), 1000L), F.Second), result); } return null; }
@Override public IExpr evaluateArg1(final IExpr arg1) { if (arg1.isInteger() && arg1.isPositive()) { try { long n = ((IInteger) arg1).toLong(); return subFactorial(n); } catch (ArithmeticException ae) { EvalEngine.get().printMessage("Subfactorial: argument n is to big."); } } return F.NIL; }
public IExpr evaluate(final IAST functionList) { final EvalEngine engine = EvalEngine.get(); if (functionList.size() > 1) { for (int i = 1; i < functionList.size() - 1; i++) { // as sideeffect evaluate the i-th argument engine.evaluate(functionList.get(i)); } return engine.evaluate(functionList.get(functionList.size() - 1)); } return F.Null; }