| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Genfun::GaudiMathImplementation::SplineBase Class Reference

`#include <GaudiMath/Splines.h>`

Collaboration diagram for Genfun::GaudiMathImplementation::SplineBase:
[legend]

## Public Types
typedef std::vector< double > | Data1D
typedef std::vector< std::pair< double, double > > | Data2D

## Public Member Functions
| SplineBase (const Data1D &x, const Data1D &y, const GaudiMath::Interpolation::Type type)
| constructor from vectors and type More...
| SplineBase (const Data2D &data, const GaudiMath::Interpolation::Type type)
| constructor from vector of (x,y(x)) pairs More...
template<class DATAX , class DATAY >
| SplineBase (const GaudiMath::Interpolation::Type type, DATAX begin_x, DATAX end_x, DATAY begin_y)
| templated constructor in the spirit of STL-algorithms More...
template<class DATA >
| SplineBase (const GaudiMath::Interpolation::Type type, DATA begin, DATA end)
| templated constructor from the sequence of (x,y(x)) pairs as sequence of pairs the class TabulatedProperty can be used More...
| SplineBase (SplineBase &&)=default
| move constructor More...
SplineBase & | operator= (SplineBase &&rhs)=default
| move assignment More...
| SplineBase (const SplineBase &rhs)
| copy constructor More...
SplineBase & | operator= (const SplineBase &rhs)
| assignment More...
double | eval (const double x) const
| evaluate the function More...
double | deriv (const double x) const
| evaluate the first derivative More...
double | deriv2 (const double x) const
| evaluate the second derivative More...
double | integ (const double a, const double b) const
| evaluate the integral on [a,b] More...

## Protected Member Functions
void | initialize () const

## Private Attributes
std::vector< double > | m_x
std::vector< double > | m_y
std::unique_ptr< gsl_spline, details::gsl_deleter > | m_spline
std::unique_ptr< gsl_interp_accel, details::gsl_deleter > | m_accel
| transient More...
GaudiMath::Interpolation::Type | m_type
| transient More...

## Detailed Description

Definition at line 53 of file Splines.h.

## Member Typedef Documentation

typedef std::vector<double> Genfun::GaudiMathImplementation::SplineBase::Data1D

Definition at line 56 of file Splines.h.

typedef std::vector<std::pair<double, double> > Genfun::GaudiMathImplementation::SplineBase::Data2D

Definition at line 57 of file Splines.h.

## Constructor & Destructor Documentation

Genfun::GaudiMathImplementation::SplineBase::SplineBase | ( | const Data1D & | x,
|  | const Data1D & | y,
|  | const GaudiMath::Interpolation::Type | type
| ) |  |

constructor from vectors and type

Parameters

  x | vector of x
  y | vector of y(x)
  type | interpolation type

Definition at line 31 of file Splines.cpp.

33 : m_x( x ), m_y( y ), m_type( type )
34 {
35 }
Genfun::GaudiMathImplementation::SplineBase::m_type
GaudiMath::Interpolation::Type m_type
transient
Definition: Splines.h:140
gaudirun.type
type
Definition: gaudirun.py:133
Genfun::GaudiMathImplementation::SplineBase::m_y
std::vector< double > m_y
Definition: Splines.h:137
Genfun::GaudiMathImplementation::SplineBase::m_x
std::vector< double > m_x
Definition: Splines.h:136

Genfun::GaudiMathImplementation::SplineBase::SplineBase | ( | const Data2D & | data,
|  | const GaudiMath::Interpolation::Type | type
| ) |  |

constructor from vector of (x,y(x)) pairs

Parameters

  data | vector of (x,y(x)) pairs
  type | interpolaiton type

Definition at line 44 of file Splines.cpp.

