improve identity

This commit is contained in:
2024-02-14 21:30:41 +01:00
parent a016163b86
commit cf64e4d33c
2 changed files with 10 additions and 5 deletions

View File

@@ -109,17 +109,20 @@ void Matrix::Transpose() {
}
void Matrix::Identity() {
assert(m_Lignes == m_Colonnes);
for (std::size_t i = 0; i < m_Lignes; i++) {
for (std::size_t j = i; j < m_Colonnes; j++) {
if (i != j) {
at(i, j) = 0;
} else {
at(i, j) = 1;
}
at(i, j) = i == j;
}
}
}
Matrix Matrix::Identity(std::size_t taille) {
Matrix id{taille, taille};
id.Identity();
return id;
}
bool Matrix::IsInversed() const {
for (std::size_t i = 0; i < m_Lignes; ++i) {
std::size_t j;