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_solver.cpp
Persson-dev f5a282c455
All checks were successful
Linux arm64 / Build (push) Successful in 6m40s
allow tests in release mode
2024-05-04 12:42:26 +02:00

51 lines
1.0 KiB
C++

#include <filesystem>
#include <fstream>
#include <iostream>
#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(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;
test_assert(solver.Image(mat) == image);
test_assert(solver.Kernel(mat) == noyau);
}
}
int main() {
TestKernelImage();
TestRectangular();
return 0;
}