From 332f8c35769e26b1ea7de774eac9c92d639874b0 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 14400683f0ef..9e60b9ebef38 100644 --- a/src/lib/matrix/matrix/Matrix.hpp +++ b/src/lib/matrix/matrix/Matrix.hpp @@ -402,6 +402,7 @@ class Matrix } 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 @@ class Matrix 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 @@ class Matrix } else { printf("% 6.5f ", d); } + + is_prev_symmetric = false; // not symmetric if once inside here } }