From 93caf546464b800ea1fbcc24fbf0b49e82b1c12e Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Mon, 18 Jul 2022 15:57:29 +0200 Subject: [PATCH] A very stupid first start of get_eigenvalues --- matrix.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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); }