slice.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. // THIS MAY HAVE BEEN SUPERSEDED BY EIGEN'S select FUNCTION
  9. //
  10. // Act like the matlab X(row_indices,col_indices) operator
  11. //
  12. // Inputs:
  13. // X m by n matrix
  14. // R list of row indices
  15. // C list of column indices
  16. // Output:
  17. // Y #R by #C matrix
  18. template <typename T>
  19. IGL_INLINE void slice(
  20. const Eigen::SparseMatrix<T>& X,
  21. const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
  22. const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
  23. Eigen::SparseMatrix<T>& Y);
  24. template <typename DerivedX>
  25. IGL_INLINE void slice(
  26. const Eigen::PlainObjectBase<DerivedX> & X,
  27. const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
  28. const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
  29. Eigen::PlainObjectBase<DerivedX> & Y);
  30. template <typename DerivedX>
  31. IGL_INLINE void slice(
  32. const Eigen::PlainObjectBase<DerivedX> & X,
  33. const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
  34. Eigen::PlainObjectBase<DerivedX> & Y);
  35. }
  36. #ifdef IGL_HEADER_ONLY
  37. # include "slice.cpp"
  38. #endif
  39. #endif