當前位置: 首頁>>代碼示例>>C#>>正文


C# Function.setParametersNumber方法代碼示例

本文整理匯總了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";
開發者ID:RoganMatrivski,項目名稱:Math-Problem-Generator,代碼行數:67,代碼來源:RegTestExpression.cs


注:本文中的System.Function.setParametersNumber方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。