add more doc

This commit is contained in:
2024-02-29 22:24:42 +01:00
parent 9028b553c3
commit 8c1c3d4f9e
9 changed files with 182 additions and 76 deletions

View File

@@ -1,15 +0,0 @@
#pragma once
class Matrix;
namespace Gauss {
/**
* \brief Echelonne une matrice en utilisant l'algorithme de Gauss-Jordan
* \param mat La matrice à échelonner
* \param reduite Mets des 0 au dessus des pivots
* \param normalise Mets les pivots à 1
*/
void GaussJordan(Matrix& mat, bool reduite, bool normalise);
} // namespace Gauss

View File

@@ -1,19 +0,0 @@
#pragma once
#include <string>
class Matrix;
class Vect;
class VectAffine;
std::ostream& operator<<(std::ostream& stream, const Matrix& mat);
std::istream& operator>>(std::istream& stream, Matrix& mat);
Matrix LoadMatrix(const std::string& fileName);
void SaveMatrix(const Matrix& mat, const std::string& fileName);
Matrix InsertMatrix();
void Print(const Matrix& mat);
void Print(const Vect& vect);
void Print(const VectAffine& vect);

View File

@@ -17,8 +17,6 @@ Matrix::Matrix(std::size_t lignes, std::size_t colonnes, std::initializer_list<E
m_Data.resize(m_Raws * m_Columns);
}
Matrix::~Matrix() {}
Matrix Matrix::operator*(const Matrix& other) const {
if (m_Columns != other.m_Raws) {
std::cerr << "Mutiplication impossible car la dimensions des matrices est incompatible" << std::endl;
@@ -92,10 +90,6 @@ bool Matrix::operator==(const Matrix& other) const {
return true;
}
Matrix::Element& Matrix::operator[](std::size_t indice) {
return m_Data[indice];
}
Matrix::Element& Matrix::at(std::size_t ligne, std::size_t colonne) {
return m_Data[ligne * m_Columns + colonne];
}

View File

@@ -1,49 +0,0 @@
#pragma once
#include <cmath>
#include <cstddef>
#include <string>
#include <vector>
/**
* \class Matrix
* \brief Représente une matrice d'éléments
*/
class Matrix {
public:
typedef long double Element;
private:
std::size_t m_Raws;
std::size_t m_Columns;
std::vector<Element> m_Data;
public:
Matrix() : m_Raws(0), m_Columns(0) {}
Matrix(std::size_t raws, std::size_t columns);
Matrix(std::size_t raws, std::size_t columns, std::initializer_list<Element>&& initList);
~Matrix();
std::size_t GetRawCount() const;
std::size_t GetColumnCount() const;
void Transpose();
static Matrix Identity(std::size_t size);
void Augment(const Matrix& right);
Matrix SubMatrix(std::size_t raw_origin, std::size_t column_origin, std::size_t raw, std::size_t column) const;
bool operator==(const Matrix& other) const;
Matrix operator*(const Matrix& other) const;
Element& operator[](std::size_t index);
Element& at(std::size_t raw, std::size_t column);
Element at(std::size_t raw, std::size_t column) const;
};
template <typename T>
bool IsEqualZero(T var) {
return std::abs(var) < std::pow(10, -5);
}

View File

@@ -1,45 +0,0 @@
#pragma once
#include <iostream>
class NR {
private:
int m_Numerator;
int m_Denominator; // has to be > 0, sign is carried by the numerator
public:
NR();
NR(int entier);
NR(int numerator, int denominator); // check if denominator != 0
int GetNumerator() const;
int GetDenominator() const;
bool operator==(const NR& opNR) const;
bool operator<(const NR& opNR) const;
bool operator>(const NR& opNR) const;
bool operator!=(const NR& opNR) const;
bool operator<=(const NR& opNR) const;
bool operator>=(const NR& opNR) const;
NR operator+(const NR& opNR) const;
NR operator-(const NR& opNR) const;
NR operator*(const NR& opNR) const;
NR operator/(const NR& opNR) const;
NR& operator+=(const NR& opNR);
NR& operator-=(const NR& opNR);
NR& operator*=(const NR& opNR);
NR& operator/=(const NR& opNR);
void Invert();
friend std::ostream& operator<<(std::ostream& os, const NR& opNR);
friend std::istream& operator>>(std::istream& os, NR& opNR);
private:
void Reduce();
};
int PGCD(int x, int y);

View File

@@ -1,46 +0,0 @@
#pragma once
#include "Vect.h"
/**
* \class Solver
* \brief Permet d'obtenir différentes propriétés d'une matrice comme l'image ou le noyau
*/
class Solver {
private:
Matrix m_Matrix;
public:
/**
* \brief Initialise le resolveur
* \param mat La matrice d'entrée
*/
Solver(const Matrix& mat);
~Solver() {}
/**
* \brief Calcule l'image de la matrice d'entrée
* \return L'espace vectoriel correspondant
*/
Vect Image() const;
/**
* \brief Calcule le noyau de la matrice d'entrée
* \return L'espace vectoriel correspondant
*/
Vect Kernel() const;
/**
* \brief Résout le système triangulaire de la forme AX=B.
* La matrice d'entrée est considéré comme étant la matrice augmenté [A|B]
* \return L'espace affine associé
*/
VectAffine TriangularSystem() const;
/**
* \brief Calcule le rang de la matrice
* \note Ceci équivaut à \code Image().GetCardinal() \endcode
*/
std::size_t Rank() const;
};

View File

@@ -1,87 +0,0 @@
#pragma once
#include "Matrix.h"
/**
* \class Vect
* \brief Représente une base d'un espace vectoriel de dimension finie
*/
class Vect {
private:
Matrix m_Data;
public:
/**
* \brief Construit une base d'un espace vectoriel à partir des colonnes d'une matrice.
* Les colonnes de 0 sont ignorées
* \param mat Une matrice échelonnée.
*/
Vect(const Matrix& mat);
/**
* \brief Permet d'obtenir le ieme vecteur de la base
* \param index l'index du vecteur souhaité
* \return Une matrice colonne
*/
Matrix GetVector(std::size_t index) const;
/**
* \brief Retourne le nombre de coordonnées des vecteurs de la base (leur nombre de colonne)
*/
std::size_t GetDimension() const;
/**
* \brief Retourne le nombre de vecteur de la base
*/
std::size_t GetCardinal() const;
/**
* \brief Exprime l'espace vectoriel comme les solutions d'un système linéaire des coordonnées des vecteurs
* \return Une matrice représentant le système linéaire
*/
Matrix GetLinearSystem() const;
/**
* \brief Concatène la base actuelle avec un nouveau vecteur
* \param mat Une matrice colonne de taille GetDimension()
*/
void AddVector(const Matrix& mat);
bool operator==(const Vect& other) const;
bool operator!=(const Vect& other) const;
private:
void Simplify();
};
/**
* \class VectAffine
* \brief Représente un espace affine
*/
class VectAffine {
private:
Vect m_Base;
Matrix m_Origin;
public:
/**
* \brief Construit un espace affine à partir d'un espace vectoriel et d'une origine
* \param base La base de l'espace vectoriel
* \param origin Le vecteur d'origine (matrice colonne)
*/
VectAffine(const Vect& base, const Matrix& origin);
/**
* \brief Retourne l'espace vectoriel correspondant
*/
const Vect& GetBase() const {
return m_Base;
}
/**
* \brief Retourne l'origine de l'espace affine
*/
const Matrix& GetOrigin() const {
return m_Origin;
}
};