#include #include #include #include "IO.h" #include "Solver.h" #include "test_assert.h" namespace fs = std::filesystem; void TestRectangular() { Matrix mat2 = {2, 4, { 1, 1, 1, 1, 1, -1, -1, 2 }}; VectAffine aff {Matrix::ColumnVector({0, -1, 1}), Matrix::ColumnVector({3.0 / 2.0, 0, -1.0 / 2.0})}; Solver solver; std::cout << solver.RectangularSystem(std::move(mat2), Matrix::ColumnVector({1, 2})).GetLinearSystem() << std::endl; std::cout << aff.GetLinearSystem() << std::endl; } void TestKernelImage() { std::string path = "test"; for (const auto& entry : fs::directory_iterator(path)) { std::string fileName = entry.path().string(); std::cout << "Opening " << fileName << " ...\n"; std::ifstream in {fileName}; Matrix mat, imageMat, noyauMat; in >> mat >> imageMat >> noyauMat; Vect image {imageMat}; Vect noyau {noyauMat}; Solver solver; Matrix copy = mat; test_assert(solver.Image(std::move(copy)) == image); test_assert(solver.Kernel(std::move(mat)) == noyau); } } int main() { TestKernelImage(); TestRectangular(); return 0; }