示例#1
0
        public void TestResizeLarger()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

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

            matrix.Resize(20, 20);

            Assert.AreEqual(matrix.Columns, 20);
            Assert.AreEqual(matrix.Rows, 20);

            for (int i = 0; i < rowCount; i++)
            {
                for (int j = 0; j < columnCount; j++)
                {
                    Assert.AreEqual(matrix[i, j], i + j);
                }
            }

            for (int i = rowCount; i < 20; i++)
            {
                for (int j = columnCount; j < 20; j++)
                {
                    Assert.AreEqual(matrix[i, j], default(double));
                }
            }
        }
示例#2
0
        public void TestResizeSmaller()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            matrix.Resize(2, 2);

            Assert.AreEqual(matrix.Columns, 2);
            Assert.AreEqual(matrix.Rows, 2);

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    Assert.AreEqual(matrix[i, j], i + j);
                }
            }
        }
示例#3
0
        public void ResizeExample()
        {
            var matrix = new ObjectMatrix <double>(3, 3);

            matrix[0, 0] = 1;
            matrix[0, 1] = 2;
            matrix[0, 2] = 3;
            matrix[1, 0] = 4;
            matrix[1, 1] = 5;
            matrix[1, 2] = 6;
            matrix[2, 0] = 7;
            matrix[2, 1] = 8;
            matrix[2, 2] = 9;

            matrix.Resize(2, 2);

            Assert.AreEqual(matrix.Columns, 2);
            Assert.AreEqual(matrix.Rows, 2);

            Assert.AreEqual(1, matrix[0, 0]);
            Assert.AreEqual(2, matrix[0, 1]);
            Assert.AreEqual(4, matrix[1, 0]);
            Assert.AreEqual(5, matrix[1, 1]);
        }
        public void ResizeExample()
        {
            var matrix = new ObjectMatrix<double>(3, 3);
            matrix[0, 0] = 1;
            matrix[0, 1] = 2;
            matrix[0, 2] = 3;
            matrix[1, 0] = 4;
            matrix[1, 1] = 5;
            matrix[1, 2] = 6;
            matrix[2, 0] = 7;
            matrix[2, 1] = 8;
            matrix[2, 2] = 9;

            matrix.Resize(2, 2);

            Assert.AreEqual(matrix.Columns, 2);
            Assert.AreEqual(matrix.Rows, 2);

            Assert.AreEqual(1, matrix[0, 0]);
            Assert.AreEqual(2, matrix[0, 1]);
            Assert.AreEqual(4, matrix[1, 0]);
            Assert.AreEqual(5, matrix[1, 1]);
        }
示例#5
0
        public void TestInvalidSize6()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            matrix.Resize(0, 0);
        }
示例#6
0
        public void TestInvalidSize5()
        {
            ObjectMatrix <int> matrix = GetTestMatrix();

            matrix.Resize(-1, -1);
        }