mode.h 1.1 KB

1234567891011121314151617181920212223242526272829303132
  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_MODE_H
  9. #define IGL_MODE_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. namespace igl
  13. {
  14. /// Takes mode of coefficients in a matrix along a given dimension
  15. ///
  16. /// @tparam T should be a eigen matrix primitive type like int or double
  17. /// @param[in] X m by n original matrix
  18. /// @param[in] d dension along which to take mode, m or n
  19. /// @param[out] M vector containing mode along dension d, if d==1 then this will be a
  20. /// n-long vector if d==2 then this will be a m-long vector
  21. template <typename T>
  22. IGL_INLINE void mode(
  23. const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
  24. const int d,
  25. Eigen::Matrix<T,Eigen::Dynamic,1> & M);
  26. }
  27. #ifndef IGL_STATIC_LIBRARY
  28. # include "mode.cpp"
  29. #endif
  30. #endif