BCDataPoint.cxx
1 /*
2  * Copyright (C) 2007-2018, the BAT core developer team
3  * All rights reserved.
4  *
5  * For the licensing terms see doc/COPYING.
6  * For documentation see http://mpp.mpg.de/bat
7  */
8 
9 // ---------------------------------------------------------
10 
11 #include "BCDataPoint.h"
12 
13 #include <TString.h>
14 
15 #include <cstdlib>
16 
17 // ---------------------------------------------------------
18 BCDataPoint::BCDataPoint(int nvariables)
19  : fData(nvariables, 0)
20 {
21 }
22 
23 // ---------------------------------------------------------
24 BCDataPoint::BCDataPoint(const std::vector<double>& x)
25  : fData(x)
26 {
27 }
28 
29 // ---------------------------------------------------------
30 void BCDataPoint::SetValues(const std::vector<double>& values)
31 {
32  // if vectors are same size, copy values
33  if (values.size() == fData.size()) {
34  fData = values;
35  }
36  // else give error
37  else {
38  BCLog::OutError("BCDataPoint::SetValues : Vectors have different ranges.");
39  exit(1);
40  }
41 }
42 
43 // ---------------------------------------------------------
44 void BCDataPoint::PrintSummary(void (*output)(const std::string&)) const
45 {
46  for (unsigned i = 0; i < fData.size(); ++i)
47  output(Form("%u : %12.5g", i, fData[i]));
48 }
void PrintSummary(void(*output)(const std::string &)=BCLog::OutSummary) const
Print summary of data point to the string handler.
Definition: BCDataPoint.cxx:44
void SetValues(const std::vector< double > &values)
Set the values of all variables.
Definition: BCDataPoint.cxx:30
BCDataPoint(int nvariables=0)
A constructor.
Definition: BCDataPoint.cxx:18