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 #include <cstdlib>
00016
00017
00018 BCDataPoint::BCDataPoint(int nvariables)
00019 {
00020
00021
00022 fData.assign(nvariables, 0.);
00023 }
00024
00025
00026 BCDataPoint::BCDataPoint(std::vector<double> x)
00027 {
00028
00029 for (std::vector<double>::const_iterator it = x.begin(); it != x.end(); ++it)
00030 fData.push_back(*it);
00031 }
00032
00033
00034 BCDataPoint::BCDataPoint(const BCDataPoint & datapoint)
00035 {
00036
00037 fData = datapoint.fData;
00038 }
00039
00040
00041 BCDataPoint::~BCDataPoint()
00042 {}
00043
00044
00045 BCDataPoint & BCDataPoint::operator = (const BCDataPoint & datapoint)
00046 {
00047 fData = datapoint.fData;
00048
00049
00050 return *this;
00051 }
00052
00053
00054 double BCDataPoint::GetValue(int index)
00055 {
00056 double value;
00057
00058
00059 if (index >= 0 && index < int(fData.size()))
00060 value = fData[index];
00061
00062 else {
00063
00064 BCLog::OutError(
00065 Form("BCDataPoint::GetValue : Index %d out of range (%d to %d).",
00066 index,0, (int)fData.size()-1));
00067 exit(1);
00068 }
00069
00070 return value;
00071 }
00072
00073
00074 void BCDataPoint::SetValue(int index, double value)
00075 {
00076
00077 if (index >= 0 && index < int(fData.size()))
00078 fData[index] = value;
00079
00080 else {
00081
00082 BCLog::OutError(
00083 Form("BCDataPoint::SetValue : Index %d out of range (%d to %d).",
00084 index, 0 ,(int)fData.size()-1));
00085 exit(1);
00086 }
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 exit(1);
00104 }
00105 }
00106
00107
00108
00109