//! More...
Classes | |
| class | op_mean |
| Class for finding mean values of a matrix. More... | |
Functions | |
| template<typename eT > | |
| static eT | op_mean::direct_mean (const eT *const X, const u32 N) |
| find the mean value of an array | |
| template<typename eT > | |
| static eT | op_mean::direct_mean (const subview< eT > &X) |
| find the mean value of a subview | |
| template<typename eT > | |
| static eT | op_mean::direct_mean (const diagview< eT > &X) |
| find the mean value of a diagview | |
| template<typename T1 > | |
| static void | op_mean::apply (Mat< typename T1::elem_type > &out, const Op< T1, op_mean > &in) |
| //! For each row or for each column, find the mean value. //! The result is stored in a dense matrix that has either one column or one row. //! The dimension, for which the means are found, is set via the mean() function. | |
//!
| eT op_mean::direct_mean | ( | const eT *const | X, | |
| const u32 | N | |||
| ) | [inline, static, inherited] |
find the mean value of an array
Definition at line 25 of file op_mean_meat.hpp.
Referenced by apply(), and mean().
{
arma_extra_debug_sigprint();
eT val = eT(0);
for(u32 i=0; i<n_elem; ++i)
{
val += X[i];
}
return val / eT(n_elem);
}
| eT op_mean::direct_mean | ( | const subview< eT > & | X | ) | [inline, static, inherited] |
find the mean value of a subview
Definition at line 45 of file op_mean_meat.hpp.
References subview< eT >::n_elem.
| eT op_mean::direct_mean | ( | const diagview< eT > & | X | ) | [inline, static, inherited] |
find the mean value of a diagview
Definition at line 65 of file op_mean_meat.hpp.
References diagview< eT >::n_elem.
| void op_mean::apply | ( | Mat< typename T1::elem_type > & | out, | |
| const Op< T1, op_mean > & | in | |||
| ) | [inline, static, inherited] |
//! For each row or for each column, find the mean value. //! The result is stored in a dense matrix that has either one column or one row. //! The dimension, for which the means are found, is set via the mean() function.
Definition at line 88 of file op_mean_meat.hpp.
References Mat< eT >::at(), Op< T1, op_type >::aux_u32_a, Mat< eT >::colptr(), direct_mean(), 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), "mean(): given matrix has no elements" );
const u32 dim = in.aux_u32_a;
arma_debug_check( (dim > 1), "mean(): incorrect usage. dim must be 0 or 1");
if(dim == 0)
{
arma_extra_debug_print("op_mean::apply(), dim = 0");
out.set_size(1, X.n_cols);
for(u32 col=0; col<X.n_cols; ++col)
{
out[col] = op_mean::direct_mean( X.colptr(col), X.n_rows );
}
}
else
if(dim == 1)
{
arma_extra_debug_print("op_mean::apply(), dim = 1");
out.set_size(X.n_rows, 1);
for(u32 row=0; row<X.n_rows; ++row)
{
eT val = eT(0);
for(u32 col=0; col<X.n_cols; ++col)
{
val += X.at(row,col);
}
out[row] = val / eT(X.n_cols);
}
}
}