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