Open alexey-malov opened 7 years ago
void GetMatrixFromStream(ifstream& matrixFileStream, double(&sourceMatrix)[3][3]);
void GetInvertMatrix(double(&sourceMatrix)[3][3], double(&invertMatrix)[3][3]);
void GetMinorMatrix(double(&sourceMatrix)[3][3], double(&minorMatrix)[3][3]);
void TransposeMatrix(double(&matrixToTranspose)[3][3]);
void InvertMatrix(double(&matrixToInvert)[3][3], double determinant);
void WriteMatrixToConsole(double(&matrix)[3][3]);
typedef double matrix[3][3];
void InvertMatrix(double(&matrixToTranspose)[3][3], double determinant)
{
double revertDeterminant = 1 / determinant;
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 3; ++j)
{
matrixToTranspose[i][j] *= revertDeterminant;
}
}
}
bool IsOnlyDigitString(const std::string &str)
{
return all_of(str.begin(), str.end(), [](char i) { return isdigit(i) || i == '-' || i == '.'; });
}
if (abs(determinant) <= DBL_EPSILON) // сравнение с нулем
{
return false;
}
if (abs(x - y) <= DBL_EPSILON) // сравнение с другим числом
{
return false;
}
double (& sm)[3][3] = sourceMatrix;
double determinant = (sm[0][0] * sm[1][1] * sm[2][2]) + (sm[0][1] * sm[1][2] * sm[2][0]) + (sm[0][2] * sm[1][0] * sm[2][1]) -
(sm[0][2] * sm[1][1] * sm[2][0]) - (sm[0][0] * sm[2][1] * sm[1][2]) - (sm[1][0] * sm[0][1] * sm[2][2]);
[x] нахождение определителя выделить в отдельную функцию
[ ] разбить по строкам для лучшей читаемости