mat_max.h 1.3 KB

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