argtum / OOP

Задания по объектно-ориентированному программированию
0 stars 0 forks source link

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

Open alexey-malov opened 5 years ago

alexey-malov commented 5 years ago
1>Start testing
1>Comparing files C:\USERS\ALEXEY~1.ISP\APPDATA\LOCAL\TEMP\output.txt and 3X3-MATRIX-OUT.TXT
1>FC: no differences encountered
1>
1>Comparing files C:\USERS\ALEXEY~1.ISP\APPDATA\LOCAL\TEMP\output.txt and EXPECTED-OUTPUT-WHEN-NUMBER-OF-ARGUMENTS-IS-NOT-2.TXT
1>FC: no differences encountered
1>
1>Comparing files C:\USERS\ALEXEY~1.ISP\APPDATA\LOCAL\TEMP\output.txt and EXPECTED-OUTPUT-WHEN-NUMBER-OF-ARGUMENTS-IS-NOT-2.TXT
1>FC: no differences encountered
1>
1>Comparing files C:\USERS\ALEXEY~1.ISP\APPDATA\LOCAL\TEMP\output.txt and EXPECTED-OUTPUT-WHEN-ONE-OF-ARGUMENTS-IS-MISSING.TXT
1>FC: no differences encountered
1>
1>Comparing files C:\USERS\ALEXEY~1.ISP\APPDATA\LOCAL\TEMP\output.txt and 4X4-MATRIX-OUT.TXT
1>FC: no differences encountered
1>
1>Comparing files C:\USERS\ALEXEY~1.ISP\APPDATA\LOCAL\TEMP\output.txt and 2X3-MATRIX-OUT.TXT
1>FC: no differences encountered
1>
1>Comparing files C:\USERS\ALEXEY~1.ISP\APPDATA\LOCAL\TEMP\output.txt and 3X2-MATRIX-OUT.TXT
1>FC: no differences encountered
1>
1>Comparing files C:\USERS\ALEXEY~1.ISP\APPDATA\LOCAL\TEMP\output.txt and EXPECTED-OUTPUT-WHEN-MATRIX-DETERMINATE-IS-0.TXT
1>FC: no differences encountered
1>
1>Comparing files C:\USERS\ALEXEY~1.ISP\APPDATA\LOCAL\TEMP\output.txt and EMPTY-OUT.TXT
1>FC: cannot open EMPTY-OUT.TXT - No such file or folder
1>
1>Program testing failed
alexey-malov commented 5 years ago

Оригинал:

1   0   -2
0   1   3
0   0   1

Вывод программы

1.000     0.000     0.000
-0.000    1.000     0.000
2.000     -3.000    1.000

Если их перемножить, не получится единичная матрица

alexey-malov commented 5 years ago
alexey-malov commented 5 years ago
void readMatrix(string fileName, Matrix& matrix, Status& status)
void readMatrix(string fileName, Matrix& matrix, Status& status)
{
    ifstream inputFile(fileName);
    string line;
    int row = 0;
    int col;

    if (!inputFile.is_open())
    {
        status = Status::InvalidInputFile;
    }
    else
    {
        while (getline(inputFile, line) && status == Status::Ok)
alexey-malov commented 5 years ago
alexey-malov commented 5 years ago
void invertMatrix(Matrix& inputMatrix, Matrix& resultMatrix, Status& status)
{
    double determinant = 0;

    if (isDeterminantNotNull(inputMatrix, determinant))
alexey-malov commented 5 years ago
            for (int row = 0; row < MATRIX_SIZE; row++)
            {
                resultMatrix[row][col] = ((inputMatrix[(row + 1) % MATRIX_SIZE][(col + 1) % MATRIX_SIZE] * inputMatrix[(row + 2) % MATRIX_SIZE][(col + 2) % MATRIX_SIZE]) - (inputMatrix[(row + 1) % MATRIX_SIZE][(col + 2) % MATRIX_SIZE] * inputMatrix[(row + 2) % MATRIX_SIZE][(col + 1) % MATRIX_SIZE])) / determinant;
            }
alexey-malov commented 5 years ago
void invertMatrix(Matrix& inputMatrix, Matrix& resultMatrix, Status& status)
{
    double determinant = 0;

    if (isDeterminantNotNull(inputMatrix, determinant))
    {
        ...
    }
    else
    {
        status = Status::CanNotInvertMatrix;
    }
}
alexey-malov commented 5 years ago