caca
All checks were successful
Linux arm64 / Build (push) Successful in 41m33s

This commit is contained in:
2024-05-14 19:00:04 +02:00
parent a135df2e96
commit 8c004b64ed
13 changed files with 2512 additions and 26 deletions

View File

@@ -16,6 +16,16 @@ static int GetRandomInt() {
return rand() % 11 - 5;
}
#define print_time(i) \
end = std::chrono::system_clock::now(); \
elapsed_seconds = end - start; \
std::cout << "elapsed time " << i << " : " << elapsed_seconds.count() << "s" << std::endl; \
start = std::chrono::system_clock::now()
static unsigned int GetRandomSize() {
return rand() % MATRIX_MAX_SIZE + 1;
}
static Matrix GetRandomMatrix(std::size_t a_Raw, std::size_t a_Column) {
Matrix matrix {a_Raw, a_Column};
@@ -29,34 +39,57 @@ static Matrix GetRandomMatrix(std::size_t a_Raw, std::size_t a_Column) {
}
static bool Test() {
Matrix matrix = GetRandomMatrix(rand() % MATRIX_MAX_SIZE + 1, rand() % MATRIX_MAX_SIZE + 1);
auto start = std::chrono::system_clock::now();
auto begin = start;
auto end = start;
std::chrono::duration<double> elapsed_seconds = end - start;
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::cout << "Begin\n";
Matrix matrix = GetRandomMatrix(GetRandomSize(), GetRandomSize());
print_time(1);
Matrix copy = matrix;
Vect kernel = solver.Kernel(std::move(copy));
print_time(2);
Matrix nullVector {matrix.GetRawCount(), 1};
nullVector.Fill(0.0);
for (std::size_t i = 0; i < kernel.GetCardinal(); i++) {
test_assert(matrix * kernel.GetVector(i) == nullVector);
Matrix result = matrix * kernel.GetVector(i);
if(!(result == nullVector)) {
test_assert(false);
}
}
print_time(3);
for (std::size_t i = 0; i < KERNEL_CHECKS; i++) {
Matrix vector = GetRandomMatrix(kernel.GetDimension(), 1);
test_assert(kernel.IsElementOf(vector) == (matrix * vector == nullVector));
}
Vect kernel2 = solver.Kernel(kernel.GetLinearSystem());
print_time(4);
Matrix linearSystem = kernel.GetLinearSystem();
print_time(5);
Vect kernel2 = solver.Kernel(std::move(linearSystem));
test_assert(kernel == kernel2);
print_time(6);
elapsed_seconds = end - begin;
std::cout << "final elapsed time: " << elapsed_seconds.count() << "s" << std::endl;
std::cout << "End\n";
return true;
}
@@ -69,6 +102,7 @@ int main() {
for (int i = 0; i < EXECUTION_COUNT; i++) {
auto handle = std::async(std::launch::async, &Test);
results.push_back(std::move(handle));
// Test();
}
for (auto& result : results) {