equality of vectorial spaces
This commit is contained in:
@@ -19,7 +19,7 @@ Vect Solver::Noyau() const {
|
||||
result.Transpose();
|
||||
|
||||
// nombre de colonnes non nulles
|
||||
std::size_t origine_colonne = Vect(result.SubMatrix(0, 0, m_Matrix.GetRawCount(), m_Matrix.GetColumnCount())).GetDimension();
|
||||
std::size_t origine_colonne = Vect(result.SubMatrix(0, 0, m_Matrix.GetRawCount(), m_Matrix.GetColumnCount())).GetCardinal();
|
||||
|
||||
return {result.SubMatrix(m_Matrix.GetRawCount(), origine_colonne, result.GetRawCount() - m_Matrix.GetRawCount(),
|
||||
result.GetColumnCount() - origine_colonne)};
|
||||
@@ -27,5 +27,5 @@ Vect Solver::Noyau() const {
|
||||
|
||||
std::size_t Solver::Rang() const {
|
||||
Vect image = Image();
|
||||
return image.GetDimension();
|
||||
return image.GetCardinal();
|
||||
}
|
||||
|
||||
36
src/Vect.cpp
36
src/Vect.cpp
@@ -23,18 +23,48 @@ void Vect::Simplify() {
|
||||
m_Data = mat;
|
||||
}
|
||||
|
||||
std::size_t Vect::GetCardinal() const {
|
||||
return m_Data.GetColumnCount();
|
||||
}
|
||||
|
||||
bool Vect::operator==(const Vect& other) const {
|
||||
if (GetDimension() != other.GetDimension() || GetCardinal() != other.GetCardinal())
|
||||
return false;
|
||||
|
||||
// on vérifie si chaque vecteur de la deuxième base appartient à la première base
|
||||
for (std::size_t i = 0; i < GetCardinal(); i++) {
|
||||
Vect base = *this;
|
||||
base.AddVector(other.m_Data.SubMatrix(0, i, GetDimension(), 1));
|
||||
if (base.GetCardinal() != GetCardinal())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Vect::AddVector(const Matrix& mat) {
|
||||
m_Data.Augmenter(mat);
|
||||
m_Data.Transpose();
|
||||
m_Data.GaussNonJordan(false);
|
||||
m_Data.Transpose();
|
||||
Simplify();
|
||||
}
|
||||
|
||||
bool Vect::operator!=(const Vect& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
Matrix Vect::GetLinearSystem() const {
|
||||
Matrix vect = m_Data;
|
||||
vect.Transpose();
|
||||
|
||||
Solver solver {vect};
|
||||
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";
|
||||
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)));
|
||||
@@ -44,5 +74,5 @@ void Vect::Print() const {
|
||||
}
|
||||
|
||||
std::size_t Vect::GetDimension() const {
|
||||
return m_Data.GetColumnCount();
|
||||
return m_Data.GetRawCount();
|
||||
}
|
||||
10
src/Vect.h
10
src/Vect.h
@@ -21,9 +21,19 @@ class Vect {
|
||||
void Print() const;
|
||||
|
||||
std::size_t GetDimension() const;
|
||||
std::size_t GetCardinal() const;
|
||||
|
||||
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();
|
||||
};
|
||||
Reference in New Issue
Block a user