slice_into.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef IGL_SLICE_INTO_H
  2. #define IGL_SLICE_INTO_H
  3. #include "igl_inline.h"
  4. #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
  5. #include <Eigen/Dense>
  6. #include <Eigen/Sparse>
  7. namespace igl
  8. {
  9. // Act like the matlab Y(row_indices,col_indices) = X
  10. //
  11. // Inputs:
  12. // X xm by xn rhs matrix
  13. // R list of row indices
  14. // C list of column indices
  15. // Y ym by yn lhs matrix
  16. // Output:
  17. // Y ym by yn lhs matrix, same as input but Y(R,C) = X
  18. template <typename T>
  19. IGL_INLINE void slice_into(
  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_into(
  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_into(
  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_into.cpp"
  38. #endif
  39. #endif