Fn_sum

Functions

template<typename T1 >
arma_inline const Op< T1, op_sumsum (const Base< typename T1::elem_type, T1 > &X, const u32 dim=0)
 Delayed sum of elements of a matrix along a specified dimension (either rows or columns). The result is stored in a dense matrix that has either one column or one row. For dim = 0, find the sum of each column. For dim = 1, find the sum of each row. The default is dim = 0. NOTE: this function works differently than in Matlab/Octave.
template<typename eT >
arma_inline arma_warn_unused eT sum (const Row< eT > &X)
 Immediate 'sum all values' operation for a row vector.
template<typename eT >
arma_inline arma_warn_unused eT sum (const Col< eT > &X)
 Immediate 'sum all values' operation for a column vector.
template<typename T1 >
arma_inline arma_warn_unused
T1::elem_type 
sum (const Op< T1, op_sum > &in)
 Immediate 'sum all values' operation, invoked, for example, by: sum(sum(A)).
template<typename T1 >
arma_inline const Op< Op< T1,
op_sum >, op_sum
sum (const Op< T1, op_sum > &in, const u32 dim)
template<typename eT >
arma_inline arma_warn_unused eT sum (const subview_row< eT > &X)
 sum all values of a subview_row
template<typename eT >
arma_inline arma_warn_unused eT sum (const subview_col< eT > &X)
 sum all values of a subview_col
template<typename eT >
arma_inline arma_warn_unused eT sum (const diagview< eT > &X)
 sum all values of a diagview

Function Documentation

template<typename T1 >
arma_inline const Op<T1, op_sum> sum ( const Base< typename T1::elem_type, T1 > &  X,
const u32  dim = 0 
) [inline]

Delayed sum of elements of a matrix along a specified dimension (either rows or columns). The result is stored in a dense matrix that has either one column or one row. For dim = 0, find the sum of each column. For dim = 1, find the sum of each row. The default is dim = 0. NOTE: this function works differently than in Matlab/Octave.

Definition at line 32 of file fn_sum.hpp.

References Base< elem_type, derived >::get_ref().

Referenced by op_cor::direct_cor(), glue_cor::direct_cor(), op_cov::direct_cov(), glue_cov::direct_cov(), op_princomp::direct_princomp(), op_princomp_cov::direct_princomp_cov(), and diskio::gen_tmp_name().

00033   {
00034   arma_extra_debug_sigprint();
00035   
00036   return Op<T1, op_sum>(X.get_ref(), dim, 0);
00037   }

template<typename eT >
arma_inline arma_warn_unused eT sum ( const Row< eT > &  X  )  [inline]

Immediate 'sum all values' operation for a row vector.

Definition at line 46 of file fn_sum.hpp.

References accu().

00047   {
00048   arma_extra_debug_sigprint();
00049   
00050   return accu(X);
00051   }

template<typename eT >
arma_inline arma_warn_unused eT sum ( const Col< eT > &  X  )  [inline]

Immediate 'sum all values' operation for a column vector.

Definition at line 61 of file fn_sum.hpp.

References accu().

00062   {
00063   arma_extra_debug_sigprint();
00064   
00065   return accu(X);
00066   }

template<typename T1 >
arma_inline arma_warn_unused T1::elem_type sum ( const Op< T1, op_sum > &  in  )  [inline]

Immediate 'sum all values' operation, invoked, for example, by: sum(sum(A)).

Definition at line 78 of file fn_sum.hpp.

References accu(), and Op< T1, op_type >::m.

00079   {
00080   arma_extra_debug_sigprint();
00081   arma_extra_debug_print("sum(): two consecutive sum() calls detected");
00082   
00083   return accu(in.m);
00084   }

template<typename T1 >
arma_inline const Op<Op<T1, op_sum>, op_sum> sum ( const Op< T1, op_sum > &  in,
const u32  dim 
) [inline]

Definition at line 91 of file fn_sum.hpp.

00092   {
00093   arma_extra_debug_sigprint();
00094   
00095   return Op<Op<T1, op_sum>, op_sum>(in, dim, 0);
00096   }

template<typename eT >
arma_inline arma_warn_unused eT sum ( const subview_row< eT > &  X  )  [inline]

sum all values of a subview_row

Definition at line 105 of file fn_sum.hpp.

References accu().

00106   {
00107   arma_extra_debug_sigprint();
00108   
00109   return accu(X);
00110   }

template<typename eT >
arma_inline arma_warn_unused eT sum ( const subview_col< eT > &  X  )  [inline]

sum all values of a subview_col

Definition at line 119 of file fn_sum.hpp.

References accu().

00120   {
00121   arma_extra_debug_sigprint();
00122   
00123   return accu(X);
00124   }

template<typename eT >
arma_inline arma_warn_unused eT sum ( const diagview< eT > &  X  )  [inline]

sum all values of a diagview

Definition at line 133 of file fn_sum.hpp.

References accu().

00134   {
00135   arma_extra_debug_sigprint();
00136   
00137   return accu(X);
00138   }