本文整理汇总了C#中Vector.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.GetLength方法的具体用法?C# Vector.GetLength怎么用?C# Vector.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.GetLength方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DualVector
public DualVector(Vector values, Vector[] gradients, Vector[,] hessians)
{
int n = 0;
Matrix[] matrixGradients = null;
if (gradients != null)
{
n = gradients.Length;
matrixGradients = new Matrix[n];
for (int i = 0; i < n; i++)
{
if (gradients[i] == null)
{
throw new ArgumentNullException("gradients", "The gradients must be fully specified.");
}
matrixGradients[i] = (Matrix)gradients[i];
}
}
Matrix[,] matrixHessians = null;
if (hessians != null)
{
if (hessians.GetLength(0) != n || hessians.GetLength(1) != n)
{
throw new ArgumentException("Inconsistent number of derivatives.");
}
matrixHessians = new Matrix[n, n];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (hessians[i, j] == null)
{
throw new ArgumentNullException("hessians", "The Hessians must be fully specified.");
}
matrixHessians[i, j] = (Matrix)hessians[i, j];
}
}
}
inner = new DualMatrix((Matrix)values, matrixGradients, matrixHessians);
}
示例2: Main
private static void Main(String[] args)
{
Vector vector = Vector.Zero(3);
Assert($"{nameof(vector)} is equal to Vector(0, 0, 0)", vector.Equals(new Vector(0, 0, 0)));
Assert($"{nameof(vector)} is not equal to Vector(1, 1, 0)", !vector.Equals(new Vector(1, 1, 0)));
Vector vector2 = new Vector(1, 2, 2);
Assert($"{nameof(vector2)} length should be equal to 3.0", vector2.GetLength() == 3.0);
Vector vector3 = new Vector(1, 1, 1);
Vector vector4 = vector2.Add(vector3);
Assert($"{nameof(vector2)} + {nameof(vector3)} is equal to Vector(2, 3, 3)", vector4.Equals(new Vector(2, 3, 3)));
Assert($"{nameof(vector2)} + {nameof(vector3)} is equal to Vector(2, 3, 3)", vector4 == new Vector(2, 3, 3));
Console.ReadKey();
}
示例3: Translate
/// <summary>
/// Translates the coordinate system by the coordinates specified
/// </summary>
/// <param name="xTranslation">Translation in the x direction</param>
/// <param name="yTranslation">Translation in the y direction</param>
/// <param name="zTranslation">Translation in the z direction</param>
/// <returns></returns>
public CoordinateSystem Translate(double xTranslation, double yTranslation, double zTranslation)
{
Vector direction = new Vector(xTranslation, yTranslation, zTranslation);
return Translate(direction, direction.GetLength());
}
示例4: ItShouldResizeFullArray
public void ItShouldResizeFullArray()
{
Vector<byte> testVector = new Vector<byte>();
testVector.Add(1);
testVector.Add(0);
testVector.Add(1);
testVector.Add(1);
testVector.Add(0);
testVector.Add(1);
testVector.Add(1);
testVector.Add(0);
testVector.Add(1);
testVector.Add(1);
testVector.Add(0);
testVector.Add(1);
int expected = 20;
int actual = testVector.GetLength();
Assert.AreEqual(expected, actual);
}
示例5: ItShouldTrimArray
public void ItShouldTrimArray()
{
Vector<byte> testVector = new Vector<byte>();
testVector.Add(1);
testVector.Add(0);
testVector.Add(1);
int expected = testVector.GetLength() / 2;
testVector.Trim();
int actual = testVector.GetLength();
Assert.AreEqual(expected, actual);
}