diff --git a/matrix.hpp b/matrix.hpp index 2016ca6..62f96cd 100644 --- a/matrix.hpp +++ b/matrix.hpp @@ -121,6 +121,24 @@ public: } return m; } + const bool is_diagonal() { + bool result = true; + if (this->num_entries != this->entry_dimension) + return !result; + for (long long i = 0; i < this->num_entries; i++) { + for (long long j = 0; j < this->num_entries; j++) { + if (i != j && this->entries[i][j] != 0) + return !result; + } + } + return result; + } + // Fixme: This is very dumb + const vector get_eigenvalues() { + if (this->is_diagonal()) + return this->get_diagonal(); + return vector(0); + } const bool is_eigenvalue(cnumber z) const { return ((*this - (this->I() * z)).determinant() == 0); }