histc.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_histc_H
  9. #define IGL_histc_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. // Like matlab's histc. Count occurances of values in X between consecutive
  15. // entries in E
  16. //
  17. // Inputs:
  18. // X m-long Vector of values
  19. // E n-long Monotonically increasing vector of edges
  20. // Outputs:
  21. // N n-long vector where N(k) reveals how many values in X fall between
  22. // E(k) <= X < E(k+1)
  23. // B m-long vector of bin ids so that B(j) = k if E(k) <= X(j) < E(k+1).
  24. // B(j) = -1 if X(j) is outside of E.
  25. //
  26. template <typename DerivedX, typename DerivedE, typename DerivedN, typename DerivedB>
  27. IGL_INLINE void histc(
  28. const Eigen::PlainObjectBase<DerivedX > & X,
  29. const Eigen::PlainObjectBase<DerivedE > & E,
  30. Eigen::PlainObjectBase<DerivedN > & N,
  31. Eigen::PlainObjectBase<DerivedB > & B);
  32. }
  33. #ifdef IGL_HEADER_ONLY
  34. # include "histc.cpp"
  35. #endif
  36. #endif