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


C# Vector.Equals方法代码示例

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


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

示例1: VectorIntEquals

    private static int VectorIntEquals()
    {
        const int Pass = 100;
        const int Fail = -1;

        Vector<int> A = new Vector<int>(3);
        Vector<int> B = new Vector<int>(3);
        Vector<int> C = new Vector<int>(5);

        bool result = A.Equals(B);
        if (!result)
        {
            return Fail;
        }

        result = A.Equals(C);
        if (result)
        {
            return Fail;
        }

        if (A.Equals(Vector<int>.Zero))
        {
            return Fail;
        }

        if (!Vector<int>.Zero.Equals(Vector<int>.Zero))
        {
            return Fail;
        }

        return Pass;
    }
开发者ID:sivarv,项目名称:coreclr,代码行数:33,代码来源:VectorIntEquals.cs

示例2: EqualIfYsAreEqual

        public void EqualIfYsAreEqual()
        {
            var vectorOne = new Vector(0, 3.33);
            var vectorTwo = new Vector(0, 3.33);

            Assert.True(vectorOne.Y.Equals(vectorTwo.Y));
            Assert.True(vectorOne.Equals(vectorTwo));
        }
开发者ID:jystic,项目名称:Triangles-in-space,代码行数:8,代码来源:VectorTests.cs

示例3: EqualIfXsAreEqual

        public void EqualIfXsAreEqual()
        {
            var vectorOne = new Vector(2.3, 0);
            var vectorTwo = new Vector(2.3, 0);

            Assert.True(vectorOne.X.Equals(vectorTwo.X));
            Assert.True(vectorOne.Equals( vectorTwo));
        }
开发者ID:jystic,项目名称:Triangles-in-space,代码行数:8,代码来源:VectorTests.cs

示例4: Equals

 public void Equals()
 {
     var v1 = new Vector(1, 2, 3);
     var v2 = new Vector(3, 4, 5);
     Assert.AreNotEqual(v1, v2);
     Assert.AreEqual(v1, new Vector(1, 2, 3));
     Assert.IsTrue(v1 == new Vector(1, 2, 3));
     Assert.IsTrue(v1 != v2);
     Assert.IsTrue(v1.Equals((object)new Vector(1, 2, 3)));
 }
开发者ID:hillwhite,项目名称:DeltaEngine,代码行数:10,代码来源:VectorTests.cs

示例5: TestEquals

        public void TestEquals()
        {
            Vector vector1 = new Vector(1.0, 2.0, 3.0);
            Vector vector2 = new Vector(1.0, 2.0, 3.0);

            Assert.That(vector1, Is.Not.SameAs(vector2));
            Assert.That(vector1, Is.EqualTo(vector2));
            Assert.False(vector1.Equals(null));
            Assert.That(vector1.GetHashCode(), Is.EqualTo(vector2.GetHashCode()));

            vector2.Altitude = null;
            Assert.That(vector1, Is.Not.EqualTo(vector2));

            vector2.Altitude = 3.0;
            vector2.Latitude = 3.0;
            Assert.That(vector1, Is.Not.EqualTo(vector2));
        }
开发者ID:karun10,项目名称:KML2SQL,代码行数:17,代码来源:VectorTest.cs

示例6: EqualsAndHashCode

        public void EqualsAndHashCode()
        {
            Vector vector1 = new Vector(new double[] { 1.0, 2.0, 3.0 });
            Vector vector2 = new Vector(new double[] { 1.0, 2.0, 3.0 });
            Vector vector3 = new Vector(new double[] { 1.0, 2.0, 3.0, 4.0 });
            Vector vector4 = new Vector(new double[] { 1.0, 2.0, 4.0 });

            Assert.IsTrue(vector1.Equals(vector2));
            Assert.IsTrue(vector2.Equals(vector1));

            Assert.AreEqual(vector2.GetHashCode(), vector1.GetHashCode());

            Assert.IsFalse(vector1.Equals(vector3));
            Assert.IsFalse(vector1.Equals(vector4));
            Assert.IsFalse(vector3.Equals(vector1));
            Assert.IsFalse(vector4.Equals(vector1));

            Assert.IsFalse(vector1.Equals(null));
            Assert.IsFalse(vector1.Equals(42));
            Assert.IsFalse(vector1.Equals("foo"));
        }
开发者ID:ajlopez,项目名称:MathelSharp,代码行数:21,代码来源:VectorTests.cs

示例7: TestSparseEquality

 public void TestSparseEquality()
 {
     var v1 = new Vector<string, int> { { "x", 1 }, { "y", 0 } };
     var v2 = new Vector<string, int> { { "x", 1 }};
     v1.Equals(v2).ShouldBeTrue();
 }
开发者ID:drbatty,项目名称:maths-core,代码行数:6,代码来源:VectorTests.cs

示例8: LogAverageFactor

        /// <summary>
        /// Evidence message for VMP
        /// </summary>
        /// <param name="product">Constant value for 'product'.</param>
        /// <param name="A">Constant value for 'a'.</param>
        /// <param name="B">Constant value for 'b'.</param>
        /// <returns>Zero</returns>
        /// <remarks><para>
        /// In Variational Message Passing, the evidence contribution of a deterministic factor is zero.
        /// Adding up these values across all factors and variables gives the log-evidence estimate for VMP.
        /// </para></remarks>
		public static double LogAverageFactor(Vector product, Matrix A, Vector B)
		{
			return product.Equals(Factor.Product(A, B)) ? 0.0 : Double.NegativeInfinity;
		}
开发者ID:dtrckd,项目名称:Mixed-Membership-Stochastic-Blockmodel,代码行数:15,代码来源:MatrixVectorProduct.cs

示例9: Vector_Equals_differentiates_two_Vectors_successfully_on_z

 public void Vector_Equals_differentiates_two_Vectors_successfully_on_z()
 {
     var v1 = new Vector(1.0f, 1.2f, 1.9f);
       var v2 = new Vector(1.0f, 1.2f, -1.9f);
       bool eqeq = v1.Equals(v2);
       Assert.IsFalse(eqeq);
 }
开发者ID:EddPorter,项目名称:RayManCS,代码行数:7,代码来源:VectorTests.cs

示例10: Vector_Equals_compares_two_Vectors_successfully

 public void Vector_Equals_compares_two_Vectors_successfully()
 {
     var v1 = new Vector(1.0f, 1.2f, 1.9f);
       var v2 = new Vector(1.0f, 1.2f, 1.9f);
       bool eqeq = v1.Equals(v2);
       Assert.IsTrue(eqeq);
 }
开发者ID:EddPorter,项目名称:RayManCS,代码行数:7,代码来源:VectorTests.cs

示例11: NotEqualIfYsAreNotEqual

        public void NotEqualIfYsAreNotEqual()
        {
            var vectorOne = new Vector(0, 3.33);
            var vectorTwo = new Vector(0, 1);

            Assert.True(vectorOne.X.Equals(vectorTwo.X));
            Assert.False(vectorOne.Y.Equals(vectorTwo.Y));
            Assert.False(vectorOne.Equals(vectorTwo));
        }
开发者ID:jystic,项目名称:Triangles-in-space,代码行数:9,代码来源:VectorTests.cs

示例12: Vector_Equals_returns_false_given_non_material

 public void Vector_Equals_returns_false_given_non_material()
 {
     var v = new Vector(1.0f, 1.2f, 1.9f);
       var m = new Material() {
     Colour = System.Drawing.Color.Green,
     Reflectance = 0.3f,
     SpecularPower = 50,
     SpecularTerm = 1.2f
       };
       bool eqeq = v.Equals(m);
       Assert.IsFalse(eqeq);
 }
开发者ID:EddPorter,项目名称:RayManCS,代码行数:12,代码来源:VectorTests.cs

示例13: NotEqualIfXsAreNotEqual

        public void NotEqualIfXsAreNotEqual()
        {
            var vectorOne = new Vector(2.3, 0);
            var vectorTwo = new Vector(32, 0);

            Assert.False(vectorOne.X.Equals(vectorTwo.X));
            Assert.True(vectorOne.Y.Equals(vectorTwo.Y));
            Assert.False(vectorOne.Equals(vectorTwo));
        }
开发者ID:jystic,项目名称:Triangles-in-space,代码行数:9,代码来源:VectorTests.cs

示例14: GetDirection

 Direction GetDirection(Vector vector)
 {
     foreach (KeyValuePair<Direction, Vector> pair in directions)
         if (vector.Equals(pair.Value)) return pair.Key;
     throw new System.Exception("Couldn't get direction for vector " + vector.ToString());
 }
开发者ID:VRWizards,项目名称:VR-Project,代码行数:6,代码来源:TrackGenerator.cs

示例15: TestInequalityWrongType

 public void TestInequalityWrongType()
 {
     var v1 = new Vector<string, int>();
     // ReSharper disable once SuspiciousTypeConversion.Global
     v1.Equals("").ShouldBeFalse();
 }
开发者ID:drbatty,项目名称:maths-core,代码行数:6,代码来源:VectorTests.cs


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