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 (const BCDataPoint &datapoint) | |
| ~BCDataPoint () | |
Assignment operators | |
| BCDataPoint & | operator= (const BCDataPoint &datapoint) |
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.
Copyright (C) 2008-2012, Daniel Kollar and Kevin Kroeninger. All rights reserved.
For the licensing terms see doc/COPYING.
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 26 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 | ( | const BCDataPoint & | datapoint | ) |
The copy constructor.
Definition at line 34 of file BCDataPoint.cxx.
| BCDataPoint::~BCDataPoint | ( | ) |
| unsigned int BCDataPoint::GetNValues | ( | ) | [inline] |
Returns the number of values.
Definition at line 81 of file BCDataPoint.h.
{ return fData.size(); };
| double BCDataPoint::GetValue | ( | int | index | ) |
| index | The index of the variable. |
Definition at line 54 of file BCDataPoint.cxx.
{
double value;
// check if index is in range. return value if true ...
if (index >= 0 && index < int(fData.size()))
value = fData[index];
// ... or give error if not.
else {
// exit on error
BCLog::OutError(
Form("BCDataPoint::GetValue : Index %d out of range (%d to %d).",
index,0, (int)fData.size()-1));
exit(1);
}
return value;
}
| std::vector<double> BCDataPoint::GetValues | ( | ) | [inline] |
| BCDataPoint & BCDataPoint::operator= | ( | const BCDataPoint & | datapoint | ) |
Defaut assignment operator
Definition at line 45 of file BCDataPoint.cxx.
| 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 74 of file BCDataPoint.cxx.
{
// check if index is in range. set value if true ...
if (index >= 0 && index < int(fData.size()))
fData[index] = value;
// ... or give error if not.
else {
// exit on error
BCLog::OutError(
Form("BCDataPoint::SetValue : Index %d out of range (%d to %d).",
index, 0 ,(int)fData.size()-1));
exit(1);
}
}
| void BCDataPoint::SetValues | ( | std::vector< double > | values | ) |
Set the values of all variables.
| values | A vector of values |
Definition at line 90 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 error if the size if not the same.
else {
BCLog::OutError("BCDataPoint::SetValues : Vectors have different ranges.");
exit(1);
}
}
std::vector<double> BCDataPoint::fData [private] |
The vector containing the values of the variables.
Definition at line 106 of file BCDataPoint.h.
1.7.1