mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-15 14:31:35 +08:00
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:
@@ -387,7 +387,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(float eps = 1e-9) const
|
void print_symmetric(float eps = 1e-9) const
|
||||||
{
|
{
|
||||||
// print column numbering
|
// print column numbering
|
||||||
if (N > 1) {
|
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> transpose() const
|
||||||
{
|
{
|
||||||
Matrix<Type, N, M> res;
|
Matrix<Type, N, M> res;
|
||||||
|
|||||||
Reference in New Issue
Block a user