slice_mask.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. namespace igl
  13. {
  14. // Act like the matlab X(row_mask,col_mask) operator, where
  15. // row_mask, col_mask are non-negative integer indices.
  16. //
  17. // Inputs:
  18. // X m by n matrix
  19. // R m list of row bools
  20. // C n list of column bools
  21. // Output:
  22. // Y #trues-in-R by #trues-in-C matrix
  23. //
  24. // See also: slice_mask
  25. template <typename DerivedX>
  26. IGL_INLINE void slice_mask(
  27. const Eigen::PlainObjectBase<DerivedX> & X,
  28. const Eigen::Array<bool,Eigen::Dynamic,1> & R,
  29. const Eigen::Array<bool,Eigen::Dynamic,1> & C,
  30. Eigen::PlainObjectBase<DerivedX> & Y);
  31. template <typename DerivedX>
  32. IGL_INLINE void slice_mask(
  33. const Eigen::PlainObjectBase<DerivedX> & X,
  34. const Eigen::Array<bool,Eigen::Dynamic,1> & R,
  35. const int dim,
  36. Eigen::PlainObjectBase<DerivedX> & Y);
  37. template <typename DerivedX>
  38. IGL_INLINE Eigen::PlainObjectBase<DerivedX> slice_mask(
  39. const Eigen::PlainObjectBase<DerivedX> & X,
  40. const Eigen::Array<bool,Eigen::Dynamic,1> & R,
  41. const Eigen::Array<bool,Eigen::Dynamic,1> & C);
  42. template <typename DerivedX>
  43. IGL_INLINE Eigen::PlainObjectBase<DerivedX> slice_mask(
  44. const Eigen::PlainObjectBase<DerivedX> & X,
  45. const Eigen::Array<bool,Eigen::Dynamic,1> & R,
  46. const int dim);
  47. }
  48. #ifndef IGL_STATIC_LIBRARY
  49. # include "slice_mask.cpp"
  50. #endif
  51. #endif