This commit is contained in:
@@ -6,14 +6,14 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
static constexpr int EXECUTION_COUNT = 10;
|
||||
static constexpr int EXECUTION_COUNT = 1000;
|
||||
static constexpr int KERNEL_CHECKS = 100;
|
||||
static constexpr int MATRIX_MAX_SIZE = 10;
|
||||
static constexpr int MATRIX_MAX_SIZE = 9;
|
||||
|
||||
static const Solver solver;
|
||||
|
||||
static unsigned int GetRandomInt() {
|
||||
return rand() % MATRIX_MAX_SIZE + 1;
|
||||
static int GetRandomInt() {
|
||||
return rand() % 11 - 5;
|
||||
}
|
||||
|
||||
static Matrix GetRandomMatrix(std::size_t a_Raw, std::size_t a_Column) {
|
||||
@@ -28,8 +28,8 @@ static Matrix GetRandomMatrix(std::size_t a_Raw, std::size_t a_Column) {
|
||||
return matrix;
|
||||
}
|
||||
|
||||
static void Test() {
|
||||
Matrix matrix = GetRandomMatrix(GetRandomInt(), GetRandomInt());
|
||||
static bool Test() {
|
||||
Matrix matrix = GetRandomMatrix(rand() % MATRIX_MAX_SIZE + 1, rand() % MATRIX_MAX_SIZE + 1);
|
||||
|
||||
for (std::size_t i = 0; i < matrix.GetRawCount(); i++) {
|
||||
for (std::size_t j = 0; j < matrix.GetColumnCount(); j++) {
|
||||
@@ -57,12 +57,13 @@ static void Test() {
|
||||
Vect kernel2 = solver.Kernel(kernel.GetLinearSystem());
|
||||
|
||||
test_assert(kernel == kernel2);
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
srand(time(0));
|
||||
|
||||
std::vector<std::future<void>> results;
|
||||
std::vector<std::future<bool>> results;
|
||||
|
||||
// appelle la fonction Test() en parallèle
|
||||
for (int i = 0; i < EXECUTION_COUNT; i++) {
|
||||
@@ -70,5 +71,10 @@ int main() {
|
||||
results.push_back(std::move(handle));
|
||||
}
|
||||
|
||||
for (auto& result : results) {
|
||||
if (!result.get())
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "IO.h"
|
||||
#include "Solver.h"
|
||||
@@ -9,18 +9,22 @@
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
const static int EXECUTION_COUNT = 100;
|
||||
static constexpr int MATRIX_MAX_SIZE = 20;
|
||||
const static int EXECUTION_COUNT = 10000;
|
||||
static constexpr int MATRIX_MAX_SIZE = 7;
|
||||
|
||||
static unsigned int GetRandomInt() {
|
||||
static int GetRandomSize() {
|
||||
return rand() % MATRIX_MAX_SIZE + 1;
|
||||
}
|
||||
|
||||
static int GetRandomInt() {
|
||||
return GetRandomSize();
|
||||
}
|
||||
|
||||
static Matrix GetRandomMatrix(std::size_t a_Raw, std::size_t a_Column) {
|
||||
Matrix matrix {a_Raw, a_Column};
|
||||
|
||||
std::generate(matrix.GetLineIterator(0), matrix.GetLineIterator(a_Raw), [](){
|
||||
return GetRandomInt();
|
||||
std::generate(matrix.GetLineIterator(0), matrix.GetLineIterator(a_Raw), []() {
|
||||
return GetRandomInt();
|
||||
});
|
||||
|
||||
return matrix;
|
||||
@@ -33,14 +37,15 @@ 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();
|
||||
test_assert(system * vector == origin);
|
||||
Matrix product = system * vector;
|
||||
test_assert(product == origin);
|
||||
}
|
||||
}
|
||||
|
||||
void RandomRectangular() {
|
||||
for (int i = 0; i < EXECUTION_COUNT; i++) {
|
||||
|
||||
Matrix system = GetRandomMatrix(GetRandomInt(), GetRandomInt());
|
||||
Matrix system = GetRandomMatrix(GetRandomSize(), GetRandomSize());
|
||||
|
||||
Matrix origin = GetRandomMatrix(system.GetRawCount(), 1);
|
||||
|
||||
@@ -76,6 +81,7 @@ void TestKernelImage() {
|
||||
}
|
||||
|
||||
int main() {
|
||||
srand(time(0));
|
||||
TestKernelImage();
|
||||
RandomRectangular();
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user