This commit is contained in:
43
test/test_random_kernel.cpp
Normal file
43
test/test_random_kernel.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "Solver.h"
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
static constexpr int EXECUTION_COUNT = 100;
|
||||
static constexpr int MATRIX_MAX_SIZE = 100;
|
||||
|
||||
static const Solver solver;
|
||||
|
||||
static unsigned int GetRandomInt() {
|
||||
return rand() % MATRIX_MAX_SIZE + 1;
|
||||
}
|
||||
|
||||
static void Test() {
|
||||
Matrix matrix {GetRandomInt(), GetRandomInt()};
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Vect vect1 = solver.Kernel(matrix);
|
||||
Vect vect2 = solver.Kernel(vect1.GetLinearSystem());
|
||||
|
||||
assert(vect1 == vect2);
|
||||
}
|
||||
|
||||
int main() {
|
||||
srand(time(0));
|
||||
|
||||
std::vector<std::future<void>> results;
|
||||
|
||||
for (int i = 0; i < EXECUTION_COUNT; i++) {
|
||||
auto handle = std::async(std::launch::async, &Test);
|
||||
results.push_back(std::move(handle));
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user