matrix: change matrix.print() back to pring all elements, don't assume symmetric matrix

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
Silvan Fuhrer
2024-06-10 11:16:32 +02:00
parent f717f5bcc9
commit 94e98c2457
+40 -1
View File
@@ -387,7 +387,7 @@ public:
}
}
void print(float eps = 1e-9) const
void print_symmetric(float eps = 1e-9) const
{
// print column numbering
if (N > 1) {
@@ -435,6 +435,45 @@ public:
}
}
void print(float eps = 1e-9) const
{
// print column numbering
if (N > 1) {
printf(" ");
for (unsigned i = 0; i < N; i++) {
printf("|%2u ", i);
}
printf("\n");
}
const Matrix<Type, M, N> &self = *this;
for (unsigned i = 0; i < M; i++) {
printf("%2u|", i); // print row numbering
for (unsigned j = 0; j < N; j++) {
double d = static_cast<double>(self(i, j));
// avoid -0.0 for display
if (fabs(d - 0.0) < (double)eps) {
// print fixed width zero
printf(" 0 ");
} else if ((fabs(d) < 1e-4) || (fabs(d) >= 10.0)) {
printf("% .1e ", d);
} else {
printf("% 6.5f ", d);
}
}
printf("\n");
}
}
Matrix<Type, N, M> transpose() const
{
Matrix<Type, N, M> res;