Beispiel #1
0
 private NumValue unary(NumValue[] params) {
   switch (m_uop) {
     case UMINUS:
       return m_right.evaluate(params).neg();
     case NOT:
       return m_right.evaluate(params).not();
     default:
       return null;
   }
 }
Beispiel #2
0
 public Func shift(int shift) {
   switch (m_type) {
     case VAR:
       return new Func(m_index + shift);
     case CONST:
       return this;
     case UNOP:
       return new Func(m_uop, m_right.shift(shift));
     case BINOP:
       return new Func(m_left.shift(shift), m_bop, m_right.shift(shift));
     default:
       return null;
   }
 }
Beispiel #3
0
 public Func nest(Func[] params) {
   switch (m_type) {
     case VAR:
       return params[m_index].copy();
     case CONST:
       return this;
     case UNOP:
       return new Func(m_uop, m_right.nest(params));
     case BINOP:
       return new Func(m_left.nest(params), m_bop, m_right.nest(params));
     default:
       return null;
   }
 }
Beispiel #4
0
 public String toString() {
   switch (m_type) {
     case VAR:
       return "in[" + m_index + "]";
     case CONST:
       return m_value.toString();
     case UNOP:
       return uopString() + "(" + m_right.toString() + ")";
     case BINOP:
       return "(" + m_left.toString() + " " + bopString() + " " + m_right.toString() + ")";
     default:
       return "";
   }
 }
Beispiel #5
0
 public NumValue evaluate(NumValue[] params) {
   switch (m_utype) {
     case SIN:
       return NumLang.Func.sin(m_func.evaluate(params));
     case COS:
       return NumLang.Func.cos(m_func.evaluate(params));
     case LN:
       return NumLang.Func.ln(m_func.evaluate(params));
     case LOG:
       return NumLang.Func.log(m_func.evaluate(params));
     case CEIL:
       return NumLang.Func.ceil(m_func.evaluate(params));
     case FLOOR:
       return NumLang.Func.floor(m_func.evaluate(params));
     default:
       return null;
   }
 }
Beispiel #6
0
 public String toString() {
   switch (m_utype) {
     case SIN:
       return "sin(" + m_func.toString() + ")";
     case COS:
       return "cos(" + m_func.toString() + ")";
     case LN:
       return "ln(" + m_func.toString() + ")";
     case LOG:
       return "log(" + m_func.toString() + ")";
     case CEIL:
       return "ceil(" + m_func.toString() + ")";
     case FLOOR:
       return "floor(" + m_func.toString() + ")";
     default:
       return null;
   }
 }
Beispiel #7
0
 public SpecialFunc copy() {
   return new SpecialFunc(m_utype, m_func.copy());
 }
Beispiel #8
0
 public Func evaluate(Func[] paramList) {
   return m_function.nest(paramList);
 }
Beispiel #9
0
 public NumValue evaluate(NumValue[] paramlist) {
   return m_function.evaluate(paramlist);
 }
Beispiel #10
0
 public FuncValue(int params, Func function) {
   m_params = params;
   m_function = function.copy();
 }
Beispiel #11
0
 public FuncValue mod(NumValue other) {
   return new FuncValue(m_params, m_function.mod(other));
 }
Beispiel #12
0
 public FuncValue divide(NumValue other) {
   return new FuncValue(m_params, m_function.divide(other));
 }
Beispiel #13
0
 private NumValue binary(NumValue[] params) {
   switch (m_bop) {
     case ADD:
       return m_left.evaluate(params).add(m_right.evaluate(params));
     case SUB:
       return m_left.evaluate(params).subtract(m_right.evaluate(params));
     case MULT:
       return m_left.evaluate(params).multiply(m_right.evaluate(params));
     case DIV:
       return m_left.evaluate(params).divide(m_right.evaluate(params));
     case EXP:
       return m_left.evaluate(params).exp(m_right.evaluate(params));
     case MOD:
       return m_left.evaluate(params).mod(m_right.evaluate(params));
     case EQ:
       return m_left.evaluate(params).eq(m_right.evaluate(params));
     case NEQ:
       return m_left.evaluate(params).neq(m_right.evaluate(params));
     case LT:
       return m_left.evaluate(params).lt(m_right.evaluate(params));
     case LEQ:
       return m_left.evaluate(params).leq(m_right.evaluate(params));
     case GT:
       return m_left.evaluate(params).gt(m_right.evaluate(params));
     case GEQ:
       return m_left.evaluate(params).geq(m_right.evaluate(params));
     default:
       return null;
   }
 }
Beispiel #14
0
 public FuncValue not() {
   return new FuncValue(m_params, m_function.not());
 }
Beispiel #15
0
 public FuncValue geq(NumValue other) {
   return new FuncValue(m_params, m_function.geq(other));
 }
Beispiel #16
0
 public FuncValue lt(NumValue other) {
   return new FuncValue(m_params, m_function.lt(other));
 }
Beispiel #17
0
 public SpecialFunc shift(int shift) {
   return new SpecialFunc(m_utype, m_func.shift(shift));
 }
Beispiel #18
0
 public FuncValue multiply(NumValue other) {
   return new FuncValue(m_params, m_function.multiply(other));
 }
Beispiel #19
0
 public SpecialFunc nest(Func[] params) {
   return new SpecialFunc(m_utype, m_func.nest(params));
 }
Beispiel #20
0
 public FuncValue exp(NumValue other) {
   return new FuncValue(m_params, m_function.exp(other));
 }
Beispiel #21
0
  /*
  	public FuncValue nest(FuncValue[] inputs)
  	{
  		Func[] funcs  = new Func[inputs.length];
  		for(int i = 0; i < inputs.length; i++)
  		{
  			funcs[i] = inputs[i].m_function;
  		}

  		int shift = inputs[0].m_params;
  		for(int i = 1; i < inputs.length; i++)
  		{
  			funcs[i] = funcs[i].shift(shift);
  			shift += inputs[i].m_params;
  		}
  		return new FuncValue(shift, m_function.nest(funcs));

  	}
  */
  public String toString() {
    String output = "|in[0]";
    for (int i = 1; i < m_params; i++) output += ", in[" + i + "]";
    output += "| -> |" + m_function.toString() + "|";
    return output;
  }
Beispiel #22
0
 public FuncValue subtract(NumValue other) {
   return new FuncValue(m_params, m_function.subtract(other));
 }