//------------------------------------------------------------------------------------------ //Поэлемнетное деление public static RealMatrix GetElementwiseDivision( RealMatrix dividendMatrix, RealMatrix dividerMatrix ) { bool equalSize = RealMatrix.IsEqualMatricesSize(dividendMatrix, dividerMatrix); if (!equalSize) { throw new MatrixException(); } int rowCount = dividendMatrix.rowCount; int columnCount = dividerMatrix.columnCount; RealMatrix newMatrix = new RealMatrix(rowCount, columnCount); for (int row = 0; row < rowCount; row++) { for (int column = 0; column < columnCount; column++) { double dividend = dividendMatrix[row, column]; double divider = dividerMatrix[row, column]; double value = dividend / divider; newMatrix[row, column] = value; } } return(newMatrix); }
//------------------------------------------------------------------------------------------ //Разность матриц public static RealMatrix operator -(RealMatrix matrixOne, RealMatrix matrixTwo) { int rowCountMatrixOne = matrixOne.rowCount; int rowCountMatrixTwo = matrixTwo.rowCount; int columnCountMatrixOne = matrixOne.columnCount; int columnCountMatrixTwo = matrixTwo.columnCount; bool sizeEquality = RealMatrix.IsEqualMatricesSize(matrixOne, matrixTwo); if (!sizeEquality) { throw new MatrixException(); } RealMatrix resultMatrix = new RealMatrix(rowCountMatrixOne, columnCountMatrixOne); for (int row = 0; row < resultMatrix.rowCount; row++) { for (int column = 0; column < resultMatrix.columnCount; column++) { resultMatrix[row, column] = matrixOne[row, column] - matrixTwo[row, column]; } } return(resultMatrix); }