本文整理匯總了C#中System.Function.addDefinitions方法的典型用法代碼示例。如果您正苦於以下問題:C# Function.addDefinitions方法的具體用法?C# Function.addDefinitions怎麽用?C# Function.addDefinitions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Function
的用法示例。
在下文中一共展示了Function.addDefinitions方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: runTest1
//.........這裏部分代碼省略.........
if ( MathFunctions.abs(value-reg) <= 0.00001)
testResult = true;
mXparser.consolePrint(value + " reg ... " + reg + " --> ");
break;
case 99:
i = new Argument("i", 5);
expStr = "2*i+sum(i,1,10,i)";
mXparser.consolePrint(expStr + " ...... ");
exp[testId] = new Expression(expStr,i);
value = exp[testId].calculate();
reg = 65;
if ( value == reg)
testResult = true;
mXparser.consolePrint(value + " reg ... " + reg + " --> ");
break;
case 100:
x = new Argument("x",3);
expStr = "sin(x)-sin(x-1)-int(cos(x),x,2,3)";
mXparser.consolePrint(expStr + " ...... ");
exp[testId] = new Expression(expStr,x);
value = exp[testId].calculate();
reg = 0;
if ( MathFunctions.abs(value-reg) <= 0.00001)
testResult = true;
mXparser.consolePrint(value + " reg ... " + reg + " --> ");
break;
case 101:
f = new Function("mg", "sin(x)+cos(y)", "x", "y");
x = new Argument("x", 3);
y = new Argument("y", 2);
expStr = "sin(x)+cos(y)-mg(x,y)";
mXparser.consolePrint(expStr + " ...... ");
exp[testId] = new Expression(expStr,x, y);
exp[testId].addDefinitions(f);
value = exp[testId].calculate();
reg = 0;
if ( MathFunctions.abs(value - reg) <= 0.000000000001)
testResult = true;
mXparser.consolePrint(value + " reg ... " + reg + " --> ");
break;
case 102:
f = new Function("mg", "sin(x)+cos(y)", "x", "y");
expStr = "der(sin(x)+cos(y),x)-der(mg(x,y),x)";
mXparser.consolePrint(expStr + " ...... ");
exp[testId] = new Expression(expStr,new Argument("x", 3), new Argument("y", 2));
exp[testId].addDefinitions(f);
value = exp[testId].calculate();
reg = 0;
if ( MathFunctions.abs(value - reg) <= 0.00000001)
testResult = true;
mXparser.consolePrint(value + " reg ... " + reg + " --> ");
break;
case 103:
f = new Function("f", "x^2", "x");
g = new Function("g", "f(x)^2", "x");
g.addDefinitions(f);
expStr = "g(x)";
mXparser.consolePrint(expStr + " ...... ");
exp[testId] = new Expression(expStr, new Argument("x", 3));
exp[testId].addDefinitions(g);
value = exp[testId].calculate();
reg = 81;
if ( value == reg )
testResult = true;
mXparser.consolePrint(value + " reg ... " + reg + " --> ");
break;