solver rework + refactor
This commit is contained in:
@@ -34,12 +34,12 @@ static void SimplifyLine(Matrix& mat, std::size_t line, std::size_t pivot_line,
|
||||
}
|
||||
}
|
||||
|
||||
void GaussJordan(Matrix& mat, bool reduite, bool normalise) {
|
||||
void GaussJordan(Matrix& a_Matrix, bool a_Reduite, bool a_Normalise) {
|
||||
int indice_ligne_pivot = -1;
|
||||
|
||||
for (std::size_t j = 0; j < mat.GetColumnCount(); j++) {
|
||||
for (std::size_t j = 0; j < a_Matrix.GetColumnCount(); j++) {
|
||||
|
||||
int indice_ligne_pivot_trouve = FirstNotNullElementIndexOnColumn(mat, j, indice_ligne_pivot + 1);
|
||||
int indice_ligne_pivot_trouve = FirstNotNullElementIndexOnColumn(a_Matrix, j, indice_ligne_pivot + 1);
|
||||
|
||||
if (indice_ligne_pivot_trouve < 0) // colonne de 0
|
||||
continue; // on regarde la prochaine colonne
|
||||
@@ -47,20 +47,20 @@ void GaussJordan(Matrix& mat, bool reduite, bool normalise) {
|
||||
indice_ligne_pivot++;
|
||||
|
||||
if (indice_ligne_pivot_trouve != indice_ligne_pivot) {
|
||||
SwapLines(mat, indice_ligne_pivot_trouve, indice_ligne_pivot);
|
||||
SwapLines(a_Matrix, indice_ligne_pivot_trouve, indice_ligne_pivot);
|
||||
}
|
||||
|
||||
Matrix::Element pivot = mat.at(indice_ligne_pivot, j);
|
||||
Matrix::Element pivot = a_Matrix.at(indice_ligne_pivot, j);
|
||||
|
||||
if (normalise) {
|
||||
DivideLine(mat, indice_ligne_pivot, pivot);
|
||||
if (a_Normalise) {
|
||||
DivideLine(a_Matrix, indice_ligne_pivot, pivot);
|
||||
}
|
||||
|
||||
// On simplifie les autres lignes
|
||||
for (std::size_t i = (reduite ? 0 : j); i < mat.GetRawCount(); i++) {
|
||||
for (std::size_t i = (a_Reduite ? 0 : j); i < a_Matrix.GetRawCount(); i++) {
|
||||
// Pour les lignes autre que la ligne pivot
|
||||
if (i != static_cast<std::size_t>(indice_ligne_pivot)) {
|
||||
SimplifyLine(mat, i, indice_ligne_pivot, j);
|
||||
SimplifyLine(a_Matrix, i, indice_ligne_pivot, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user