fn_min.hpp
Go to the documentation of this file.
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 
16 
23 
24 template<typename T1>
26 const Op<T1, op_min>
27 min(const Base<typename T1::elem_type,T1>& X, const uword dim = 0)
28  {
30 
31  return Op<T1, op_min>(X.get_ref(), dim, 0);
32  }
33 
34 
36 template<typename eT>
37 inline
39 eT
40 min(const Row<eT>& A)
41  {
43 
44  const uword A_n_elem = A.n_elem;
45 
46  arma_debug_check( (A_n_elem == 0), "min(): given object has no elements" );
47 
48  return op_min::direct_min(A.mem, A_n_elem);
49  }
50 
51 
52 
54 template<typename eT>
55 inline
57 eT
58 min(const Col<eT>& A)
59  {
61 
62  const uword A_n_elem = A.n_elem;
63 
64  arma_debug_check( (A_n_elem == 0), "min(): given object has no elements" );
65 
66  return op_min::direct_min(A.mem, A_n_elem);
67  }
68 
69 
70 
74 template<typename T1>
75 inline
77 typename T1::elem_type
78 min(const Op<T1, op_min>& in)
79  {
81  arma_extra_debug_print("min(): two consecutive min() calls detected");
82 
83  typedef typename T1::elem_type eT;
84 
85  const unwrap<T1> tmp1(in.m);
86  const Mat<eT>& X = tmp1.M;
87 
88  const uword X_n_elem = X.n_elem;
89 
90  arma_debug_check( (X_n_elem == 0), "min(): given object has no elements" );
91 
92  return op_min::direct_min(X.mem, X_n_elem);
93  }
94 
95 
96 
97 template<typename T1>
98 inline
100 min(const Op<T1, op_min>& in, const uword dim)
101  {
103 
104  return Op< Op<T1, op_min>, op_min>(in, dim, 0);
105  }
106 
107 
108 
109 template<typename eT>
110 inline
112 eT
114  {
116 
117  arma_debug_check( (A.n_elem == 0), "min(): given object has no elements" );
118 
119  return op_min::direct_min(A);
120  }
121 
122 
123 
124 template<typename eT>
125 inline
127 eT
129  {
131 
132  arma_debug_check( (A.n_elem == 0), "min(): given object has no elements" );
133 
134  return op_min::direct_min(A.colptr(0), A.n_rows);
135  }
136 
137 
138 
139 template<typename eT>
140 inline
142 eT
143 min(const diagview<eT>& A)
144  {
146 
147  arma_debug_check( (A.n_elem == 0), "min(): given object has no elements" );
148 
149  return op_min::direct_min(A);
150  }
151 
152 
153 
154 template<typename eT>
155 inline
157 eT
158 min(const Op<subview<eT>, op_min>& in)
159  {
161  arma_extra_debug_print("min(): two consecutive min() calls detected");
162 
163  const subview<eT>& X = in.m;
164 
165  arma_debug_check( (X.n_elem == 0), "min(): given object has no elements" );
166 
167  return op_min::direct_min(X);
168  }
169 
170 
171 
172 template<typename eT, typename T1>
173 inline
175 eT
177  {
179 
180  const Mat<eT> X(A);
181 
182  const uword X_n_elem = X.n_elem;
183 
184  arma_debug_check( (X_n_elem == 0), "min(): given object has no elements" );
185 
186  return op_min::direct_min(X.mem, X_n_elem);
187  }
188 
189 
190 
arma_inline const derived & get_ref() const
Definition: Base_meat.hpp:22
const uword n_rows
static eT direct_min(const eT *const X, const uword N)
const uword n_elem
number of elements in the matrix (read-only)
Definition: Mat_bones.hpp:31
#define arma_extra_debug_print
Definition: debug.hpp:1118
arma_aligned const T1 & m
storage of reference to the operand (eg. a matrix)
Definition: Op_bones.hpp:45
arma_inline const Op< T1, op_min > min(const Base< typename T1::elem_type, T1 > &X, const uword dim=0)
Delayed &#39;minimum values&#39; operation. The dimension, along which the minima are found, is set via &#39;dim&#39;. For dim = 0, the minimum value of each column is found (i.e. searches by traversing across rows). For dim = 1, the minimum value of each row is found (i.e. searches by traversing across columns). The default is dim = 0.
Definition: fn_min.hpp:27
const uword n_elem
u32 uword
Definition: typedef.hpp:85
Class for column vectors (matrices with only one column)
Definition: Col_bones.hpp:20
#define arma_debug_check
Definition: debug.hpp:1084
const Mat< eT > M
Definition: unwrap.hpp:32
arma_aligned const Mat< eT > & m
arma_inline eT * colptr(const uword in_col)
Class for row vectors (matrices with only one row)
#define arma_extra_debug_sigprint
Definition: debug.hpp:1116
#define arma_warn_unused
Dense matrix class.
#define arma_inline
const uword n_elem
Class for finding minimum values in a matrix.
arma_aligned const eT *const mem
pointer to the memory used by the matrix (memory is read-only)
Definition: Mat_bones.hpp:40
Class for storing data required to extract and set the diagonals of a matrix.


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:57