BayesianAnalysisToolkit  0.9.3
Private Attributes | List of all members
BCDataPoint Class Reference

A class representing a data point. More...

#include <BCDataPoint.h>

Public Member Functions

Constructors and destructors
 BCDataPoint (int nvariables)
 
 BCDataPoint (const std::vector< double > &x)
 
Member functions (get)
double GetValue (unsigned index) const
 
const std::vector< double > & GetValues () const
 
unsigned int GetNValues () const
 
Member functions (set)
void SetValue (unsigned index, double value)
 
void SetValues (const std::vector< double > &values)
 

Private Attributes

std::vector< double > fData
 

Detailed Description

A class representing a data point.

Author
Daniel Kollar
Kevin Kröninger
Version
1.0
Date
08.2008 This class represents a data point which is the basic unit of information. A data point can be an event, a bin content, etc. Each data point can store several variables of type double. The variables are organized in a vector.

Definition at line 31 of file BCDataPoint.h.

Constructor & Destructor Documentation

BCDataPoint::BCDataPoint ( int  nvariables)

A constructor.

Parameters
nvariablesThe number of variables stored in a data. object

Definition at line 19 of file BCDataPoint.cxx.

20 {
21  // assign the specified number of variables to the data
22  // point and fill with zero
23  fData.assign(nvariables, 0.);
24 }
BCDataPoint::BCDataPoint ( const std::vector< double > &  x)

A constructor.

Parameters
xThe vector containing the data.

Definition at line 27 of file BCDataPoint.cxx.

28 {
29  // copy all values of x to the data point
30  fData = x;
31 }

Member Function Documentation

unsigned int BCDataPoint::GetNValues ( ) const
inline

Returns the number of values.

Definition at line 65 of file BCDataPoint.h.

66  { return fData.size(); };
double BCDataPoint::GetValue ( unsigned  index) const
Parameters
indexThe index of the variable.
Returns
The value of the variable.

Definition at line 34 of file BCDataPoint.cxx.

35 {
36  double value;
37 
38  // check if index is in range. return value if true ...
39  if (index < fData.size())
40  value = fData[index];
41  // ... or give error if not.
42  else {
43  // exit on error
45  Form("BCDataPoint::GetValue : Index %u out of range (%u to %u).",
46  index, 0, unsigned(fData.size()-1)));
47  exit(1);
48  }
49 
50  return value;
51 }
const std::vector<double>& BCDataPoint::GetValues ( ) const
inline
Returns
A vector of values.

Definition at line 60 of file BCDataPoint.h.

61  { return fData; };
void BCDataPoint::SetValue ( unsigned  index,
double  value 
)

Set the value of a variable.

Parameters
indexThe index of the variable
valueThe value of the variable

Definition at line 54 of file BCDataPoint.cxx.

55 {
56  // check if index is in range. set value if true ...
57  if (index < fData.size())
58  fData[index] = value;
59  // ... or give error if not.
60  else {
61  // exit on error
63  Form("BCDataPoint::SetValue : Index %u out of range (%u to %u).",
64  index, 0 , unsigned(fData.size()-1)));
65  exit(1);
66  }
67 }
void BCDataPoint::SetValues ( const std::vector< double > &  values)

Set the values of all variables.

Parameters
valuesA vector of values

Definition at line 70 of file BCDataPoint.cxx.

71 {
72  // check if sizes are the same. if true, clear the data point and copy from
73  // the vector passed to the method ...
74  if (values.size() == fData.size())
75  {
76  fData = values;
77  }
78  // ... or give error if the size if not the same.
79  else {
80  BCLog::OutError("BCDataPoint::SetValues : Vectors have different ranges.");
81  exit(1);
82  }
83 }

Member Data Documentation

std::vector<double> BCDataPoint::fData
private

The vector containing the values of the variables.

Definition at line 90 of file BCDataPoint.h.


The documentation for this class was generated from the following files: