Compare commits
3 Commits
88cc529009
...
efd0a88868
| Author | SHA1 | Date | |
|---|---|---|---|
| efd0a88868 | |||
| 54798d0ff2 | |||
| 99467048e2 |
@@ -25,6 +25,18 @@ Vect Solver::Noyau() const {
|
||||
result.GetColumnCount() - origine_colonne)};
|
||||
}
|
||||
|
||||
VectAffine Solver::SystemeTriangulaire() const {
|
||||
Matrix mat = m_Matrix;
|
||||
mat.GaussJordan(true);
|
||||
|
||||
Solver solver{mat.SubMatrix(0, 0, mat.GetRawCount(), mat.GetColumnCount() - 1)};
|
||||
|
||||
Vect noyau = solver.Noyau();
|
||||
Matrix origin = mat.SubMatrix(0, mat.GetColumnCount() - 1, mat.GetRawCount(), 1);
|
||||
|
||||
return {noyau, origin};
|
||||
}
|
||||
|
||||
std::size_t Solver::Rang() const {
|
||||
Vect image = Image();
|
||||
return image.GetCardinal();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
class Solver {
|
||||
private:
|
||||
Matrix m_Matrix;
|
||||
|
||||
public:
|
||||
Solver(const Matrix& mat);
|
||||
~Solver() {}
|
||||
@@ -12,5 +13,7 @@ class Solver {
|
||||
Vect Image() const;
|
||||
Vect Noyau() const;
|
||||
|
||||
VectAffine SystemeTriangulaire() const;
|
||||
|
||||
std::size_t Rang() const;
|
||||
};
|
||||
13
src/Vect.cpp
13
src/Vect.cpp
@@ -1,6 +1,7 @@
|
||||
#include "Vect.h"
|
||||
|
||||
#include "Solver.h"
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
Vect::Vect(const Matrix& mat) : m_Data(mat) {
|
||||
@@ -67,7 +68,7 @@ void Vect::Print() const {
|
||||
std::cout << "Espace vectoriel de dimension " << GetCardinal() << " de base :\n\n";
|
||||
for (std::size_t i = 0; i < m_Data.GetRawCount(); i++) {
|
||||
for (std::size_t j = 0; j < m_Data.GetColumnCount(); j++) {
|
||||
printf("[ %.3f ]\t", static_cast<float>(m_Data.at(i, j)));
|
||||
printf("[ %u ]\t", static_cast<float>(m_Data.at(i, j)));
|
||||
}
|
||||
std::cout << "\n";
|
||||
}
|
||||
@@ -76,3 +77,13 @@ void Vect::Print() const {
|
||||
std::size_t Vect::GetDimension() const {
|
||||
return m_Data.GetRawCount();
|
||||
}
|
||||
|
||||
VectAffine::VectAffine(const Vect& base, const Matrix& origine) :
|
||||
m_Base(base), m_Origin(origine.SubMatrix(0, 0, m_Base.GetDimension(), 1)) {}
|
||||
|
||||
void VectAffine::Print() const {
|
||||
std::cout << "\tEspace Affine :\n\n";
|
||||
m_Base.Print();
|
||||
std::cout << "\nOrigine :\n\n";
|
||||
m_Origin.Print();
|
||||
}
|
||||
|
||||
20
src/Vect.h
20
src/Vect.h
@@ -37,3 +37,23 @@ class Vect {
|
||||
private:
|
||||
void Simplify();
|
||||
};
|
||||
|
||||
|
||||
class VectAffine {
|
||||
private:
|
||||
Vect m_Base;
|
||||
Matrix m_Origin;
|
||||
|
||||
public:
|
||||
VectAffine(const Vect& base, const Matrix& origin);
|
||||
|
||||
void Print() const;
|
||||
|
||||
const Vect& GetBase() const {
|
||||
return m_Base;
|
||||
}
|
||||
|
||||
const Matrix& GetOrigin() const {
|
||||
return m_Origin;
|
||||
}
|
||||
};
|
||||
@@ -32,6 +32,9 @@ void test() {
|
||||
noyau.Print();
|
||||
std::cout << "Système :\n";
|
||||
noyau.GetLinearSystem().Print();
|
||||
|
||||
std::cout << "\n\n";
|
||||
solver.SystemeTriangulaire().Print();
|
||||
}
|
||||
|
||||
void prompt() {
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
#include "Solver.h"
|
||||
#include <cassert>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "Solver.h"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
int main() {
|
||||
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{1, 1}, imageMat{1, 1}, noyauMat{1, 1};
|
||||
in >> mat >> imageMat >> noyauMat;
|
||||
|
||||
@@ -19,6 +23,7 @@ int main() {
|
||||
Vect noyau{noyauMat};
|
||||
|
||||
Solver solver{mat};
|
||||
|
||||
assert(solver.Image() == image);
|
||||
assert(solver.Noyau() == noyau);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user