CMS 3D CMS Logo

EquidistantSequence.cc
Go to the documentation of this file.
1 #include <cmath>
3 
5 
6 namespace npstat {
8  const double maxScale,
9  const unsigned nScales)
10  : std::vector<double>() {
11  switch (nScales) {
12  case 0:
13  break;
14 
15  case 1: {
16  this->reserve(nScales);
17  const double sc = (minScale == maxScale ? minScale : (minScale + maxScale) / 2.0);
18  push_back(sc);
19  } break;
20 
21  default: {
22  this->reserve(nScales);
23  const double step = (maxScale - minScale) / (nScales - 1);
25  for (unsigned i = 1; i < nScales - 1; ++i)
26  push_back(minScale + i * step);
28  } break;
29  }
30  }
31 
32  EquidistantInLogSpace::EquidistantInLogSpace(const double minScale, const double maxScale, const unsigned nScales)
33  : std::vector<double>() {
34  if (nScales)
35  if (!(minScale > 0.0 && maxScale > 0.0))
37  "In npstat::EquidistantInLogSpace constructor: "
38  "minimum and maximum scales must be positive");
39  switch (nScales) {
40  case 0:
41  break;
42 
43  case 1: {
44  this->reserve(nScales);
45  const double sc = (minScale == maxScale ? minScale : sqrt(minScale * maxScale));
46  push_back(sc);
47  } break;
48 
49  default: {
50  this->reserve(nScales);
51  const double logmax = log(maxScale);
52  const double logmin = log(minScale);
53  const double logstep = (logmax - logmin) / (nScales - 1);
55  for (unsigned i = 1; i < nScales - 1; ++i)
56  push_back(exp(logmin + i * logstep));
58  } break;
59  }
60  }
61 } // namespace npstat
Equidistant sequences of points in either linear or log space.
Exceptions for the npstat namespace.
T sqrt(T t)
Definition: SSEVec.h:23
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
step
Definition: StallMonitor.cc:83