slice.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef IGL_SLICE_H
  2. #define IGL_SLICE_H
  3. #include "igl_inline.h"
  4. #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
  5. #include <Eigen/Sparse>
  6. namespace igl
  7. {
  8. // Act like the matlab X(row_indices,col_indices) operator
  9. //
  10. // Inputs:
  11. // X m by n matrix
  12. // R list of row indices
  13. // C list of column indices
  14. // Output:
  15. // Y #R by #C matrix
  16. template <typename T>
  17. IGL_INLINE void slice(
  18. const Eigen::SparseMatrix<T>& X,
  19. const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
  20. const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
  21. Eigen::SparseMatrix<T>& Y);
  22. template <typename DerivedX>
  23. IGL_INLINE void slice(
  24. const Eigen::PlainObjectBase<DerivedX> & X,
  25. const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
  26. const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
  27. Eigen::PlainObjectBase<DerivedX> & Y);
  28. template <typename DerivedX>
  29. IGL_INLINE void slice(
  30. const Eigen::PlainObjectBase<DerivedX> & X,
  31. const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
  32. Eigen::PlainObjectBase<DerivedX> & Y);
  33. }
  34. #ifdef IGL_HEADER_ONLY
  35. # include "slice.cpp"
  36. #endif
  37. #endif