/** * 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. * */ public static IAST ast(final IExpr head) { return AST.newInstance(head); }
public static IExpr convertComplex(org.apache.commons.math3.complex.Complex[] array) throws ConversionException { return AST.newInstance(F.List, array); } }
public static IAST convertComplex(boolean evalComplex, org.hipparchus.complex.Complex[] array) throws ConversionException { return AST.newInstance(F.List, evalComplex, array); } }
/** {@inheritDoc} */ @Override public final IASTAppendable copyUntil(final int intialCapacity, int index) { return AST.newInstance(intialCapacity, this, index); }
/** * Create a new abstract syntax tree (AST). * * @param intialArgumentsCapacity * the initial capacity of arguments of the 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. * @return */ public static IAST newInstance(final int intialArgumentsCapacity, final IExpr head) { return AST.newInstance(intialArgumentsCapacity, head); }
/** * 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. * */ public final static IASTAppendable ast(final IExpr head) { return AST.newInstance(head); }
/** {@inheritDoc} */ @Override public IASTAppendable copyUntil(int index) { return AST.newInstance(index, this, index); }
public IAST copyUntil(int index) { return newInstance(this, index); }
/** * Create a new abstract syntax tree (AST). * * @param intialArgumentsCapacity * the initial capacity of arguments of the 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. * @return */ public static IAST newInstance(final int intialArgumentsCapacity, final IExpr head) { return AST.newInstance(intialArgumentsCapacity, head); }
/** * Create a new abstract syntax tree (AST). * * @param arr * @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. * @return */ public static IAST ast(final IExpr[] arr, final IExpr head) { return AST.newInstance(arr, head); // for (int i = 0; i < arr.length; i++) { // ast.add(arr[i]); // } // return ast; }
/** {@inheritDoc} */ @Override public final IASTAppendable copyHead(final int intialCapacity) { return AST.newInstance(intialCapacity, head()); }
/** {@inheritDoc} */ @Override public final IASTAppendable copyHead() { return AST.newInstance(head()); }
public IAST copyHead() { return newInstance(get(0)); }
/** * Constructs a list with header <i>symbol</i> and the arguments containing the given DoubleImpl matrix values as * <i>List</i> rows * * @param symbol * @param matrix * @return * @see Num */ public static AST newInstance(final ISymbol symbol, final double[][] matrix) { IExpr[] eArr = new IExpr[matrix.length + 1]; eArr[0] = symbol; for (int i = 1; i <= matrix.length; i++) { eArr[i] = newInstance(F.List, matrix[i - 1]); } return new AST(eArr); }
/** * 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 IASTAppendable 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.append(null); } } return ast; }
/** * 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; }
/** * simple parser to simplify unit tests. The parser assumes that the String contains no syntax errors. * * Example "List[x,List[y]]" * * @param inputString * @return */ public static IAST parse(final String inputString) { final StringTokenizer tokenizer = new StringTokenizer(inputString, "[],", true); String token = tokenizer.nextToken(); final IASTAppendable list = newInstance(StringX.valueOf(token)); token = tokenizer.nextToken(); if ("[".equals(token)) { parseList(tokenizer, list); return list; } // syntax fError occured return null; }
/** * simple parser to simplify unit tests. The parser assumes that the String * contains no syntax errors. * * Example "List[x,List[y]]" */ public static AST parse(final String inputString) { final StringTokenizer tokenizer = new StringTokenizer(inputString, "[],", true); final AST list = newInstance(null); String token = tokenizer.nextToken(); list.setHeader(StringX.valueOf(token)); token = tokenizer.nextToken(); if (token.equals("[")) { parseList(tokenizer, list); return list; } // syntax fError occured return null; }
/** * 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; }
/** * 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.append(f.get(i)); } } else { ast = AST.newInstance(f.size() - last + first - 1, head); // range exclude for (int i = 1; i < first; i++) { ast.append(f.get(i)); } for (int j = last; j < f.size(); j++) { ast.append(f.get(j)); } } return ast; }