Skip to content

Commit

Permalink
Matrix: print full matrix already if only one element is not symmetric
Browse files Browse the repository at this point in the history
Signed-off-by: Silvan Fuhrer <[email protected]>
  • Loading branch information
sfuhrer committed Jun 11, 2024
1 parent 9ececfd commit 332f8c3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/matrix/matrix/Matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ class Matrix
}

const Matrix<Type, M, N> &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
Expand All @@ -410,7 +411,7 @@ class Matrix
double d = static_cast<double>(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<double>(self(j, i))) < (double)eps)
) {
// print empty space
Expand All @@ -428,6 +429,8 @@ class Matrix
} else {
printf("% 6.5f ", d);
}

is_prev_symmetric = false; // not symmetric if once inside here
}
}

Expand Down

0 comments on commit 332f8c3

Please sign in to comment.