ismember.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 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_ISMEMBER_H
  9. #define IGL_ISMEMBER_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. // Determine if elements of A exist in elements of B
  15. //
  16. // Inputs:
  17. // A ma by na matrix
  18. // B mb by nb matrix
  19. // Outputs:
  20. // IA ma by na matrix of flags whether corresponding element of A exists in
  21. // B
  22. // LOCB ma by na matrix of indices in B locating matching element (-1 if
  23. // not found), indices assume column major ordering
  24. //
  25. template <
  26. typename DerivedA,
  27. typename DerivedB,
  28. typename DerivedIA,
  29. typename DerivedLOCB>
  30. IGL_INLINE void ismember(
  31. const Eigen::MatrixBase<DerivedA> & A,
  32. const Eigen::MatrixBase<DerivedB> & B,
  33. Eigen::PlainObjectBase<DerivedIA> & IA,
  34. Eigen::PlainObjectBase<DerivedLOCB> & LOCB);
  35. template <
  36. typename DerivedA,
  37. typename DerivedB,
  38. typename DerivedIA,
  39. typename DerivedLOCB>
  40. IGL_INLINE void ismember_rows(
  41. const Eigen::MatrixBase<DerivedA> & A,
  42. const Eigen::MatrixBase<DerivedB> & B,
  43. Eigen::PlainObjectBase<DerivedIA> & IA,
  44. Eigen::PlainObjectBase<DerivedLOCB> & LOCB);
  45. }
  46. #ifndef IGL_STATIC_LIBRARY
  47. # include "ismember.cpp"
  48. #endif
  49. #endif