本文整理汇总了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;
}
示例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));
}
示例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));
}
示例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)));
}
示例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));
}
示例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"));
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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));
}
示例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());
}
示例15: TestInequalityWrongType
public void TestInequalityWrongType()
{
var v1 = new Vector<string, int>();
// ReSharper disable once SuspiciousTypeConversion.Global
v1.Equals("").ShouldBeFalse();
}