puzatkin-ivan / oop

Лабораторные работы по ООП
0 stars 0 forks source link

Замечания по Invert #2

Open alexey-malov opened 6 years ago

alexey-malov commented 6 years ago

https://github.com/puzatkin-ivan/oop/blob/66aaec9d0bf07b016e8d45b4291785d9497db943/lab1/invert/main.cpp#L25-L39

alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
double GetMatrixDeterminant2x2(const Matrix3x3 & matrix, size_t strikeoutRow, size_t strikeoutColumn)
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
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;
}
alexey-malov commented 6 years ago
bool CalculateInverseMatrix(const Matrix3x3 & matrix, Matrix3x3 & inverseMatrix)
{
    auto matrixDeterminant = GetMatrixDeterminant3x3(matrix);

    if (matrixDeterminant == 0)
    {
        std::cout << "Determinant = 0" << std::endl;
        return false;
    }
alexey-malov commented 6 years ago
    for (size_t i = 0; i < MAX_SIZE_MATRIX; ++i)
    {
        auto& row = inverseMatrix[i];