Jpp  18.5.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 409 of file JMath.hh.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 413 of file JMath.hh.

413  :
414  value (getZero<JValue_t>()),
415  weight(0.0)
416  {}
double weight
Definition: JMath.hh:475
JValue_t value
Definition: JMath.hh:474
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 426 of file JMath.hh.

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

Member Function Documentation

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

Reset.

Definition at line 440 of file JMath.hh.

441  {
442  this->value = getZero<JValue_t>();
443  this->weight = 0.0;
444  }
double weight
Definition: JMath.hh:475
JValue_t value
Definition: JMath.hh:474
template<class JValue_t>
JMATH::JAverage< JValue_t >::operator JValue_t ( ) const
inline

Type conversion operator.

Returns
value

Definition at line 452 of file JMath.hh.

453  {
454  if (weight != 0.0)
455  return value * (1.0 / weight);
456  else
457  THROW(JDivisionByZero, "Invalid weight.");
458  }
double weight
Definition: JMath.hh:475
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
JValue_t value
Definition: JMath.hh:474
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 467 of file JMath.hh.

468  {
469  this->value += value;
470  this->weight += w;
471  }
data_type w[N+1][M+1]
Definition: JPolint.hh:867
double weight
Definition: JMath.hh:475
JValue_t value
Definition: JMath.hh:474

Member Data Documentation

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

Definition at line 474 of file JMath.hh.

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

Definition at line 475 of file JMath.hh.


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