本文整理汇总了C#中Variable.Evaluate方法的典型用法代码示例。如果您正苦于以下问题:C# Variable.Evaluate方法的具体用法?C# Variable.Evaluate怎么用?C# Variable.Evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Variable
的用法示例。
在下文中一共展示了Variable.Evaluate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetInterpolatedValueReturnsDefaultValueOnEmpty2ArgsFunction
public void GetInterpolatedValueReturnsDefaultValueOnEmpty2ArgsFunction()
{
IVariable<double> x = new Variable<double>("x");
IVariable<double> y = new Variable<double>("y");
x.ExtrapolationType = ExtrapolationType.Constant;
y.ExtrapolationType = ExtrapolationType.Constant;
IVariable<double> f1 = new Variable<double>("f1");
IFunction function = new Function("testfunction");
function.Arguments.Add(x);
function.Arguments.Add(y);
function.Components.Add(f1);
f1.DefaultValue = 100.0;
Assert.AreEqual(100,
f1.Evaluate<double>(x.CreateValueFilter(7.5),
(new VariableValueFilter<double>(y, 68.2))));
}
示例2: GetExceptionExtrapolatingValues2ArgsFunction
public void GetExceptionExtrapolatingValues2ArgsFunction()
{
IVariable<double> x = new Variable<double>("x");
IVariable<double> y = new Variable<double>("y");
IVariable<double> f1 = new Variable<double>("f1");
IFunction function = new Function("testfunction");
function.Arguments.Add(x);
function.Arguments.Add(y);
function.Components.Add(f1);
var xValues = new[] {1.0, 2.0, 3.0};
var yValues = new[] {10.0, 20.0, 30.0, 40.0};
var fValues = new[,]
{
{100.0, 200.0, 300.0, 400.0},
{1000.0, 2000.0, 3000.0, 4000.0},
{10000.0, 20000.0, 30000.0, 40000.0}
};
function.SetValues(fValues, new VariableValueFilter<double>(x, xValues), new VariableValueFilter<double>(y, yValues),
new ComponentFilter(f1));
//no interpolation..on a defined spot
Assert.AreEqual(100,
f1.Evaluate<double>(new VariableValueFilter<double>(x, 0.5),
(new VariableValueFilter<double>(y, 10.0))));
Assert.AreEqual(100,
f1.Evaluate<double>(new VariableValueFilter<double>(x, 1.5),
(new VariableValueFilter<double>(y, 10.0))));
}
示例3: InterpolatedLinear2D
public void InterpolatedLinear2D()
{
IVariable<double> x = new Variable<double>("x");
IVariable<double> y = new Variable<double>("y");
IVariable<double> f1 = new Variable<double>("f1");
var function = new Function("testfunction");
function.Arguments.Add(x);
function.Arguments.Add(y);
function.Components.Add(f1);
var xValues = new[] { 1.0, 2.0, 3.0 };
var yValues = new[] { 10.0, 20.0, 30.0, 40.0 };
var fValues = new[,]
{
{100.0, 200.0, 300.0, 400.0},
{1000.0, 2000.0, 3000.0, 4000.0},
{10000.0, 20000.0, 30000.0, 40000.0}
};
function.SetValues(fValues, new VariableValueFilter<double>(x, xValues), new VariableValueFilter<double>(y, yValues), new ComponentFilter(f1));
//no interpolation..on a defined spot
Assert.AreEqual(100, f1.Evaluate<double>(new VariableValueFilter<double>(x, 1.0), (new VariableValueFilter<double>(y, 10.0))));
//interpolation among first argument
Assert.AreEqual(640.0, f1.Evaluate<double>(new VariableValueFilter<double>(x, 1.6), (new VariableValueFilter<double>(y, 10.0))), 0.001);
//interpolation among second argument
Assert.AreEqual(260.0, f1.Evaluate<double>(new VariableValueFilter<double>(x, 1.0), (new VariableValueFilter<double>(y, 26.0))), 0.001);
//interpolation among two arguments
Assert.AreEqual(1664.0, f1.Evaluate<double>(new VariableValueFilter<double>(x, 1.6), (new VariableValueFilter<double>(y, 26.0))), 0.001);
}
示例4: GetUniformInterpolatedValue
public void GetUniformInterpolatedValue()
{
IVariable<double> x = new Variable<double>("x");
IVariable<double> y = new Variable<double>("y");
IVariable<double> f1 = new Variable<double>("f1");
f1.Arguments.Add(x);
f1.Arguments.Add(y);
var xValues = new[] { 1.0, 2.0 };
var yValues = new[] { 1.0, 2.0 };
var fValues = new[,]
{
{100.0, 100.0},
{100.0, 100.0}
};
f1.SetValues(fValues,
new VariableValueFilter<double>(x, xValues),
new VariableValueFilter<double>(y, yValues));
var value = f1.Evaluate<double>(
new VariableValueFilter<double>(x, 1.5),
new VariableValueFilter<double>(y, 1.5));
Assert.AreEqual(100,value);
}
示例5: InterpolatedConstant2D
public void InterpolatedConstant2D()
{
IVariable<double> x = new Variable<double>("x");
IVariable<double> y = new Variable<double>("y");
IVariable<double> f1 = new Variable<double>("f1");
Function function = new Function("testfunction");
function.Arguments.Add(x);
function.Arguments.Add(y);
function.Components.Add(f1);
x.InterpolationType = ApproximationType.Constant;
y.InterpolationType = ApproximationType.Constant;
var xValues = new double[] { 1.0, 2.0, 3.0 };
var yValues = new double[] { 10.0, 20.0, 30.0, 40.0 };
var fValues = new[,]
{
{100.0, 200.0, 300.0, 400.0},
{1000.0, 2000.0, 3000.0, 4000.0},
{10000.0, 20000.0, 30000.0, 40000.0}
};
function.SetValues(fValues, new VariableValueFilter<double>(x, xValues), new VariableValueFilter<double>(y, yValues), new ComponentFilter(f1));
//interpolation among first argument
Assert.AreEqual(100.0, f1.Evaluate<double>(new VariableValueFilter<double>(x, 1.6), (new VariableValueFilter<double>(y, 10.0))));
//interpolation among second argument
Assert.AreEqual(200.0, f1.Evaluate<double>(new VariableValueFilter<double>(x, 1.0), (new VariableValueFilter<double>(y, 26.0))));
//interpolation among two arguments
Assert.AreEqual(200.0, f1.Evaluate<double>(new VariableValueFilter<double>(x, 1.6), (new VariableValueFilter<double>(y, 26.0))), 0.001);
}