herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.3.0
Sampling
exsample
linear_interpolator.h
1
// -*- C++ -*-
2
//
3
// linear_interpolator.h is part of ExSample -- A Library for Sampling Sudakov-Type Distributions
4
//
5
// Copyright (C) 2008-2019 Simon Platzer -- simon.plaetzer@desy.de, The Herwig Collaboration
6
//
7
// ExSample is licenced under version 3 of the GPL, see COPYING for details.
8
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
9
//
10
//
11
#ifndef EXSAMPLE_linear_interpolator_h_included
12
#define EXSAMPLE_linear_interpolator_h_included
13
14
#include "utility.h"
15
16
namespace
exsample {
17
20
struct
inversion_has_no_solution
{ };
21
24
struct
constant_interpolation
{
25
27
constant_interpolation
(
double
xlow,
28
double
xhigh,
29
double
h)
30
:
range
(xlow,xhigh),
value
(h) {}
31
33
std::pair<double,double>
range
;
34
36
double
value
;
37
38
};
39
42
class
linear_interpolator
{
43
44
public
:
45
47
linear_interpolator
();
48
51
explicit
linear_interpolator
(
const
std::map<double,double>& points);
52
53
public
:
54
56
double
operator()
(
double
x)
const
;
57
59
std::pair<double,double>
range
()
const
{
return
range_
; }
60
61
public
:
62
65
bool
invertible
(
double
f)
const
{
66
return
(
range_
.first <= f &&
67
range_
.second >= f);
68
}
69
72
double
unique_inverse
(
double
f)
const
;
73
75
std::map<double,double>&
interpolation
() {
76
return
interpolation_
;
77
}
78
80
void
set_interpolation
(
double
point,
double
value);
81
83
void
reset
();
84
85
public
:
86
88
template
<
class
OStream>
89
void
put
(OStream& os)
const
;
90
92
template
<
class
IStream>
93
void
get
(IStream& is);
94
95
private
:
96
98
std::map<double, double>
interpolation_
;
99
101
std::pair<double,double>
range_
;
102
103
};
104
106
template
<
class
OStream>
107
inline
OStream&
operator<<
(OStream& os,
const
linear_interpolator
& ip) {
108
ip.
put
(os);
109
return
os;
110
}
111
113
template
<
class
IStream>
114
inline
IStream&
operator>>
(IStream& is, linear_interpolator& ip) {
115
ip.get(is);
116
return
is;
117
}
118
119
}
120
121
#include "linear_interpolator.icc"
122
123
#endif
// EXSAMPLE_linear_interpolator_h_included
exsample::linear_interpolator
A linear interpolation allowing for inversion of the linear interpolation.
Definition:
linear_interpolator.h:42
exsample::linear_interpolator::linear_interpolator
linear_interpolator()
default constructor
exsample::linear_interpolator::interpolation_
std::map< double, double > interpolation_
map points to values
Definition:
linear_interpolator.h:98
exsample::linear_interpolator::linear_interpolator
linear_interpolator(const std::map< double, double > &points)
construct a linear interpolator given the map of interpolation points and values
exsample::linear_interpolator::set_interpolation
void set_interpolation(double point, double value)
set the value at the given point
exsample::linear_interpolator::invertible
bool invertible(double f) const
return true, if an inverse exists for the given value
Definition:
linear_interpolator.h:65
exsample::linear_interpolator::interpolation
std::map< double, double > & interpolation()
access the interpolation map
Definition:
linear_interpolator.h:75
exsample::linear_interpolator::put
void put(OStream &os) const
put to ostream
exsample::linear_interpolator::reset
void reset()
reset after interpolation points have been changed
exsample::linear_interpolator::operator()
double operator()(double x) const
return the interpolations value at the given point
exsample::linear_interpolator::get
void get(IStream &is)
get from istream
exsample::linear_interpolator::range_
std::pair< double, double > range_
the range of the interpolation
Definition:
linear_interpolator.h:101
exsample::linear_interpolator::range
std::pair< double, double > range() const
return the range of the interpolation
Definition:
linear_interpolator.h:59
exsample::linear_interpolator::unique_inverse
double unique_inverse(double f) const
return the inverse, assuming the inverse is unique
operator>>
vector< T > & operator>>(vector< T > &tv, U &u)
operator<<
vector< T > & operator<<(vector< T > &tv, const U &u)
exsample::constant_interpolation
Exception thrown, if a constant piece of the interpolation has been hit.
Definition:
linear_interpolator.h:24
exsample::constant_interpolation::value
double value
The value of the interpolation in the range.
Definition:
linear_interpolator.h:36
exsample::constant_interpolation::constant_interpolation
constant_interpolation(double xlow, double xhigh, double h)
standard constructor
Definition:
linear_interpolator.h:27
exsample::constant_interpolation::range
std::pair< double, double > range
The range in which the interpolation is constant.
Definition:
linear_interpolator.h:33
exsample::inversion_has_no_solution
Exception thrown, if inversion of the interpolation has no solution.
Definition:
linear_interpolator.h:20
Generated on Thu Jun 20 2024 17:50:53 for Herwig by
1.9.6