comparison armadillo-3.900.4/include/armadillo_bits/fn_min.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_min
10 //! @{
11
12 //! \brief
13 //! Delayed 'minimum values' operation.
14 //! The dimension, along which the minima are found, is set via 'dim'.
15 //! For dim = 0, the minimum value of each column is found (i.e. searches by traversing across rows).
16 //! For dim = 1, the minimum value of each row is found (i.e. searches by traversing across columns).
17 //! The default is dim = 0.
18
19 template<typename T1>
20 arma_inline
21 const Op<T1, op_min>
22 min
23 (
24 const T1& X,
25 const uword dim = 0,
26 const typename enable_if< is_arma_type<T1>::value == true >::result* junk1 = 0,
27 const typename enable_if< resolves_to_vector<T1>::value == false >::result* junk2 = 0
28 )
29 {
30 arma_extra_debug_sigprint();
31 arma_ignore(junk1);
32 arma_ignore(junk2);
33
34 return Op<T1, op_min>(X, dim, 0);
35 }
36
37
38 template<typename T1>
39 arma_inline
40 const Op<T1, op_min>
41 min
42 (
43 const T1& X,
44 const uword dim,
45 const typename enable_if<resolves_to_vector<T1>::value == true>::result* junk = 0
46 )
47 {
48 arma_extra_debug_sigprint();
49 arma_ignore(junk);
50
51 return Op<T1, op_min>(X, dim, 0);
52 }
53
54
55
56 template<typename T1>
57 inline
58 arma_warn_unused
59 typename T1::elem_type
60 min
61 (
62 const T1& X,
63 const arma_empty_class junk1 = arma_empty_class(),
64 const typename enable_if<resolves_to_vector<T1>::value == true>::result* junk2 = 0
65 )
66 {
67 arma_extra_debug_sigprint();
68 arma_ignore(junk1);
69 arma_ignore(junk2);
70
71 return op_min::min(X);
72 }
73
74
75
76 //! \brief
77 //! Immediate 'find minimum value' operation,
78 //! invoked, for example, by: min(min(A))
79 template<typename T1>
80 inline
81 arma_warn_unused
82 typename T1::elem_type
83 min(const Op<T1, op_min>& in)
84 {
85 arma_extra_debug_sigprint();
86 arma_extra_debug_print("min(): two consecutive min() calls detected");
87
88 return op_min::min(in.m);
89 }
90
91
92
93 template<typename T1>
94 arma_inline
95 const Op< Op<T1, op_min>, op_min>
96 min(const Op<T1, op_min>& in, const uword dim)
97 {
98 arma_extra_debug_sigprint();
99
100 return Op< Op<T1, op_min>, op_min>(in, dim, 0);
101 }
102
103
104
105 template<typename T>
106 arma_inline
107 arma_warn_unused
108 const typename arma_scalar_only<T>::result &
109 min(const T& x)
110 {
111 return x;
112 }
113
114
115
116 template<typename T1>
117 inline
118 arma_warn_unused
119 typename
120 enable_if2
121 <
122 (is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1>::value == true),
123 typename T1::elem_type
124 >::result
125 min(const T1& x)
126 {
127 arma_extra_debug_sigprint();
128
129 return spop_min::vector_min(x);
130 }
131
132
133
134 template<typename T1>
135 inline
136 typename
137 enable_if2
138 <
139 (is_arma_sparse_type<T1>::value == true) && (resolves_to_sparse_vector<T1>::value == false),
140 const SpOp<T1, spop_min>
141 >::result
142 min(const T1& X, const uword dim = 0)
143 {
144 arma_extra_debug_sigprint();
145
146 return SpOp<T1, spop_min>(X, dim, 0);
147 }
148
149
150
151 template<typename T1>
152 inline
153 arma_warn_unused
154 typename T1::elem_type
155 min(const SpOp<T1, spop_min>& X)
156 {
157 arma_extra_debug_sigprint();
158 arma_extra_debug_print("min(): two consecutive min() calls detected");
159
160 return spop_min::vector_min(X.m);
161 }
162
163
164
165 template<typename T1>
166 inline
167 const SpOp< SpOp<T1, spop_min>, spop_min>
168 min(const SpOp<T1, spop_min>& in, const uword dim)
169 {
170 arma_extra_debug_sigprint();
171
172 return SpOp< SpOp<T1, spop_min>, spop_min>(in, dim, 0);
173 }
174
175
176
177 //! @}