Exemplo n.º 1
0
  public static void test4() {
    FSin sin = new FSin("x");
    FCos cos = new FCos("y");
    MathFunc f = sin * cos;
    System.out.println(f);
    System.out.println(f.getVarNames());
    System.out.println(f.apply(Math.PI / 2, Math.PI / 4));

    CompiledFunc cf = f.compile();
    System.out.println(cf.apply(Math.PI / 2, Math.PI / 4));
    // bug in order of args
    System.out.println(f.compile(new String[] {"y", "x"}).apply(Math.PI / 2, Math.PI / 4));
  }
Exemplo n.º 2
0
 public static void test5() {
   MathFunc f = FX.x * FX.y * FX.z + 1;
   System.out.println(f);
   System.out.println(f.getVarNames());
   System.out.println(f.apply(2, 3, 4));
   CompiledFunc cf = f.compile();
   System.out.println(cf.apply(2, 3, 4));
 }
Exemplo n.º 3
0
  public static void test1() {
    MathFunc x = FX.x;
    MathFunc y = FX.y;
    MathFunc xy = x.S(y);

    FuncClassLoader<CompiledFunc> fcl = new FuncClassLoader<CompiledFunc>();
    ClassGen genClass = BytecodeUtils.genClass(xy, null, "add", true, false);
    CompiledFunc fxy = fcl.newInstance(genClass);
    System.out.println(fxy.apply(1.0, 2.0));

    System.out.println(xy.compile(new String[] {"y", "x"}).apply(1.0, 2.0));
  }