本文整理汇总了C#中Variable.AddValues方法的典型用法代码示例。如果您正苦于以下问题:C# Variable.AddValues方法的具体用法?C# Variable.AddValues怎么用?C# Variable.AddValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Variable
的用法示例。
在下文中一共展示了Variable.AddValues方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteTwoDimensionalFunctionUsingIndexFilters
public void WriteTwoDimensionalFunctionUsingIndexFilters()
{
//writing index based now only works for adding slices..
var flow = new Variable<int>();
var x = new Variable<int>();
var y = new Variable<int>();
flow.Arguments.Add(x);
flow.Arguments.Add(y);
x.AddValues(new[] {1, 2, 3});
y.AddValues(new[] {10, 20, 30});
//we now have 3x3 array for flow..write the last 'slice'
var xIndex = new VariableIndexRangeFilter(x, 2);
var yIndex = new VariableIndexRangeFilter(y, 0, 2);
flow.SetValues(new[] {1, 2, 3}, new[] {xIndex, yIndex});
Assert.AreEqual(9, flow.Values.Count);
Assert.AreEqual(3, flow.Values[8]);
}
示例2: AddValuesGivesExceptionOnDependendVariables
public void AddValuesGivesExceptionOnDependendVariables()
{
IVariable<int> x = new Variable<int>();
IVariable<int> y = new Variable<int>();
y.Arguments.Add(x);
//TODO: factor to x.Values.Add( ) and check the array in function
y.AddValues(new[] { 2 });
}
示例3: AddValuesPossibleForIndependVariable
public void AddValuesPossibleForIndependVariable()
{
IVariable<int> x = new Variable<int>();
//TODO: factor to x.Values.Add( ) and check the array in function
x.AddValues(new[]{2});
Assert.AreEqual(1,x.Values.Count);
}
示例4: GetVariableValueFilterIndexesShouldBeFast
public void GetVariableValueFilterIndexesShouldBeFast()
{
IVariable<double> x = new Variable<double>("x");
IVariable<double> y = new Variable<double>("y");
var amount = 5000;
IList<double> allValues = new List<double>(amount);
for (int i = 0; i < amount; i++)
allValues.Add(i);
x.AddValues(allValues);
y.Arguments.Add(x);
IFunctionStore store = y.Store;
IList<double> valuesToSelect = new List<double>();
valuesToSelect.Add(allValues[0]);
valuesToSelect.Add(allValues[50]);
valuesToSelect.Add(allValues[amount-1]);
IMultiDimensionalArray array = null;
TestHelper.AssertIsFasterThan(130,
() =>
{
for (int i = 0; i < 5000; i++)
{
array = store.GetVariableValues(x,new VariableValueFilter<double>(x,valuesToSelect));
}
});
//orig: 600ms
//now: 15ms
Assert.AreEqual(3,array.Count);
}