Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-2.4.4/include/armadillo_bits/fn_max.hpp @ 0:8b6102e2a9b0
Armadillo Library
author | maxzanoni76 <max.zanoni@eecs.qmul.ac.uk> |
---|---|
date | Wed, 11 Apr 2012 09:27:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8b6102e2a9b0 |
---|---|
1 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2008-2011 Conrad Sanderson | |
3 // | |
4 // This file is part of the Armadillo C++ library. | |
5 // It is provided without any warranty of fitness | |
6 // for any purpose. You can redistribute this file | |
7 // and/or modify it under the terms of the GNU | |
8 // Lesser General Public License (LGPL) as published | |
9 // by the Free Software Foundation, either version 3 | |
10 // of the License or (at your option) any later version. | |
11 // (see http://www.opensource.org/licenses for more info) | |
12 | |
13 | |
14 //! \addtogroup fn_max | |
15 //! @{ | |
16 | |
17 | |
18 //! \brief | |
19 //! Delayed 'maximum values' operation. | |
20 //! The dimension, along which the maxima are found, is set via 'dim'. | |
21 //! For dim = 0, the maximum value of each column is found (i.e. searches by traversing across rows). | |
22 //! For dim = 1, the maximum value of each row is found (i.e. searches by traversing across columns). | |
23 //! The default is dim = 0. | |
24 | |
25 template<typename T1> | |
26 arma_inline | |
27 const Op<T1, op_max> | |
28 max(const Base<typename T1::elem_type,T1>& X, const uword dim = 0) | |
29 { | |
30 arma_extra_debug_sigprint(); | |
31 | |
32 return Op<T1, op_max>(X.get_ref(), dim, 0); | |
33 } | |
34 | |
35 | |
36 //! Immediate 'find the maximum value in a row vector' operation | |
37 template<typename eT> | |
38 inline | |
39 arma_warn_unused | |
40 eT | |
41 max(const Row<eT>& A) | |
42 { | |
43 arma_extra_debug_sigprint(); | |
44 | |
45 const uword A_n_elem = A.n_elem; | |
46 | |
47 arma_debug_check( (A_n_elem == 0), "max(): given object has no elements" ); | |
48 | |
49 return op_max::direct_max(A.mem, A_n_elem); | |
50 } | |
51 | |
52 | |
53 | |
54 //! Immediate 'find the maximum value in a column vector' operation | |
55 template<typename eT> | |
56 inline | |
57 arma_warn_unused | |
58 eT | |
59 max(const Col<eT>& A) | |
60 { | |
61 arma_extra_debug_sigprint(); | |
62 | |
63 const uword A_n_elem = A.n_elem; | |
64 | |
65 arma_debug_check( (A_n_elem == 0), "max(): given object has no elements" ); | |
66 | |
67 return op_max::direct_max(A.mem, A_n_elem); | |
68 } | |
69 | |
70 | |
71 | |
72 //! \brief | |
73 //! Immediate 'find maximum value' operation, | |
74 //! invoked, for example, by: max(max(A)) | |
75 template<typename T1> | |
76 inline | |
77 arma_warn_unused | |
78 typename T1::elem_type | |
79 max(const Op<T1, op_max>& in) | |
80 { | |
81 arma_extra_debug_sigprint(); | |
82 arma_extra_debug_print("max(): two consecutive max() calls detected"); | |
83 | |
84 typedef typename T1::elem_type eT; | |
85 | |
86 const unwrap<T1> tmp1(in.m); | |
87 const Mat<eT>& X = tmp1.M; | |
88 | |
89 const uword X_n_elem = X.n_elem; | |
90 | |
91 arma_debug_check( (X_n_elem == 0), "max(): given object has no elements" ); | |
92 | |
93 return op_max::direct_max(X.mem, X_n_elem); | |
94 } | |
95 | |
96 | |
97 | |
98 template<typename T1> | |
99 arma_inline | |
100 const Op< Op<T1, op_max>, op_max> | |
101 max(const Op<T1, op_max>& in, const uword dim) | |
102 { | |
103 arma_extra_debug_sigprint(); | |
104 | |
105 return Op< Op<T1, op_max>, op_max>(in, dim, 0); | |
106 } | |
107 | |
108 | |
109 | |
110 template<typename eT> | |
111 inline | |
112 arma_warn_unused | |
113 eT | |
114 max(const subview_row<eT>& A) | |
115 { | |
116 arma_extra_debug_sigprint(); | |
117 | |
118 arma_debug_check( (A.n_elem == 0), "max(): given object has no elements" ); | |
119 | |
120 return op_max::direct_max(A); | |
121 } | |
122 | |
123 | |
124 | |
125 template<typename eT> | |
126 inline | |
127 arma_warn_unused | |
128 eT | |
129 max(const subview_col<eT>& A) | |
130 { | |
131 arma_extra_debug_sigprint(); | |
132 | |
133 arma_debug_check( (A.n_elem == 0), "max(): given object has no elements" ); | |
134 | |
135 return op_max::direct_max(A.colptr(0), A.n_rows); | |
136 } | |
137 | |
138 | |
139 | |
140 template<typename eT> | |
141 inline | |
142 arma_warn_unused | |
143 eT | |
144 max(const Op<subview<eT>, op_max>& in) | |
145 { | |
146 arma_extra_debug_sigprint(); | |
147 arma_extra_debug_print("max(): two consecutive max() calls detected"); | |
148 | |
149 const subview<eT>& X = in.m; | |
150 | |
151 arma_debug_check( (X.n_elem == 0), "max(): given object has no elements" ); | |
152 | |
153 return op_max::direct_max(X); | |
154 } | |
155 | |
156 | |
157 | |
158 template<typename eT> | |
159 inline | |
160 arma_warn_unused | |
161 eT | |
162 max(const diagview<eT>& A) | |
163 { | |
164 arma_extra_debug_sigprint(); | |
165 | |
166 arma_debug_check( (A.n_elem == 0), "max(): given object has no elements" ); | |
167 | |
168 return op_max::direct_max(A); | |
169 } | |
170 | |
171 | |
172 | |
173 template<typename eT, typename T1> | |
174 inline | |
175 arma_warn_unused | |
176 eT | |
177 max(const subview_elem1<eT,T1>& A) | |
178 { | |
179 arma_extra_debug_sigprint(); | |
180 | |
181 const Mat<eT> X(A); | |
182 | |
183 const uword X_n_elem = X.n_elem; | |
184 | |
185 arma_debug_check( (X_n_elem == 0), "max(): given object has no elements" ); | |
186 | |
187 return op_max::direct_max(X.mem, X_n_elem); | |
188 } | |
189 | |
190 | |
191 | |
192 //! @} |