Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/fn_max.hpp @ 49:1ec0e2823891
Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author | Chris Cannam |
---|---|
date | Thu, 13 Jun 2013 10:25:24 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
48:69251e11a913 | 49:1ec0e2823891 |
---|---|
1 // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2008-2012 Conrad Sanderson | |
3 // | |
4 // This Source Code Form is subject to the terms of the Mozilla Public | |
5 // License, v. 2.0. If a copy of the MPL was not distributed with this | |
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
7 | |
8 | |
9 //! \addtogroup fn_max | |
10 //! @{ | |
11 | |
12 | |
13 //! \brief | |
14 //! Delayed 'maximum values' operation. | |
15 //! The dimension, along which the maxima are found, is set via 'dim'. | |
16 //! For dim = 0, the maximum value of each column is found (i.e. searches by traversing across rows). | |
17 //! For dim = 1, the maximum value of each row is found (i.e. searches by traversing across columns). | |
18 //! The default is dim = 0. | |
19 | |
20 template<typename T1> | |
21 arma_inline | |
22 const Op<T1, op_max> | |
23 max | |
24 ( | |
25 const T1& X, | |
26 const uword dim = 0, | |
27 const typename enable_if< is_arma_type<T1>::value == true >::result* junk1 = 0, | |
28 const typename enable_if< resolves_to_vector<T1>::value == false >::result* junk2 = 0 | |
29 ) | |
30 { | |
31 arma_extra_debug_sigprint(); | |
32 arma_ignore(junk1); | |
33 arma_ignore(junk2); | |
34 | |
35 return Op<T1, op_max>(X, dim, 0); | |
36 } | |
37 | |
38 | |
39 | |
40 template<typename T1> | |
41 arma_inline | |
42 const Op<T1, op_max> | |
43 max | |
44 ( | |
45 const T1& X, | |
46 const uword dim, | |
47 const typename enable_if<resolves_to_vector<T1>::value == true>::result* junk = 0 | |
48 ) | |
49 { | |
50 arma_extra_debug_sigprint(); | |
51 arma_ignore(junk); | |
52 | |
53 return Op<T1, op_max>(X, dim, 0); | |
54 } | |
55 | |
56 | |
57 | |
58 template<typename T1> | |
59 inline | |
60 arma_warn_unused | |
61 typename T1::elem_type | |
62 max | |
63 ( | |
64 const T1& X, | |
65 const arma_empty_class junk1 = arma_empty_class(), | |
66 const typename enable_if<resolves_to_vector<T1>::value == true>::result* junk2 = 0 | |
67 ) | |
68 { | |
69 arma_extra_debug_sigprint(); | |
70 arma_ignore(junk1); | |
71 arma_ignore(junk2); | |
72 | |
73 return op_max::max(X); | |
74 } | |
75 | |
76 | |
77 | |
78 //! \brief | |
79 //! Immediate 'find maximum value' operation, | |
80 //! invoked, for example, by: max(max(A)) | |
81 template<typename T1> | |
82 inline | |
83 arma_warn_unused | |
84 typename T1::elem_type | |
85 max(const Op<T1, op_max>& in) | |
86 { | |
87 arma_extra_debug_sigprint(); | |
88 arma_extra_debug_print("max(): two consecutive max() calls detected"); | |
89 | |
90 return op_max::max(in.m); | |
91 } | |
92 | |
93 | |
94 | |
95 template<typename T1> | |
96 arma_inline | |
97 const Op< Op<T1, op_max>, op_max> | |
98 max(const Op<T1, op_max>& in, const uword dim) | |
99 { | |
100 arma_extra_debug_sigprint(); | |
101 | |
102 return Op< Op<T1, op_max>, op_max>(in, dim, 0); | |
103 } | |
104 | |
105 | |
106 | |
107 template<typename T> | |
108 arma_inline | |
109 arma_warn_unused | |
110 const typename arma_scalar_only<T>::result & | |
111 max(const T& x) | |
112 { | |
113 return x; | |
114 } | |
115 | |
116 | |
117 | |
118 | |
119 template<typename T1> | |
120 inline | |
121 arma_warn_unused | |
122 typename | |
123 enable_if2 | |
124 < | |
125 (is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1>::value == true), | |
126 typename T1::elem_type | |
127 >::result | |
128 max(const T1& x) | |
129 { | |
130 arma_extra_debug_sigprint(); | |
131 | |
132 return spop_max::vector_max(x); | |
133 } | |
134 | |
135 | |
136 | |
137 template<typename T1> | |
138 inline | |
139 typename | |
140 enable_if2 | |
141 < | |
142 (is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1>::value == false), | |
143 const SpOp<T1, spop_max> | |
144 >::result | |
145 max(const T1& X, const uword dim = 0) | |
146 { | |
147 arma_extra_debug_sigprint(); | |
148 | |
149 return SpOp<T1, spop_max>(X, dim, 0); | |
150 } | |
151 | |
152 | |
153 | |
154 template<typename T1> | |
155 inline | |
156 arma_warn_unused | |
157 typename T1::elem_type | |
158 max(const SpOp<T1, spop_max>& X) | |
159 { | |
160 arma_extra_debug_sigprint(); | |
161 arma_extra_debug_print("max(): two consecutive max() calls detected"); | |
162 | |
163 return spop_max::vector_max(X.m); | |
164 } | |
165 | |
166 | |
167 | |
168 template<typename T1> | |
169 inline | |
170 const SpOp< SpOp<T1, spop_max>, spop_max> | |
171 max(const SpOp<T1, spop_max>& in, const uword dim) | |
172 { | |
173 arma_extra_debug_sigprint(); | |
174 | |
175 return SpOp< SpOp<T1, spop_max>, spop_max>(in, dim, 0); | |
176 } | |
177 | |
178 | |
179 | |
180 //! @} |