Open alexey-malov opened 6 years ago
using Matrix3x3 = std::array<std::array<double, 3>, 3>;
double GetMatrixDeterminant2x2(const Matrix3x3 & matrix, size_t strikeoutRow, size_t strikeoutColumn)
double GetMatrixDeterminant3x3(const Matrix3x3 & matrix)
{
double determinant = 0;
size_t column = 0;
for (size_t index = 0; index < matrix.size(); ++index)
{
auto sign = std::pow(-1, index);
determinant += sign * matrix[0][index] * GetMatrixDeterminant2x2(matrix, 0, index);
}
return determinant;
}
bool CalculateInverseMatrix(const Matrix3x3 & matrix, Matrix3x3 & inverseMatrix)
{
auto matrixDeterminant = GetMatrixDeterminant3x3(matrix);
if (matrixDeterminant == 0)
{
std::cout << "Determinant = 0" << std::endl;
return false;
}
for (size_t i = 0; i < MAX_SIZE_MATRIX; ++i)
{
auto& row = inverseMatrix[i];
https://github.com/puzatkin-ivan/oop/blob/66aaec9d0bf07b016e8d45b4291785d9497db943/lab1/invert/main.cpp#L25-L39