Genfun::GaudiMathImplementation::SplineBase Class Reference

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

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 ()
 
SplineBaseoperator= (const SplineBase &)
 
 SplineBase ()
 
SplineBaseoperator= (const SplineBase &)
 

Private Attributes

bool m_init
 
size_t m_dim
 
double * m_x
 
double * m_y
 
gsl_spline * m_spline
 
gsl_interp_accel * m_accel
 
GaudiMath::Interpolation::Type m_type
 

Detailed Description

Definition at line 36 of file Splines.h.

Member Typedef Documentation

Definition at line 39 of file Splines.h.

Definition at line 39 of file Splines.h.

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

Definition at line 40 of file Splines.h.

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

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

37  : m_init ( false )
38  , m_dim ( x.size() )
39  , m_x ( new double[ x.size() ] )
40  , m_y ( new double[ y.size() ] )
41  , m_spline ( 0 )
42  , m_accel ( 0 )
43  , m_type ( type )
44  {
45 #ifdef WIN32
46 // Disable the warning
47 // C4996: 'std::copy': Function call with parameters that may be unsafe
48 // The parameters are checked
49 #pragma warning(push)
50 #pragma warning(disable:4996)
51 #endif
52  std::copy( x.begin() , x.end() , m_x ) ;
53  std::copy( y.begin() , y.end() , m_y ) ;
54 #ifdef WIN32
55 #pragma warning(pop)
56 #endif
57 
58  }
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:137
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 68 of file Splines.cpp.

70  : m_init ( false )
71  , m_dim ( data.size() )
72  , m_x ( new double[ data.size() ] )
73  , m_y ( new double[ data.size() ] )
74  , m_spline ( 0 )
75  , m_accel ( 0 )
76  , m_type ( type )
77  {
78  double* _x = m_x ;
79  double* _y = m_y ;
80  for( Data2D::const_iterator it =
81  data.begin() ; data.end() != it ; ++it )
82  {
83  *_x = it -> first ; ++_x ;
84  *_y = it -> second ; ++_y ;
85  }
86  }
constexpr double second
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:137
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 66 of file Splines.h.

70  : m_init ( false )
71  , m_dim ( end_x - begin_x )
72  , m_x ( new double[ end_x - begin_x ] )
73  , m_y ( new double[ end_x - begin_x ] )
74  , m_spline ( 0 )
75  , m_accel ( 0 )
76  , m_type ( type )
77  {
78  std::copy ( begin_x , end_x , m_x ) ;
79  std::copy ( begin_y , begin_y + ( end_x - begin_x ) , m_y ) ;
80  }
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:137
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 90 of file Splines.h.

93  : m_init ( false )
94  , m_dim ( end - begin )
95  , m_x ( new double[ end - begin ] )
96  , m_y ( new double[ end - begin ] )
97  , m_spline ( 0 )
98  , m_accel ( 0 )
99  , m_type ( type )
100  {
101  double* _x = m_x ;
102  double* _y = m_y ;
103  for ( DATA it = begin ; end != it ; ++ it )
104  {
105  *_x = it -> first ; ++_x ;
106  *_y = it -> second ; ++_y ;
107  };
108  }
constexpr double second
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:137
tuple end
Definition: IOTest.py:101
string type
Definition: gaudirun.py:151
Genfun::GaudiMathImplementation::SplineBase::SplineBase ( const SplineBase right)

copy constructor

Definition at line 92 of file Splines.cpp.

93  : m_init ( false )
94  , m_dim ( right.m_dim )
95  , m_x ( new double[ right.m_dim ] )
96  , m_y ( new double[ right.m_dim ] )
97  , m_spline ( 0 )
98  , m_accel ( 0 )
99  , m_type ( right.m_type )
100  {
101  const std::size_t size = sizeof(double) * m_dim;
102  std::memcpy(m_x, right.m_x, size);
103  std::memcpy(m_y, right.m_y, size);
104  }
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:137
Genfun::GaudiMathImplementation::SplineBase::~SplineBase ( )
virtual

destructor

Definition at line 110 of file Splines.cpp.

