equality of vectorial spaces

This commit is contained in:
2024-02-16 10:39:42 +01:00
parent c2fd2805fa
commit 46dcad1457
3 changed files with 45 additions and 5 deletions

View File

@@ -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();
}