Пример #1
0
 /**
  * Sets the children of node to be those specified in array.
  *
  * @param node the node whose children will be set.
  * @param children an array of nodes which will be the children of the node.
  */
 public void copyChildren(Node node, Node children[]) {
   int nchild = children.length;
   node.jjtOpen();
   for (int i = 0; i < nchild; ++i) {
     children[i].jjtSetParent(node);
     node.jjtAddChild(children[i], i);
   }
   node.jjtClose();
 }
  /**
   * Differentiates an expression tree wrt a variable var.
   *
   * @param node the top node of the expression tree
   * @param var the variable to differentiate wrt
   * @return the top node of the differentiated expression
   * @throws ParseException if some error occurred while trying to differentiate, for instance of no
   *     rule supplied for given function.
   * @throws IllegalArgumentException
   */
  public Node differentiate(Node node, String var, DJep djep)
      throws ParseException, IllegalArgumentException {
    this.localDJep = djep;
    this.nf = djep.getNodeFactory();
    this.tu = djep.getTreeUtils();
    // this.opSet=djep.getOperatorSet();

    if (node == null) throw new IllegalArgumentException("node parameter is null");
    if (var == null) throw new IllegalArgumentException("var parameter is null");

    Node res = (Node) node.jjtAccept(this, var);
    return res;
  }
Пример #3
0
 public Object eval(Node node) throws ParseException {
   MatrixValueI val = (MatrixValueI) node.jjtAccept(this, null);
   return val.copy();
 }