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


C# Matrix.Equals方法代码示例

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


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

示例1: Equal_After_Change_Matrixes_Test

 public void Equal_After_Change_Matrixes_Test()
 {
     Matrix a = new Matrix(2, 2, 10);
     Matrix b = new Matrix(2, 2, 10);
     Assert.IsTrue(a.Equals(b));
     b[2, 2] = 5;
     Assert.IsFalse(a.Equals(b));
     b[2, 2] = 10;
     Assert.IsTrue(a.Equals(b));
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:10,代码来源:MatrixTest.cs

示例2: AreEqual

 public void AreEqual()
 {
     float[] values = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
     var matrix1 = new Matrix(values);
     var matrix2 = new Matrix(values);
     Assert.IsTrue(matrix1 == matrix2);
     Assert.IsTrue(matrix1.Equals(matrix2));
     matrix2[5] = 20;
     Assert.IsTrue(matrix1 != matrix2);
     Assert.IsTrue(matrix1.Equals(values));
     values[0] = 17;
     Assert.IsFalse(matrix1.Equals(values));
     Assert.IsFalse(matrix1.Equals(Point.One));
     Assert.Throws<IndexOutOfRangeException>(() => matrix1.Equals(new float[17]));
 }
开发者ID:hillwhite,项目名称:DeltaEngine,代码行数:15,代码来源:MatrixTests.cs

示例3: EqualsTest

 public void EqualsTest()
 {
     Matrix a = new Matrix(2, 2, 10);
     Matrix b = new Matrix(2, 2, 10);
     Matrix c = new Matrix(2, 2, 10);
     Matrix x = new Matrix(2, 2, 5);
     // Testing Equals
     Assert.IsTrue(a.Equals(b));
     Assert.IsFalse(a.Equals(x));
     // x.Equals(x) returns true
     Assert.IsTrue(a.Equals(a));
     // x.Equals(y) returns the same value as y.Equals(x)
     Assert.AreEqual(a.Equals(b), b.Equals(a)); //both true
     Assert.AreEqual(a.Equals(x), x.Equals(a)); // both false
     // if (x.Equals(y) && y.Equals(z)) returns true, then x.Equals(z) returns true.
     Assert.IsTrue(a.Equals(b) && b.Equals(c) && a.Equals(c));
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:17,代码来源:MatrixTest.cs

示例4: Matrix_EqualsTestsCorrectly

        public void Matrix_EqualsTestsCorrectly()
        {
            var matrix1 = new Matrix(
                11, 12, 13, 14, 
                21, 22, 23, 24, 
                31, 32, 33, 34,
                41, 42, 43, 44);
            
            var matrix2 = new Matrix(
                11, 12, 13, 14, 
                21, 22, 23, 24, 
                31, 32, 33, 34, 
                41, 42, 43, 44);
            
            var matrix3 = Matrix.Identity;

            TheResultingValue(matrix1.Equals(matrix2)).ShouldBe(true);
            TheResultingValue(matrix1.Equals(matrix3)).ShouldBe(false);
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:19,代码来源:MatrixTests.cs

示例5: TestInvert

      public void TestInvert()
      {
         Matrix<Single> m = new Matrix<Single>(3, 3);
         Matrix<Single> mInvert = new Matrix<Single>(3, 3);

         m.SetIdentity();

         CvInvoke.Invert(m, mInvert, Emgu.CV.CvEnum.DecompMethod.LU);

         EmguAssert.IsTrue(m.Equals(mInvert));
      }
开发者ID:neutmute,项目名称:emgucv,代码行数:11,代码来源:AutoTestMatrix.cs

示例6: TestConcate

        public void TestConcate()
        {
            Matrix<float> mat = new Matrix<float>(30, 40);
             mat.SetRandUniform(new MCvScalar(0), new MCvScalar(255));

             Matrix<float> m1 = mat.GetSubRect(new Rectangle(0, 0, mat.Cols, 20));
             Matrix<float> m2 = mat.GetSubRect(new Rectangle(0, 20, mat.Cols, mat.Rows - 20));
             Matrix<float> mat2 = m1.ConcateVertical(m2);
             Assert.IsTrue(mat.Equals(mat2));

             Matrix<float> m3 = mat.GetSubRect(new Rectangle(0, 0, 10, mat.Rows));
             Matrix<float> m4 = mat.GetSubRect(new Rectangle(10, 0, mat.Cols - 10, mat.Rows));
             Matrix<float> mat3 = m3.ConcateHorizontal(m4);
             Assert.IsTrue(mat.Equals(mat3));

             Matrix<float> m5 = mat.GetRows(0, 5, 1);
             Matrix<float> m6 = mat.GetRows(5, 6, 1);
             Matrix<float> m7 = mat.GetRows(6, mat.Rows, 1);
             Assert.IsTrue(mat.RemoveRows(5, 6).Equals(m5.ConcateVertical(m7)));
             Assert.IsTrue(mat.RemoveRows(0, 1).Equals(mat.GetRows(1, mat.Rows, 1)));
             Assert.IsTrue(mat.RemoveRows(mat.Rows - 1, mat.Rows).Equals(mat.GetRows(0, mat.Rows - 1, 1)));
        }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:22,代码来源:AutoTestMatrix.cs

示例7: Simple

        public void Simple()
        {
            var matrixA = new Matrix(5, 5);

            //      // [ 2,  1,  1,  3,  2 ]
            //      // [ 1,  2,  2,  1,  1 ]
            //      // [ 1,  2,  9,  1,  5 ]
            //      // [ 3,  1,  1,  7,  1 ]
            //      // [ 2,  1,  5,  1,  8 ]

            matrixA[0, 0] = 2;
            matrixA[0, 1] = 1;
            matrixA[0, 2] = 1;
            matrixA[0, 3] = 3;
            matrixA[0, 4] = 2;

            matrixA[1, 0] = 1;
            matrixA[1, 1] = 2;
            matrixA[1, 2] = 2;
            matrixA[1, 3] = 1;
            matrixA[1, 4] = 1;

            matrixA[2, 0] = 1;
            matrixA[2, 1] = 2;
            matrixA[2, 2] = 9;
            matrixA[2, 3] = 1;
            matrixA[2, 4] = 5;

            matrixA[3, 0] = 3;
            matrixA[3, 1] = 1;
            matrixA[3, 2] = 1;
            matrixA[3, 3] = 7;
            matrixA[3, 4] = 1;

            matrixA[4, 0] = 2;
            matrixA[4, 1] = 1;
            matrixA[4, 2] = 5;
            matrixA[4, 3] = 1;
            matrixA[4, 4] = 8;

            var decomposition = new CholeskyDecomposition(matrixA);

            var AA = decomposition.LeftFactorMatrix * decomposition.RightFactorMatrix;

            Assert.AreEqual(AA.Rows, 5);
            Assert.AreEqual(AA.Columns, 5);

            Assert.IsTrue(matrixA.Equals(AA, DoubleExtensions.DefaultPrecision));
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:49,代码来源:LeftRightFactors.cs

示例8: EqualsTest

 public void EqualsTest()
 {
     double[,] data = null; // TODO: инициализация подходящего значения
     Matrix target = new Matrix(data); // TODO: инициализация подходящего значения
     object obj = null; // TODO: инициализация подходящего значения
     bool expected = false; // TODO: инициализация подходящего значения
     bool actual;
     actual = target.Equals(obj);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Проверьте правильность этого метода теста.");
 }
开发者ID:vanderkorn,项目名称:math,代码行数:11,代码来源:MatrixTest.cs

示例9: TestXmlSerializeAndDeserialize

      public void TestXmlSerializeAndDeserialize()
      {
         using (Matrix<Byte> mat = new Matrix<byte>(50, 60))
         {
            mat.SetRandUniform(new MCvScalar(0), new MCvScalar(255));

#if !WINDOWS_PHONE_APP
            XDocument doc = Toolbox.XmlSerialize<Matrix<Byte>>(mat);
            //Trace.WriteLine(doc.OuterXml);

            using (Matrix<Byte> mat2 = Toolbox.XmlDeserialize<Matrix<Byte>>(doc))
               EmguAssert.IsTrue(mat.Equals(mat2));
#endif
         }
      }
开发者ID:neutmute,项目名称:emgucv,代码行数:15,代码来源:AutoTestMatrix.cs

示例10: MatrixCreate

        public void MatrixCreate()
        {
            double[][] a = { new double[] { 1, 2 }, new double[] { 2, 3 } };
            Matrix ma = new Matrix(a);
            double[][] b = { new double[] { 1.0, 2.0 }, new double[] { 2.0, 3.0 } };
            Matrix mb = Matrix.Create(b);

            Assert.That(ma, Is.EqualTo(mb));
            Assert.That(ma.Equals(mb), Is.True);
            Assert.That(ma.AlmostEquals(mb), Is.True);
        }
开发者ID:AdrianCNewman,项目名称:mathnet-iridium,代码行数:11,代码来源:MatrixArithmeticsTest.cs

示例11: transformWorld

        public void transformWorld(Matrix rotationX, Matrix rotationY, Matrix rotationZ, Matrix scaleXYZ, 
            Matrix translateXYZ)
        {
            Matrices.worldTransMtx = Matrix.Identity;

            if (!rotationZ.Equals(Matrix.Zero)) Matrices.worldTransMtx = Matrix.Multiply(Matrices.worldTransMtx, rotationZ);
            if (!rotationY.Equals(Matrix.Zero)) Matrices.worldTransMtx = Matrix.Multiply(Matrices.worldTransMtx, rotationY);
            if (!rotationX.Equals(Matrix.Zero)) Matrices.worldTransMtx = Matrix.Multiply(Matrices.worldTransMtx, rotationX);
            if (!scaleXYZ.Equals(Matrix.Zero)) Matrices.worldTransMtx = Matrix.Multiply(Matrices.worldTransMtx, scaleXYZ);
            if (!translateXYZ.Equals(Matrix.Zero)) Matrices.worldTransMtx = Matrix.Multiply(Matrices.worldTransMtx, translateXYZ);
        }
开发者ID:GreggBzz,项目名称:Outerspace,代码行数:11,代码来源:D3DScene.cs

示例12: TestMultiChannelMatrix

      public void TestMultiChannelMatrix()
      {
         Matrix<float> m = new Matrix<float>(10, 20, 2);
         m.SetRandUniform(new MCvScalar(), new MCvScalar(255, 255));
         EmguAssert.AreEqual(10, m.Rows);
         EmguAssert.AreEqual(20, m.Cols);
         EmguAssert.AreEqual(2, m.NumberOfChannels);

#if !WINDOWS_PHONE_APP
         XDocument xDoc = Toolbox.XmlSerialize<Matrix<float>>(m);
         Matrix<float> m2 = Toolbox.XmlDeserialize<Matrix<float>>(xDoc);
         EmguAssert.IsTrue(m.Equals(m2));
#endif
      }
开发者ID:neutmute,项目名称:emgucv,代码行数:14,代码来源:AutoTestMatrix.cs

示例13: Equal_Parameter_Null_Test

 public void Equal_Parameter_Null_Test()
 {
     Matrix a = new Matrix(2, 2, 1);
     Assert.IsFalse(a.Equals(null));
     Matrix b = null;
     Assert.IsFalse(a.Equals(b));
     Assert.IsFalse(a == b);
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:8,代码来源:MatrixTest.cs

示例14: EqualsAndHashCode

        public void EqualsAndHashCode()
        {
            Matrix matrix1 = new Matrix(new double[][] { new double[] { 1.0, 2.0 }, new double[] { 3.0, 4.0 } });
            Matrix matrix2 = new Matrix(new double[][] { new double[] { 1.0, 2.0 }, new double[] { 3.0, 4.0 } });
            Matrix matrix3 = new Matrix(new double[][] { new double[] { 1.0, 2.0 }, new double[] { 3.0, 5.0 } });
            Matrix matrix4 = new Matrix(new double[][] { new double[] { 1.0, 2.0, 3.0 }, new double[] { 3.0, 4.0, 5.0 } });
            Matrix matrix5 = new Matrix(new double[][] { new double[] { 1.0, 2.0 }, new double[] { 3.0, 4.0 }, new double[] { 5.0, 6.0 } });

            Assert.IsTrue(matrix1.Equals(matrix2));
            Assert.IsTrue(matrix2.Equals(matrix1));

            Assert.AreEqual(matrix2.GetHashCode(), matrix1.GetHashCode());

            Assert.IsFalse(matrix1.Equals(matrix3));
            Assert.IsFalse(matrix1.Equals(matrix4));
            Assert.IsFalse(matrix1.Equals(matrix5));
            Assert.IsFalse(matrix3.Equals(matrix1));
            Assert.IsFalse(matrix4.Equals(matrix1));
            Assert.IsFalse(matrix5.Equals(matrix1));

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

示例15: TestRuntimeSerialize3

      public void TestRuntimeSerialize3()
      {
         MCvPoint3D32f[] data = new MCvPoint3D32f[] { new MCvPoint3D32f() };

         GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);

         Matrix<float> mat = new Matrix<float>(data.GetLength(0), 1, 3, handle.AddrOfPinnedObject(), sizeof(float) * 3);

         System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
             formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

         Byte[] bytes;
         using (MemoryStream ms = new MemoryStream())
         {
            formatter.Serialize(ms, mat);
            bytes = ms.GetBuffer();
         }
         using (MemoryStream ms2 = new MemoryStream(bytes))
         {
            Matrix<float> mat2 = (Matrix<float>) formatter.Deserialize(ms2);
            EmguAssert.IsTrue(mat.Equals(mat2));
         }
         handle.Free();
      }
开发者ID:neutmute,项目名称:emgucv,代码行数:24,代码来源:AutoTestMatrix.cs


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