111  {
112  if ( 0 != m_spline ) { gsl_spline_free ( m_spline ) ; }
113  if ( 0 != m_accel ) { gsl_interp_accel_free ( m_accel ) ; }
114 
115  if ( 0 != m_x ) { delete[] m_x ; }
116  if ( 0 != m_y ) { delete[] m_y ; }
117  }
Genfun::GaudiMathImplementation::SplineBase::SplineBase ( )
private
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 66 of file Splines.h.

70  : m_init ( false )
71  , m_dim ( end_x - begin_x )
72  , m_x ( new double[ end_x - begin_x ] )
73  , m_y ( new double[ end_x - begin_x ] )
74  , m_spline ( 0 )
75  , m_accel ( 0 )
76  , m_type ( type )
77  {
78  std::copy ( begin_x , end_x , m_x ) ;
79  std::copy ( begin_y , begin_y + ( end_x - begin_x ) , m_y ) ;
80  }
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:137
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 90 of file Splines.h.

93  : m_init ( false )
94  , m_dim ( end - begin )
95  , m_x ( new double[ end - begin ] )
96  , m_y ( new double[ end - begin ] )
97  , m_spline ( 0 )
98  , m_accel ( 0 )
99  , m_type ( type )
100  {
101  double* _x = m_x ;
102  double* _y = m_y ;
103  for ( DATA it = begin ; end != it ; ++ it )
104  {
105  *_x = it -> first ; ++_x ;
106  *_y = it -> second ; ++_y ;
107  };
108  }
constexpr double second
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:137
tuple end
Definition: IOTest.py:101
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 ( )
private

Member Function Documentation

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

evaluate the first derivative

Definition at line 165 of file Splines.cpp.

166  {
167  if ( !m_init ) { initialize() ; }
168  return gsl_spline_eval_deriv ( m_spline , x , m_accel );
169  }
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 173 of file Splines.cpp.

174  {
175  if ( !m_init ) { initialize() ; }
176  return gsl_spline_eval_deriv2 ( m_spline , x , m_accel );
177  }
double Genfun::GaudiMathImplementation::SplineBase::eval ( const double  x) const

evaluate the function

Definition at line 157 of file Splines.cpp.

158  {
159  if ( !m_init ) { initialize() ; }
160  return gsl_spline_eval ( m_spline , x , m_accel );
161  }
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 121 of file Splines.cpp.

122  {
123  if ( m_init ) { return ; } // RETURN
124 
125  const gsl_interp_type* T = 0 ;
126 
127  switch ( m_type )
128  {
130  T = gsl_interp_linear ; break ;
132  T = gsl_interp_polynomial ; break ;
134  T = gsl_interp_cspline ; break ;
136  T = gsl_interp_cspline_periodic ; break ;
138  T = gsl_interp_akima ; break ;
140  T = gsl_interp_akima_periodic ; break ;
141  default :
142  T = gsl_interp_cspline ; break ;
143  };
144 
145  m_spline = gsl_spline_alloc( T , m_dim ) ;
146 
147  gsl_spline_init( m_spline , m_x , m_y , m_dim ) ;
148 
149  m_accel = gsl_interp_accel_alloc() ;
150 
151  m_init = true ;
152 
153  }
GaudiMath::Interpolation::Type m_type
Definition: Splines.h:137
double Genfun::GaudiMathImplementation::SplineBase::integ ( const double  a,
const double  b 
) const

evaluate the integral on [a,b]

Definition at line 181 of file Splines.cpp.

183  {
184  if ( !m_init ) { initialize() ; }
185  return gsl_spline_eval_integ ( m_spline , a , b , m_accel ) ;
186  }
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 )
private
SplineBase& Genfun::GaudiMathImplementation::SplineBase::operator= ( const SplineBase )
private

Member Data Documentation

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

Definition at line 136 of file Splines.h.

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

Definition at line 132 of file Splines.h.

bool Genfun::GaudiMathImplementation::SplineBase::m_init
mutableprivate

Definition at line 131 of file Splines.h.

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

Definition at line 135 of file Splines.h.

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

Definition at line 137 of file Splines.h.

double * Genfun::GaudiMathImplementation::SplineBase::m_x
private

Definition at line 133 of file Splines.h.

double * Genfun::GaudiMathImplementation::SplineBase::m_y
private

Definition at line 134 of file Splines.h.


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