Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef _EIGEN_CHECKS_H_
- #define _EIGEN_CHECKS_H_
- // cast to avoid -Wno-enum-compare
- #define assert_dim_eq(l,r) \
- static_assert(static_cast<int>(std::decay<decltype(l)>::type::ColsAtCompileTime) == \
- static_cast<int>(std::decay<decltype(r)>::type::ColsAtCompileTime) or \
- std::decay<decltype(l)>::type::ColsAtCompileTime == Eigen::Dynamic or \
- std::decay<decltype(r)>::type::ColsAtCompileTime == Eigen::Dynamic, \
- "lhs.cols != rhs.cols !"); \
- static_assert(static_cast<int>(std::decay<decltype(l)>::type::RowsAtCompileTime) == \
- static_cast<int>(std::decay<decltype(r)>::type::RowsAtCompileTime) or \
- std::decay<decltype(l)>::type::RowsAtCompileTime == Eigen::Dynamic or \
- std::decay<decltype(r)>::type::RowsAtCompileTime == Eigen::Dynamic, \
- "lhs.rows != rhs.rows !"); \
- assert(l.rows() == r.rows() && "lhs.rows != rhs.rows !"); \
- assert(l.cols() == r.cols() && "lhs.cols != rhs.cols !"); \
- #define assert_vector(x) \
- static_assert(std::decay<decltype(x)>::type::ColsAtCompileTime == 1 or \
- std::decay<decltype(x)>::type::ColsAtCompileTime == -1, \
- "Expected a vector !"); \
- assert(x.cols() == 1 && "Expected a vector !"); \
- #define assert_colmajor_vector(x) \
- static_assert(std::decay<decltype(x)>::type::RowsAtCompileTime == 1 or \
- std::decay<decltype(x)>::type::RowsAtCompileTime == -1, \
- "Expected a vector !"); \
- assert(x.rows() == 1 && "Expected a vector !"); \
- #endif /* _EIGEN_CHECKS_H_ */
Add Comment
Please, Sign In to add comment