fix react system
This commit is contained in:
@@ -47,7 +47,7 @@ VectAffine Solver::RectangularSystem(Matrix&& a_MatrixA, const Matrix& a_VectorB
|
|||||||
|
|
||||||
// on rajoute des 0 si il faut
|
// on rajoute des 0 si il faut
|
||||||
|
|
||||||
Matrix fullOrigin {mat.GetColumnCount() - 1, 1};
|
Matrix fullOrigin {mat.GetColumnCount(), 1};
|
||||||
for (std::size_t i = 0; i < mat.GetRawCount(); i++) {
|
for (std::size_t i = 0; i < mat.GetRawCount(); i++) {
|
||||||
int pivot_index = FirstNotNullElementIndexOnLine(mat, i);
|
int pivot_index = FirstNotNullElementIndexOnLine(mat, i);
|
||||||
if(pivot_index >= 0){
|
if(pivot_index >= 0){
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "IO.h"
|
#include "IO.h"
|
||||||
#include "Solver.h"
|
#include "Solver.h"
|
||||||
@@ -9,7 +10,7 @@
|
|||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
const static int EXECUTION_COUNT = 100;
|
const static int EXECUTION_COUNT = 100;
|
||||||
static constexpr int MATRIX_MAX_SIZE = 5;
|
static constexpr int MATRIX_MAX_SIZE = 20;
|
||||||
|
|
||||||
static unsigned int GetRandomInt() {
|
static unsigned int GetRandomInt() {
|
||||||
return rand() % MATRIX_MAX_SIZE + 1;
|
return rand() % MATRIX_MAX_SIZE + 1;
|
||||||
@@ -18,11 +19,9 @@ static unsigned int GetRandomInt() {
|
|||||||
static Matrix GetRandomMatrix(std::size_t a_Raw, std::size_t a_Column) {
|
static Matrix GetRandomMatrix(std::size_t a_Raw, std::size_t a_Column) {
|
||||||
Matrix matrix {a_Raw, a_Column};
|
Matrix matrix {a_Raw, a_Column};
|
||||||
|
|
||||||
for (std::size_t i = 0; i < matrix.GetRawCount(); i++) {
|
std::generate(matrix.GetLineIterator(0), matrix.GetLineIterator(a_Raw), [](){
|
||||||
for (std::size_t j = 0; j < matrix.GetColumnCount(); j++) {
|
return GetRandomInt();
|
||||||
matrix.at(i, j) = GetRandomInt();
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
@@ -34,10 +33,7 @@ void TestRectangular(const Matrix& system, const Matrix& origin) {
|
|||||||
|
|
||||||
for (std::size_t i = 0; i < solution.GetBase().GetCardinal(); i++) {
|
for (std::size_t i = 0; i < solution.GetBase().GetCardinal(); i++) {
|
||||||
Matrix vector = solution.GetBase().GetVector(i) + solution.GetOrigin();
|
Matrix vector = solution.GetBase().GetVector(i) + solution.GetOrigin();
|
||||||
for (std::size_t j = 0; j < system.GetRawCount(); j++) {
|
test_assert(system * vector == origin);
|
||||||
Matrix line = system.SubMatrix(j, 0, 1, system.GetColumnCount());
|
|
||||||
test_assert(line * vector == origin.SubMatrix(j, 0, 1, 1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,13 +42,8 @@ void RandomRectangular() {
|
|||||||
|
|
||||||
Matrix system = GetRandomMatrix(GetRandomInt(), GetRandomInt());
|
Matrix system = GetRandomMatrix(GetRandomInt(), GetRandomInt());
|
||||||
|
|
||||||
if (system.GetColumnCount() == system.GetRawCount())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Matrix origin = GetRandomMatrix(system.GetRawCount(), 1);
|
Matrix origin = GetRandomMatrix(system.GetRawCount(), 1);
|
||||||
|
|
||||||
std::cout << "PIPI\n";
|
|
||||||
|
|
||||||
TestRectangular(system, origin);
|
TestRectangular(system, origin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user