From a1d74ec126a4441f00720af3faa8c379ff2400a9 Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Wed, 14 Feb 2024 22:22:59 +0100 Subject: [PATCH] vectorial space to linear equation --- src/Matrix.cpp | 4 ++-- src/Vect.cpp | 12 ++++++++++++ src/Vect.h | 2 ++ src/main.cpp | 11 +++++++++-- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/Matrix.cpp b/src/Matrix.cpp index a30e09b..465bc55 100644 --- a/src/Matrix.cpp +++ b/src/Matrix.cpp @@ -1,11 +1,11 @@ +#include "Matrix.h" + #include #include #include #include #include -#include "Matrix.h" - Matrix::Matrix(const std::string& fileNameInput) { Load(fileNameInput); } diff --git a/src/Vect.cpp b/src/Vect.cpp index 1dad13f..5930737 100644 --- a/src/Vect.cpp +++ b/src/Vect.cpp @@ -1,4 +1,6 @@ #include "Vect.h" + +#include "Solver.h" #include Vect::Vect(const Matrix& mat) : m_Data(mat) { @@ -21,6 +23,16 @@ void Vect::Simplify() { m_Data = mat; } +Matrix Vect::GetLinearSystem() const { + Matrix vect = m_Data; + vect.Transpose(); + + Solver solver {vect}; + vect = solver.Noyau().m_Data; + vect.Transpose(); + return vect; +} + void Vect::Print() const { std::cout << "Espace vectoriel de dimension " << GetDimension() << " de base :\n\n"; for (std::size_t i = 0; i < m_Data.GetRawCount(); i++) { diff --git a/src/Vect.h b/src/Vect.h index a99c3ba..5f89f02 100644 --- a/src/Vect.h +++ b/src/Vect.h @@ -22,6 +22,8 @@ class Vect { std::size_t GetDimension() const; + Matrix GetLinearSystem() const; + private: void Simplify(); }; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 30091d6..39d5061 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,10 +21,17 @@ void test() { Solver solver{mat2}; + Vect image = solver.Image(); + Vect noyau = solver.Noyau(); + std::cout << "\tImage :\n"; - solver.Image().Print(); + image.Print(); + std::cout << "Système :\n"; + image.GetLinearSystem().Print(); std::cout << "\tNoyau :\n"; - solver.Noyau().Print(); + noyau.Print(); + std::cout << "Système :\n"; + noyau.GetLinearSystem().Print(); } void prompt() {