| The Gaudi Framework v28r2-patches (bc4ad17a)

- 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 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 (const SplineBase &)
| copy constructor More...
| ~SplineBase ()
| destructor 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 Member Functions
| SplineBase ()=delete
SplineBase & | operator= (const SplineBase &)=delete

## Private Attributes
bool | m_init = false
size_t | m_dim
std::unique_ptr< double[]> | m_x
std::unique_ptr< double[]> | m_y
gsl_spline * | m_spline = nullptr
gsl_interp_accel * | m_accel = nullptr
GaudiMath::Interpolation::Type | m_type

## Detailed Description

Definition at line 40 of file Splines.h.

## Member Typedef Documentation

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

Definition at line 43 of file Splines.h.

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

Definition at line 44 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 33 of file Splines.cpp.

36 : m_init ( false )
37 , m_dim ( x.size() )
38 , m_x ( new double[ x.size() ] )
39 , m_y ( new double[ y.size() ] )
40 , m_spline ( nullptr )
41 , m_accel ( nullptr )
42 , m_type ( type )
43 {
44 #ifdef WIN32
45 // Disable the warning
46 // C4996: 'std::copy': Function call with parameters that may be unsafe
47 // The parameters are checked
48 #pragma warning(push)
49 #pragma warning(disable:4996)
50 #endif
51 std::copy( x.begin() , x.end() , m_x.get() ) ;
52 std::copy( y.begin() , y.end() , m_y.get() ) ;
53 #ifdef WIN32
54 #pragma warning(pop)
55 #endif
56
57 }
std::copy
T copy(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_init
bool m_init
Definition: Splines.h:129
Genfun::GaudiMathImplementation::SplineBase::m_y
std::unique_ptr< double[]> m_y
Definition: Splines.h:132
Genfun::GaudiMathImplementation::SplineBase::m_spline
gsl_spline * m_spline
Definition: Splines.h:133
Genfun::GaudiMathImplementation::SplineBase::m_type
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:135
Genfun::GaudiMathImplementation::SplineBase::m_x
std::unique_ptr< double[]> m_x
Definition: Splines.h:131
gaudirun.type
type
Definition: gaudirun.py:125
std::unique_ptr::get
T get(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_dim
size_t m_dim
Definition: Splines.h:130
Genfun::GaudiMathImplementation::SplineBase::m_accel
gsl_interp_accel * m_accel
Definition: Splines.h:134

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 67 of file Splines.cpp.

69 : m_init ( false )
70 , m_dim ( data.size() )
71 , m_x ( new double[ data.size() ] )
72 , m_y ( new double[ data.size() ] )
73 , m_type ( type )
74 {
75 double* _x = m_x.get() ;
76 double* _y = m_y.get() ;
77 for( const auto& i : data )
78 {
79 *_x = i.first ; ++_x ;
80 *_y = i.second ; ++_y ;
81 }
82 }
Genfun::GaudiMathImplementation::SplineBase::m_init
bool m_init
Definition: Splines.h:129
Genfun::GaudiMathImplementation::SplineBase::m_y
std::unique_ptr< double[]> m_y
Definition: Splines.h:132
Genfun::GaudiMathImplementation::SplineBase::m_type
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:135
Genfun::GaudiMathImplementation::SplineBase::m_x
std::unique_ptr< double[]> m_x
Definition: Splines.h:131
gaudirun.type
type
Definition: gaudirun.py:125
std::unique_ptr::get
T get(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_dim
size_t m_dim
Definition: Splines.h:130
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 70 of file Splines.h.

74 : m_dim ( end_x - begin_x )
75 , m_x ( new double[ end_x - begin_x ] )
76 , m_y ( new double[ end_x - begin_x ] )
77 , m_type ( type )
78 {
79 std::copy ( begin_x , end_x , m_x.get() ) ;
80 std::copy ( begin_y , begin_y + ( end_x - begin_x ) , m_y.get() ) ;
81 }
std::copy
T copy(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_y
std::unique_ptr< double[]> m_y
Definition: Splines.h:132
Genfun::GaudiMathImplementation::SplineBase::m_type
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:135
Genfun::GaudiMathImplementation::SplineBase::m_x
std::unique_ptr< double[]> m_x
Definition: Splines.h:131
gaudirun.type
type
Definition: gaudirun.py:125
std::unique_ptr::get
T get(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_dim
size_t m_dim
Definition: Splines.h:130
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 91 of file Splines.h.

94 : m_dim ( end - begin )
95 , m_x ( new double[ end - begin ] )
96 , m_y ( new double[ end - begin ] )
97 , m_type ( type )
98 {
99 double* _x = m_x.get() ;
100 double* _y = m_y.get() ;
101 for ( auto it = begin ; end != it ; ++ it )
102 {
103 *_x++ = it -> first ;
104 *_y++ = it -> second ;
105 };
106 }
Genfun::GaudiMathImplementation::SplineBase::m_y
std::unique_ptr< double[]> m_y
Definition: Splines.h:132
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:48
Gaudi::Units::second
constexpr double second
Definition: SystemOfUnits.h:122
Genfun::GaudiMathImplementation::SplineBase::m_type
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:135
Genfun::GaudiMathImplementation::SplineBase::m_x
std::unique_ptr< double[]> m_x
Definition: Splines.h:131
gaudirun.type
type
Definition: gaudirun.py:125
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:50
std::unique_ptr::get
T get(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_dim
size_t m_dim
Definition: Splines.h:130

Genfun::GaudiMathImplementation::SplineBase::SplineBase | ( | const SplineBase & | right | ) |

copy constructor

Definition at line 88 of file Splines.cpp.

89 : m_init ( false )
90 , m_dim ( right.m_dim )
91 , m_x ( new double[ right.m_dim ] )
92 , m_y ( new double[ right.m_dim ] )
93 , m_type ( right.m_type )
94 {
95 std::copy_n(right.m_x.get(),m_dim,m_x.get());
96 std::copy_n(right.m_y.get(),m_dim,m_y.get());
97 }
Genfun::GaudiMathImplementation::SplineBase::m_init
bool m_init
Definition: Splines.h:129
std::right
T right(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_y
std::unique_ptr< double[]> m_y
Definition: Splines.h:132
std::copy_n
T copy_n(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_type
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:135
Genfun::GaudiMathImplementation::SplineBase::m_x
std::unique_ptr< double[]> m_x
Definition: Splines.h:131
std::unique_ptr::get
T get(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_dim
size_t m_dim
Definition: Splines.h:130

Genfun::GaudiMathImplementation::SplineBase::~SplineBase | ( |  | ) |

destructor

Definition at line 103 of file Splines.cpp.

104 {
105 if ( m_spline ) { gsl_spline_free ( m_spline ) ; }
106 if ( m_accel ) { gsl_interp_accel_free ( m_accel ) ; }
107 }
Genfun::GaudiMathImplementation::SplineBase::m_spline
gsl_spline * m_spline
Definition: Splines.h:133
Genfun::GaudiMathImplementation::SplineBase::m_accel
gsl_interp_accel * m_accel
Definition: Splines.h:134

Genfun::GaudiMathImplementation::SplineBase::SplineBase | ( |  | ) |
| private delete

## Member Function Documentation

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

evaluate the first derivative

Definition at line 155 of file Splines.cpp.

156 {
157 if ( !m_init ) { initialize() ; }
158 return gsl_spline_eval_deriv ( m_spline , x , m_accel );
159 }
Genfun::GaudiMathImplementation::SplineBase::m_init
bool m_init
Definition: Splines.h:129
Genfun::GaudiMathImplementation::SplineBase::m_spline
gsl_spline * m_spline
Definition: Splines.h:133
Genfun::GaudiMathImplementation::SplineBase::m_accel
gsl_interp_accel * m_accel
Definition: Splines.h:134
Genfun::GaudiMathImplementation::SplineBase::initialize
void initialize() const
Definition: Splines.cpp:111

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

evaluate the second derivative

Definition at line 163 of file Splines.cpp.

164 {
165 if ( !m_init ) { initialize() ; }
166 return gsl_spline_eval_deriv2 ( m_spline , x , m_accel );
167 }
Genfun::GaudiMathImplementation::SplineBase::m_init
bool m_init
Definition: Splines.h:129
Genfun::GaudiMathImplementation::SplineBase::m_spline
gsl_spline * m_spline
Definition: Splines.h:133
Genfun::GaudiMathImplementation::SplineBase::m_accel
gsl_interp_accel * m_accel
Definition: Splines.h:134
Genfun::GaudiMathImplementation::SplineBase::initialize
void initialize() const
Definition: Splines.cpp:111

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

evaluate the function

Definition at line 147 of file Splines.cpp.

148 {
149 if ( !m_init ) { initialize() ; }
150 return gsl_spline_eval ( m_spline , x , m_accel );
151 }
Genfun::GaudiMathImplementation::SplineBase::m_init
bool m_init
Definition: Splines.h:129
Genfun::GaudiMathImplementation::SplineBase::m_spline
gsl_spline * m_spline
Definition: Splines.h:133
Genfun::GaudiMathImplementation::SplineBase::m_accel
gsl_interp_accel * m_accel
Definition: Splines.h:134
Genfun::GaudiMathImplementation::SplineBase::initialize
void initialize() const
Definition: Splines.cpp:111

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

Definition at line 111 of file Splines.cpp.

112 {
113 if ( m_init ) { return ; } // RETURN
114
115 const gsl_interp_type* T = nullptr ;
116
117 switch ( m_type )
118 {
119 case GaudiMath::Interpolation::Linear :
120 T = gsl_interp_linear ; break ;
121 case GaudiMath::Interpolation::Polynomial :
122 T = gsl_interp_polynomial ; break ;
123 case GaudiMath::Interpolation::Cspline :
124 T = gsl_interp_cspline ; break ;
125 case GaudiMath::Interpolation::Cspline_Periodic :
126 T = gsl_interp_cspline_periodic ; break ;
127 case GaudiMath::Interpolation::Akima :
128 T = gsl_interp_akima ; break ;
129 case GaudiMath::Interpolation::Akima_Periodic :
130 T = gsl_interp_akima_periodic ; break ;
131 default :
132 T = gsl_interp_cspline ; break ;
133 };
134
135 m_spline = gsl_spline_alloc( T , m_dim ) ;
136
137 gsl_spline_init( m_spline , m_x.get() , m_y.get() , m_dim ) ;
138
139 m_accel = gsl_interp_accel_alloc() ;
140
141 m_init = true ;
142
143 }
GaudiMath::Interpolation::Akima
Definition: Interpolation.h:17
Genfun::GaudiMathImplementation::SplineBase::m_init
bool m_init
Definition: Splines.h:129
Genfun::GaudiMathImplementation::SplineBase::m_y
std::unique_ptr< double[]> m_y
Definition: Splines.h:132
GaudiMath::Interpolation::Polynomial
Definition: Interpolation.h:14
Genfun::GaudiMathImplementation::SplineBase::m_spline
gsl_spline * m_spline
Definition: Splines.h:133
Genfun::GaudiMathImplementation::SplineBase::m_type
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:135
Genfun::GaudiMathImplementation::SplineBase::m_x
std::unique_ptr< double[]> m_x
Definition: Splines.h:131
GaudiMath::Interpolation::Cspline
Definition: Interpolation.h:15
std::unique_ptr::get
T get(T...args)
Genfun::GaudiMathImplementation::SplineBase::m_dim
size_t m_dim
Definition: Splines.h:130
GaudiMath::Interpolation::Akima_Periodic
Definition: Interpolation.h:18
GaudiMath::Interpolation::Cspline_Periodic
Definition: Interpolation.h:16
GaudiMath::Interpolation::Linear
Definition: Interpolation.h:13
Genfun::GaudiMathImplementation::SplineBase::m_accel
gsl_interp_accel * m_accel
Definition: Splines.h:134

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

evaluate the integral on [a,b]

Definition at line 171 of file Splines.cpp.

173 {
174 if ( !m_init ) { initialize() ; }
175 return gsl_spline_eval_integ ( m_spline , a , b , m_accel ) ;
176 }
Genfun::GaudiMathImplementation::SplineBase::m_init
bool m_init
Definition: Splines.h:129
Genfun::GaudiMathImplementation::SplineBase::m_spline
gsl_spline * m_spline
Definition: Splines.h:133
Genfun::GaudiMathImplementation::SplineBase::m_accel
gsl_interp_accel * m_accel
Definition: Splines.h:134
Genfun::GaudiMathImplementation::SplineBase::initialize
void initialize() const
Definition: Splines.cpp:111

SplineBase& Genfun::GaudiMathImplementation::SplineBase::operator= | ( | const SplineBase & |  | ) |
| private delete

## Member Data Documentation

gsl_interp_accel* Genfun::GaudiMathImplementation::SplineBase::m_accel = nullptr
| mutable private

Definition at line 134 of file Splines.h.

size_t Genfun::GaudiMathImplementation::SplineBase::m_dim
| private

Definition at line 130 of file Splines.h.

bool Genfun::GaudiMathImplementation::SplineBase::m_init = false
| mutable private

Definition at line 129 of file Splines.h.

gsl_spline* Genfun::GaudiMathImplementation::SplineBase::m_spline = nullptr
| mutable private

Definition at line 133 of file Splines.h.

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

Definition at line 135 of file Splines.h.

std::unique_ptr<double[]> Genfun::GaudiMathImplementation::SplineBase::m_x
| private

Definition at line 131 of file Splines.h.

std::unique_ptr<double[]> Genfun::GaudiMathImplementation::SplineBase::m_y
| private

Definition at line 132 of file Splines.h.

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

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