From 8ef738db5520a3228c6c32c8a91f12a5a22b0990 Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Wed, 14 Feb 2024 21:31:05 +0100 Subject: [PATCH] matrice augmenter --- src/Matrix.cpp | 19 +++++++++++++++++++ src/Matrix.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/Matrix.cpp b/src/Matrix.cpp index 8b3a7c9..a30e09b 100644 --- a/src/Matrix.cpp +++ b/src/Matrix.cpp @@ -136,6 +136,25 @@ bool Matrix::IsInversed() const { 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 { if (m_Lignes != other.m_Lignes || m_Colonnes != other.m_Colonnes) return false; diff --git a/src/Matrix.h b/src/Matrix.h index 5122715..a858f89 100644 --- a/src/Matrix.h +++ b/src/Matrix.h @@ -44,6 +44,8 @@ class Matrix { 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; bool operator==(const Matrix& other) const;