5 #include "Alignment/Geners/interface/binaryIO.hh" 6 #include "Alignment/Geners/interface/IOException.hh" 15 "In npstat::GridAxis::initialize: insufficient number " 16 "of coordinates (at least 2 are required)");
21 for (
unsigned i = 0;
i <
npt_; ++
i) {
24 "In npstat::GridAxis::initialize: in log space" 25 "all coordinates must be positive");
31 for (
unsigned i = 1;
i <
npt_; ++
i)
32 if (
c[
i] <=
c[
i - 1
U])
34 "In npstat::GridAxis::initialize: " 35 "all coordinates must be distinct");
39 : coords_(coords), npt_(coords_.size()), useLogSpace_(useLogSpace) {
44 : coords_(coords), label_(
label ?
label :
""), npt_(coords_.size()), useLogSpace_(useLogSpace) {
54 return std::pair<unsigned, double>(0
U, 1.0);
56 return std::pair<unsigned, double>(
npt_ - 2
U, 0.0);
61 const double*
l = &
logs_[0];
62 const double w = 1.0 - (
log(
x) -
l[ibnd]) / (
l[ibnd + 1
U] -
l[ibnd]);
63 return std::pair<unsigned, double>(ibnd,
w);
65 const double w = 1.0 - (
x -
c[ibnd]) / (
c[ibnd + 1
U] -
c[ibnd]);
66 return std::pair<unsigned, double>(ibnd,
w);
78 const double*
l = &
logs_[0];
79 const double bw =
l[1] -
l[0];
80 return std::pair<unsigned, double>(0
U, 1.0 - (
log(
x) -
l[0]) / bw);
82 const double bw =
c[1] -
c[0];
83 return std::pair<unsigned, double>(0
U, 1.0 - (
x -
c[0]) / bw);
87 const double*
l = &
logs_[0];
89 return std::pair<unsigned, double>(
npt_ - 2
U, (
l[
npt_ - 1
U] -
log(
x)) / bw);
92 return std::pair<unsigned, double>(
npt_ - 2
U, (
c[
npt_ - 1
U] -
x) / bw);
98 const double*
l = &
logs_[0];
99 const double w = 1.0 - (
log(
x) -
l[ibnd]) / (
l[ibnd + 1
U] -
l[ibnd]);
100 return std::pair<unsigned, double>(ibnd,
w);
102 const double w = 1.0 - (
x -
c[ibnd]) / (
c[ibnd + 1
U] -
c[ibnd]);
103 return std::pair<unsigned, double>(ibnd,
w);
118 static const gs::ClassId current(gs::ClassId::makeId<GridAxis>());
119 current.ensureSameId(
id);
121 std::vector<double>
coords;
128 gs::read_pod(
in, &useLogSpace);
131 throw gs::IOReadFailure(
132 "In npstat::GridAxis::read: " 133 "input stream failure");
144 const unsigned long n =
coords_.size();
145 if (
n != r.coords_.size())
147 for (
unsigned long i = 0;
i <
n; ++
i)
std::pair< unsigned, double > linearInterval(double coordinate) const
bool isClose(const GridAxis &r, double tol) const
bool closeWithinTolerance(const double &a, const double &b, const double &tol)
Exceptions for the npstat namespace.
const std::string & label() const
Non-uniformly spaced coordinate sets for use in constructing rectangular grids.
Determine if two doubles are within requested relative tolerance of each other.
std::pair< unsigned, double > getInterval(double coordinate) const
bool write(std::ostream &of) const
std::vector< double > logs_
static GridAxis * read(const gs::ClassId &id, std::istream &in)
const std::vector< double > & coords() const
bool operator==(const GridAxis &r) const
std::vector< double > coords_