当前位置: 首页>>代码示例>>C#>>正文


C# Variable.CreateValueFilter方法代码示例

本文整理汇总了C#中Variable.CreateValueFilter方法的典型用法代码示例。如果您正苦于以下问题:C# Variable.CreateValueFilter方法的具体用法?C# Variable.CreateValueFilter怎么用?C# Variable.CreateValueFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Variable的用法示例。


在下文中一共展示了Variable.CreateValueFilter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EvaluateReturnsDefaultValueOnEmptyFunction

        public void EvaluateReturnsDefaultValueOnEmptyFunction()
        {
            IVariable<double> x = new Variable<double>("x");
            IVariable<double> y = new Variable<double>("y");

            IFunction f = new Function();
            f.Arguments.Add(x);
            f.Components.Add(y);
            x.ExtrapolationType = ApproximationType.Constant; 

            y.DefaultValue = 10.0;
            
            Assert.AreEqual(10.0, f.Evaluate<double>(x.CreateValueFilter(1.0)));
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:14,代码来源:FunctionApproximationTest.cs

示例2: FilterDependendVariable

        public void FilterDependendVariable()
        {
            //int sa = componentArrays.Aggregate(1, (product, item) => (product *= item.Count));
            IVariable<double> y = new Variable<double>("y");
            IVariable<double> x = new Variable<double>("x");

            y.Arguments.Add(x);

            x.SetValues(new[] { 1.0, 2.0, 3.0 });
            y.SetValues(new[] { 10.0, 20.0, 30.0 });

            var filtered = y.Filter(x.CreateValueFilter(2.0));

            Assert.AreEqual(1, filtered.Components[0].Values.Count);
            Assert.AreEqual(20, filtered.Values[0]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:16,代码来源:FunctionFilterTest.cs

示例3: FilterFunction

        public void FilterFunction()
        {
            IVariable<double> x = new Variable<double>("x");
            IVariable<double> y = new Variable<double>("y");
            IVariable<double> fx = new Variable<double>("fx");
            IVariable<double> fy = new Variable<double>("fy");

            IFunction f = new Function();
            f.Arguments.Add(x);
            f.Arguments.Add(y);
            f.Components.Add(fx);
            f.Components.Add(fy);

            x.SetValues(new[] { 1.0, 2.0, 3.0 });
            y.SetValues(new[] { 10.0, 20.0 });

            f.Components[0].Values[1, 1] = 100.0;
            f.Components[1].Values[1, 1] = 200.0;

            // fx       10.0  20.0 
            //          ------------
            //    1.0  | 0.0    0.0
            //    2.0  | 0.0  100.0 
            //    3.0  | 0.0    0.0
            //
            // fy       10.0  20.0 
            //          ------------
            //    1.0  | 0.0    0.0
            //    2.0  | 0.0  200.0 
            //    3.0  | 0.0    0.0

            var filteredFunction = f.Filter(x.CreateValueFilter(2.0), y.CreateValueFilter(20.0));

            Assert.AreEqual(2, filteredFunction.Components.Count);
            Assert.AreEqual(2, filteredFunction.Arguments.Count);

            Assert.AreEqual(1, filteredFunction.Arguments[0].Values.Count);
            Assert.AreEqual(1, filteredFunction.Arguments[1].Values.Count);
            Assert.AreEqual(1, filteredFunction.Components[0].Values.Count);
            Assert.AreEqual(1, filteredFunction.Components[1].Values.Count);

            Assert.AreEqual(100.0, filteredFunction.Components[0].Values[0]);
            Assert.AreEqual(200.0, filteredFunction.Components[1].Values[0]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:44,代码来源:FunctionFilterTest.cs

示例4: 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))));
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:19,代码来源:FunctionApproximationTest.cs

示例5: GetValueOfFilteredFunctionUsingValueOfFiltererArgument

        public void GetValueOfFilteredFunctionUsingValueOfFiltererArgument()
        {
            IVariable<double> y = new Variable<double>("y");
            IVariable<double> x = new Variable<double>("x");

            y.Arguments.Add(x);

            x.SetValues(new[] { 1.0, 2.0, 3.0 });
            y.SetValues(new[] { 10.0, 20.0, 30.0 });

            var filtered = y.Filter(x.CreateValueFilter(2.0));
            
            //arguments of filtered functions are ignored!
            Assert.IsNull(filtered[3.0]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:15,代码来源:FunctionFilterTest.cs

示例6: Function2DGetValuesUsingOneArgumentValue

        public void Function2DGetValuesUsingOneArgumentValue()
        {
            IVariable<float> f = new Variable<float>("f");
            IVariable<float> x1 = new Variable<float>("x1");
            IVariable<float> x2 = new Variable<float>("x2");

            IFunction function = new Function("OneComponentTwoArguments Test");
            function.Components.Add(f);
            function.Arguments.Add(x1);
            function.Arguments.Add(x2);

            /*   x2
             *    ^
             *    |
             *    |  x  x     <=== f(x1,x2)
             *    |  x  x
             *    |  x  x
             *    | 
             *     --------> x1
             * 
             */

            function[0.0f, 0.0f] = 0.0f;
            function[1.0f, 0.0f] = 0.0f;
            function[0.0f, 1.0f] = 100.0f;
            function[1.0f, 1.0f] = 100.0f;
            function[0.0f, 2.0f] = 200.0f;
            function[1.0f, 2.0f] = 200.0f;


            // get all values
            IList allValues = function.GetValues();
            Assert.AreEqual(6, allValues.Count);

            // get values filtered by 1st argument
            IMultiDimensionalArray filteredValues1 = function.GetValues(new VariableValueFilter<float>(x1, 1.0f));

            Assert.AreEqual(x2.Values.Count, filteredValues1.Count);

            // get values filtered by 2 arguments
            IMultiDimensionalArray filteredValues2 = function.GetValues(x1.CreateValueFilter(1.0f), x2.CreateValueFilter(1.0f));

            Assert.AreEqual(1, filteredValues2.Count);
            Assert.AreEqual(100f, filteredValues2[0, 0]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:45,代码来源:FunctionFilterTest.cs

示例7: FilterFilteredFunction

        public void FilterFilteredFunction()
        {
            IVariable<int> x = new Variable<int>();
            x.SetValues(new[] { 1, 2, 3, 4, 5 });

            var filtered = x.Filter(x.CreateValuesFilter(new[] { 2, 3, 4 }));

            var filtered2 = filtered.Filter(x.CreateValueFilter(3));

            Assert.AreEqual(3, filtered.Values.Count);
            Assert.IsTrue(filtered.Values.Cast<int>().SequenceEqual(new[] { 2, 3, 4 }));

            Assert.AreEqual(1, filtered2.Values.Count);
            Assert.AreEqual(3, filtered2.Values[0]);

            // change filters
            ((IVariableValueFilter)filtered2.Filters[0]).Values.Add(5);
            ((IVariableValueFilter)filtered2.Filters[0]).Values.Add(4);
            Assert.AreEqual(2, filtered2.Values.Count);

            // expanding filter in the "filtered" will also expand "filtered2"
            ((IVariableValueFilter)filtered.Filters[0]).Values.Add(5);
            Assert.AreEqual(4, filtered.Values.Count);
            Assert.AreEqual(3, filtered2.Values.Count);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:25,代码来源:FunctionFilterTest.cs


注:本文中的Variable.CreateValueFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。