fix gauss

This commit is contained in:
2024-02-08 11:30:54 +01:00
parent 7a02a9d1cf
commit 0ed89e2827
2 changed files with 11 additions and 5 deletions

View File

@@ -147,7 +147,7 @@ void Matrix::GaussNonJordan(bool reduite) {
// std::cout << "l'indice du maximum est : " << indice_ligne_maximum << "\n\n";
// Si A[k,j]≠0 alors (A[k,j] désigne la valeur de la ligne k et de la colonne j)
if (at(indice_ligne_maximum, j) != 0) {
if (!IsEqualZero(at(indice_ligne_maximum, j))) {
r++;
// PrintDebug();
@@ -179,10 +179,11 @@ void Matrix::GaussNonJordan(bool reduite) {
}
void Matrix::GaussJordan(bool reduite) {
GaussNonJordan(reduite);
for (std::size_t i = 0; i < m_Lignes; i++) {
int k = -1;
for (std::size_t j = 0; j < m_Colonnes; j++) {
if (at(i, j) != 0) {
if (!IsEqualZero(at(i, j))) {
k = j;
break;
}

View File

@@ -2,16 +2,17 @@
#include <iostream>
void test() {
Matrix mat{"matrice5x5.mat"};
Matrix mat{"matrice4x4.mat"};
mat.Print();
// mat.Save("matrice3x3.mat");
std::cout << "sdfdjiofoseifheoiefhoig\n";
mat.Print();
mat = {"matrice5x5.mat"};
//mat = {"matrice4x4.mat"};
mat.GaussJordan(false);
std::cout << "\nResultat :\n";
mat.Print();
mat.Transpose();
std::cout << "<<\nTransposée:\n";
mat.Print();
// mat.Save("matrice4x4echelonne.mat");
}
@@ -30,10 +31,14 @@ void prompt() {
mat.Insert();
mat.Print();
mat.GaussJordan(true);
mat.Print();
}
int main(int argc, char** argv) {
// test();
test();
prompt();
return 0;
}