/** * Create a Complex(a, b) symbolic expression? * * @param a0 * @param a1 * @return */ public static IAST Complex(final IExpr a0, final IExpr a1) { return binaryAST2(Complex, a0, a1); }
/** * Create a <code>Distributed(x, <distribution>)</code> AST. * * @param x * @param distribution * @return */ public static IAST Distributed(final IExpr x, final IAST distribution) { return binaryAST2(Distributed, x, distribution); }
/** * <code>Log[10, a0]</code>. * * @param a0 * @return <code>Log[10, a0]</code>. */ public static IAST Log10(final IExpr a0) { return binaryAST2(Log, F.C10, a0); }
/** * Create a "square" expression: <code>Power(x, 2)</code>. * * @param x * @return */ public static IAST Sqr(final IExpr x) { return binaryAST2(Power, x, C2); }
/** * Convert to Integrate[] * * @param a0 * @param a1 * @return */ public static IAST Int(final IExpr a0, final IExpr a1) { // Integrate.setAttributes(ISymbol.CONSOLE_OUTPUT); return binaryAST2(Integrate, a0, a1); }
/** * Bell polynomial. * * @param a0 * @param a1 * @return */ public static IAST BellB(final IExpr a0, final IExpr a1) { return binaryAST2(F.BellB, a0, a1); }
/** * The division <code>arg1 / arg2</code> will be represented by <code>arg1 * arg2^(-1)</code>. * * @param arg1 * numerator * @param arg2 * denominator * @return */ public static IAST Divide(final IExpr arg1, final IExpr arg2) { return binaryAST2(Times, arg1, binaryAST2(Power, arg2, CN1)); }
/** * Create a "square root" expression: <code>Power(x, 1/2)</code>. * * @param x * @return */ public static IAST Sqrt(final IExpr x) { return binaryAST2(Power, x, C1D2); }
public IsBinaryFalse(final IExpr head, EvalEngine engine) { fEngine = engine; fAST = (IASTMutable) F.binaryAST2(head, null, null); }
public IsBinaryTrue(final IExpr head, EvalEngine engine) { fEngine = engine; fAST = (IASTMutable) F.binaryAST2(head, null, null); }
public static IAST QuantityMagnitude(final IExpr a0, final IExpr a1) { return binaryAST2(QuantityMagnitude, a0, a1); }
public static IAST Zeta(final IExpr a0, final IExpr a1) { return binaryAST2(Zeta, a0, a1); }
/** * Create an "interval" expression: <code>Interval(List(from, to))</code>. * * @param min * minimum value of the interval * @param max * maximum value of the interval * @return */ public static IAST Interval(final IExpr min, final IExpr max) { return unaryAST1(Interval, binaryAST2(List, min, max)); }
/** * Create the result for a <code>simplifyCompare()</code> step * <code>equalOrUnequalSymbol[lhsAST.rest(), rhs]</code> * * @param equalOrUnequalSymbol * @param lhsAST * @param rhs * * @return */ private static IExpr createComparatorResult(IBuiltInSymbol equalOrUnequalSymbol, IAST lhsAST, IExpr rhs) { return F.binaryAST2(equalOrUnequalSymbol, lhsAST.rest(), rhs); }
public IAST getAsAST() { ISymbol setSymbol = getSetSymbol(); IAST temp = F.binaryAST2(setSymbol, getLHS(), getRHS()); if (isFlagOn(HOLDPATTERN)) { return F.HoldPattern(temp); } if (isFlagOn(LITERAL)) { return F.Literal(temp); } return temp; }
@Override public IExpr evaluate(final IAST ast, EvalEngine engine) { Validate.checkSize(ast, 2); IExpr arg1 = ast.arg1(); if (arg1.isAST()) { IAST list = (IAST) arg1; int size = list.size(); IASTAppendable resultList = F.ast(list.head(), size, false); return foldLeft(null, list, 1, size, (x, y) -> F.binaryAST2(F.Plus, x, y), resultList); } return F.NIL; }
public static IExpr operatorFormAST1(final IAST ast) { if (ast.head().isAST1() && ast.isAST1()) { return binaryAST2(ast.topHead(), ast.arg1(), ((IAST) ast.head()).arg1()); } return NIL; }
private static IExpr evaluateNestList(final IAST ast, EvalEngine engine) { try { IExpr temp = engine.evaluate(ast.arg3()); if (temp.isAST()) { final IAST list = (IAST) temp; IExpr arg1 = engine.evaluate(ast.arg1()); IExpr arg2 = engine.evaluate(ast.arg2()); return list.foldLeft((x, y) -> F.binaryAST2(arg1, x, y), arg2, 1); } } catch (final ArithmeticException e) { } return F.NIL; }
private static IAST evaluateNestList(final IAST ast, final IASTAppendable resultList, EvalEngine engine) { try { IExpr temp = engine.evaluate(ast.arg3()); if (temp.isAST()) { final IAST list = (IAST) temp; IExpr arg1 = engine.evaluate(ast.arg1()); IExpr arg2 = engine.evaluate(ast.arg2()); return foldLeft(arg2, list, 1, list.size(), (x, y) -> F.binaryAST2(arg1, x, y), resultList); } } catch (final ArithmeticException e) { } return F.NIL; }
@Override public IExpr evaluate(final IAST ast, EvalEngine engine) { Validate.checkRange(ast, 2, 3); IExpr arg1 = ast.arg1(); int[] dim = arg1.isMatrix(); if (dim != null) { // Gram-Schmidt orthogonalization IExpr result = F.Map(F.Function(F.Normalize(F.Slot1)), // F.Fold(F.Function(F.Append(F.Slot1, F.binaryAST2(oneStep, F.Slot2, F.Slot1))), F.List(), arg1)); return engine.evaluate(result); } return F.NIL; }