Genfun::GaudiMathImplementation::SplineBase Class Reference

#include </scratch/z5/marcocle/GaudiDocs/lhcb-release/996/GAUDI/GAUDI_v26r4/InstallArea/x86_64-slc6-gcc48-opt/include/GaudiMath/Splines.h>

Collaboration diagram for Genfun::GaudiMathImplementation::SplineBase:

Public Types

typedef std::vector< double > Data1D
 
typedef std::vector< std::pair< double, double > > Data2D
 
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...
 
virtual ~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...
 
 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...
 
virtual ~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
 
void initialize () const
 

Private Member Functions

 SplineBase ()=delete
 
SplineBaseoperator= (const SplineBase &)=delete
 
 SplineBase ()=delete
 
SplineBaseoperator= (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 35 of file Splines.h.

Member Typedef Documentation

Definition at line 38 of file Splines.h.

Definition at line 38 of file Splines.h.

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

Definition at line 39 of file Splines.h.

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

Definition at line 39 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
xvector of x
yvector of y(x)
typeinterpolation 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 ( 0 )
41  , m_accel ( 0 )
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::unique_ptr< double[]> m_y
Definition: Splines.h:127
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:130
std::unique_ptr< double[]> m_x
Definition: Splines.h:126
string type
Definition: gaudirun.py:151
Genfun::GaudiMathImplementation::SplineBase::SplineBase ( const Data2D data,
const GaudiMath::Interpolation::Type  type 
)

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

Parameters
datavector of (x,y(x)) pairs
typeinterpolaiton 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_spline ( 0 )
74  , m_accel ( 0 )
75  , m_type ( type )
76  {
77  double* _x = m_x.get() ;
78  double* _y = m_y.get() ;
79  for( const auto& i : data )
80  {
81  *_x = i.first ; ++_x ;
82  *_y = i.second ; ++_y ;
83  }
84  }
std::unique_ptr< double[]> m_y
Definition: Splines.h:127
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:130
std::unique_ptr< double[]> m_x
Definition: Splines.h:126
list i
Definition: ana.py:128
string type
Definition: gaudirun.py:151
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
typeinterpolation type
begin_xbegin of X-sequence
end_xend of X-sequence
begin_Ybegin of Y-sequence

Definition at line 65 of file Splines.h.

69  : m_dim ( end_x - begin_x )
70  , m_x ( new double[ end_x - begin_x ] )
71  , m_y ( new double[ end_x - begin_x ] )
72  , m_type ( type )
73  {
74  std::copy ( begin_x , end_x , m_x.get() ) ;
75  std::copy ( begin_y , begin_y + ( end_x - begin_x ) , m_y.get() ) ;
76  }
std::unique_ptr< double[]> m_y
Definition: Splines.h:127
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:130
std::unique_ptr< double[]> m_x
Definition: Splines.h:126
string type
Definition: gaudirun.py:151
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
typeinterpolation type
beginbegin of sequence of (x,y(x)) pairs
endend of sequence of (x,y(x)) pairs

Definition at line 86 of file Splines.h.

89  : m_dim ( end - begin )
90  , m_x ( new double[ end - begin ] )
91  , m_y ( new double[ end - begin ] )
92  , m_type ( type )
93  {
94  double* _x = m_x.get() ;
95  double* _y = m_y.get() ;
96  for ( auto it = begin ; end != it ; ++ it )
97  {
98  *_x++ = it -> first ;
99  *_y++ = it -> second ;
100  };
101  }
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:45
std::unique_ptr< double[]> m_y
Definition: Splines.h:127
constexpr double second
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:130
std::unique_ptr< double[]> m_x
Definition: Splines.h:126
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
string type
Definition: gaudirun.py:151
Genfun::GaudiMathImplementation::SplineBase::SplineBase ( const SplineBase right)

copy constructor

Definition at line 90 of file Splines.cpp.

91  : m_init ( false )
92  , m_dim ( right.m_dim )
93  , m_x ( new double[ right.m_dim ] )
94  , m_y ( new double[ right.m_dim ] )
95  , m_spline ( 0 )
96  , m_accel ( 0 )
97  , m_type ( right.m_type )
98  {
99  std::copy_n(right.m_x.get(),m_dim,m_x.get());
100  std::copy_n(right.m_y.get(),m_dim,m_y.get());
101  }
std::unique_ptr< double[]> m_y
Definition: Splines.h:127
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:130
std::unique_ptr< double[]> m_x
Definition: Splines.h:126
Genfun::GaudiMathImplementation::SplineBase::~SplineBase ( )
virtual

destructor

Definition at line 107 of file Splines.cpp.

108  {
109  if ( 0 != m_spline ) { gsl_spline_free ( m_spline ) ; }
110  if ( 0 != m_accel ) { gsl_interp_accel_free ( m_accel ) ; }
111  }
Genfun::GaudiMathImplementation::SplineBase::SplineBase ( )
privatedelete
Genfun::GaudiMathImplementation::SplineBase::SplineBase ( const Data1D x,
const Data1D y,
const GaudiMath::Interpolation::Type  type 
)

constructor from vectors and type

Parameters
xvector of x
yvector of y(x)
typeinterpolation type
Genfun::GaudiMathImplementation::SplineBase::SplineBase ( const Data2D data,
const GaudiMath::Interpolation::Type  type 
)

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

Parameters
datavector of (x,y(x)) pairs
typeinterpolaiton type
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
typeinterpolation type
begin_xbegin of X-sequence
end_xend of X-sequence
begin_Ybegin of Y-sequence

Definition at line 65 of file Splines.h.

69  : m_dim ( end_x - begin_x )
70  , m_x ( new double[ end_x - begin_x ] )
71  , m_y ( new double[ end_x - begin_x ] )
72  , m_type ( type )
73  {
74  std::copy ( begin_x , end_x , m_x.get() ) ;
75  std::copy ( begin_y , begin_y + ( end_x - begin_x ) , m_y.get() ) ;
76  }
std::unique_ptr< double[]> m_y
Definition: Splines.h:127
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:130
std::unique_ptr< double[]> m_x
Definition: Splines.h:126
string type
Definition: gaudirun.py:151
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
typeinterpolation type
beginbegin of sequence of (x,y(x)) pairs
endend of sequence of (x,y(x)) pairs

Definition at line 86 of file Splines.h.

89  : m_dim ( end - begin )
90  , m_x ( new double[ end - begin ] )
91  , m_y ( new double[ end - begin ] )
92  , m_type ( type )
93  {
94  double* _x = m_x.get() ;
95  double* _y = m_y.get() ;
96  for ( auto it = begin ; end != it ; ++ it )
97  {
98  *_x++ = it -> first ;
99  *_y++ = it -> second ;
100  };
101  }
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:45
std::unique_ptr< double[]> m_y
Definition: Splines.h:127
constexpr double second
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:130
std::unique_ptr< double[]> m_x
Definition: Splines.h:126
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
string type
Definition: gaudirun.py:151
Genfun::GaudiMathImplementation::SplineBase::SplineBase ( const SplineBase )

copy constructor

virtual Genfun::GaudiMathImplementation::SplineBase::~SplineBase ( )
virtual

destructor

Genfun::GaudiMathImplementation::SplineBase::SplineBase ( )
privatedelete

Member Function Documentation

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

evaluate the first derivative

Definition at line 159 of file Splines.cpp.

160  {
161  if ( !m_init ) { initialize() ; }
162  return gsl_spline_eval_deriv ( m_spline , x , m_accel );
163  }
double Genfun::GaudiMathImplementation::SplineBase::deriv ( const double  x) const

evaluate the first derivative

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

evaluate the second derivative

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

evaluate the second derivative

Definition at line 167 of file Splines.cpp.

168  {
169  if ( !m_init ) { initialize() ; }
170  return gsl_spline_eval_deriv2 ( m_spline , x , m_accel );
171  }
double Genfun::GaudiMathImplementation::SplineBase::eval ( const double  x) const

evaluate the function

Definition at line 151 of file Splines.cpp.

152  {
153  if ( !m_init ) { initialize() ; }
154  return gsl_spline_eval ( m_spline , x , m_accel );
155  }
double Genfun::GaudiMathImplementation::SplineBase::eval ( const double  x) const

evaluate the function

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

Definition at line 115 of file Splines.cpp.

116  {
117  if ( m_init ) { return ; } // RETURN
118 
119  const gsl_interp_type* T = 0 ;
120 
121  switch ( m_type )
122  {
124  T = gsl_interp_linear ; break ;
126  T = gsl_interp_polynomial ; break ;
128  T = gsl_interp_cspline ; break ;
130  T = gsl_interp_cspline_periodic ; break ;
132  T = gsl_interp_akima ; break ;
134  T = gsl_interp_akima_periodic ; break ;
135  default :
136  T = gsl_interp_cspline ; break ;
137  };
138 
139  m_spline = gsl_spline_alloc( T , m_dim ) ;
140 
141  gsl_spline_init( m_spline , m_x.get() , m_y.get() , m_dim ) ;
142 
143  m_accel = gsl_interp_accel_alloc() ;
144 
145  m_init = true ;
146 
147  }
std::unique_ptr< double[]> m_y
Definition: Splines.h:127
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:130
std::unique_ptr< double[]> m_x
Definition: Splines.h:126
double Genfun::GaudiMathImplementation::SplineBase::integ ( const double  a,
const double  b 
) const

evaluate the integral on [a,b]

Definition at line 175 of file Splines.cpp.

177  {
178  if ( !m_init ) { initialize() ; }
179  return gsl_spline_eval_integ ( m_spline , a , b , m_accel ) ;
180  }
double Genfun::GaudiMathImplementation::SplineBase::integ ( const double  a,
const double  b 
) const

evaluate the integral on [a,b]

SplineBase& Genfun::GaudiMathImplementation::SplineBase::operator= ( const SplineBase )
privatedelete
SplineBase& Genfun::GaudiMathImplementation::SplineBase::operator= ( const SplineBase )
privatedelete

Member Data Documentation

gsl_interp_accel * Genfun::GaudiMathImplementation::SplineBase::m_accel = nullptr
mutableprivate

Definition at line 129 of file Splines.h.

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

Definition at line 125 of file Splines.h.

bool Genfun::GaudiMathImplementation::SplineBase::m_init = false
mutableprivate

Definition at line 124 of file Splines.h.

gsl_spline * Genfun::GaudiMathImplementation::SplineBase::m_spline = nullptr
mutableprivate

Definition at line 128 of file Splines.h.

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

Definition at line 130 of file Splines.h.

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

Definition at line 126 of file Splines.h.

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

Definition at line 127 of file Splines.h.


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