Jpp  16.0.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
JMATH::JAverage< JValue_t > Struct Template Reference

Auxiliary class to determine average of set of values. More...

#include <JMath.hh>

Public Member Functions

 JAverage ()
 Default constructor. More...
 
template<class T >
 JAverage (T __begin, T __end)
 Constructor. More...
 
void reset ()
 Reset. More...
 
 operator JValue_t () const
 Type conversion operator. More...
 
void put (const JValue_t &value, const double w=1.0)
 Put value. More...
 

Private Attributes

JValue_t value
 
double weight
 

Detailed Description

template<class JValue_t>
struct JMATH::JAverage< JValue_t >

Auxiliary class to determine average of set of values.

Definition at line 412 of file JMath.hh.

Constructor & Destructor Documentation

template<class JValue_t>
JMATH::JAverage< JValue_t >::JAverage ( )
inline

Default constructor.

Definition at line 416 of file JMath.hh.

416  :
417  value (getZero<JValue_t>()),
418  weight(0.0)
419  {}
double weight
Definition: JMath.hh:478
JValue_t value
Definition: JMath.hh:477
template<class JValue_t>
template<class T >
JMATH::JAverage< JValue_t >::JAverage ( T  __begin,
T  __end 
)
inline

Constructor.

Parameters
__beginbegin of data
__endend of data

Definition at line 429 of file JMath.hh.

429  :
430  value (getZero<JValue_t>()),
431  weight(0.0)
432  {
433  for (T i = __begin; i != __end; ++i) {
434  value += (*i);
435  weight += 1.0;
436  }
437  }
double weight
Definition: JMath.hh:478
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JValue_t value
Definition: JMath.hh:477

Member Function Documentation

template<class JValue_t>
void JMATH::JAverage< JValue_t >::reset ( )
inline

Reset.

Definition at line 443 of file JMath.hh.

444  {
445  this->value = getZero<JValue_t>();
446  this->weight = 0.0;
447  }
double weight
Definition: JMath.hh:478
JValue_t value
Definition: JMath.hh:477
template<class JValue_t>
JMATH::JAverage< JValue_t >::operator JValue_t ( ) const
inline

Type conversion operator.

Returns
value

Definition at line 455 of file JMath.hh.

456  {
457  if (weight != 0.0)
458  return value * (1.0 / weight);
459  else
460  THROW(JDivisionByZero, "Invalid weight.");
461  }
double weight
Definition: JMath.hh:478
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
JValue_t value
Definition: JMath.hh:477
template<class JValue_t>
void JMATH::JAverage< JValue_t >::put ( const JValue_t &  value,
const double  w = 1.0 
)
inline

Put value.

Parameters
valuevalue
wweight

Definition at line 470 of file JMath.hh.

471  {
472  this->value += value;
473  this->weight += w;
474  }
data_type w[N+1][M+1]
Definition: JPolint.hh:757
double weight
Definition: JMath.hh:478
JValue_t value
Definition: JMath.hh:477

Member Data Documentation

template<class JValue_t>
JValue_t JMATH::JAverage< JValue_t >::value
private

Definition at line 477 of file JMath.hh.

template<class JValue_t>
double JMATH::JAverage< JValue_t >::weight
private

Definition at line 478 of file JMath.hh.


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