A class representing a data point. More...
#include <BCDataPoint.h>
Public Member Functions | |
Constructors and destructors | |
BCDataPoint (std::vector< double > x) | |
BCDataPoint (int nvariables) | |
~BCDataPoint () | |
Member functions (get) | |
const unsigned int | GetNValues () |
double | GetValue (int index) |
std::vector< double > | GetValues () |
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.
00019 { 00020 // assign the specified number of variables to the data 00021 // point and fill with zero 00022 fData.assign(nvariables, 0.); 00023 }
BCDataPoint::BCDataPoint | ( | std::vector< double > | x | ) |
A constructor.
x | The vector containing the data. |
Definition at line 27 of file BCDataPoint.cxx.
00028 { 00029 // copy all values of x to the data point 00030 for (std::vector<double>::const_iterator it = x.begin(); it != x.end(); ++it) 00031 fData.push_back(*it); 00032 }
BCDataPoint::~BCDataPoint | ( | ) |
const unsigned int BCDataPoint::GetNValues | ( | ) | [inline] |
Returns the number of values.
Definition at line 69 of file BCDataPoint.h.
00070 { return fData.size(); };
double BCDataPoint::GetValue | ( | int | index | ) |
index | The index of the variable. |
Definition at line 41 of file BCDataPoint.cxx.
00042 { 00043 // this is not good at all 00044 // -1 can be ok value 00045 // and one can turn off warnings 00046 // so if index is out of range the program should stop 00047 double value = -1.0; 00048 00049 // check if index is in range. return value if true ... 00050 if (index >= 0 && index < int(fData.size())) 00051 value = fData[index]; 00052 // ... or give warning if not. 00053 else 00054 BCLog::Out(BCLog::warning, BCLog::warning, 00055 TString::Format("BCDataPoint::GetValue : Index %d out of range (%d to %d).",index,0,fData.size())); 00056 00057 return value; 00058 }
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 62 of file BCDataPoint.cxx.
00063 { 00064 // this is not good at all 00065 // -1 can be ok value 00066 // and one can turn off warnings 00067 // so if index is out of range the program should stop 00068 00069 // check if index is in range. set value if true ... 00070 if (index >= 0 && index < int(fData.size())) 00071 fData[index] = value; 00072 // ... or give warning if not. 00073 else 00074 BCLog::Out(BCLog::warning, BCLog::warning, 00075 TString::Format("BCDataPoint::SetValue : Index %d out of range (%d to %d).",index,0,fData.size())); 00076 }
void BCDataPoint::SetValues | ( | std::vector< double > | values | ) |
Set the values of all variables.
values | A vector of values |
Definition at line 80 of file BCDataPoint.cxx.
00081 { 00082 // check if sizes are the same. if true, clear the data point and copy from 00083 // the vector passed to the method ... 00084 if (values.size() == fData.size()) 00085 { 00086 fData.clear(); 00087 for (std::vector<double>::const_iterator it = values.begin(); it != values.end(); ++it) 00088 fData.push_back(*it); 00089 } 00090 // ... or give warning if the size if not the same. 00091 else 00092 BCLog::Out(BCLog::warning, BCLog::warning,"BCDataPoint::SetValues. vectors have different ranges."); 00093 }
std::vector<double> BCDataPoint::fData [private] |
The vector containing the values of the variables.
Definition at line 94 of file BCDataPoint.h.