A class representing a data point. More...
#include <BCDataPoint.h>
Public Member Functions | |
Constructors and destructors | |
BCDataPoint (int nvariables) | |
BCDataPoint (std::vector< double > x) | |
~BCDataPoint () | |
Member functions (get) | |
double | GetValue (int index) |
std::vector< double > | GetValues () |
unsigned int | GetNValues () |
Member functions (set) | |
void | SetValue (int index, double value) |
void | SetValues (std::vector< double > values) |
Private Attributes | |
std::vector< double > | fData |
A class representing a data point.
Definition at line 30 of file BCDataPoint.h.
BCDataPoint::BCDataPoint | ( | int | nvariables | ) |
A constructor.
nvariables | The number of variables stored in a data. object |
Definition at line 18 of file BCDataPoint.cxx.
{ // assign the specified number of variables to the data // point and fill with zero fData.assign(nvariables, 0.); }
BCDataPoint::BCDataPoint | ( | std::vector< double > | x | ) |
A constructor.
x | The vector containing the data. |
Definition at line 27 of file BCDataPoint.cxx.
{ // copy all values of x to the data point for (std::vector<double>::const_iterator it = x.begin(); it != x.end(); ++it) fData.push_back(*it); }
BCDataPoint::~BCDataPoint | ( | ) |
unsigned int BCDataPoint::GetNValues | ( | ) | [inline] |
Returns the number of values.
Definition at line 69 of file BCDataPoint.h.
{ return fData.size(); };
double BCDataPoint::GetValue | ( | int | index | ) |
index | The index of the variable. |
Definition at line 41 of file BCDataPoint.cxx.
{ // this is not good at all // -1 can be ok value // and one can turn off warnings // so if index is out of range the program should stop double value = -1.0; // check if index is in range. return value if true ... if (index >= 0 && index < int(fData.size())) value = fData[index]; // ... or give warning if not. else BCLog::Out(BCLog::warning, BCLog::warning, TString::Format( "BCDataPoint::GetValue : Index %d out of range (%d to %d).", index, 0, fData.size()-1)); return value; }
std::vector<double> BCDataPoint::GetValues | ( | ) | [inline] |
void BCDataPoint::SetValue | ( | int | index, | |
double | value | |||
) |
Set the value of a variable.
index | The index of the variable | |
value | The value of the variable |
Definition at line 63 of file BCDataPoint.cxx.
{ // this is not good at all // -1 can be ok value // and one can turn off warnings // so if index is out of range the program should stop // check if index is in range. set value if true ... if (index >= 0 && index < int(fData.size())) fData[index] = value; // ... or give warning if not. else BCLog::Out(BCLog::warning, BCLog::warning,TString::Format( "BCDataPoint::SetValue : Index %d out of range (%d to %d).", index, 0 ,fData.size()-1)); }
void BCDataPoint::SetValues | ( | std::vector< double > | values | ) |
Set the values of all variables.
values | A vector of values |
Definition at line 82 of file BCDataPoint.cxx.
{ // check if sizes are the same. if true, clear the data point and copy from // the vector passed to the method ... if (values.size() == fData.size()) { fData.clear(); for (std::vector<double>::const_iterator it = values.begin(); it != values.end(); ++it) fData.push_back(*it); } // ... or give warning if the size if not the same. else BCLog::Out(BCLog::warning, BCLog::warning,"BCDataPoint::SetValues : Vectors have different ranges."); }
std::vector<double> BCDataPoint::fData [private] |
The vector containing the values of the variables.
Definition at line 94 of file BCDataPoint.h.