44 : m_type( type )
45 {
46 m_x.reserve( data.size() );
47 m_y.reserve( data.size() );
48 for ( const auto& i : data ) {
49 m_x.push_back( i.first );
50 m_y.push_back( i.second );
51 }
52 }
std::vector::push_back
T push_back(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_type
GaudiMath::Interpolation::Type m_type
transient
Definition: Splines.h:140
gaudirun.type
type
Definition: gaudirun.py:133
Genfun::GaudiMathImplementation::SplineBase::m_y
std::vector< double > m_y
Definition: Splines.h:137
Genfun::GaudiMathImplementation::SplineBase::m_x
std::vector< double > m_x
Definition: Splines.h:136
std::vector::reserve
T reserve(T...args)
template<class DATAX , class DATAY >

Genfun::GaudiMathImplementation::SplineBase::SplineBase | ( | const GaudiMath::Interpolation::Type | type,
|  | DATAX | begin_x,
|  | DATAX | end_x,
|  | DATAY | begin_y
| ) |  |
| inline

templated constructor in the spirit of STL-algorithms

Parameters

  type | interpolation type
  begin_x | begin of X-sequence
  end_x | end of X-sequence
  begin_Y | begin of Y-sequence

Definition at line 78 of file Splines.h.

79 : m_type( type )
80 {
81 auto size = std::distance( begin_x, end_x );
82 m_x.reserve( size );
83 std::copy_n( begin_x, size, std::back_inserter( m_x ) );
84 m_y.reserve( size );
85 std::copy_n( begin_y, size, std::back_inserter( m_y ) );
86 }
std::distance
T distance(T...args)
std::copy_n
T copy_n(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_type
GaudiMath::Interpolation::Type m_type
transient
Definition: Splines.h:140
gaudirun.type
type
Definition: gaudirun.py:133
Genfun::GaudiMathImplementation::SplineBase::m_y
std::vector< double > m_y
Definition: Splines.h:137
std::back_inserter
T back_inserter(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_x
std::vector< double > m_x
Definition: Splines.h:136
std::vector::reserve
T reserve(T...args)
template<class DATA >

Genfun::GaudiMathImplementation::SplineBase::SplineBase | ( | const GaudiMath::Interpolation::Type | type,
|  | DATA | begin,
|  | DATA | end
| ) |  |
| inline

templated constructor from the sequence of (x,y(x)) pairs as sequence of pairs the class TabulatedProperty can be used

Parameters

  type | interpolation type
  begin | begin of sequence of (x,y(x)) pairs
  end | end of sequence of (x,y(x)) pairs

Definition at line 95 of file Splines.h.

95 : m_type( type )
96 {
97 m_x.reserve( end - begin );
98 m_y.reserve( end - begin );
99 for ( ; begin != end; ++begin ) {
100 m_x.push_back( begin->first );
101 m_y.push_back( begin->second );
102 };
103 }
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:58
std::vector::push_back
T push_back(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_type
GaudiMath::Interpolation::Type m_type
transient
Definition: Splines.h:140
gaudirun.type
type
Definition: gaudirun.py:133
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:64
Genfun::GaudiMathImplementation::SplineBase::m_y
std::vector< double > m_y
Definition: Splines.h:137
Genfun::GaudiMathImplementation::SplineBase::m_x
std::vector< double > m_x
Definition: Splines.h:136
std::vector::reserve
T reserve(T...args)

Genfun::GaudiMathImplementation::SplineBase::SplineBase | ( | SplineBase && |  | ) |
| default

move constructor

Genfun::GaudiMathImplementation::SplineBase::SplineBase | ( | const SplineBase & | rhs | ) |
| inline

copy constructor

Definition at line 110 of file Splines.h.

110 : m_x( rhs.m_x ), m_y( rhs.m_y ), m_type( rhs.m_type )
111 // note that we do NOT copy m_spline, m_accel!
112 {
113 }
Genfun::GaudiMathImplementation::SplineBase::m_type
GaudiMath::Interpolation::Type m_type
transient
Definition: Splines.h:140
Genfun::GaudiMathImplementation::SplineBase::m_y
std::vector< double > m_y
Definition: Splines.h:137
Genfun::GaudiMathImplementation::SplineBase::m_x
std::vector< double > m_x
Definition: Splines.h:136

## Member Function Documentation

double Genfun::GaudiMathImplementation::SplineBase::deriv | ( | const double | x | ) | const

evaluate the first derivative

Definition at line 107 of file Splines.cpp.

108 {
109 if ( !m_spline ) {
110 initialize();
111 }
112 return gsl_spline_eval_deriv( m_spline.get(), x, m_accel.get() );
113 }
Genfun::GaudiMathImplementation::SplineBase::m_spline
std::unique_ptr< gsl_spline, details::gsl_deleter > m_spline
Definition: Splines.h:138
std::unique_ptr::get
T get(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_accel
std::unique_ptr< gsl_interp_accel, details::gsl_deleter > m_accel
transient
Definition: Splines.h:139
Genfun::GaudiMathImplementation::SplineBase::initialize
void initialize() const
Definition: Splines.cpp:56

double Genfun::GaudiMathImplementation::SplineBase::deriv2 | ( | const double | x | ) | const

evaluate the second derivative

Definition at line 117 of file Splines.cpp.

118 {
119 if ( !m_spline ) {
120 initialize();
121 }
122 return gsl_spline_eval_deriv2( m_spline.get(), x, m_accel.get() );
123 }
Genfun::GaudiMathImplementation::SplineBase::m_spline
std::unique_ptr< gsl_spline, details::gsl_deleter > m_spline
Definition: Splines.h:138
std::unique_ptr::get
T get(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_accel
std::unique_ptr< gsl_interp_accel, details::gsl_deleter > m_accel
transient
Definition: Splines.h:139
Genfun::GaudiMathImplementation::SplineBase::initialize
void initialize() const
Definition: Splines.cpp:56

double Genfun::GaudiMathImplementation::SplineBase::eval | ( | const double | x | ) | const

evaluate the function

Definition at line 97 of file Splines.cpp.

98 {
99 if ( !m_spline ) {
100 initialize();
101 }
102 return gsl_spline_eval( m_spline.get(), x, m_accel.get() );
103 }
Genfun::GaudiMathImplementation::SplineBase::m_spline
std::unique_ptr< gsl_spline, details::gsl_deleter > m_spline
Definition: Splines.h:138
std::unique_ptr::get
T get(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_accel
std::unique_ptr< gsl_interp_accel, details::gsl_deleter > m_accel
transient
Definition: Splines.h:139
Genfun::GaudiMathImplementation::SplineBase::initialize
void initialize() const
Definition: Splines.cpp:56

void Genfun::GaudiMathImplementation::SplineBase::initialize | ( |  | ) | const
| protected

Definition at line 56 of file Splines.cpp.

57 {
58 if ( m_spline ) {
59 return;
60 } // RETURN
61
62 const gsl_interp_type* T = nullptr;
63
64 switch ( m_type ) {
65 case GaudiMath::Interpolation::Linear:
66 T = gsl_interp_linear;
67 break;
68 case GaudiMath::Interpolation::Polynomial:
69 T = gsl_interp_polynomial;
70 break;
71 case GaudiMath::Interpolation::Cspline:
72 T = gsl_interp_cspline;
73 break;
74 case GaudiMath::Interpolation::Cspline_Periodic:
75 T = gsl_interp_cspline_periodic;
76 break;
77 case GaudiMath::Interpolation::Akima:
78 T = gsl_interp_akima;
79 break;
80 case GaudiMath::Interpolation::Akima_Periodic:
81 T = gsl_interp_akima_periodic;
82 break;
83 default:
84 T = gsl_interp_cspline;
85 break;
86 };
87
88 m_spline.reset( gsl_spline_alloc( T, m_x.size() ) );
89 gsl_spline_init( m_spline.get(), m_x.data(), m_y.data(), m_x.size() );
90 m_accel.reset( gsl_interp_accel_alloc() );
91
92 if ( !m_accel ) m_spline.reset();
93 }
GaudiMath::Interpolation::Akima
Definition: Interpolation.h:20
Genfun::GaudiMathImplementation::SplineBase::m_spline
std::unique_ptr< gsl_spline, details::gsl_deleter > m_spline
Definition: Splines.h:138
GaudiMath::Interpolation::Polynomial
Definition: Interpolation.h:17
std::vector::data
T data(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_type
GaudiMath::Interpolation::Type m_type
transient
Definition: Splines.h:140
GaudiMath::Interpolation::Cspline
Definition: Interpolation.h:18
std::unique_ptr::reset
T reset(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_y
std::vector< double > m_y
Definition: Splines.h:137
std::unique_ptr::get
T get(T...args)
std::vector::size
T size(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_accel
std::unique_ptr< gsl_interp_accel, details::gsl_deleter > m_accel
transient
Definition: Splines.h:139
GaudiMath::Interpolation::Akima_Periodic
Definition: Interpolation.h:21
GaudiMath::Interpolation::Cspline_Periodic
Definition: Interpolation.h:19
GaudiMath::Interpolation::Linear
Definition: Interpolation.h:16
Genfun::GaudiMathImplementation::SplineBase::m_x
std::vector< double > m_x
Definition: Splines.h:136

double Genfun::GaudiMathImplementation::SplineBase::integ | ( | const double | a,
|  | const double | b
| ) |  | const

evaluate the integral on [a,b]

Definition at line 127 of file Splines.cpp.

128 {
129 if ( !m_spline ) {
130 initialize();
131 }
132 return gsl_spline_eval_integ( m_spline.get(), a, b, m_accel.get() );
133 }
Genfun::GaudiMathImplementation::SplineBase::m_spline
std::unique_ptr< gsl_spline, details::gsl_deleter > m_spline
Definition: Splines.h:138
std::unique_ptr::get
T get(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_accel
std::unique_ptr< gsl_interp_accel, details::gsl_deleter > m_accel
transient
Definition: Splines.h:139
Genfun::GaudiMathImplementation::SplineBase::initialize
void initialize() const
Definition: Splines.cpp:56

SplineBase& Genfun::GaudiMathImplementation::SplineBase::operator= | ( | SplineBase && | rhs | ) |
| default

move assignment

SplineBase& Genfun::GaudiMathImplementation::SplineBase::operator= | ( | const SplineBase & | rhs | ) |
| inline

assignment

Definition at line 115 of file Splines.h.

116 {
117 *this = SplineBase( rhs );
118 return *this;
119 }
Genfun::GaudiMathImplementation::SplineBase::SplineBase
SplineBase(const Data1D &x, const Data1D &y, const GaudiMath::Interpolation::Type type)
constructor from vectors and type
Definition: Splines.cpp:31

## Member Data Documentation

std::unique_ptr<gsl_interp_accel, details::gsl_deleter> Genfun::GaudiMathImplementation::SplineBase::m_accel
| mutable private

transient

Definition at line 139 of file Splines.h.

std::unique_ptr<gsl_spline, details::gsl_deleter> Genfun::GaudiMathImplementation::SplineBase::m_spline
| mutable private

Definition at line 138 of file Splines.h.

GaudiMath::Interpolation::Type Genfun::GaudiMathImplementation::SplineBase::m_type
| private

transient

Definition at line 140 of file Splines.h.

std::vector<double> Genfun::GaudiMathImplementation::SplineBase::m_x
| private

Definition at line 136 of file Splines.h.

std::vector<double> Genfun::GaudiMathImplementation::SplineBase::m_y
| private

Definition at line 137 of file Splines.h.

The documentation for this class was generated from the following files:

- GaudiGSL/GaudiMath/Splines.h
- GaudiGSL/src/Lib/Splines.cpp