STK++ 0.9.13
STK::Stat::SumOp< Derived > Struct Template Reference

Compute the sum of the variable V. More...

#include <STK_Stat_Functors.h>

Public Types

typedef Derived::Type Type
 

Public Member Functions

 SumOp (ExprBase< Derived > const &V)
 constructor
 
Type const operator() () const
 
template<class Weights >
Type const operator() (ExprBase< Weights > const &w) const
 

Protected Attributes

Derived constV_
 

Detailed Description

template<class Derived>
struct STK::Stat::SumOp< Derived >

Compute the sum of the variable V.

Definition at line 219 of file STK_Stat_Functors.h.

Member Typedef Documentation

◆ Type

template<class Derived >
typedef Derived::Type STK::Stat::SumOp< Derived >::Type

Definition at line 221 of file STK_Stat_Functors.h.

Constructor & Destructor Documentation

◆ SumOp()

template<class Derived >
STK::Stat::SumOp< Derived >::SumOp ( ExprBase< Derived > const V)
inline

constructor

Definition at line 223 of file STK_Stat_Functors.h.

223 : V_(V.asDerived())
#define STK_STATIC_ASSERT_ONE_DIMENSION_ONLY(EXPR)
Derived const & V_

References STK_STATIC_ASSERT_ONE_DIMENSION_ONLY.

Member Function Documentation

◆ operator()() [1/2]

template<class Derived >
Type const STK::Stat::SumOp< Derived >::operator() ( ) const
inline
Returns
the sum of the variable V

\[ \sum_{i=1}^n V(i) \]

Definition at line 228 of file STK_Stat_Functors.h.

229 {
230 Type sum = 0.;
231 for (int i=V_.begin(); i<V_.end(); i++) { sum += V_[i];}
232 return sum;
233 }
hidden::FunctorTraits< Derived, SumOp >::Row sum(Derived const &A)
Compute the sum of A.

References STK::Stat::sum(), and STK::Stat::SumOp< Derived >::V_.

◆ operator()() [2/2]

template<class Derived >
template<class Weights >
Type const STK::Stat::SumOp< Derived >::operator() ( ExprBase< Weights > const w) const
inline
Returns
the weighted sum of the variable V

\[ \hat{\mu} = \sum_{i=1}^n w(i) V(i). \]

Parameters
wthe weights

Definition at line 239 of file STK_Stat_Functors.h.

240 {
242 // sum the weighted samples
243 Type sum = 0.0;
244 for (int i=V_.begin(); i<V_.end(); i++) { sum += w[i] * V_[i];}
245 return sum;
246 }

References STK_STATIC_ASSERT_ONE_DIMENSION_ONLY, STK::Stat::sum(), and STK::Stat::SumOp< Derived >::V_.

Member Data Documentation

◆ V_

template<class Derived >
Derived const& STK::Stat::SumOp< Derived >::V_
protected

The documentation for this struct was generated from the following file: