This commit is contained in:
@@ -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