...
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; |
VariableIndexFiltersVariableIndexRangeFilters
VariableIndexFilters VariableIndexRangeFilters work similar to VariableValueFilters but they used the indexes indices in the argument variable values to make a selection.
...
And we get the following grid
x\y | 10 | 20 | 30 |
---|---|---|---|
0 | - | - | - |
1 | - | - | - |
2 | 1 | 2 | 3 |
VariableIndexRangesFilters VariableIndexRangesFilters
They are the same as VariableIndexRangeFilters except that now multiple ranges can be defined in one filter.They are the same as VariableIndexRangeFilters except that now multiple ranges can be defined in one filter.
VariableReduceFilter
Can be used to reduce function in dimensionality. For example a two dimension (two-argument) function can be reduced to a one dimensional (one-argument) function. This is only possible if the dimension that is being reduced has a single value.
Code Block |
---|
IVariable<int> x = new Variable<int>("x"); IVariable<int> y = new Variable<int>("y"); IVariable<int> fx = new Variable<int>("fx"); fx.Arguments.Add(x); fx.Arguments.Add(y); x.SetValues(new[] {1, 2, 3}); y.SetValues(new[] {1,2}); fx[3, 1] = 20; var reducedFunction = fx.Filter(new VariableValueFilter<int>(y, 1), new VariableReduceFilter(y)); //the function 'lost' an argument Assert.AreEqual(1, reducedFunction.Arguments.Count); Assert.AreEqual(3, reducedFunction.Values.Count); Assert.AreEqual(20, reducedFunction.Values[2]); |
This filter is used for example to get a timeseries out of a timedependent coverage (reducing location) or to get a timeIndependent coverage out of a timedependent (reducing time)