unique_rows.h 1.3 KB

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