max@0
|
1 // Copyright (C) 2009-2010 NICTA (www.nicta.com.au)
|
max@0
|
2 // Copyright (C) 2009-2010 Conrad Sanderson
|
max@0
|
3 //
|
max@0
|
4 // This file is part of the Armadillo C++ library.
|
max@0
|
5 // It is provided without any warranty of fitness
|
max@0
|
6 // for any purpose. You can redistribute this file
|
max@0
|
7 // and/or modify it under the terms of the GNU
|
max@0
|
8 // Lesser General Public License (LGPL) as published
|
max@0
|
9 // by the Free Software Foundation, either version 3
|
max@0
|
10 // of the License or (at your option) any later version.
|
max@0
|
11 // (see http://www.opensource.org/licenses for more info)
|
max@0
|
12
|
max@0
|
13
|
max@0
|
14 //! \addtogroup op_median
|
max@0
|
15 //! @{
|
max@0
|
16
|
max@0
|
17
|
max@0
|
18 template<typename T>
|
max@0
|
19 struct arma_cx_median_packet
|
max@0
|
20 {
|
max@0
|
21 T val;
|
max@0
|
22 uword index;
|
max@0
|
23 };
|
max@0
|
24
|
max@0
|
25
|
max@0
|
26
|
max@0
|
27 template<typename T>
|
max@0
|
28 inline
|
max@0
|
29 bool
|
max@0
|
30 operator< (const arma_cx_median_packet<T>& A, const arma_cx_median_packet<T>& B)
|
max@0
|
31 {
|
max@0
|
32 return A.val < B.val;
|
max@0
|
33 }
|
max@0
|
34
|
max@0
|
35
|
max@0
|
36
|
max@0
|
37 //! Class for finding median values of a matrix
|
max@0
|
38 class op_median
|
max@0
|
39 {
|
max@0
|
40 public:
|
max@0
|
41
|
max@0
|
42 template<typename eT>
|
max@0
|
43 arma_inline static eT robust_mean(const eT A, const eT B);
|
max@0
|
44
|
max@0
|
45 template<typename eT>
|
max@0
|
46 inline static eT direct_median(std::vector<eT>& X);
|
max@0
|
47
|
max@0
|
48 template<typename eT>
|
max@0
|
49 inline static eT direct_median(const eT* X, const uword n_elem);
|
max@0
|
50
|
max@0
|
51 template<typename eT>
|
max@0
|
52 inline static eT direct_median(const subview<eT>& X);
|
max@0
|
53
|
max@0
|
54 template<typename eT>
|
max@0
|
55 inline static eT direct_median(const diagview<eT>& X);
|
max@0
|
56
|
max@0
|
57 template<typename T1>
|
max@0
|
58 inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_median>& in);
|
max@0
|
59
|
max@0
|
60
|
max@0
|
61 //
|
max@0
|
62 // for complex numbers
|
max@0
|
63
|
max@0
|
64 template<typename T>
|
max@0
|
65 arma_inline static std::complex<T> robust_mean(const std::complex<T>& A, const std::complex<T>& B);
|
max@0
|
66
|
max@0
|
67 template<typename T>
|
max@0
|
68 inline static void direct_cx_median_index(uword& out_index1, uword& out_index2, std::vector< arma_cx_median_packet<T> >& X);
|
max@0
|
69
|
max@0
|
70 template<typename T>
|
max@0
|
71 inline static void direct_cx_median_index(uword& out_index1, uword& out_index2, const std::complex<T>* X, const uword n_elem);
|
max@0
|
72
|
max@0
|
73 template<typename T>
|
max@0
|
74 inline static void direct_cx_median_index(uword& out_index1, uword& out_index2, const subview< std::complex<T> >& X);
|
max@0
|
75
|
max@0
|
76 template<typename T>
|
max@0
|
77 inline static void direct_cx_median_index(uword& out_index1, uword& out_index2, const diagview< std::complex<T> >& X);
|
max@0
|
78
|
max@0
|
79 template<typename T, typename T1>
|
max@0
|
80 inline static void apply(Mat< std::complex<T> >& out, const Op<T1,op_median>& in);
|
max@0
|
81
|
max@0
|
82
|
max@0
|
83 };
|
max@0
|
84
|
max@0
|
85 //! @}
|