This repository has been archived on 2025-02-26. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Pivot/test/test_random_kernel.cpp
Persson-dev 13c9bc40db
All checks were successful
Linux arm64 / Build (push) Successful in 1m1s
added random kernel tests
2024-03-06 22:53:07 +01:00

44 lines
908 B
C++

#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;
}