51 lines
1.0 KiB
C++
51 lines
1.0 KiB
C++
#include <cassert>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
|
|
#include "IO.h"
|
|
#include "Solver.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;
|
|
|
|
assert(solver.Image(mat) == image);
|
|
assert(solver.Kernel(mat) == noyau);
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
TestKernelImage();
|
|
TestRectangular();
|
|
return 0;
|
|
} |