This commit is contained in:
@@ -66,16 +66,23 @@ class Matrix {
|
|||||||
void Transpose();
|
void Transpose();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Augmente la matrice actuelle avec une autre
|
* \brief Augmente la matrice actuelle à droite avec une autre
|
||||||
* \param a_Right Une matrice avec le bon nombre de lignes
|
* \param a_Right Une matrice avec le bon nombre de lignes
|
||||||
* \pre Les deux matrices doivent avoir le même nombre de lignes
|
* \pre Les deux matrices doivent avoir le même nombre de lignes
|
||||||
*/
|
*/
|
||||||
void Augment(const Matrix& a_Right);
|
void Augment(const Matrix& a_Right);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Augmente la matrice actuelle en dessous avec une autre
|
||||||
|
* \param a_Bottom Une matrice avec le bon nombre de colonnes
|
||||||
|
* \pre Les deux matrices doivent avoir le même nombre de colonnes
|
||||||
|
*/
|
||||||
|
void AugmentBottom(const Matrix& a_Bottom);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Affecte tous les coefficients de la matrice à un élément
|
* \brief Affecte tous les coefficients de la matrice à un élément
|
||||||
* \param a_Element L'élément à affecter
|
* \param a_Element L'élément à affecter
|
||||||
*/
|
*/
|
||||||
void Fill(Element a_Element);
|
void Fill(Element a_Element);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -97,6 +97,25 @@ void Matrix::Augment(const Matrix& a_Right) {
|
|||||||
*this = temp;
|
*this = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Matrix::AugmentBottom(const Matrix& a_Bottom) {
|
||||||
|
assert(a_Bottom.m_Columns == m_Columns);
|
||||||
|
Matrix temp {m_Raws + a_Bottom.GetRawCount(), m_Columns};
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < m_Raws; i++) {
|
||||||
|
for (std::size_t j = 0; j < m_Columns; j++) {
|
||||||
|
temp.at(i, j) = at(i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < a_Bottom.GetRawCount(); i++) {
|
||||||
|
for (std::size_t j = 0; j < GetColumnCount(); j++) {
|
||||||
|
temp.at(i + GetRawCount(), j) = a_Bottom.at(i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*this = temp;
|
||||||
|
}
|
||||||
|
|
||||||
Matrix Matrix::operator+(const Matrix& a_Other) const {
|
Matrix Matrix::operator+(const Matrix& a_Other) const {
|
||||||
assert(GetColumnCount() == a_Other.GetColumnCount() && GetRawCount() == a_Other.GetRawCount());
|
assert(GetColumnCount() == a_Other.GetColumnCount() && GetRawCount() == a_Other.GetRawCount());
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,7 @@
|
|||||||
#include "Gauss.h"
|
#include "Gauss.h"
|
||||||
|
|
||||||
Vect Solver::Image(Matrix&& a_Matrix) const {
|
Vect Solver::Image(Matrix&& a_Matrix) const {
|
||||||
a_Matrix.Transpose();
|
Gauss::GaussJordanColumn(a_Matrix, true, true);
|
||||||
Gauss::GaussJordan(a_Matrix, true, true);
|
|
||||||
a_Matrix.Transpose();
|
|
||||||
return {a_Matrix};
|
return {a_Matrix};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,16 +12,14 @@ Vect Solver::Kernel(Matrix&& a_Matrix) const {
|
|||||||
std::size_t matrixRawCount = a_Matrix.GetRawCount();
|
std::size_t matrixRawCount = a_Matrix.GetRawCount();
|
||||||
std::size_t matrixColumnCount = a_Matrix.GetColumnCount();
|
std::size_t matrixColumnCount = a_Matrix.GetColumnCount();
|
||||||
|
|
||||||
a_Matrix.Transpose();
|
a_Matrix.AugmentBottom(Matrix::Identity(a_Matrix.GetColumnCount()));
|
||||||
a_Matrix.Augment(Matrix::Identity(a_Matrix.GetRawCount()));
|
Gauss::GaussJordanColumn(a_Matrix, true, true);
|
||||||
Gauss::GaussJordan(a_Matrix, true, true);
|
|
||||||
a_Matrix.Transpose();
|
|
||||||
|
|
||||||
// nombre de colonnes non nulles
|
// nombre de colonnes non nulles
|
||||||
std::size_t origine_colonne = Vect(a_Matrix.SubMatrix(0, 0, matrixRawCount, matrixColumnCount)).GetCardinal();
|
std::size_t origine_colonne = Vect(a_Matrix.SubMatrix(0, 0, matrixRawCount, matrixColumnCount)).GetCardinal();
|
||||||
|
|
||||||
return {a_Matrix.SubMatrix(matrixRawCount, origine_colonne, a_Matrix.GetRawCount() - matrixRawCount,
|
return {a_Matrix.SubMatrix(
|
||||||
a_Matrix.GetColumnCount() - origine_colonne)};
|
matrixRawCount, origine_colonne, a_Matrix.GetRawCount() - matrixRawCount, a_Matrix.GetColumnCount() - origine_colonne)};
|
||||||
}
|
}
|
||||||
|
|
||||||
VectAffine Solver::RectangularSystem(Matrix&& a_MatrixA, const Matrix& a_VectorB) const {
|
VectAffine Solver::RectangularSystem(Matrix&& a_MatrixA, const Matrix& a_VectorB) const {
|
||||||
|
|||||||
Reference in New Issue
Block a user