unique.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_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. // Templates:
  18. // T comparable type T
  19. // Inputs:
  20. // A #A vector of type T
  21. // Outputs:
  22. // C #C vector of unique entries in A
  23. // IA #C index vector so that C = A(IA);
  24. // IC #A index vector so that A = C(IC);
  25. template <typename T>
  26. IGL_INLINE void unique(
  27. const std::vector<T> & A,
  28. std::vector<T> & C,
  29. std::vector<size_t> & IA,
  30. std::vector<size_t> & IC);
  31. template <typename T>
  32. IGL_INLINE void unique(
  33. const std::vector<T> & A,
  34. std::vector<T> & C);
  35. template <
  36. typename DerivedA,
  37. typename DerivedC,
  38. typename DerivedIA,
  39. typename DerivedIC>
  40. IGL_INLINE void unique(
  41. const Eigen::DenseBase<DerivedA> & A,
  42. Eigen::PlainObjectBase<DerivedC> & C,
  43. Eigen::PlainObjectBase<DerivedIA> & IA,
  44. Eigen::PlainObjectBase<DerivedIC> & IC);
  45. template <
  46. typename DerivedA,
  47. typename DerivedC>
  48. IGL_INLINE void unique(
  49. const Eigen::DenseBase<DerivedA> & A,
  50. Eigen::PlainObjectBase<DerivedC> & C);
  51. }
  52. #ifndef IGL_STATIC_LIBRARY
  53. # include "unique.cpp"
  54. #endif
  55. #endif