slice_into.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_SLICE_INTO_H
  9. #define IGL_SLICE_INTO_H
  10. #include "igl_inline.h"
  11. #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
  12. #include <Eigen/Dense>
  13. #include <Eigen/Sparse>
  14. namespace igl
  15. {
  16. // Act like the matlab Y(row_indices,col_indices) = X
  17. //
  18. // Inputs:
  19. // X xm by xn rhs matrix
  20. // R list of row indices
  21. // C list of column indices
  22. // Y ym by yn lhs matrix
  23. // Output:
  24. // Y ym by yn lhs matrix, same as input but Y(R,C) = X
  25. template <typename T>
  26. IGL_INLINE void slice_into(
  27. const Eigen::SparseMatrix<T>& X,
  28. const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
  29. const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
  30. Eigen::SparseMatrix<T>& Y);
  31. template <typename DerivedX>
  32. IGL_INLINE void slice_into(
  33. const Eigen::PlainObjectBase<DerivedX> & X,
  34. const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
  35. const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
  36. Eigen::PlainObjectBase<DerivedX> & Y);
  37. template <typename DerivedX>
  38. IGL_INLINE void slice_into(
  39. const Eigen::PlainObjectBase<DerivedX> & X,
  40. const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
  41. Eigen::PlainObjectBase<DerivedX> & Y);
  42. }
  43. #ifdef IGL_HEADER_ONLY
  44. # include "slice_into.cpp"
  45. #endif
  46. #endif