private void reverseButton_Click(object sender, EventArgs e) { matrix1 = new rectMatrix(Convert.ToInt32(heighMatrixFirst_textBox.Text), Convert.ToInt32(weightMatrixFirst_textBox.Text)); matrix1 = ReadMatrix(matrix1.heigh, matrix1.weigth, matrixElementList1); matrix2 = new rectMatrix(matrix1.heigh - 1, matrix1.weigth - 1); rectMatrix.getMatrixWithoutRowAndCol(matrix1.matrixArr, matrix1.heigh, 1, 1, ref matrix2); //AutoFilling(matrix2.heigh.ToString(), matrix2.weigth.ToString(), matrix2, panelOfElements2, ref matrixElementList2); //ShowMatrixOnForm(matrix2,matrixElementList2); int det = rectMatrix.matrixDet(matrix1.matrixArr, matrix1.heigh); rectMatrix reverseMatrix = rectMatrix.MatrixTranspOperation(matrix1); double[,] reverseArr = new double[reverseMatrix.heigh, reverseMatrix.weigth]; rectMatrix.multScalar(rectMatrix.ToDoubleConverter(reverseMatrix.matrixArr, reverseMatrix.heigh, reverseMatrix.weigth), reverseMatrix.heigh, reverseMatrix.weigth, 1 / det); AutoFilling(reverseMatrix.heigh.ToString(), reverseMatrix.weigth.ToString(), reverseMatrix, panelOfElements2, ref matrixElementList2); ShowMatrixOnForm(reverseArr, reverseMatrix.heigh, reverseMatrix.weigth, matrixElementList2); MessageBox.Show(reverseMatrix.ToString()); detTextBox.Text = det.ToString(); rectMatrix minorsMatr = rectMatrix.MatrixTranspOperation(rectMatrix.getMinorsMatrix(matrix1)); reverseArr = rectMatrix.multScalar(rectMatrix.ToDoubleConverter(minorsMatr.matrixArr, minorsMatr.heigh, minorsMatr.weigth), minorsMatr.heigh, minorsMatr.weigth, 1 / det); ShowMatrixOnForm(reverseArr, reverseMatrix.heigh, reverseMatrix.weigth, matrixElementList2); //MessageBox.Show(); }
static public rectMatrix getMinorsMatrix(rectMatrix matrix) { rectMatrix outMatrix = new rectMatrix(matrix.heigh, matrix.weigth); rectMatrix minor = new rectMatrix(matrix.heigh - 1, matrix.weigth - 1); int determinator = 0; for (int i = 0; i < matrix.heigh; i++) { for (int j = 0; j < matrix.weigth; j++) { rectMatrix.getMatrixWithoutRowAndCol(matrix.matrixArr, matrix.heigh, i, j, ref minor); MessageBox.Show(minor.ToString()); determinator = rectMatrix.matrixDet(minor.matrixArr, matrix.heigh - 1); MessageBox.Show($"{determinator}"); outMatrix.matrixArr[i, j] = determinator; } } return(outMatrix); }