mode.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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_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 dension
  15. //
  16. // Templates:
  17. // T should be a eigen matrix primitive type like int or double
  18. // Inputs:
  19. // X m by n original matrix
  20. // d dension along which to take mode, m or n
  21. // Outputs:
  22. // M vector containing mode along dension d, if d==1 then this will be a
  23. // n-long vector if d==2 then this will be a m-long vector
  24. template <typename T>
  25. IGL_INLINE void mode(
  26. const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
  27. const int d,
  28. Eigen::Matrix<T,Eigen::Dynamic,1> & M);
  29. }
  30. #ifndef IGL_STATIC_LIBRARY
  31. # include "mode.cpp"
  32. #endif
  33. #endif