Classes | |
class | op_min |
Class for finding minimum values in a matrix. More... | |
Functions | |
template<typename eT > | |
static eT | op_min::direct_min (const eT *const X, const u32 N) |
Find the minimum value in an array. | |
template<typename eT > | |
static eT | op_min::direct_min (const subview< eT > &X) |
find the minimum value in a subview | |
template<typename eT > | |
static eT | op_min::direct_min (const diagview< eT > &X) |
find the minimum value in a diagview | |
template<typename T1 > | |
static void | op_min::apply (Mat< typename T1::elem_type > &out, const Op< T1, op_min > &in) |
For each row or for each column, find the minimum value. The result is stored in a dense matrix that has either one column or one row. The dimension, for which the minima are found, is set via the min() function. | |
template<typename T > | |
static std::complex< T > | op_min::direct_min (const std::complex< T > *const X, const u32 n_elem) |
Find the minimum value in an array (version for complex numbers). | |
template<typename T > | |
static std::complex< T > | op_min::direct_min (const subview< std::complex< T > > &X) |
Find the minimum value in a subview (version for complex numbers). | |
template<typename T > | |
static std::complex< T > | op_min::direct_min (const diagview< std::complex< T > > &X) |
Find the minimum value in a diagview (version for complex numbers). | |
template<typename T , typename T1 > | |
static void | op_min::apply (Mat< std::complex< T > > &out, const Op< T1, op_min > &in) |
Implementation for complex numbers. |
eT op_min::direct_min | ( | const eT *const | X, | |
const u32 | N | |||
) | [inline, static, inherited] |
Find the minimum value in an array.
Definition at line 24 of file op_min_meat.hpp.
Referenced by apply(), and min().
00025 { 00026 arma_extra_debug_sigprint(); 00027 00028 eT min_val = X[0]; 00029 00030 for(u32 i=1; i<n_elem; ++i) 00031 { 00032 const eT tmp_val = X[i]; 00033 00034 if(tmp_val < min_val) 00035 { 00036 min_val = tmp_val; 00037 } 00038 } 00039 00040 return min_val; 00041 }
eT op_min::direct_min | ( | const subview< eT > & | X | ) | [inline, static, inherited] |
find the minimum value in a subview
Definition at line 49 of file op_min_meat.hpp.
References subview< eT >::n_elem.
00050 { 00051 arma_extra_debug_sigprint(); 00052 00053 eT min_val = X[0]; 00054 00055 for(u32 i=1; i<X.n_elem; ++i) 00056 { 00057 eT tmp_val = X[i]; 00058 00059 if(tmp_val < min_val) 00060 { 00061 min_val = tmp_val; 00062 } 00063 } 00064 00065 return min_val; 00066 }
eT op_min::direct_min | ( | const diagview< eT > & | X | ) | [inline, static, inherited] |
find the minimum value in a diagview
Definition at line 74 of file op_min_meat.hpp.
References diagview< eT >::n_elem.
00075 { 00076 arma_extra_debug_sigprint(); 00077 00078 eT min_val = X[0]; 00079 00080 for(u32 i=1; i<X.n_elem; ++i) 00081 { 00082 eT tmp_val = X[i]; 00083 00084 if(tmp_val < min_val) 00085 { 00086 min_val = tmp_val; 00087 } 00088 } 00089 00090 return min_val; 00091 }
void op_min::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Op< T1, op_min > & | in | |||
) | [inline, static, inherited] |
For each row or for each column, find the minimum value. The result is stored in a dense matrix that has either one column or one row. The dimension, for which the minima are found, is set via the min() function.
Definition at line 100 of file op_min_meat.hpp.
References Mat< eT >::at(), Op< T1, op_type >::aux_u32_a, Mat< eT >::colptr(), direct_min(), Op< T1, op_type >::m, Mat< eT >::n_cols, Mat< eT >::n_elem, Mat< eT >::n_rows, and Mat< eT >::set_size().
00101 { 00102 arma_extra_debug_sigprint(); 00103 00104 typedef typename T1::elem_type eT; 00105 00106 const unwrap_check<T1> tmp(in.m, out); 00107 const Mat<eT>& X = tmp.M; 00108 00109 arma_debug_check( (X.n_elem == 0), "op_min::apply(): given matrix has no elements" ); 00110 00111 const u32 dim = in.aux_u32_a; 00112 arma_debug_check( (dim > 1), "op_min::apply(): incorrect usage. dim must be 0 or 1"); 00113 00114 00115 if(dim == 0) // column-wise min 00116 { 00117 arma_extra_debug_print("op_min::apply(), dim = 0"); 00118 00119 out.set_size(1, X.n_cols); 00120 00121 for(u32 col=0; col<X.n_cols; ++col) 00122 { 00123 out[col] = op_min::direct_min( X.colptr(col), X.n_rows ); 00124 } 00125 } 00126 else 00127 if(dim == 1) // row-wise min 00128 { 00129 arma_extra_debug_print("op_min::apply(), dim = 1"); 00130 00131 out.set_size(X.n_rows, 1); 00132 00133 for(u32 row=0; row<X.n_rows; ++row) 00134 { 00135 eT min_val = X.at(row,0); 00136 00137 for(u32 col=1; col<X.n_cols; ++col) 00138 { 00139 const eT tmp_val = X.at(row,col); 00140 00141 if(tmp_val < min_val) 00142 { 00143 min_val = tmp_val; 00144 } 00145 } 00146 00147 out[row] = min_val; 00148 00149 } 00150 00151 } 00152 00153 }
std::complex< T > op_min::direct_min | ( | const std::complex< T > *const | X, | |
const u32 | n_elem | |||
) | [inline, static, inherited] |
Find the minimum value in an array (version for complex numbers).
Definition at line 161 of file op_min_meat.hpp.
References abs().
00162 { 00163 arma_extra_debug_sigprint(); 00164 00165 u32 index = 0; 00166 T min_val = std::abs(X[index]); 00167 00168 for(u32 i=1; i<n_elem; ++i) 00169 { 00170 const T tmp_val = std::abs(X[i]); 00171 00172 if(tmp_val < min_val) 00173 { 00174 min_val = tmp_val; 00175 index = i; 00176 } 00177 } 00178 00179 return X[index]; 00180 }
std::complex< T > op_min::direct_min | ( | const subview< std::complex< T > > & | X | ) | [inline, static, inherited] |
Find the minimum value in a subview (version for complex numbers).
Definition at line 188 of file op_min_meat.hpp.
References abs().
00189 { 00190 arma_extra_debug_sigprint(); 00191 00192 u32 index = 0; 00193 T min_val = std::abs(X[index]); 00194 00195 for(u32 i=1; i<X.n_elem; ++i) 00196 { 00197 const T tmp_val = std::abs(X[i]); 00198 00199 if(tmp_val < min_val) 00200 { 00201 min_val = tmp_val; 00202 index = i; 00203 } 00204 } 00205 00206 return X[index]; 00207 }
std::complex< T > op_min::direct_min | ( | const diagview< std::complex< T > > & | X | ) | [inline, static, inherited] |
Find the minimum value in a diagview (version for complex numbers).
Definition at line 215 of file op_min_meat.hpp.
References abs().
00216 { 00217 arma_extra_debug_sigprint(); 00218 00219 u32 index = 0; 00220 T min_val = std::abs(X[index]); 00221 00222 for(u32 i=1; i<X.n_elem; ++i) 00223 { 00224 const T tmp_val = std::abs(X[i]); 00225 00226 if(tmp_val < min_val) 00227 { 00228 min_val = tmp_val; 00229 index = i; 00230 } 00231 } 00232 00233 return X[index]; 00234 }
void op_min::apply | ( | Mat< std::complex< T > > & | out, | |
const Op< T1, op_min > & | in | |||
) | [inline, static, inherited] |
Implementation for complex numbers.
Definition at line 240 of file op_min_meat.hpp.
References abs(), Mat< eT >::at(), Op< T1, op_type >::aux_u32_a, Mat< eT >::colptr(), direct_min(), Op< T1, op_type >::m, Mat< eT >::n_cols, Mat< eT >::n_elem, and Mat< eT >::n_rows.
00241 { 00242 arma_extra_debug_sigprint(); 00243 00244 typedef typename std::complex<T> eT; 00245 isnt_same_type<eT, typename T1::elem_type>::check(); 00246 00247 const unwrap_check<T1> tmp(in.m, out); 00248 const Mat<eT>& X = tmp.M; 00249 00250 arma_debug_check( (X.n_elem == 0), "op_min::apply(): given matrix has no elements" ); 00251 00252 const u32 dim = in.aux_u32_a; 00253 arma_debug_check( (dim > 1), "op_min::apply(): incorrect usage. dim must be 0 or 1"); 00254 00255 00256 if(dim == 0) // column-wise min 00257 { 00258 arma_extra_debug_print("op_min::apply(), dim = 0"); 00259 00260 out.set_size(1, X.n_cols); 00261 00262 for(u32 col=0; col<X.n_cols; ++col) 00263 { 00264 out[col] = op_min::direct_min( X.colptr(col), X.n_rows ); 00265 } 00266 } 00267 else 00268 if(dim == 1) // row-wise min 00269 { 00270 arma_extra_debug_print("op_min::apply(), dim = 1"); 00271 00272 out.set_size(X.n_rows, 1); 00273 00274 for(u32 row=0; row<X.n_rows; ++row) 00275 { 00276 u32 index = 0; 00277 T min_val = std::abs(X.at(row,index)); 00278 00279 for(u32 col=1; col<X.n_cols; ++col) 00280 { 00281 const T tmp_val = std::abs(X.at(row,col)); 00282 00283 if(tmp_val < min_val) 00284 { 00285 min_val = tmp_val; 00286 index = col; 00287 } 00288 } 00289 00290 out[row] = X.at(row,index); 00291 } 00292 00293 } 00294 00295 }