Guest User

Untitled

a guest
Dec 14th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. #ifndef _EIGEN_CHECKS_H_
  2. #define _EIGEN_CHECKS_H_
  3.  
  4. // cast to avoid -Wno-enum-compare
  5. #define assert_dim_eq(l,r) \
  6. static_assert(static_cast<int>(std::decay<decltype(l)>::type::ColsAtCompileTime) == \
  7. static_cast<int>(std::decay<decltype(r)>::type::ColsAtCompileTime) or \
  8. std::decay<decltype(l)>::type::ColsAtCompileTime == Eigen::Dynamic or \
  9. std::decay<decltype(r)>::type::ColsAtCompileTime == Eigen::Dynamic, \
  10. "lhs.cols != rhs.cols !"); \
  11. static_assert(static_cast<int>(std::decay<decltype(l)>::type::RowsAtCompileTime) == \
  12. static_cast<int>(std::decay<decltype(r)>::type::RowsAtCompileTime) or \
  13. std::decay<decltype(l)>::type::RowsAtCompileTime == Eigen::Dynamic or \
  14. std::decay<decltype(r)>::type::RowsAtCompileTime == Eigen::Dynamic, \
  15. "lhs.rows != rhs.rows !"); \
  16. assert(l.rows() == r.rows() && "lhs.rows != rhs.rows !"); \
  17. assert(l.cols() == r.cols() && "lhs.cols != rhs.cols !"); \
  18.  
  19. #define assert_vector(x) \
  20. static_assert(std::decay<decltype(x)>::type::ColsAtCompileTime == 1 or \
  21. std::decay<decltype(x)>::type::ColsAtCompileTime == -1, \
  22. "Expected a vector !"); \
  23. assert(x.cols() == 1 && "Expected a vector !"); \
  24.  
  25. #define assert_colmajor_vector(x) \
  26. static_assert(std::decay<decltype(x)>::type::RowsAtCompileTime == 1 or \
  27. std::decay<decltype(x)>::type::RowsAtCompileTime == -1, \
  28. "Expected a vector !"); \
  29. assert(x.rows() == 1 && "Expected a vector !"); \
  30.  
  31. #endif /* _EIGEN_CHECKS_H_ */
Add Comment
Please, Sign In to add comment