CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EquidistantSequence.cc
Go to the documentation of this file.
1 #include <cmath>
3 
5 
6 namespace npstat {
8  const double minScale, const double maxScale, const unsigned nScales)
9  : std::vector<double>()
10  {
11  switch (nScales)
12  {
13  case 0:
14  break;
15 
16  case 1:
17  {
18  this->reserve(nScales);
19  const double sc = (minScale == maxScale ? minScale :
20  (minScale + maxScale)/2.0);
21  push_back(sc);
22  }
23  break;
24 
25  default:
26  {
27  this->reserve(nScales);
28  const double step = (maxScale - minScale)/(nScales - 1);
29  push_back(minScale);
30  for (unsigned i=1; i<nScales - 1; ++i)
31  push_back(minScale + i*step);
32  push_back(maxScale);
33  }
34  break;
35  }
36  }
37 
39  const double minScale, const double maxScale, const unsigned nScales)
40  : std::vector<double>()
41  {
42  if (nScales)
43  if (!(minScale > 0.0 && maxScale > 0.0))
45  "In npstat::EquidistantInLogSpace constructor: "
46  "minimum and maximum scales must be positive");
47  switch (nScales)
48  {
49  case 0:
50  break;
51 
52  case 1:
53  {
54  this->reserve(nScales);
55  const double sc = (minScale == maxScale ? minScale :
56  sqrt(minScale*maxScale));
57  push_back(sc);
58  }
59  break;
60 
61  default:
62  {
63  this->reserve(nScales);
64  const double logmax = log(maxScale);
65  const double logmin = log(minScale);
66  const double logstep = (logmax - logmin)/(nScales - 1);
67  push_back(minScale);
68  for (unsigned i=1; i<nScales - 1; ++i)
69  push_back(exp(logmin + i*logstep));
70  push_back(maxScale);
71  }
72  break;
73  }
74  }
75 }
int i
Definition: DBlmapReader.cc:9
static std::vector< std::string > checklist log
Equidistant sequences of points in either linear or log space.
Exceptions for the npstat namespace.
T sqrt(T t)
Definition: SSEVec.h:48