public static AST newInstance(final ISymbol symbol, final int[] arr) { // AST ast; // if (Config.SERVER_MODE) { // ast = FACTORY.object(); // } else { // ast = new AST(5, false); // } AST ast = new AST(5, false); ast.add(symbol); for (int i = 1; i <= arr.length; i++) { ast.add(i, IntegerSym.valueOf(arr[i - 1])); } return ast; }
public static AST newInstance(final IExpr head) { // AST ast; // if (Config.SERVER_MODE) { // ast = FACTORY.object(); // } else { // ast = new AST(5, false); // } AST ast = new AST(5, false); ast.add(head); return ast; }
/** * * @param intialCapacity * the initial capacity (i.e. number of arguments without the header * element) of the list. * @param head * @return */ public static AST newInstance(final int intialCapacity, final IExpr head) { AST ast = new AST(intialCapacity + 1, false); ast.add(head); return ast; }
/** * Constructs a list with header <i>symbol</i> and the arguments containing * the given DoubleImpl values. * * @see Num */ public static AST newInstance(final ISymbol symbol, final double[] arr) { // AST ast; // if (Config.SERVER_MODE) { // ast = FACTORY.object(); // } else { // ast = new AST(5, false); // } AST ast = new AST(5, false); ast.add(symbol); for (int i = 1; i <= arr.length; i++) { ast.add(i, Num.valueOf(arr[i - 1])); } return ast; }
/** * {@inheritDoc} */ public boolean addAll(List<? extends IExpr> ast, int startPosition, int endPosition) { if (ast.size() > 0 && startPosition < endPosition) { ensureCapacity(size() + (endPosition - startPosition)); for (int i = startPosition; i < endPosition; i++) { add(ast.get(i)); } return true; } return false; }
/** * Create a new abstract syntax tree (AST). * * @param head * the header expression of the function. If the ast represents a * function like <code>f[x,y], Sin[x],...</code>, the * <code>head</code> will be an instance of type ISymbol. * @param initialCapacity * the initial capacity (i.e. number of arguments without the header * element) of the list. * @param initNull * initialize all elements with <code>null</code>. * @return */ public static IAST ast(final IExpr head, final int initialCapacity, final boolean initNull) { final AST ast = AST.newInstance(initialCapacity, head); if (initNull) { for (int i = 0; i < initialCapacity; i++) { ast.add(null); } } return ast; }
/** * Constructs a list with header <i>symbol</i> and the arguments containing * the given DoubleImpl matrix values as <i>List</i> rows * * @see Num */ public static AST newInstance(final ISymbol symbol, final double[][] matrix) { // AST ast; // if (Config.SERVER_MODE) { // ast = FACTORY.object(); // } else { // ast = new AST(5, false); // } AST ast = new AST(5, false); ast.add(symbol); AST row; for (int i = 1; i <= matrix.length; i++) { row = newInstance(F.List, matrix[i - 1]); ast.add(i, row); } return ast; }
public static AST newInstance(final ISymbol symbol, final org.apache.commons.math3.complex.Complex[] arr) { // AST ast; // if (Config.SERVER_MODE) { // ast = FACTORY.object(); // } else { // ast = new AST(5, false); // } AST ast = new AST(5, false); ast.add(symbol); for (int i = 1; i <= arr.length; i++) { ast.add(i, ComplexNum.valueOf(arr[i - 1].getReal(),arr[i - 1].getImaginary())); } return ast; }
/** * Creates a new AST from the given <code>ast</code> and <code>head</code>. if * <code>include</code> is set to <code>true </code> all arguments from index * first to last-1 are copied in the new list if <code>include</code> is set * to <code> false </code> all arguments excluded from index first to last-1 * are copied in the new list * */ public static IAST ast(final IAST f, final IExpr head, final boolean include, final int first, final int last) { AST ast = null; if (include) { ast = AST.newInstance(last - first, head); // range include for (int i = first; i < last; i++) { ast.add(f.get(i)); } } else { ast = AST.newInstance(f.size() - last + first - 1, head); // range exclude for (int i = 1; i < first; i++) { ast.add(f.get(i)); } for (int j = last; j < f.size(); j++) { ast.add(f.get(j)); } } return ast; }
public Matrix plus(final Matrix that) { if ((that.getRows() != getRows()) || (that.getColumns() != fColumns)) { throw new DimensionException("Matrix#plus([" + getRows() + "," + fColumns + "],[" + that.getRows() + "," + that.getColumns() + "])"); } AST resultAST = createAST(fAst.size() - 1); AST tempAST; for (int i = 1; i < fAst.size(); i++) { tempAST = createAST(getColumns()); ((IAST) fAst.get(i)).map(tempAST, (IAST) that.fAst.get(i), new BinaryMap(F.Plus())); resultAST.add(tempAST); } return new Matrix(resultAST, getColumns()); }