matrice augmenter

This commit is contained in:
2024-02-14 21:31:05 +01:00
parent cf64e4d33c
commit 8ef738db55
2 changed files with 21 additions and 0 deletions

View File

@@ -136,6 +136,25 @@ bool Matrix::IsInversed() const {
return true; return true;
} }
void Matrix::Augmenter(const Matrix& droite) {
assert(droite.m_Lignes == m_Lignes);
Matrix temp{m_Lignes, m_Colonnes + droite.m_Colonnes};
for (std::size_t i = 0; i < m_Lignes; i++) {
for (std::size_t j = 0; j < m_Colonnes; j++) {
temp.at(i, j) = at(i, j);
}
}
for (std::size_t i = 0; i < m_Lignes; i++) {
for (std::size_t j = 0; j < droite.m_Colonnes; j++) {
temp.at(i, j + m_Colonnes) = droite.at(i, j);
}
}
*this = temp;
}
bool Matrix::operator==(const Matrix& other) const { bool Matrix::operator==(const Matrix& other) const {
if (m_Lignes != other.m_Lignes || m_Colonnes != other.m_Colonnes) if (m_Lignes != other.m_Lignes || m_Colonnes != other.m_Colonnes)
return false; return false;

View File

@@ -44,6 +44,8 @@ class Matrix {
bool IsInversed() const; bool IsInversed() const;
void Augmenter(const Matrix& droite);
Matrix SubMatrix(std::size_t origine_ligne, std::size_t origine_colonne, std::size_t ligne, std::size_t colonne) const; Matrix SubMatrix(std::size_t origine_ligne, std::size_t origine_colonne, std::size_t ligne, std::size_t colonne) const;
bool operator==(const Matrix& other) const; bool operator==(const Matrix& other) const;