STK++ 0.9.13
STK::hidden::CountVisitor< Type_ > Struct Template Reference

Visitor counting the number of not-zero element in an array This visitor can be used in conjunction with the comparison operators in order to get the number of element matching a condition. More...

#include <STK_Visitors.h>

Public Types

typedef int Type
 
typedef int constTypeConst
 

Public Member Functions

 CountVisitor ()
 
void operator() (Type_ const &value, int i, int j)
 
void operator() (Type_ const &value, int i)
 
TypeConst result () const
 

Public Attributes

int res_
 

Detailed Description

template<typename Type_>
struct STK::hidden::CountVisitor< Type_ >

Visitor counting the number of not-zero element in an array This visitor can be used in conjunction with the comparison operators in order to get the number of element matching a condition.

For example:

// get in c the number of element of A equal to 2
int c = (A == 2).count()
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
hidden::SliceVisitorSelector< Derived, hidden::CountVisitor, Arrays::by_col_ >::type_result count(Derived const &A)
If A is a row-vector or a column-vector then the function will return the usual count value of the ve...
See also
ExprBase::count()

Definition at line 292 of file STK_Visitors.h.

Member Typedef Documentation

◆ Type

template<typename Type_ >
typedef int STK::hidden::CountVisitor< Type_ >::Type

Definition at line 295 of file STK_Visitors.h.

◆ TypeConst

template<typename Type_ >
typedef int const& STK::hidden::CountVisitor< Type_ >::TypeConst

Definition at line 296 of file STK_Visitors.h.

Constructor & Destructor Documentation

◆ CountVisitor()

template<typename Type_ >
STK::hidden::CountVisitor< Type_ >::CountVisitor ( )
inline

Definition at line 297 of file STK_Visitors.h.

Member Function Documentation

◆ operator()() [1/2]

template<typename Type_ >
void STK::hidden::CountVisitor< Type_ >::operator() ( Type_ const value,
int  i 
)
inline

Definition at line 300 of file STK_Visitors.h.

301 { if (value) ++res_;}

References STK::hidden::CountVisitor< Type_ >::res_.

◆ operator()() [2/2]

template<typename Type_ >
void STK::hidden::CountVisitor< Type_ >::operator() ( Type_ const value,
int  i,
int  j 
)
inline

Definition at line 298 of file STK_Visitors.h.

299 { if (value) ++res_;}

References STK::hidden::CountVisitor< Type_ >::res_.

◆ result()

template<typename Type_ >
TypeConst STK::hidden::CountVisitor< Type_ >::result ( ) const
inline

Definition at line 302 of file STK_Visitors.h.

302{ return res_;}

References STK::hidden::CountVisitor< Type_ >::res_.

Member Data Documentation

◆ res_


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