public static MatrixClass <T> operator *(MatrixClass <T> matrix1, MatrixClass <T> matrix2) { MatrixClass <T> newMatrix = new MatrixClass <T>(matrix1.matrix.GetLength(0), matrix1.matrix.GetLength(1)); if (matrix1.matrix.GetLength(1) == matrix2.matrix.GetLength(0)) { for (int i = 0; i < newMatrix.matrix.GetLength(0); i++) { for (int j = 0; j < newMatrix.matrix.GetLength(1); j++) { newMatrix[i, j] = (dynamic)0; for (int k = 0; k < matrix1.matrix.GetLength(1); k++) { newMatrix[i, j] = newMatrix[i, j] + (dynamic)matrix1[i, k] * matrix2[k, j]; } } } } else { throw new Exception("Impossible operation"); } return(newMatrix); }
static void Main(string[] args) { Console.Write("enter the side for matrix: "); int side = MustIntNumber(); int[,] Matrix1 = MatrixClass.CreateMatrix(side); MatrixClass.ShowMatrix(Matrix1); Console.WriteLine(MatrixClass.FindMin(Matrix1)); MatrixClass matrixOb = new MatrixClass(); Console.WriteLine(matrixOb.DiagonalDifference(Matrix1)); }
//public -> private private void Gen() { row1 = Convert.ToInt32(firstMatrixRows.Text); row2 = Convert.ToInt32(seckondMatrixRows.Text); col1 = Convert.ToInt32(firstMatrixColumns.Text); col2 = Convert.ToInt32(secondMatrixColumns.Text); A = new MatrixClass <int>(row1, col1); A.Generate(generate, row1, col1); txtMatrixA.Text = A.Print(); B = new MatrixClass <int>(row2, col2); B.Generate(generate, row2, col2); txtMatrixB.Text = B.Print(); }
public static MatrixClass <T> operator -(MatrixClass <T> matrix1, MatrixClass <T> matrix2) { if (matrix1.matrix.GetLength(0) != matrix1.matrix.GetLength(0) || matrix1.matrix.GetLength(1) != matrix1.matrix.GetLength(1)) { throw new Exception("Impossible operation"); } MatrixClass <T> newMatrix = new MatrixClass <T>(matrix1.matrix.GetLength(0), matrix1.matrix.GetLength(0)); for (int i = 0; i < matrix1.matrix.GetLength(0); i++) { for (int j = 0; j < matrix1.matrix.GetLength(1); j++) { newMatrix[i, j] = (dynamic)matrix1[i, j] - matrix2[i, j]; } } return(newMatrix); }
private void MyltiplyMatrix() { var matrix = new MatrixClass(M,N,L,IsDouble, ThreadCount); matrix.MyltipyMatrix(); LogString += "Затраченное время: "+ matrix.Time + " мс\n"; }
public void Sum() { S = A + B; txtMatrixS.Text = S.Print(); }
public void Multiplication() { S = A * B; txtMatrixS.Text = S.Print(); }