本文整理汇总了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");
}
});
}
示例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;
}
示例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));
}