-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCustomFunction.cs
More file actions
54 lines (45 loc) · 1.35 KB
/
Copy pathCustomFunction.cs
File metadata and controls
54 lines (45 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
namespace AK
{
public class CustomFunction
{
public string name;
public System.Func<double[],double> funcmd;
public System.Func<object[],double> funcmo;
public System.Func<double,double> func1d;
public int paramCount;
public bool enableSymbolicationTimeEvaluation;
public CustomFunction(string name, int paramCount, System.Func<double[],double> func, bool enableSymbolicationTimeEvaluation)
{
this.funcmd = func;
this.enableSymbolicationTimeEvaluation = enableSymbolicationTimeEvaluation;
this.paramCount = paramCount;
this.name = name;
}
public CustomFunction(string name, int paramCount, System.Func<object[],double> func, bool enableSymbolicationTimeEvaluation)
{
this.funcmo = func;
this.enableSymbolicationTimeEvaluation = enableSymbolicationTimeEvaluation;
this.paramCount = paramCount;
this.name = name;
}
public CustomFunction(string name, System.Func<double,double> func, bool enableSymbolicationTimeEvaluation)
{
this.func1d = func;
this.enableSymbolicationTimeEvaluation = enableSymbolicationTimeEvaluation;
this.paramCount = 1;
this.name = name;
}
public double Invoke(double[] p)
{
return funcmd(p);
}
public double Invoke(object[] p)
{
return funcmo(p);
}
public double Invoke(double x)
{
return func1d != null ? func1d(x) : funcmd(new double[]{x});
}
}
}