fn_max.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 
17 
24 
25 template<typename T1>
27 const Op<T1, op_max>
28 max(const Base<typename T1::elem_type,T1>& X, const uword dim = 0)
29  {
31 
32  return Op<T1, op_max>(X.get_ref(), dim, 0);
33  }
34 
35 
37 template<typename eT>
38 inline
40 eT
41 max(const Row<eT>& A)
42  {
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 
55 template<typename eT>
56 inline
58 eT
59 max(const Col<eT>& A)
60  {
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 
75 template<typename T1>
76 inline
78 typename T1::elem_type
79 max(const Op<T1, op_max>& in)
80  {
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>
101 max(const Op<T1, op_max>& in, const uword dim)
102  {
104 
105  return Op< Op<T1, op_max>, op_max>(in, dim, 0);
106  }
107 
108 
109 
110 template<typename eT>
111 inline
113 eT
115  {
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
128 eT
130  {
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
143 eT
144 max(const Op<subview<eT>, op_max>& in)
145  {
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
161 eT
162 max(const diagview<eT>& A)
163  {
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
176 eT
178  {
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 
arma_inline const derived & get_ref() const
Definition: Base_meat.hpp:22
const uword n_rows
const uword n_elem
number of elements in the matrix (read-only)
Definition: Mat_bones.hpp:31
arma_inline const Op< T1, op_max > max(const Base< typename T1::elem_type, T1 > &X, const uword dim=0)
Delayed &#39;maximum values&#39; operation. The dimension, along which the maxima are found, is set via &#39;dim&#39;. For dim = 0, the maximum value of each column is found (i.e. searches by traversing across rows). For dim = 1, the maximum value of each row is found (i.e. searches by traversing across columns). The default is dim = 0.
Definition: fn_max.hpp:28
#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
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
Class for finding maximum values in a matrix.
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
static eT direct_max(const eT *const X, const uword N)
Dense matrix class.
#define arma_inline
const uword n_elem
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