From 5dd76332ba935295bdb55211d4997c5a435057f4 Mon Sep 17 00:00:00 2001 From: Silvan Fuhrer Date: Tue, 11 Jun 2024 10:46:04 +0200 Subject: [PATCH] Matrix: print full matrix already if only one element is not symmetric Signed-off-by: Silvan Fuhrer --- src/lib/matrix/matrix/Matrix.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/matrix/matrix/Matrix.hpp b/src/lib/matrix/matrix/Matrix.hpp index 14400683f0..9e60b9ebef 100644 --- a/src/lib/matrix/matrix/Matrix.hpp +++ b/src/lib/matrix/matrix/Matrix.hpp @@ -402,6 +402,7 @@ public: } const Matrix &self = *this; + bool is_prev_symmetric = true; // assume symmetric until one element is not for (unsigned i = 0; i < M; i++) { printf("%2u|", i); // print row numbering @@ -410,7 +411,7 @@ public: double d = static_cast(self(i, j)); // if symmetric don't print upper triangular elements - if ((M == N) && (j > i) && (i < N) && (j < M) + if (is_prev_symmetric && (M == N) && (j > i) && (i < N) && (j < M) && (fabs(d - static_cast(self(j, i))) < (double)eps) ) { // print empty space @@ -428,6 +429,8 @@ public: } else { printf("% 6.5f ", d); } + + is_prev_symmetric = false; // not symmetric if once inside here } }