Exemple #1
0
 static void Main(string[] args)
 {
     CoolMatrix matrix = new[,]
     {
         { 1, 2 }
     };
     var expectedSize = new Size(width: 3, height: 2);
     matrix.Transpose();
     Console.WriteLine(expectedSize);
     Console.WriteLine(matrix.Size);
     Console.ReadLine();
 }
        public void Transpose_Always_TransposesMatrix()
        {
            CoolMatrix matrix = new[,]
            {
                { 1, 2 }
            };

            CoolMatrix expected = new[,]
            {
                { 1 },
                { 2 }
            };

            Assert.AreEqual(expected, matrix.Transpose());
        }
Exemple #3
0
        public void Matrix_Transpose_Test()
        {
            Matrix one = new[,]
                {{1, 2, 3},
                 {4, 5, 6},
                 {7, 8, 9}};

            Matrix oneT = new[,]
                {{1, 4, 7},
                 {2, 5, 8},
                 {3, 6, 9}};

            Matrix two = new[,]
                {{1, 2, 3, 9},
                 {4, 5, 6, 12},
                 {7, 8, 10, 13}};

            Matrix twoT = new[,]
                {{1, 4, 7},
                 {2, 5, 8},
                 {3, 6, 10},
                 {9,12, 13}};

            Assert.Equal(oneT, one.Transpose());
            Assert.Equal(oneT, one.T);
            Assert.Equal(one, oneT.Transpose());
            Assert.Equal(one, oneT.T);
            Assert.Equal(twoT, two.Transpose());
            Assert.Equal(twoT, two.T);
            Assert.Equal(two, twoT.Transpose());
            Assert.Equal(two, twoT.T);
        }
        public void Transpose_ForVerticalMatrix_ReturnsCorrectResult()
        {
            CoolMatrix matrix = new[,]
            {
                {1},
                {2}
            };

            CoolMatrix expected = new[,]
            {
                {1, 2}
            };

            Assert.AreEqual(expected, matrix.Transpose());
        }
        public void Transpose_ForSquareMatrix_ReturnsCorrectResult()
        {
            CoolMatrix matrix = new[,]
            {
                {1, 2},
                {3, 4}
            };

            CoolMatrix expected = new[,]
            {
                {1, 3},
                {2, 4}
            };

            Assert.AreEqual(expected, matrix.Transpose());
        }
        public void Transpose_ForOneElementMatrix_RetursTheSameMatrix()
        {
            CoolMatrix matrix = new[,]
            {
                {9}
            };

            Assert.AreEqual(matrix, matrix.Transpose());
        }
Exemple #7
0
        public void TestMatrixTranspose()
        {
            var testInput = new[,]
            {
                {1D},
                {1D}
            };

            var testResult = testInput.Transpose();

            //one row, two columns
            Assert.AreEqual(1D, testResult[0, 0]);
            Assert.AreEqual(1D, testResult[0, 1]);
        }