herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.3.0
Utilities
Interpolator.h
1
// -*- C++ -*-
2
//
3
// Interpolator.h is a part of Herwig - A multi-purpose Monte Carlo event generator
4
// Copyright (C) 2002-2019 The Herwig Collaboration
5
//
6
// Herwig is licenced under version 3 of the GPL, see COPYING for details.
7
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8
//
9
#ifndef HERWIG_Interpolator_H
10
#define HERWIG_Interpolator_H
11
//
12
// This is the declaration of the Interpolator class.
13
//
14
15
#include "ThePEG/Interface/Interfaced.h"
16
#include <cassert>
17
18
namespace
Herwig
{
19
20
using namespace
ThePEG
;
21
30
template
<
typename
ValT,
typename
ArgT>
31
class
Interpolator
:
public
Interfaced
{
32
33
public
:
34
38
typedef
typename
Ptr<Interpolator<ValT,ArgT>
>::pointer
Ptr
;
39
45
Interpolator
() :
_order
(3),
_copyx
(5),
_copyfun
(5) {}
46
50
Interpolator
(
const
vector<ValT> & f,
51
const
vector<ArgT> & x,
52
unsigned
int
order)
53
:
_fun
(f.size(),0.0),
_xval
(x.size(),0.0),
_order
(order),
54
_funit
(
TypeTraits
<ValT>::baseunit()),
55
_xunit
(
TypeTraits
<ArgT>::baseunit()),
56
_copyx
(order+2),
_copyfun
(order+2) {
57
assert(
_order
>0);
58
assert(x.size() == f.size());
59
for
(
size_t
i = 0; i < f.size(); ++i) {
60
_fun
[i] = f[i] /
_funit
;
61
_xval
[i] = x[i] /
_xunit
;
62
}
63
}
64
68
template
<
size_t
N>
69
Interpolator
(
const
array<ValT,N> & f,
70
const
array<ArgT,N> & x,
71
unsigned
int
order)
72
:
_fun
(N,0.0),
_xval
(N,0.0),
_order
(order),
73
_funit
(
TypeTraits
<ValT>::baseunit()),
74
_xunit
(
TypeTraits
<ArgT>::baseunit()),
75
_copyx
(order+2),
_copyfun
(order+2) {
76
assert(
_order
>0);
77
for
(
size_t
i = 0; i < N; ++i) {
78
_fun
[i] = f[i] /
_funit
;
79
_xval
[i] = x[i] /
_xunit
;
80
}
81
}
83
87
Interpolator
(
size_t
size,
88
const
double
f[], ValT funit,
89
const
double
x[], ArgT xunit,
90
unsigned
int
order)
91
:
_fun
(size,0.0),
_xval
(size,0.0),
_order
(order),
92
_funit
(funit),
_xunit
(xunit),
_copyx
(order+2),
_copyfun
(order+2) {
93
assert(
_order
>0);
94
for
(
size_t
i = 0; i < size; ++i) {
95
_fun
[i] = f[i];
96
_xval
[i] = x[i];
97
}
98
}
100
104
ValT
operator ()
(ArgT)
const
;
106
typedef
ValT
ValType
;
108
typedef
ArgT
ArgType
;
109
110
public
:
111
118
void
persistentOutput
(
PersistentOStream
& os)
const
;
119
125
void
persistentInput
(
PersistentIStream
& is,
int
version);
127
134
static
void
Init
();
135
136
protected
:
137
144
virtual
IBPtr
clone
()
const
{
return
new_ptr(*
this
); }
145
150
virtual
IBPtr
fullclone
()
const
{
return
new_ptr(*
this
); }
152
153
private
:
154
159
Interpolator
&
operator=
(
const
Interpolator
&) =
delete
;
160
161
private
:
162
166
vector<double>
_fun
;
167
171
vector<double>
_xval
;
172
176
unsigned
int
_order
;
177
181
ValT
_funit
;
182
186
ArgT
_xunit
;
187
191
mutable
vector<double>
_copyx
;
192
196
mutable
vector<double>
_copyfun
;
197
198
};
199
204
template
<
typename
ValT,
typename
ArgT>
205
inline
typename
Interpolator<ValT,ArgT>::Ptr
206
make_InterpolatorPtr
(
size_t
size,
207
const
double
f[], ValT funit,
208
const
double
x[], ArgT xunit,
209
unsigned
int
order)
210
{
211
return
new_ptr(
Interpolator<ValT,ArgT>
(size,
212
f,funit,
213
x,xunit,
214
order));
215
}
216
221
template
<
typename
ValT,
typename
ArgT>
222
inline
typename
Interpolator<ValT,ArgT>::Ptr
223
make_InterpolatorPtr
(
const
typename
std::vector<ValT> & f,
224
const
typename
std::vector<ArgT> & x,
225
unsigned
int
order)
226
{
227
return
new_ptr(
Interpolator<ValT,ArgT>
(f,x,order));
228
}
229
234
template
<
typename
ValT,
typename
ArgT,
size_t
N>
235
inline
typename
Interpolator<ValT,ArgT>::Ptr
236
make_InterpolatorPtr
(
const
typename
std::array<ValT,N> & f,
237
const
typename
std::array<ArgT,N> & x,
238
unsigned
int
order)
239
{
240
return
new_ptr(
Interpolator<ValT,ArgT>
(f,x,order));
241
}
242
243
}
244
245
#ifndef ThePEG_TEMPLATES_IN_CC_FILE
246
#include "Interpolator.tcc"
247
#endif
248
249
#endif
/* HERWIG_Interpolator_H */
Herwig::Interpolator
Definition:
Interpolator.h:31
Herwig::Interpolator::Init
static void Init()
The standard Init function used to initialize the interfaces.
Herwig::Interpolator::ValType
ValT ValType
Return type for GaussianIntegrator.
Definition:
Interpolator.h:106
Herwig::Interpolator::fullclone
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
Definition:
Interpolator.h:150
Herwig::Interpolator::persistentInput
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
Herwig::Interpolator::_xunit
ArgT _xunit
The Unit of the argument values.
Definition:
Interpolator.h:186
Herwig::Interpolator::persistentOutput
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
Herwig::Interpolator::operator()
ValT operator()(ArgT) const
Return the interpolated value.
Herwig::Interpolator::_order
unsigned int _order
the order of interpolation.
Definition:
Interpolator.h:176
Herwig::Interpolator::Interpolator
Interpolator(size_t size, const double f[], ValT funit, const double x[], ArgT xunit, unsigned int order)
Constructor from bare arrays.
Definition:
Interpolator.h:87
Herwig::Interpolator::Interpolator
Interpolator(const array< ValT, N > &f, const array< ArgT, N > &x, unsigned int order)
Constructor with data as arrays.
Definition:
Interpolator.h:69
Herwig::Interpolator::operator=
Interpolator & operator=(const Interpolator &)=delete
The assignment operator is private and must never be called.
Herwig::Interpolator::_fun
vector< double > _fun
the function values.
Definition:
Interpolator.h:166
Herwig::Interpolator::ArgType
ArgT ArgType
Argument type for GaussianIntegrator.
Definition:
Interpolator.h:108
Herwig::Interpolator::Interpolator
Interpolator(const vector< ValT > &f, const vector< ArgT > &x, unsigned int order)
Constructor with data as vectors.
Definition:
Interpolator.h:50
Herwig::Interpolator::_copyfun
vector< double > _copyfun
Temporary storage vector.
Definition:
Interpolator.h:196
Herwig::Interpolator::_copyx
vector< double > _copyx
Temporary storage vector.
Definition:
Interpolator.h:191
Herwig::Interpolator::Ptr
Ptr< Interpolator< ValT, ArgT > >::pointer Ptr
Pointer to an Interpolator.
Definition:
Interpolator.h:38
Herwig::Interpolator::Interpolator
Interpolator()
The default constructor.
Definition:
Interpolator.h:45
Herwig::Interpolator::clone
virtual IBPtr clone() const
Make a simple clone of this object.
Definition:
Interpolator.h:144
Herwig::Interpolator::_xval
vector< double > _xval
The x values.
Definition:
Interpolator.h:171
Herwig::Interpolator::_funit
ValT _funit
The Unit of the function values.
Definition:
Interpolator.h:181
ThePEG::Interfaced
ThePEG::PersistentIStream
ThePEG::PersistentOStream
Herwig
-*- C++ -*-
Definition:
BasicConsistency.h:17
Herwig::make_InterpolatorPtr
Interpolator< ValT, ArgT >::Ptr make_InterpolatorPtr(size_t size, const double f[], ValT funit, const double x[], ArgT xunit, unsigned int order)
helper function to create InterpolatorPtr easily from bare arrays (analogous to make_pair() )
Definition:
Interpolator.h:206
ThePEG
ThePEG::IBPtr
ThePEG::Ptr< InterfacedBase >::pointer IBPtr
ThePEG::TypeTraits
Generated on Thu Jun 20 2024 17:50:53 for Herwig by
1.9.6