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


C# Variable.Evaluate方法代码示例

本文整理汇总了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))));
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:19,代码来源:FunctionApproximationTest.cs

示例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))));

        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:33,代码来源:FunctionApproximationTest.cs

示例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);

        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:35,代码来源:FunctionApproximationTest.cs

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

示例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);

        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:35,代码来源:FunctionApproximationTest.cs


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