add IsElementOf + ColumnVector
This commit is contained in:
16
src/Vect.cpp
16
src/Vect.cpp
@@ -37,15 +37,19 @@ std::size_t Vect::GetCardinal() const {
|
||||
return m_Data.GetColumnCount();
|
||||
}
|
||||
|
||||
bool Vect::IsElementOf(const Matrix& vec) const {
|
||||
Vect base = *this;
|
||||
base.AddVector(vec);
|
||||
return base.GetCardinal() == GetCardinal();
|
||||
}
|
||||
|
||||
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 à l'espace vectoriel engendré par 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())
|
||||
if (!IsElementOf(other.GetVector(i)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -78,4 +82,8 @@ std::size_t Vect::GetDimension() const {
|
||||
}
|
||||
|
||||
VectAffine::VectAffine(const Vect& base, const Matrix& origine) :
|
||||
m_Base(base), m_Origin(origine.SubMatrix(0, 0, m_Base.GetDimension(), 1)) {}
|
||||
m_Base(base), m_Origin(origine.SubMatrix(0, 0, m_Base.GetDimension(), 1)) {}
|
||||
|
||||
bool VectAffine::IsElementOf(const Matrix& vec) const {
|
||||
return m_Base.IsElementOf(vec - m_Origin);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user