equations cartesiennes.
All checks were successful
Linux arm64 / Build (push) Successful in 3m10s

This commit is contained in:
2024-05-11 18:44:20 +02:00
parent 6833811b97
commit a02f71e29e
2 changed files with 39 additions and 17 deletions

View File

@@ -4,6 +4,8 @@
#include "Solver.h" #include "Solver.h"
#include <imgui.h> #include <imgui.h>
static std::string equationsResultImage;
static Matrix LoadMatrixFromStdVect(const std::vector<std::vector<int>>& data) { static Matrix LoadMatrixFromStdVect(const std::vector<std::vector<int>>& data) {
Matrix result {data.size(), data.empty() ? 0 : data[0].size()}; Matrix result {data.size(), data.empty() ? 0 : data[0].size()};
for (std::size_t i = 0; i < result.GetRawCount(); i++) { for (std::size_t i = 0; i < result.GetRawCount(); i++) {
@@ -15,6 +17,9 @@ static Matrix LoadMatrixFromStdVect(const std::vector<std::vector<int>>& data) {
} }
static std::string PrintVect(const Vect& vect) { static std::string PrintVect(const Vect& vect) {
if (vect.GetCardinal() == 0)
return "{0}";
std::string result = "Vect( "; std::string result = "Vect( ";
for (std::size_t i = 0; i < vect.GetCardinal(); i++) { for (std::size_t i = 0; i < vect.GetCardinal(); i++) {
Matrix vector = vect.GetVector(i); Matrix vector = vect.GetVector(i);
@@ -84,7 +89,10 @@ void PivotGui::Render() {
} }
} }
ImGui::Text("Matrice finale:"); // Display the equationsResult strings in the GUI if they are not empty
if (!equationsResultImage.empty()) {
ImGui::TextWrapped(equationsResultImage.c_str());
}
ImGui::EndChild(); // End Matrice initiale ImGui::EndChild(); // End Matrice initiale
@@ -100,7 +108,7 @@ void PivotGui::Render() {
static std::string result = "RIEN"; static std::string result = "RIEN";
ImGui::Text(result.c_str()); ImGui::TextWrapped(result.c_str());
ImGui::End(); // End fenetre top right ImGui::End(); // End fenetre top right
@@ -110,22 +118,36 @@ void PivotGui::Render() {
ImGui::Begin("Bottom Part", nullptr, ImGui::Begin("Bottom Part", nullptr,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar); ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar);
// rajouter des boutons clickables if (ImGui::Button("Calcul")) {
if (ImGui::Button("Calcul noyau")) {
// Code de calcul
Vect kernel = solver.Kernel(LoadMatrixFromStdVect(matrixValues));
result = PrintVect(kernel); // Calculate the kernel and image
}
ImGui::SameLine(); // Align buttons horizontally
if (ImGui::Button("Calcul rang")) {
// Code de calcul
std::size_t rank = solver.Rank(LoadMatrixFromStdVect(matrixValues));
}
ImGui::SameLine(); // Align buttons horizontally
if (ImGui::Button("Calcul image")) {
// Code de calcul
Vect image = solver.Image(LoadMatrixFromStdVect(matrixValues)); Vect image = solver.Image(LoadMatrixFromStdVect(matrixValues));
Matrix linearSystem = image.GetLinearSystem();
// Create a column matrix with as many elements as the number of columns in the linear system
std::vector<std::string> columnMatrix(linearSystem.GetColumnCount());
for (size_t i = 0; i < linearSystem.GetColumnCount(); ++i) {
columnMatrix[i] = std::string(1, 'a' + static_cast<char>(i));
}
// Multiply the linear system matrix by the column matrix
std::vector<std::string> resultMatrix(linearSystem.GetRawCount());
for (size_t i = 0; i < linearSystem.GetRawCount(); ++i) {
for (size_t j = 0; j < linearSystem.GetColumnCount(); ++j) {
resultMatrix[i] += std::to_string(static_cast<int>(linearSystem.at(i, j))) + "*" + columnMatrix[j] + " + ";
}
resultMatrix[i] = resultMatrix[i].substr(0, resultMatrix[i].length() - 3) + " = 0";
}
// Store the equationsResult strings in the global variable
equationsResultImage = "Equations cartesiennes de l'espace vectoriel (Image):\n";
for (const auto& equation : resultMatrix) {
equationsResultImage += equation + "\n";
}
result = std::string("Noyau: ") + "\n" + PrintVect(solver.Kernel(LoadMatrixFromStdVect(matrixValues))) + "\n" + "\n" +
"Rang: " + "\n" + std::to_string(solver.Rank(LoadMatrixFromStdVect(matrixValues))) + "\n" + "\n" +
"Image: " + "\n" + PrintVect(image);
} }
ImGui::End(); // End fenetre bas ImGui::End(); // End fenetre bas

View File

@@ -7,4 +7,4 @@ void Init();
void Render(); void Render();
void Destroy(); void Destroy();
} // namespace PivotGui } // namespace PivotGui