slice_mask.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 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_MASK_H
  9. #define IGL_SLICE_MASK_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Sparse>
  12. #include <Eigen/Core>
  13. namespace igl
  14. {
  15. // Act like the matlab X(row_mask,col_mask) operator, where
  16. // row_mask, col_mask are non-negative integer indices.
  17. //
  18. // Inputs:
  19. // X m by n matrix
  20. // R m list of row bools
  21. // C n list of column bools
  22. // Output:
  23. // Y #trues-in-R by #trues-in-C matrix
  24. //
  25. // See also: slice_mask
  26. template <typename DerivedX>
  27. IGL_INLINE void slice_mask(
  28. const Eigen::PlainObjectBase<DerivedX> & X,
  29. const Eigen::Array<bool,Eigen::Dynamic,1> & R,
  30. const Eigen::Array<bool,Eigen::Dynamic,1> & C,
  31. Eigen::PlainObjectBase<DerivedX> & Y);
  32. template <typename DerivedX>
  33. IGL_INLINE void slice_mask(
  34. const Eigen::PlainObjectBase<DerivedX> & X,
  35. const Eigen::Array<bool,Eigen::Dynamic,1> & R,
  36. const int dim,
  37. Eigen::PlainObjectBase<DerivedX> & Y);
  38. template <typename DerivedX>
  39. IGL_INLINE Eigen::PlainObjectBase<DerivedX> slice_mask(
  40. const Eigen::PlainObjectBase<DerivedX> & X,
  41. const Eigen::Array<bool,Eigen::Dynamic,1> & R,
  42. const Eigen::Array<bool,Eigen::Dynamic,1> & C);
  43. template <typename DerivedX>
  44. IGL_INLINE Eigen::PlainObjectBase<DerivedX> slice_mask(
  45. const Eigen::PlainObjectBase<DerivedX> & X,
  46. const Eigen::Array<bool,Eigen::Dynamic,1> & R,
  47. const int dim);
  48. }
  49. #ifndef IGL_STATIC_LIBRARY
  50. # include "slice_mask.cpp"
  51. #endif
  52. #endif