mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-02 05:04:08 +08:00
support for std::cout
This commit is contained in:
parent
9cd6ac3dd9
commit
d999923a35
@ -13,6 +13,13 @@ endif()
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
|
||||
STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel;Profile")
|
||||
|
||||
option (SUPPORT_STDIOSTREAM
|
||||
"If enabled provides support for << operator (as used with
|
||||
std::cout)" OFF)
|
||||
if((SUPPORT_STDIOSTREAM))
|
||||
add_definitions(-DSUPPORT_STDIOSTREAM)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS_PROFILE
|
||||
${CMAKE_CXX_FLAGS_DEBUG}
|
||||
--coverage
|
||||
|
||||
@ -13,6 +13,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#if defined(SUPPORT_STDIOSTREAM)
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#endif // defined(SUPPORT_STDIOSTREAM)
|
||||
|
||||
#include "math.hpp"
|
||||
|
||||
@ -413,6 +417,23 @@ Matrix<Type, M, N> ones() {
|
||||
return m;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_STDIOSTREAM)
|
||||
template<typename Type, size_t M, size_t N>
|
||||
std::ostream& operator<<(std::ostream& os,
|
||||
const matrix::Matrix<Type, M, N>& matrix)
|
||||
{
|
||||
for (size_t i = 0; i < M; ++i) {
|
||||
os << "[";
|
||||
for (size_t j = 0; j < N; ++j) {
|
||||
os << std::setw(10) << static_cast<double>(matrix(i, j));
|
||||
os << "\t";
|
||||
}
|
||||
os << "]" << std::endl;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
#endif // defined(SUPPORT_STDIOSTREAM)
|
||||
|
||||
typedef Matrix<float, 3, 3> Matrix3f;
|
||||
|
||||
}; // namespace matrix
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user