| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# Genfun::GaudiMathImplementation::SplineBase Class Reference

`#include <Splines.h>`

List of all members.

## 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
| SplineBase (const Data2D &data, const GaudiMath::Interpolation::Type type)
| constructor from vector of (x,y(x)) pairs
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
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
| SplineBase (const SplineBase &)
| copy constructor
virtual | ~SplineBase ()
| destructor
double | eval (const double x) const
| evaluate the function
double | deriv (const double x) const
| evaluate the first derivative
double | deriv2 (const double x) const
| evaluate the second derivative
double | integ (const double a, const double b) const
| evaluate the integral on [a,b]
## Protected Member Functions
void | initialize () const
## Private Member Functions
| SplineBase ()
SplineBase & | operator= (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

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

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.

## 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
  | x | vector of x
  | y | vector of y(x)
  | type | interpolation type

Definition at line 32 of file Splines.cpp.

    00035       : m_init      ( false    )
    00036       , m_dim       ( x.size() )
    00037       , m_x         ( new double[ x.size() ] )
    00038       , m_y         ( new double[ y.size() ] )
    00039       , m_spline    ( 0 )
    00040       , m_accel     ( 0 )
    00041       , m_type      ( type )
    00042     {
    00043       std::copy( x.begin() , x.end() , m_x ) ;
    00044       std::copy( y.begin() , y.end() , m_y ) ;
    00045     };

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
  | data | vector of (x,y(x)) pairs
  | type | interpolaiton type

Definition at line 55 of file Splines.cpp.

    00057       : m_init      ( false       )
    00058       , m_dim       ( data.size() )
    00059       , m_x         ( new double[ data.size() ] )
    00060       , m_y         ( new double[ data.size() ] )
    00061       , m_spline    ( 0    )
    00062       , m_accel     ( 0    )
    00063       , m_type      ( type )
    00064     {
    00065       double*  _x = m_x ;
    00066       double*  _y = m_y ;
    00067       for( Data2D::const_iterator it =
    00068              data.begin() ; data.end() != it ; ++it )
    00069       {
    00070         *_x = it -> first  ; ++_x ;
    00071         *_y = it -> second ; ++_y ;
    00072       }
    00073     };

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 66 of file Splines.h.

    00070         : m_init      ( false           )
    00071         , m_dim       ( end_x - begin_x )
    00072         , m_x         ( new double[ end_x - begin_x ] )
    00073         , m_y         ( new double[ end_x - begin_x ] )
    00074         , m_spline    ( 0    )
    00075         , m_accel     ( 0    )
    00076         , m_type      ( type )
    00077       {
    00078         std::copy ( begin_x , end_x                         , m_x ) ;
    00079         std::copy ( begin_y , begin_y + ( end_x - begin_x ) , m_y ) ;
    00080       };

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 90 of file Splines.h.

    00093         : m_init      ( false        )
    00094         , m_dim       ( end - begin  )
    00095         , m_x         ( new double[ end - begin ] )
    00096         , m_y         ( new double[ end - begin ] )
    00097         , m_spline    ( 0    )
    00098         , m_accel     ( 0    )
    00099         , m_type      ( type )
    00100       {
    00101         double* _x = m_x ;
    00102         double* _y = m_y ;
    00103         for ( DATA it = begin ; end != it ; ++ it )
    00104         {
    00105           *_x = it -> first  ; ++_x ;
    00106           *_y = it -> second ; ++_y ;
    00107         };
    00108       };

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

copy constructor

Definition at line 79 of file Splines.cpp.

    00080       : m_init      ( false       )
    00081       , m_dim       ( right.m_dim )
    00082       , m_x         ( new double[ right.m_dim ] )
    00083       , m_y         ( new double[ right.m_dim ] )
    00084       , m_spline    ( 0            )
    00085       , m_accel     ( 0            )
    00086       , m_type      ( right.m_type )
    00087     {
    00088       std::copy( right.m_x , right.m_x + right.m_dim , m_x ) ;
    00089       std::copy( right.m_y , right.m_y + right.m_dim , m_y ) ;
    00090     };

Genfun::GaudiMathImplementation::SplineBase::~SplineBase | ( |  | ) | `[virtual]`

destructor

Definition at line 96 of file Splines.cpp.

    00097     {
    00098       if ( 0 != m_spline ) { gsl_spline_free       ( m_spline ) ; }
    00099       if ( 0 != m_accel  ) { gsl_interp_accel_free ( m_accel  ) ; }
    00100
    00101       if ( 0 != m_x      ) { delete[] m_x      ; }
    00102       if ( 0 != m_y      ) { delete[] m_y      ; }
    00103     };

Genfun::GaudiMathImplementation::SplineBase::SplineBase | ( |  | ) | `[private]`

## Member Function Documentation

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

evaluate the function

Definition at line 143 of file Splines.cpp.

    00144     {
    00145       if ( !m_init ) { initialize() ; }
    00146       return gsl_spline_eval ( m_spline , x , m_accel );
    00147     };

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

evaluate the first derivative

Definition at line 151 of file Splines.cpp.

    00152     {
    00153       if ( !m_init ) { initialize() ; }
    00154       return gsl_spline_eval_deriv  ( m_spline , x , m_accel );
    00155     };

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

evaluate the second derivative

Definition at line 159 of file Splines.cpp.

    00160     {
    00161       if ( !m_init ) { initialize() ; }
    00162       return gsl_spline_eval_deriv2 ( m_spline , x , m_accel );
    00163     };

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

evaluate the integral on [a,b]

Definition at line 167 of file Splines.cpp.

    00169     {
    00170       if ( !m_init ) { initialize() ; }
    00171       return gsl_spline_eval_integ ( m_spline , a , b , m_accel ) ;
    00172     };

void Genfun::GaudiMathImplementation::SplineBase::initialize | ( |  | ) | const`[protected]`

Definition at line 107 of file Splines.cpp.

    00108     {
    00109       if ( m_init ) { return ; }                                 // RETURN
    00110
    00111       const gsl_interp_type* T = 0 ;
    00112
    00113       switch ( m_type )
    00114       {
    00115       case GaudiMath::Interpolation::Linear           :
    00116         T = gsl_interp_linear            ; break ;
    00117       case GaudiMath::Interpolation::Polynomial       :
    00118         T = gsl_interp_polynomial        ; break ;
    00119       case GaudiMath::Interpolation::Cspline          :
    00120         T = gsl_interp_cspline           ; break ;
    00121       case GaudiMath::Interpolation::Cspline_Periodic :
    00122         T = gsl_interp_cspline_periodic  ; break ;
    00123       case GaudiMath::Interpolation::Akima            :
    00124         T = gsl_interp_akima             ; break ;
    00125       case GaudiMath::Interpolation::Akima_Periodic   :
    00126         T = gsl_interp_akima_periodic    ; break ;
    00127       default :
    00128         T = gsl_interp_cspline           ; break ;
    00129       };
    00130
    00131       m_spline = gsl_spline_alloc( T , m_dim ) ;
    00132
    00133       gsl_spline_init( m_spline , m_x , m_y , m_dim ) ;
    00134
    00135       m_accel  = gsl_interp_accel_alloc() ;
    00136
    00137       m_init   = true ;
    00138
    00139     };

SplineBase& Genfun::GaudiMathImplementation::SplineBase::operator= | ( | const SplineBase & |  | ) | `[private]`

## Member Data Documentation

bool Genfun::GaudiMathImplementation::SplineBase::m_init`[mutable, private]`

Definition at line 131 of file Splines.h.

size_t Genfun::GaudiMathImplementation::SplineBase::m_dim`[private]`

Definition at line 132 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.

gsl_spline* Genfun::GaudiMathImplementation::SplineBase::m_spline`[mutable, private]`

Definition at line 135 of file Splines.h.

gsl_interp_accel* Genfun::GaudiMathImplementation::SplineBase::m_accel`[mutable, private]`

Definition at line 136 of file Splines.h.

GaudiMath::Interpolation::Type Genfun::GaudiMathImplementation::SplineBase::m_type`[private]`

Definition at line 137 of file Splines.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7/GaudiGSL/GaudiMath/Splines.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7/GaudiGSL/src/Lib/Splines.cpp