unique.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  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_UNIQUE_H
  9. #define IGL_UNIQUE_H
  10. #include "igl_inline.h"
  11. #include <vector>
  12. #include <Eigen/Core>
  13. namespace igl
  14. {
  15. /// Act like matlab's [C,IA,IC] = unique(X)
  16. ///
  17. /// @tparam T comparable type T
  18. /// @param[in] A #A vector of type T
  19. /// @param[out] C #C vector of unique entries in A
  20. /// @param[out] IA #C index vector so that C = A(IA);
  21. /// @param[out] IC #A index vector so that A = C(IC);
  22. template <typename T>
  23. IGL_INLINE void unique(
  24. const std::vector<T> & A,
  25. std::vector<T> & C,
  26. std::vector<size_t> & IA,
  27. std::vector<size_t> & IC);
  28. /// \overload
  29. template <typename T>
  30. IGL_INLINE void unique(
  31. const std::vector<T> & A,
  32. std::vector<T> & C);
  33. /// \overload
  34. template <
  35. typename DerivedA,
  36. typename DerivedC,
  37. typename DerivedIA,
  38. typename DerivedIC>
  39. IGL_INLINE void unique(
  40. const Eigen::MatrixBase<DerivedA> & A,
  41. Eigen::PlainObjectBase<DerivedC> & C,
  42. Eigen::PlainObjectBase<DerivedIA> & IA,
  43. Eigen::PlainObjectBase<DerivedIC> & IC);
  44. /// \overload
  45. template <
  46. typename DerivedA,
  47. typename DerivedC>
  48. IGL_INLINE void unique(
  49. const Eigen::MatrixBase<DerivedA> & A,
  50. Eigen::PlainObjectBase<DerivedC> & C);
  51. }
  52. #ifndef IGL_STATIC_LIBRARY
  53. # include "unique.cpp"
  54. #endif
  55. #endif