...
Code Block |
---|
var x = new Variable<int>("x"); var y = new Variable<int>("y"); var f = new Function{Components = {y},Arguments = {x}}; y.SetValues(new[] { 1 }, new VariableValueFilter<int>(x, 0)); //this is equivalent of the previous call f[0] = 1; |
VariableIndexFilters
VariableIndexFilters work similar to VariableValueFilters but they used the indexes in the argument variable values to make a selection.
For example the following grid
x\y | 10 | 20 | 30 |
---|---|---|---|
0 | - | - | - |
1 | - | - | - |
2 | - | - | - |
Can be generated like this
Code Block |
---|
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});
|
Now we can set the bottom row like this
Code Block |
---|
//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});
|
And we get the following grid
x\y | 10 | 20 | 30 |
---|---|---|---|
0 | - | - | - |
1 | - | - | - |
2 | 1 | 2 | 3 |