Ejemplo n.º 1
0
 /**
  * Create a differention rule for function with 2 arguments. The rules must be in terms of "x" and
  * "y"
  *
  * @param inName name of function
  * @param inPfmc PostfixMathCommandI for function
  * @param rule1 a string represention differation of function wrt "x"
  * @param rule2 a string represention differation of function wrt "y"
  * @throws ParseException
  */
 private MacroDiffRules(
     DJep djep, String inName, PostfixMathCommandI inPfmc, String rule1, String rule2)
     throws ParseException {
   name = inName;
   pfmc = inPfmc;
   if (pfmc != null) {
     int nParam = pfmc.getNumberOfParameters();
     if (nParam != 2) {
       throw new ParseException(
           "Number of rules must match number of parameters for "
               + inName
               + " which is "
               + nParam);
     }
   }
   XSymbolTable localSymTab =
       (XSymbolTable) ((XSymbolTable) djep.getSymbolTable()).newInstance(); // new
   // SymbolTable();
   localSymTab.copyConstants(djep.getSymbolTable());
   XJep localJep = djep.newInstance(localSymTab);
   Node node1 = localJep.parse(rule1);
   Node node2 = localJep.parse(rule2);
   rules = new Node[2];
   rules[0] = node1;
   rules[1] = node2;
 }
Ejemplo n.º 2
0
  /**
   * Create a differentation rule for function with n arguments. The rules must be in terms of "x1",
   * "x2", ... "xn"
   *
   * @param inName name of function
   * @param inPfmc PostfixMathCommandI for function
   * @throws ParseException
   */
  private MacroDiffRules(DJep djep, String inName, PostfixMathCommandI inPfmc, String[] inRules)
      throws ParseException {
    name = inName;
    pfmc = inPfmc;
    if (pfmc != null) {
      int nParam = pfmc.getNumberOfParameters();
      if (nParam != inRules.length) {
        throw new ParseException(
            "Number of rules must match number of parameters for "
                + inName
                + " which is "
                + nParam);
      }
    }

    XSymbolTable localSymTab = (XSymbolTable) ((XSymbolTable) djep.getSymbolTable()).newInstance();
    localSymTab.copyConstants(djep.getSymbolTable());
    XJep localJep = djep.newInstance(localSymTab);

    rules = new Node[inRules.length];
    for (int i = 0; i < inRules.length; ++i) {
      rules[i] = localJep.parse(inRules[i]);
    }
  }