示例#1
0
        public void ProductMatIntTest()
        {
            Matrix.Services.Models.Matrix A = new Matrix.Services.Models.Matrix(2, 3);

            A.Content = new object[, ] {
                { 1, 2, 3 }, { 4, 5, 6 }
            };

            Matrix.Services.Models.Matrix B = 2 * A;

            Matrix.Services.Models.Matrix result = new Matrix.Services.Models.Matrix(2, 3);
            result.Content = new object[, ] {
                { 2, 4, 6 }, { 8, 10, 12 }
            };

            Assert.AreEqual(true, B.Equals(result));
        }
示例#2
0
        public void ProductMatrixTest()
        {
            Matrix.Services.Models.Matrix A = new Matrix.Services.Models.Matrix(2, 2);
            A.Content = new object[, ] {
                { 1, 3 }, { -1, 2 }
            };

            Matrix.Services.Models.Matrix B = new Matrix.Services.Models.Matrix(2, 3);
            B.Content = new object[, ] {
                { 1, 3, 2 }, { 2, -3, 1 }
            };

            Matrix.Services.Models.Matrix matResult = A * B;

            Matrix.Services.Models.Matrix matExpected = new Matrix.Services.Models.Matrix(2, 3);
            matExpected.Content = new object[, ] {
                { 7, -6, 5 }, { 3, -9, 0 }
            };

            Assert.AreEqual(true, matExpected.Equals(matResult));
        }
示例#3
0
        public void SubtractionMatrixTest()
        {
            Matrix.Services.Models.Matrix A = new Matrix.Services.Models.Matrix(2, 3);

            A.Content = new object[, ] {
                { 1, 2, 3 }, { 4, 5, 6 }
            };

            Matrix.Services.Models.Matrix B = new Matrix.Services.Models.Matrix(2, 3);

            B.Content = new object[, ] {
                { 3, 2, 1 }, { 6, 5, 4 }
            };

            Matrix.Services.Models.Matrix matResult = A - B;

            Matrix.Services.Models.Matrix matExpected = new Matrix.Services.Models.Matrix(2, 3);

            matExpected.Content = new object[, ] {
                { -2, 0, 2 }, { -2, 0, 2 }
            };

            Assert.AreEqual(true, matResult.Equals(matExpected));
        }