//! More...
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 25 of file op_min_meat.hpp.
Referenced by apply(), and min().
{
arma_extra_debug_sigprint();
eT min_val = X[0];
for(u32 i=1; i<n_elem; ++i)
{
const eT tmp_val = X[i];
if(tmp_val < min_val)
{
min_val = tmp_val;
}
}
return min_val;
}
| eT op_min::direct_min | ( | const subview< eT > & | X | ) | [inline, static, inherited] |
find the minimum value in a subview
Definition at line 50 of file op_min_meat.hpp.
References subview< eT >::n_elem.
| eT op_min::direct_min | ( | const diagview< eT > & | X | ) | [inline, static, inherited] |
find the minimum value in a diagview
Definition at line 75 of file op_min_meat.hpp.
References diagview< eT >::n_elem.
| 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 101 of file op_min_meat.hpp.
References Mat< eT >::at(), Op< T1, op_type >::aux_u32_a, Mat< eT >::colptr(), direct_min(), unwrap_check< T1 >::M, Op< T1, op_type >::m, Mat< eT >::n_cols, Mat< eT >::n_elem, Mat< eT >::n_rows, and Mat< eT >::set_size().
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M;
arma_debug_check( (X.n_elem == 0), "min(): given matrix has no elements" );
const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "min(): incorrect usage. dim must be 0 or 1");
if(dim == 0) // column-wise min
{
arma_extra_debug_print("op_min::apply(), dim = 0");
out.set_size(1, X.n_cols);
for(u32 col=0; col<X.n_cols; ++col)
{
out[col] = op_min::direct_min( X.colptr(col), X.n_rows );
}
}
else
if(dim == 1) // row-wise min
{
arma_extra_debug_print("op_min::apply(), dim = 1");
out.set_size(X.n_rows, 1);
for(u32 row=0; row<X.n_rows; ++row)
{
eT min_val = X.at(row,0);
for(u32 col=1; col<X.n_cols; ++col)
{
const eT tmp_val = X.at(row,col);
if(tmp_val < min_val)
{
min_val = tmp_val;
}
}
out[row] = min_val;
}
}
}
| 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 162 of file op_min_meat.hpp.
References abs().
| 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 189 of file op_min_meat.hpp.
References abs().
| 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 216 of file op_min_meat.hpp.
References abs().
| 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 241 of file op_min_meat.hpp.
References abs(), Mat< eT >::at(), Op< T1, op_type >::aux_u32_a, Mat< eT >::colptr(), direct_min(), unwrap_check< T1 >::M, Op< T1, op_type >::m, Mat< eT >::n_cols, Mat< eT >::n_elem, and Mat< eT >::n_rows.
{
arma_extra_debug_sigprint();
typedef typename std::complex<T> eT;
isnt_same_type<eT, typename T1::elem_type>::check();
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& X = tmp.M;
arma_debug_check( (X.n_elem == 0), "min(): given matrix has no elements" );
const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "min(): incorrect usage. dim must be 0 or 1");
if(dim == 0) // column-wise min
{
arma_extra_debug_print("op_min::apply(), dim = 0");
out.set_size(1, X.n_cols);
for(u32 col=0; col<X.n_cols; ++col)
{
out[col] = op_min::direct_min( X.colptr(col), X.n_rows );
}
}
else
if(dim == 1) // row-wise min
{
arma_extra_debug_print("op_min::apply(), dim = 1");
out.set_size(X.n_rows, 1);
for(u32 row=0; row<X.n_rows; ++row)
{
u32 index = 0;
T min_val = std::abs(X.at(row,index));
for(u32 col=1; col<X.n_cols; ++col)
{
const T tmp_val = std::abs(X.at(row,col));
if(tmp_val < min_val)
{
min_val = tmp_val;
index = col;
}
}
out[row] = X.at(row,index);
}
}
}