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

@@ -2,6 +2,12 @@
#include "Matrix.h"
#include "test_assert.h"
#include <chrono>
#include <iostream>
static constexpr int MATRIX_MAX_SIZE = 300;
static constexpr int EXECUTION_COUNT = 1;
struct Test {
Matrix mat;
Matrix res;
@@ -30,6 +36,22 @@ static const std::vector<Test> TEST_MATRICES = {
}}}
};
static unsigned int GetRandomInt() {
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};
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();
}
}
return matrix;
}
void test() {
for (Test test : TEST_MATRICES) {
Gauss::GaussJordan(test.mat, true, true);
@@ -37,7 +59,26 @@ void test() {
}
}
void gaussTest() {
auto start = std::chrono::system_clock::now();
for (int i = 0; i < EXECUTION_COUNT; i++) {
Matrix mat = GetRandomMatrix(500, 500);
Gauss::GaussJordan(mat, false, false);
}
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "\tgauss jordan elapsed time : " << elapsed_seconds.count() << "s" << std::endl;
}
void speedTest() {
gaussTest();
// gaussColumnTest();
}
int main(int argc, char** argv) {
test();
speedTest();
return 0;
}