op_median_proto.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2009 NICTA
00002 // 
00003 // Authors:
00004 // - Conrad Sanderson (conradsand at ieee dot org)
00005 // 
00006 // This file is part of the Armadillo C++ library.
00007 // It is provided without any warranty of fitness
00008 // for any purpose. You can redistribute this file
00009 // and/or modify it under the terms of the GNU
00010 // Lesser General Public License (LGPL) as published
00011 // by the Free Software Foundation, either version 3
00012 // of the License or (at your option) any later version.
00013 // (see http://www.opensource.org/licenses for more info)
00014 
00015 
00016 //! \addtogroup op_median
00017 //! @{
00018 
00019 
00020 template<typename T>
00021 struct arma_cx_median_packet
00022   {
00023   T   val;
00024   u32 index;
00025   };
00026 
00027 
00028 
00029 template<typename T>
00030 inline
00031 bool
00032 operator< (const arma_cx_median_packet<T>& A, const arma_cx_median_packet<T>& B)
00033   {
00034   return A.val < B.val;
00035   }
00036 
00037 
00038 
00039 //! Class for finding median values of a matrix
00040 class op_median
00041   {
00042   public:
00043   
00044   template<typename eT>
00045   inline static eT              direct_median(std::vector<eT>& X);
00046   
00047   template<typename eT>
00048   inline static eT              direct_median(const eT* X, const u32 n_elem);
00049   
00050   template<typename eT>
00051   inline static eT              direct_median(const subview<eT>& X);
00052   
00053   template<typename eT>
00054   inline static eT              direct_median(const diagview<eT>& X);
00055   
00056   template<typename T1>
00057   inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_median>& in);
00058   
00059   
00060   //
00061   // for complex numbers
00062   
00063   template<typename T>
00064   inline static void direct_cx_median_index(u32& out_index1, u32& out_index2, std::vector< arma_cx_median_packet<T> >& X);
00065   
00066   template<typename T>
00067   inline static void direct_cx_median_index(u32& out_index1, u32& out_index2, const std::complex<T>* X, const u32 n_elem);
00068   
00069   template<typename T>
00070   inline static void direct_cx_median_index(u32& out_index1, u32& out_index2, const subview< std::complex<T> >& X);
00071   
00072   template<typename T>
00073   inline static void direct_cx_median_index(u32& out_index1, u32& out_index2, const diagview< std::complex<T> >& X);
00074   
00075   template<typename T, typename T1>
00076   inline static void apply(Mat< std::complex<T> >& out, const Op<T1,op_median>& in);
00077   
00078   
00079   };
00080 
00081 //! @}