static void Main(string[] args) { int[,] array = new int[3, 3] { { 1, 4, 5 }, { 52, 34, 3 }, { 6, 734, 8 } }; SquareMatrix<int> m = new SquareMatrix<int>(array); Console.WriteLine(m.ToString()); m.Change += IsChange; m[1, 2] = 100; Thread.Sleep(1000); Console.WriteLine(); Console.WriteLine(m.ToString()); int[,] arrayM = new int[3, 3] { { 1, 1, 1 }, { 1, 1, 1 }, { 1, 1, 1 } }; Matrix<int> firstM = new SquareMatrix<int>(array); Console.WriteLine(firstM.ToString()); Matrix<int> secondM = new SymmetricMatrix<int>(arrayM); Console.WriteLine(secondM.ToString()); var result = WorkWithMatrix.Add( firstM,secondM, (a, b) => a + b); System.Console.WriteLine(result.ToString()); int [,] arD1 = new int[3,3]{{1,0,0},{0,1,0},{0,0,1}}; int[,] arD2 = new int[3, 3] { { 2, 0, 0 }, { 0, 2, 0 }, { 0, 0, 2 } }; var fisrtDM = new DiagonalMatrix<int>(arD1); Console.WriteLine(fisrtDM.ToString()); var secondDM = new DiagonalMatrix<int>(arD2); Console.WriteLine(secondDM.ToString()); result = WorkWithMatrix.Add(fisrtDM, secondDM, (a, b) => a + b); System.Console.WriteLine(result.ToString()); Console.ReadKey(); }
public void SymmetricMatrixCtor_MormalSize() { SymmetricMatrix <int> matr = new SymmetricMatrix <int>(3); string res = "0 0 0 \n0 0 0 \n0 0 0 \n"; Assert.AreEqual(res, matr.ToString()); }
public void SymmetricMatrixCtor_MormalSymmetricMatrix() { int[,] matr = new int[3, 3] { { 0, 1, 2 }, { 1, 0, 3 }, { 2, 3, 0 } }; SymmetricMatrix <int> symmatr = new SymmetricMatrix <int>(matr); string res = "0 1 2 \n1 0 3 \n2 3 0 \n"; Assert.AreEqual(res, symmatr.ToString()); }
static void Main(string[] args) { int[,] squareArray = { { 1, 2, 3 }, { 1, 2, 9 }, { 2, 4, 1 } }; int[,] diagonalArray = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; int[,] semetricalArray = { { 1, 3, 5 }, { 3, 2, 4 }, { 5, 4, 6 } }; try { var squareMatrix = new SquareMatrix<int>(squareArray); var diagonalMatrix = new DiagonalMatrix<int>(diagonalArray); var semetricalMatrix = new SymmetricMatrix<int>(semetricalArray); Console.WriteLine(diagonalMatrix.ToString()); Console.WriteLine(semetricalMatrix.ToString()); var resultSum=semetricalMatrix.SumMatrix(diagonalMatrix, (a, b) => a + b); Console.WriteLine(resultSum.ToString()); diagonalMatrix.Changes+= Change; diagonalMatrix[2, 2] = 123; diagonalMatrix[2, 2] = 0; } catch (ArgumentNullException e) { Console.WriteLine(e.Message); } catch (ArgumentException e) { Console.WriteLine(e.Message); } catch (IndexOutOfRangeException e) { Console.WriteLine(e.Message); } finally { Console.ReadKey(); } }