op_median_bones.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
  2. // Copyright 2008-2016 National ICT Australia (NICTA)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // ------------------------------------------------------------------------
  15. //! \addtogroup op_median
  16. //! @{
  17. template<typename T>
  18. struct arma_cx_median_packet
  19. {
  20. T val;
  21. uword index;
  22. };
  23. template<typename T>
  24. arma_inline
  25. bool
  26. operator< (const arma_cx_median_packet<T>& A, const arma_cx_median_packet<T>& B)
  27. {
  28. return A.val < B.val;
  29. }
  30. //! Class for finding median values of a matrix
  31. class op_median
  32. : public traits_op_xvec
  33. {
  34. public:
  35. template<typename eT, typename T1>
  36. inline static void apply(Mat<eT>& out, const Op<T1,op_median>& in, const typename arma_not_cx<eT>::result* junk = 0);
  37. template<typename eT, typename T1>
  38. inline static void apply(Mat<eT>& out, const Op<T1,op_median>& in, const typename arma_cx_only<eT>::result* junk = 0);
  39. //
  40. //
  41. template<typename T1>
  42. inline static typename T1::elem_type median_vec(const T1& X, const typename arma_not_cx<typename T1::elem_type>::result* junk = 0);
  43. template<typename T1>
  44. inline static typename T1::elem_type median_vec(const T1& X, const typename arma_cx_only<typename T1::elem_type>::result* junk = 0);
  45. //
  46. //
  47. template<typename eT>
  48. inline static eT direct_median(std::vector<eT>& X);
  49. template<typename T>
  50. inline static void direct_cx_median_index(uword& out_index1, uword& out_index2, std::vector< arma_cx_median_packet<T> >& X);
  51. };
  52. //! @}