Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "BCDataPoint.h"
00011 #include "BCLog.h"
00012
00013 #include <TString.h>
00014
00015
00016 BCDataPoint::BCDataPoint(int nvariables)
00017 {
00018
00019
00020 fData.assign(nvariables, 0.);
00021 }
00022
00023
00024 BCDataPoint::BCDataPoint(std::vector<double> x)
00025 {
00026
00027 for (std::vector<double>::const_iterator it = x.begin(); it != x.end(); ++it)
00028 fData.push_back(*it);
00029 }
00030
00031
00032 BCDataPoint::BCDataPoint(const BCDataPoint & datapoint)
00033 {
00034
00035 fData = datapoint.fData;
00036 }
00037
00038
00039 BCDataPoint::~BCDataPoint()
00040 {}
00041
00042
00043 BCDataPoint & BCDataPoint::operator = (const BCDataPoint & datapoint)
00044 {
00045
00046 fData = datapoint.fData;
00047
00048
00049 return *this;
00050 }
00051
00052
00053 double BCDataPoint::GetValue(int index)
00054 {
00055
00056
00057
00058
00059 double value = -1.0;
00060
00061
00062 if (index >= 0 && index < int(fData.size()))
00063 value = fData[index];
00064
00065 else
00066 BCLog::OutError(
00067 TString::Format("BCDataPoint::GetValue : Index %d out of range (%d to %ld).", index,0, fData.size()-1));
00068
00069 return value;
00070 }
00071
00072
00073 void BCDataPoint::SetValue(int index, double value)
00074 {
00075
00076
00077
00078
00079
00080
00081 if (index >= 0 && index < int(fData.size()))
00082 fData[index] = value;
00083
00084 else
00085 BCLog::OutError(
00086 TString::Format("BCDataPoint::SetValue : Index %d out of range (%d to %ld).",index, 0 ,fData.size()-1));
00087 }
00088
00089
00090 void BCDataPoint::SetValues(std::vector <double> values)
00091 {
00092
00093
00094 if (values.size() == fData.size())
00095 {
00096 fData.clear();
00097 for (std::vector<double>::const_iterator it = values.begin(); it != values.end(); ++it)
00098 fData.push_back(*it);
00099 }
00100
00101 else
00102 BCLog::OutError("BCDataPoint::SetValues : Vectors have different ranges.");
00103 }
00104
00105
00106
00107