mat_max.h 987 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef IGL_MAT_MAX_H
  2. #define IGL_MAT_MAX_H
  3. #include "igl_inline.h"
  4. #include <Eigen/Dense>
  5. namespace igl
  6. {
  7. // Ideally this becomes a super overloaded function supporting everything
  8. // that matlab's max supports
  9. // Max function for matrices to act like matlab's max function. Specifically
  10. // like [Y,I] = max(X,[],dim);
  11. //
  12. // Templates:
  13. // T should be a eigen matrix primitive type like int or double
  14. // Inputs:
  15. // X m by n matrix
  16. // dim dimension along which to take max
  17. // Outputs:
  18. // Y n-long vector (if dim == 1)
  19. // or
  20. // Y m-long vector (if dim == 2)
  21. // I vector the same size as Y containing the indices along dim of maximum
  22. // entries
  23. template <typename T>
  24. IGL_INLINE void mat_max(
  25. const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
  26. const int dim,
  27. Eigen::Matrix<T,Eigen::Dynamic,1> & Y,
  28. Eigen::Matrix<int,Eigen::Dynamic,1> & I);
  29. }
  30. #ifdef IGL_HEADER_ONLY
  31. # include "mat_max.cpp"
  32. #endif
  33. #endif