Esempio n. 1
0
        public void TestInterchangeRows()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            int columnCount = matrix.Columns;
            int rowCount    = matrix.Rows;

            matrix.InterchangeRows(0, 1);

            Assert.AreEqual(matrix.Columns, columnCount);
            Assert.AreEqual(matrix.Rows, rowCount);

            for (int i = 0; i < matrix.Rows; i++)
            {
                for (int j = 0; j < matrix.Columns; j++)
                {
                    if (i == 0)
                    {
                        Assert.AreEqual(matrix[i, j], (i + 1) + (j));
                    }
                    else if (i == 1)
                    {
                        Assert.AreEqual(matrix[i, j], (i - 1) + (j));
                    }
                    else
                    {
                        Assert.AreEqual(matrix[i, j], i + j);
                    }
                }
            }
        }
Esempio n. 2
0
        public void InterchangeRowsExample()
        {
            var matrix = new ObjectMatrix <double>(2, 2);

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

            matrix.InterchangeRows(0, 1);

            Assert.AreEqual(3, matrix[0, 0]);
            Assert.AreEqual(4, matrix[0, 1]);
            Assert.AreEqual(1, matrix[1, 0]);
            Assert.AreEqual(2, matrix[1, 1]);
        }
Esempio n. 3
0
        public void InterchangeRowsExample()
        {
            var matrix = new ObjectMatrix<double>(2, 2);
            matrix[0, 0] = 1;
            matrix[0, 1] = 2;
            matrix[1, 0] = 3;
            matrix[1, 1] = 4;

            matrix.InterchangeRows(0, 1);

            Assert.AreEqual(3, matrix[0, 0]);
            Assert.AreEqual(4, matrix[0, 1]);
            Assert.AreEqual(1, matrix[1, 0]);
            Assert.AreEqual(2, matrix[1, 1]);
        }
Esempio n. 4
0
        public void TestInterchangeRowsInvalidRow4()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            matrix.InterchangeRows(0, matrix.Rows);
        }
Esempio n. 5
0
        public void TestInterchangeRowsInvalidRow1()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            matrix.InterchangeRows(-1, 1);
        }