unique_rows.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2017 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_ROWS_H
  9. #define IGL_UNIQUE_ROWS_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,'rows')
  16. //
  17. // Templates:
  18. // DerivedA derived scalar type, e.g. MatrixXi or MatrixXd
  19. // DerivedIA derived integer type, e.g. MatrixXi
  20. // DerivedIC derived integer type, e.g. MatrixXi
  21. // Inputs:
  22. // A m by n matrix whose entries are to unique'd according to rows
  23. // Outputs:
  24. // C #C vector of unique rows in A
  25. // IA #C index vector so that C = A(IA,:);
  26. // IC #A index vector so that A = C(IC,:);
  27. template <typename DerivedA, typename DerivedC, typename DerivedIA, typename DerivedIC>
  28. IGL_INLINE void unique_rows(
  29. const Eigen::DenseBase<DerivedA>& A,
  30. Eigen::PlainObjectBase<DerivedC>& C,
  31. Eigen::PlainObjectBase<DerivedIA>& IA,
  32. Eigen::PlainObjectBase<DerivedIC>& IC);
  33. }
  34. #ifndef IGL_STATIC_LIBRARY
  35. # include "unique_rows.cpp"
  36. #endif
  37. #endif