public void GetSubMatrixExample() { 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; var result1 = matrix.GetSubMatrix(0, 0, 1, 1); Assert.AreEqual(1, result1.Rows); Assert.AreEqual(1, result1.Columns); var result2 = matrix.GetSubMatrix(1, 2, 2, 1); Assert.AreEqual(2, result2.Rows); Assert.AreEqual(1, result2.Columns); }
public void TestGetSubMatrix() { ObjectMatrix <int> matrix = GetTestMatrix(); ObjectMatrix <int> result = matrix.GetSubMatrix(0, 0, 3, 3); Assert.AreEqual(result.Rows, 3); Assert.AreEqual(result.Columns, 3); for (int i = 0; i < result.Rows; i++) { for (int j = 0; j < result.Columns; j++) { Assert.AreEqual(result[i, j], i + j); } } result = matrix.GetSubMatrix(1, 2, 3, 3); for (int i = 0; i < result.Rows; i++) { for (int j = 0; j < result.Columns; j++) { Assert.AreEqual(result[i, j], i + 1 + j + 2); } } }
public void GetSubMatrixExample() { 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; var result1 = matrix.GetSubMatrix(0, 0, 1, 1); Assert.AreEqual(1, result1.Rows); Assert.AreEqual(1, result1.Columns); var result2 = matrix.GetSubMatrix(1, 2, 2, 1); Assert.AreEqual(2, result2.Rows); Assert.AreEqual(1, result2.Columns); }
public void TestInvalidGetSubMatrix5() { ObjectMatrix <int> matrix = GetTestMatrix(); matrix.GetSubMatrix(0, 0, 16, 6); }
public void TestInvalidGetSubMatrix2() { ObjectMatrix <int> matrix = GetTestMatrix(); matrix.GetSubMatrix(0, -1, 1, 1); }