public void SumExtensionMethod_ComputeSumOfTwoSymetricMatrices() { int[][] testArray = { new[] { 1, 3, 0 }, new[] { 3, 2, 6 }, new[] { 0, 6, 5 } }; var matrix = new SymentricMatrix<int>(testArray); var other = new SymentricMatrix<int>(testArray); var actualResult = matrix.Sum(other, (m, n) => m + n); int[][] expectedArray = { new[] { 2, 6, 0 }, new[] { 6, 4, 12 }, new[] { 0, 12, 10 } }; var expectedResult = new SquareMatrix<int>(expectedArray); for (int i = 0; i < matrix.Order; i++) { for (int j = 0; j < matrix.Order; j++) { Assert.AreEqual(expectedResult[i, j], actualResult[i, j]); } } }
public void SymentricMatrixCtor_InputOrderAsParameter() { var order = 3; var matrix = new SymentricMatrix <int>(order); Assert.AreEqual(order, matrix.Order); }
public void SymentricMatrixCtor_InputArrayAsParameter() { int[] testArray = { 1, 3, 0, 3, 2, 6, 0, 6, 5 }; var matrix = new SymentricMatrix <int>(testArray); int[,] expectedResult = { { 1, 3, 0 }, { 3, 2, 6 }, { 0, 6, 5 } }; CollectionAssert.AreEqual(expectedResult, matrix); }
public void SymentricMatrixCtor_InputJaggedArrayAsParameter() { int[][] testArray = { new[] { 4, 1, 5 }, new[] { 1, 2, 8 }, new[] { 5, 8, 6 } }; var matrix = new SymentricMatrix <int>(testArray); for (int i = 0; i < matrix.Order; i++) { for (int j = 0; j < matrix.Order; j++) { Assert.AreEqual(testArray[i].ElementAt(j), matrix[i, j]); } } }
public void SumExtensionMethod_ComputeSumOfSquareMatrixAndSymetricMatrix() { int[][] squareArray = { new[] { 4, 1, 5 }, new[] { 7, 2, 8 }, new[] { 3, 1, 6 } }; int[][] symetricArray = { new[] { 1, 3, 0 }, new[] { 3, 2, 6 }, new[] { 0, 6, 5 } }; var matrix = new SquareMatrix<int>(squareArray); var other = new SymentricMatrix<int>(symetricArray); var actualResult = matrix.Sum(other, (m, n) => m + n); int[][] expectedArray = { new[] { 5, 4, 5 }, new[] { 10, 4, 14 }, new[] { 3, 7, 11 } }; var expectedResult = new SquareMatrix<int>(expectedArray); for (int i = 0; i < matrix.Order; i++) { for (int j = 0; j < matrix.Order; j++) { Assert.AreEqual(expectedResult[i, j], actualResult[i, j]); } } }
/// <summary> /// Visits the specified matrix. /// </summary> /// <param name="matrix">The matrix.</param> /// <returns>Returns a square matrix</returns> public abstract SquareMatrix <T> Visit(SymentricMatrix <T> matrix);