improve identity
This commit is contained in:
@@ -109,17 +109,20 @@ void Matrix::Transpose() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Matrix::Identity() {
|
void Matrix::Identity() {
|
||||||
|
assert(m_Lignes == m_Colonnes);
|
||||||
for (std::size_t i = 0; i < m_Lignes; i++) {
|
for (std::size_t i = 0; i < m_Lignes; i++) {
|
||||||
for (std::size_t j = i; j < m_Colonnes; j++) {
|
for (std::size_t j = i; j < m_Colonnes; j++) {
|
||||||
if (i != j) {
|
at(i, j) = i == j;
|
||||||
at(i, j) = 0;
|
|
||||||
} else {
|
|
||||||
at(i, j) = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Matrix Matrix::Identity(std::size_t taille) {
|
||||||
|
Matrix id{taille, taille};
|
||||||
|
id.Identity();
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
bool Matrix::IsInversed() const {
|
bool Matrix::IsInversed() const {
|
||||||
for (std::size_t i = 0; i < m_Lignes; ++i) {
|
for (std::size_t i = 0; i < m_Lignes; ++i) {
|
||||||
std::size_t j;
|
std::size_t j;
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ class Matrix {
|
|||||||
|
|
||||||
void Identity();
|
void Identity();
|
||||||
|
|
||||||
|
static Matrix Identity(std::size_t taille);
|
||||||
|
|
||||||
bool IsInversed() const;
|
bool IsInversed() const;
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user