python.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include <pybind/pybind.h>
  3. #include <pybind/operators.h>
  4. #include <pybind/complex.h>
  5. #include <pybind/numpy.h>
  6. #include <pybind/stl.h>
  7. #include <pybind/functional.h>
  8. #include "py_doc.h"
  9. #include <Eigen/Dense>
  10. template<typename Scalar>
  11. void assert_is_VectorX(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
  12. {
  13. if (v.cols() != 1)
  14. throw std::runtime_error(name + " must be a column vector.");
  15. }
  16. template<typename Scalar>
  17. void assert_is_RowVectorX(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
  18. {
  19. if (v.rows() != 1)
  20. throw std::runtime_error(name + " must be a row vector.");
  21. }
  22. template<typename Scalar>
  23. void assert_is_Vector3(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
  24. {
  25. if ((v.cols() != 1) || (v.rows() != 3))
  26. throw std::runtime_error(name + " must be a column vector with 3 entries.");
  27. }
  28. template<typename Scalar>
  29. void assert_is_RowVector3(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
  30. {
  31. if ((v.cols() != 3) || (v.rows() != 1))
  32. throw std::runtime_error(name + " must be a row vector with 3 entries.");
  33. }
  34. template<typename Scalar>
  35. void assert_is_Vector4(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
  36. {
  37. if ((v.cols() != 1) || (v.rows() != 4))
  38. throw std::runtime_error(name + " must be a column vector with 4 entries.");
  39. }
  40. template<typename Scalar>
  41. void assert_is_RowVector4(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
  42. {
  43. if ((v.cols() != 4) || (v.rows() != 1))
  44. throw std::runtime_error(name + " must be a row vector with 4 entries.");
  45. }
  46. template<typename Scalar>
  47. void assert_is_Matrix4(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
  48. {
  49. if ((v.cols() != 4) || (v.rows() != 4))
  50. throw std::runtime_error(name + " must be a 4x4 matrix.");
  51. }
  52. namespace py = pybind;