mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-05 04:01:35 +08:00
support for std::cout
This commit is contained in:
@@ -13,6 +13,13 @@ endif()
|
|||||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
|
||||||
STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel;Profile")
|
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
|
set(CMAKE_CXX_FLAGS_PROFILE
|
||||||
${CMAKE_CXX_FLAGS_DEBUG}
|
${CMAKE_CXX_FLAGS_DEBUG}
|
||||||
--coverage
|
--coverage
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#if defined(SUPPORT_STDIOSTREAM)
|
||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
#endif // defined(SUPPORT_STDIOSTREAM)
|
||||||
|
|
||||||
#include "math.hpp"
|
#include "math.hpp"
|
||||||
|
|
||||||
@@ -413,6 +417,23 @@ Matrix<Type, M, N> ones() {
|
|||||||
return m;
|
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;
|
typedef Matrix<float, 3, 3> Matrix3f;
|
||||||
|
|
||||||
}; // namespace matrix
|
}; // namespace matrix
|
||||||
|
|||||||
Reference in New Issue
Block a user