Very good library

Sep 30, 2014 at 9:12 PM
First thank you for the great work. There seems to be a bug when I run Sample2

The only change that I am making is to simplify the function as follows:

Function f = x * y;
//Function f = Function.Exp(x * y) + x + 0.5;
//f *= Function.Cos(f);
//f *= Function.Cos(f);
//f *= Function.Cos(f);
//f *= Function.Cos(f);
//f = f.Derivative(x);

The error comes when I execute this line:
CompiledFunction g2 = Compiler.Compile(f, new Variable[] { x, y }, 1); / 2 /

The error is: the 'references' dictionary does not contain the key:
code.AppendLine("y[" + i + "]=" + references[functions[i]].GenerateCode(this) + ";");

Is there a simple fix?

Thanks,
Andrew
Coordinator
Oct 1, 2014 at 11:27 AM
I can't reproduce this. I works fine on my machine. Have you tried with the lastest version from the source control? You can download it as a zip-file.

Morten
Oct 1, 2014 at 1:42 PM
Edited Oct 1, 2014 at 1:43 PM
Indeed, I was using FuncLib 0.4 (Jan 14, 2012, Beta). The latest version does not have this issue.

One improvement that in my case speeds up the evaluation of the compiled functions is to add a base class
   public class GeneratedFunctionBase
    {
        public virtual void Value(double[] x, double[] y)
        {
        }
    }
and to inherit GeneratedFunction from it
  code.AppendLine("public class GeneratedFunction : GeneratedFunctionBase");
  code.AppendLine("public override void Value(double[] x, double[] y)");
Thanks again for the good work.

Andrew