本文整理汇总了C#中System.Function.setParametersNumber方法的典型用法代码示例。如果您正苦于以下问题:C# Function.setParametersNumber方法的具体用法?C# Function.setParametersNumber怎么用?C# Function.setParametersNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Function
的用法示例。
在下文中一共展示了Function.setParametersNumber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: runTest1
//.........这里部分代码省略.........
Function Cnk = new Function("Cnk","if( k>0, if( k<n, Cnk(n-1,k-1)+Cnk(n-1,k), 1), 1)","n", "k");
expStr = "C(10,5)-Cnk(10,5)";
mXparser.consolePrint(expStr + " ...... ");
exp[testId] = new Expression(expStr);
exp[testId].addDefinitions(Cnk);
value = exp[testId].calculate();
reg = 0;
if ( MathFunctions.abs(value - reg) <= 0.000001 )
testResult = true;
mXparser.consolePrint(value + " reg ... " + reg + " --> ");
break;
case 118:
n = new Argument("n");
fib1 = new RecursiveArgument("fib1", "fib1(n-1)+fib1(n-2)", n);
fib1.addBaseCase(0, 0);
fib1.addBaseCase(1, 1);
fib2 = new RecursiveArgument("fib2", "if( n>1, fib2(n-1)+fib2(n-2), if(n>0,1,0) )", n);
Function fib3 = new Function("fib3","if(n>1, fib3(n-1)+fib3(n-2), if(n>0,1,0))","n");
expStr = "sum(i,1,10,(fib1(i) = fib2(i)) & (fib2(i) = fib3(i)) )";
mXparser.consolePrint(expStr + " ...... ");
exp[testId] = new Expression(expStr, fib1, fib2);
exp[testId].addDefinitions(fib3);
value = exp[testId].calculate();
reg = 10;
if ( MathFunctions.abs(value - reg) <= 0.000001 )
testResult = true;
mXparser.consolePrint(value + " reg ... " + reg + " --> ");
break;
case 119:
m = new Argument("m");
n = new Argument("n", "m-1", m);
x = new Argument("x",3);
Function H = new Function("H","if(m>1, 2*x*H(n,x)-2*n*H(n-1,x), if(m>0, 2*x, 1) )", m, x, n);
H.setParametersNumber(2);
expStr = "H(0,x) + H(1,x) + H(2,x) + H(3,x) - ( (1) + (2*x) + (4*x^2-2) + (8*x^3-12*x) )";
mXparser.consolePrint(expStr + " ...... ");
exp[testId] = new Expression(expStr, x);
exp[testId].addDefinitions(H);
value = exp[testId].calculate();
reg = 0;
if ( MathFunctions.abs(value - reg) <= 0.000001 )
testResult = true;
mXparser.consolePrint(value + " reg ... " + reg + " --> ");
break;
case 120:
m = new Argument("m",4);
n = new Argument("n", "m-1", m);
x = new Argument("x",3);
H = new Function("H","if(m>1, 2*x*H(n,x)-2*n*H(n-1,x), if(m>0, 2*x, 1) )", m, x, n);
H.setParametersNumber(2);
k = new Argument("k",5);
expStr = "der( H(k,x), x) - 2*k*H(k-1,x)";
mXparser.consolePrint(expStr + " ...... ");
exp[testId] = new Expression(expStr, x,k );
exp[testId].addDefinitions(H);
value = exp[testId].calculate();
reg = 0;
if ( MathFunctions.abs(value - reg) <= 0.0001 )
testResult = true;
mXparser.consolePrint(value + " reg ... " + reg + " --> ");
break;
case 121:
Function T = new Function("T","if(k>1, 2*x*T(k-1,x)-T(k-2,x), if(k>0, x, 1) )", "k", "x");
k = new Argument("k",5);
x = new Argument("x",3);
expStr = "T(k,x) - ( (x + sqrt(x^2-1))^k + (x - sqrt(x^2-1))^k)/2";