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


C# Vector.GetValue方法代码示例

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


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

示例1: IsValid

		/// <summary>
		/// Evaluate the constraint
		/// </summary>
		/// <param name="target">The target vector to evaluate.</param>
		/// <returns></returns>
		public bool IsValid(Vector target)
		{
			if (target == null)
			{
				return false;
			}

			return _constraint.LogicalEvaluate(
				delegate(ExpressionIdentifier identifier)
				{
					Dimension dimension = _dimensions[identifier.Name];

					if (dimension.Domain == typeof(int))
					{
						return ExpressionConstant.Constant(target.GetValue<int>((Dimension<int>)dimension));
					}
					else if (dimension.Domain == typeof(bool))
					{
						return ExpressionConstant.Constant(target.GetValue<bool>((Dimension<bool>)dimension));
					}
					else if (dimension.Domain == typeof(string))
					{
						return ExpressionConstant.Constant(target.GetValue<string>((Dimension<string>)dimension));
					}
					else
					{
						throw new InvalidOperationException("Invalid type");
					}
				});
		}
开发者ID:larsenjo,项目名称:odata.net,代码行数:35,代码来源:SymbolicConstraint.cs

示例2: IsValid

        /// <summary>
        /// Checks the input vector and returns true if it doesn't violate this constraint.
        /// </summary>
        /// <param name="target">The target vector to validate.</param>
        /// <returns>
        ///     <c>true</c> if the specified <paramref name="target"/>is valid; otherwise, <c>false</c>.
        /// </returns>
        public bool IsValid(Vector target)
        {
            object[] parameterValues = this.requiredDimensions.Select(d => target.GetValue(d)).ToArray();

            bool result = (bool)this.methodInfo.Invoke(this.instance, parameterValues);

            return result;
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:15,代码来源:TestMatrixMethodBasedConstraint.cs

示例3: TestLUDecomposition

        public static void TestLUDecomposition()
        {
            //-----------------------------
            //| 0.18 | 0.41 | 0.14 | 0.51 |
            //| 0.60 | 0.24 | 0.30 | 0.13 |
            //| 0.57 | 0.99 | 0.97 | 0.19 |
            //| 0.96 | 0.58 | 0.66 | 0.85 |
            //-----------------------------

            Matrix matrix = new Matrix(4, 4);
            matrix.SetValue(0, 0, 0.18);
            matrix.SetValue(0, 1, 0.60);
            matrix.SetValue(0, 2, 0.57);
            matrix.SetValue(0, 3, 0.96);
            matrix.SetValue(1, 0, 0.41);
            matrix.SetValue(1, 1, 0.24);
            matrix.SetValue(1, 2, 0.99);
            matrix.SetValue(1, 3, 0.58);
            matrix.SetValue(2, 0, 0.14);
            matrix.SetValue(2, 1, 0.30);
            matrix.SetValue(2, 2, 0.97);
            matrix.SetValue(2, 3, 0.66);
            matrix.SetValue(3, 0, 0.51);
            matrix.SetValue(3, 1, 0.13);
            matrix.SetValue(3, 2, 0.19);
            matrix.SetValue(3, 3, 0.85);
            Vector b = new Vector(4);
            b.SetValue(0, 1);
            b.SetValue(1, 2);
            b.SetValue(2, 3);
            b.SetValue(3, 4);
            Vector x = new Vector(4);

            //LU分解による解法
            int sig;
            Permutation perm = new Permutation(4);
            LinearAlgebra.LUDecomposition(ref matrix, ref perm, out sig);
            LinearAlgebra.LUSolve(matrix, perm, b, ref x);
            LinearAlgebra.LUSolve(matrix, perm, ref b);

            //QR分解による解法
            /*Vector tau = new Vector(4);
            LinearAlgebra.QRDecomposition(ref matrix, ref tau);
            LinearAlgebra.QRSolve(matrix, tau, b, ref x);*/

            Console.WriteLine(x.GetValue(0));
            Console.WriteLine(x.GetValue(1));
            Console.WriteLine(x.GetValue(2));
            Console.WriteLine(x.GetValue(3));
        }
开发者ID:mastobaev,项目名称:gsldotnet,代码行数:50,代码来源:LinearAlgebraTester.cs


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