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


C# Vector.GetLength方法代码示例

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

示例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();
        }
开发者ID:szabototo89,项目名称:szabototo89.github.io,代码行数:16,代码来源:Program.cs

示例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());
 }
开发者ID:samuto,项目名称:designscript,代码行数:12,代码来源:CoordinateSystem.cs

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

示例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);
 }
开发者ID:bogdanuifalean,项目名称:JuniorMind,代码行数:11,代码来源:VectorTest.cs


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