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
|
||||
|
||||
Matrix fullOrigin {mat.GetColumnCount() - 1, 1};
|
||||
Matrix fullOrigin {mat.GetColumnCount(), 1};
|
||||
for (std::size_t i = 0; i < mat.GetRawCount(); i++) {
|
||||
int pivot_index = FirstNotNullElementIndexOnLine(mat, i);
|
||||
if(pivot_index >= 0){
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "IO.h"
|
||||
#include "Solver.h"
|
||||
@@ -9,7 +10,7 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
const static int EXECUTION_COUNT = 100;
|
||||
static constexpr int MATRIX_MAX_SIZE = 5;
|
||||
static constexpr int MATRIX_MAX_SIZE = 20;
|
||||
|
||||
static unsigned int GetRandomInt() {
|
||||
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) {
|
||||
Matrix matrix {a_Raw, a_Column};
|
||||
|
||||
for (std::size_t i = 0; i < matrix.GetRawCount(); i++) {
|
||||
for (std::size_t j = 0; j < matrix.GetColumnCount(); j++) {
|
||||
matrix.at(i, j) = GetRandomInt();
|
||||
}
|
||||
}
|
||||
std::generate(matrix.GetLineIterator(0), matrix.GetLineIterator(a_Raw), [](){
|
||||
return GetRandomInt();
|
||||
});
|
||||
|
||||
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++) {
|
||||
Matrix vector = solution.GetBase().GetVector(i) + solution.GetOrigin();
|
||||
for (std::size_t j = 0; j < system.GetRawCount(); j++) {
|
||||
Matrix line = system.SubMatrix(j, 0, 1, system.GetColumnCount());
|
||||
test_assert(line * vector == origin.SubMatrix(j, 0, 1, 1));
|
||||
}
|
||||
test_assert(system * vector == origin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,13 +42,8 @@ void RandomRectangular() {
|
||||
|
||||
Matrix system = GetRandomMatrix(GetRandomInt(), GetRandomInt());
|
||||
|
||||
if (system.GetColumnCount() == system.GetRawCount())
|
||||
continue;
|
||||
|
||||
Matrix origin = GetRandomMatrix(system.GetRawCount(), 1);
|
||||
|
||||
std::cout << "PIPI\n";
|
||||
|
||||
TestRectangular(system, origin);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user