Chris@49
|
1 // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
|
Chris@49
|
2 // Copyright (C) 2009-2012 Conrad Sanderson
|
Chris@49
|
3 //
|
Chris@49
|
4 // This Source Code Form is subject to the terms of the Mozilla Public
|
Chris@49
|
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
|
Chris@49
|
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
Chris@49
|
7
|
Chris@49
|
8
|
Chris@49
|
9 //! \addtogroup fn_mean
|
Chris@49
|
10 //! @{
|
Chris@49
|
11
|
Chris@49
|
12
|
Chris@49
|
13
|
Chris@49
|
14 template<typename T1>
|
Chris@49
|
15 arma_inline
|
Chris@49
|
16 const Op<T1, op_mean>
|
Chris@49
|
17 mean
|
Chris@49
|
18 (
|
Chris@49
|
19 const T1& X,
|
Chris@49
|
20 const uword dim = 0,
|
Chris@49
|
21 const typename enable_if< is_arma_type<T1>::value == true >::result* junk1 = 0,
|
Chris@49
|
22 const typename enable_if< resolves_to_vector<T1>::value == false >::result* junk2 = 0
|
Chris@49
|
23 )
|
Chris@49
|
24 {
|
Chris@49
|
25 arma_extra_debug_sigprint();
|
Chris@49
|
26 arma_ignore(junk1);
|
Chris@49
|
27 arma_ignore(junk2);
|
Chris@49
|
28
|
Chris@49
|
29 return Op<T1, op_mean>(X, dim, 0);
|
Chris@49
|
30 }
|
Chris@49
|
31
|
Chris@49
|
32
|
Chris@49
|
33
|
Chris@49
|
34 template<typename T1>
|
Chris@49
|
35 arma_inline
|
Chris@49
|
36 const Op<T1, op_mean>
|
Chris@49
|
37 mean
|
Chris@49
|
38 (
|
Chris@49
|
39 const T1& X,
|
Chris@49
|
40 const uword dim,
|
Chris@49
|
41 const typename enable_if<resolves_to_vector<T1>::value == true>::result* junk = 0
|
Chris@49
|
42 )
|
Chris@49
|
43 {
|
Chris@49
|
44 arma_extra_debug_sigprint();
|
Chris@49
|
45 arma_ignore(junk);
|
Chris@49
|
46
|
Chris@49
|
47 return Op<T1, op_mean>(X, dim, 0);
|
Chris@49
|
48 }
|
Chris@49
|
49
|
Chris@49
|
50
|
Chris@49
|
51
|
Chris@49
|
52 template<typename T1>
|
Chris@49
|
53 inline
|
Chris@49
|
54 arma_warn_unused
|
Chris@49
|
55 typename T1::elem_type
|
Chris@49
|
56 mean
|
Chris@49
|
57 (
|
Chris@49
|
58 const T1& X,
|
Chris@49
|
59 const arma_empty_class junk1 = arma_empty_class(),
|
Chris@49
|
60 const typename enable_if<resolves_to_vector<T1>::value == true>::result* junk2 = 0
|
Chris@49
|
61 )
|
Chris@49
|
62 {
|
Chris@49
|
63 arma_extra_debug_sigprint();
|
Chris@49
|
64 arma_ignore(junk1);
|
Chris@49
|
65 arma_ignore(junk2);
|
Chris@49
|
66
|
Chris@49
|
67 return op_mean::mean_all(X);
|
Chris@49
|
68 }
|
Chris@49
|
69
|
Chris@49
|
70
|
Chris@49
|
71
|
Chris@49
|
72 //! \brief
|
Chris@49
|
73 //! Immediate 'find mean value' operation,
|
Chris@49
|
74 //! invoked, for example, by: mean(mean(A))
|
Chris@49
|
75 template<typename T1>
|
Chris@49
|
76 inline
|
Chris@49
|
77 arma_warn_unused
|
Chris@49
|
78 typename T1::elem_type
|
Chris@49
|
79 mean(const Op<T1, op_mean>& in)
|
Chris@49
|
80 {
|
Chris@49
|
81 arma_extra_debug_sigprint();
|
Chris@49
|
82 arma_extra_debug_print("mean(): two consecutive mean() calls detected");
|
Chris@49
|
83
|
Chris@49
|
84 return op_mean::mean_all(in.m);
|
Chris@49
|
85 }
|
Chris@49
|
86
|
Chris@49
|
87
|
Chris@49
|
88
|
Chris@49
|
89 template<typename T1>
|
Chris@49
|
90 arma_inline
|
Chris@49
|
91 const Op< Op<T1, op_mean>, op_mean>
|
Chris@49
|
92 mean(const Op<T1, op_mean>& in, const uword dim)
|
Chris@49
|
93 {
|
Chris@49
|
94 arma_extra_debug_sigprint();
|
Chris@49
|
95
|
Chris@49
|
96 return Op< Op<T1, op_mean>, op_mean>(in, dim, 0);
|
Chris@49
|
97 }
|
Chris@49
|
98
|
Chris@49
|
99
|
Chris@49
|
100
|
Chris@49
|
101 template<typename T>
|
Chris@49
|
102 arma_inline
|
Chris@49
|
103 arma_warn_unused
|
Chris@49
|
104 const typename arma_scalar_only<T>::result &
|
Chris@49
|
105 mean(const T& x)
|
Chris@49
|
106 {
|
Chris@49
|
107 return x;
|
Chris@49
|
108 }
|
Chris@49
|
109
|
Chris@49
|
110
|
Chris@49
|
111
|
Chris@49
|
112 template<typename T1>
|
Chris@49
|
113 inline
|
Chris@49
|
114 arma_warn_unused
|
Chris@49
|
115 const SpOp<T1, spop_mean>
|
Chris@49
|
116 mean
|
Chris@49
|
117 (
|
Chris@49
|
118 const T1& X,
|
Chris@49
|
119 const uword dim = 0,
|
Chris@49
|
120 const typename enable_if< is_arma_sparse_type<T1>::value == true >::result* junk1 = 0,
|
Chris@49
|
121 const typename enable_if< resolves_to_sparse_vector<T1>::value == false >::result* junk2 = 0
|
Chris@49
|
122 )
|
Chris@49
|
123 {
|
Chris@49
|
124 arma_extra_debug_sigprint();
|
Chris@49
|
125
|
Chris@49
|
126 arma_ignore(junk1);
|
Chris@49
|
127 arma_ignore(junk2);
|
Chris@49
|
128
|
Chris@49
|
129 return SpOp<T1, spop_mean>(X, dim, 0);
|
Chris@49
|
130 }
|
Chris@49
|
131
|
Chris@49
|
132
|
Chris@49
|
133
|
Chris@49
|
134 template<typename T1>
|
Chris@49
|
135 inline
|
Chris@49
|
136 arma_warn_unused
|
Chris@49
|
137 const SpOp<T1, spop_mean>
|
Chris@49
|
138 mean
|
Chris@49
|
139 (
|
Chris@49
|
140 const T1& X,
|
Chris@49
|
141 const uword dim,
|
Chris@49
|
142 const typename enable_if< resolves_to_sparse_vector<T1>::value == true >::result* junk1 = 0
|
Chris@49
|
143 )
|
Chris@49
|
144 {
|
Chris@49
|
145 arma_extra_debug_sigprint();
|
Chris@49
|
146 arma_ignore(junk1);
|
Chris@49
|
147
|
Chris@49
|
148 return SpOp<T1, spop_mean>(X, dim, 0);
|
Chris@49
|
149 }
|
Chris@49
|
150
|
Chris@49
|
151
|
Chris@49
|
152
|
Chris@49
|
153 template<typename T1>
|
Chris@49
|
154 inline
|
Chris@49
|
155 arma_warn_unused
|
Chris@49
|
156 typename T1::elem_type
|
Chris@49
|
157 mean
|
Chris@49
|
158 (
|
Chris@49
|
159 const T1& X,
|
Chris@49
|
160 const arma_empty_class junk1 = arma_empty_class(),
|
Chris@49
|
161 const typename enable_if< resolves_to_sparse_vector<T1>::value == true >::result* junk2 = 0
|
Chris@49
|
162 )
|
Chris@49
|
163 {
|
Chris@49
|
164 arma_extra_debug_sigprint();
|
Chris@49
|
165
|
Chris@49
|
166 arma_ignore(junk1);
|
Chris@49
|
167 arma_ignore(junk2);
|
Chris@49
|
168
|
Chris@49
|
169 return spop_mean::mean_all(X);
|
Chris@49
|
170 }
|
Chris@49
|
171
|
Chris@49
|
172
|
Chris@49
|
173
|
Chris@49
|
174 template<typename T1>
|
Chris@49
|
175 inline
|
Chris@49
|
176 arma_warn_unused
|
Chris@49
|
177 typename T1::elem_type
|
Chris@49
|
178 mean(const SpOp<T1, spop_mean>& in)
|
Chris@49
|
179 {
|
Chris@49
|
180 arma_extra_debug_sigprint();
|
Chris@49
|
181 arma_extra_debug_print("mean(): two consecutive mean() calls detected");
|
Chris@49
|
182
|
Chris@49
|
183 return spop_mean::mean_all(in.m);
|
Chris@49
|
184 }
|
Chris@49
|
185
|
Chris@49
|
186
|
Chris@49
|
187
|
Chris@49
|
188 //! @}
|