Gaudi Framework, version v23r0

Home   Generated: Mon Jan 30 2012
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

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 ()
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 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.

      : m_init      ( false    )
      , m_dim       ( x.size() )
      , m_x         ( new double[ x.size() ] )
      , m_y         ( new double[ y.size() ] )
      , m_spline    ( 0 )
      , m_accel     ( 0 )
      , m_type      ( type )
    {
#ifdef WIN32
// Disable the warning
//    C4996: 'std::copy': Function call with parameters that may be unsafe
// The parameters are checked
#pragma warning(push)
#pragma warning(disable:4996)
#endif
      std::copy( x.begin() , x.end() , m_x ) ;
      std::copy( y.begin() , y.end() , m_y ) ;
#ifdef WIN32
#pragma warning(pop)
#endif

    }
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.

      : m_init      ( false       )
      , m_dim       ( data.size() )
      , m_x         ( new double[ data.size() ] )
      , m_y         ( new double[ data.size() ] )
      , m_spline    ( 0    )
      , m_accel     ( 0    )
      , m_type      ( type )
    {
      double*  _x = m_x ;
      double*  _y = m_y ;
      for( Data2D::const_iterator it =
             data.begin() ; data.end() != it ; ++it )
      {
        *_x = it -> first  ; ++_x ;
        *_y = it -> second ; ++_y ;
      }
    }
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.

        : m_init      ( false           )
        , m_dim       ( end_x - begin_x )
        , m_x         ( new double[ end_x - begin_x ] )
        , m_y         ( new double[ end_x - begin_x ] )
        , m_spline    ( 0    )
        , m_accel     ( 0    )
        , m_type      ( type )
      {
        std::copy ( begin_x , end_x                         , m_x ) ;
        std::copy ( begin_y , begin_y + ( end_x - begin_x ) , m_y ) ;
      }
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.

        : m_init      ( false        )
        , m_dim       ( end - begin  )
        , m_x         ( new double[ end - begin ] )
        , m_y         ( new double[ end - begin ] )
        , m_spline    ( 0    )
        , m_accel     ( 0    )
        , m_type      ( type )
      {
        double* _x = m_x ;
        double* _y = m_y ;
        for ( DATA it = begin ; end != it ; ++ it )
        {
          *_x = it -> first  ; ++_x ;
          *_y = it -> second ; ++_y ;
        };
      }
Genfun::GaudiMathImplementation::SplineBase::SplineBase ( const SplineBase right )

copy constructor

Definition at line 92 of file Splines.cpp.

      : m_init      ( false       )
      , m_dim       ( right.m_dim )
      , m_x         ( new double[ right.m_dim ] )
      , m_y         ( new double[ right.m_dim ] )
      , m_spline    ( 0            )
      , m_accel     ( 0            )
      , m_type      ( right.m_type )
    {
      std::memcpy(m_x, right.m_x, m_dim);
      std::memcpy(m_y, right.m_y, m_dim);
    }
Genfun::GaudiMathImplementation::SplineBase::~SplineBase (  ) [virtual]

destructor

Definition at line 109 of file Splines.cpp.

    {
      if ( 0 != m_spline ) { gsl_spline_free       ( m_spline ) ; }
      if ( 0 != m_accel  ) { gsl_interp_accel_free ( m_accel  ) ; }

      if ( 0 != m_x      ) { delete[] m_x      ; }
      if ( 0 != m_y      ) { delete[] m_y      ; }
    }
Genfun::GaudiMathImplementation::SplineBase::SplineBase (  ) [private]

Member Function Documentation

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

evaluate the first derivative

Definition at line 164 of file Splines.cpp.

    {
      if ( !m_init ) { initialize() ; }
      return gsl_spline_eval_deriv  ( m_spline , x , m_accel );
    }
double Genfun::GaudiMathImplementation::SplineBase::deriv2 ( const double  x ) const

evaluate the second derivative

Definition at line 172 of file Splines.cpp.

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

evaluate the function

Definition at line 156 of file Splines.cpp.

    {
      if ( !m_init ) { initialize() ; }
      return gsl_spline_eval ( m_spline , x , m_accel );
    }
void Genfun::GaudiMathImplementation::SplineBase::initialize (  ) const [protected]

Definition at line 120 of file Splines.cpp.

    {
      if ( m_init ) { return ; }                                 // RETURN

      const gsl_interp_type* T = 0 ;

      switch ( m_type )
      {
      case GaudiMath::Interpolation::Linear           :
        T = gsl_interp_linear            ; break ;
      case GaudiMath::Interpolation::Polynomial       :
        T = gsl_interp_polynomial        ; break ;
      case GaudiMath::Interpolation::Cspline          :
        T = gsl_interp_cspline           ; break ;
      case GaudiMath::Interpolation::Cspline_Periodic :
        T = gsl_interp_cspline_periodic  ; break ;
      case GaudiMath::Interpolation::Akima            :
        T = gsl_interp_akima             ; break ;
      case GaudiMath::Interpolation::Akima_Periodic   :
        T = gsl_interp_akima_periodic    ; break ;
      default :
        T = gsl_interp_cspline           ; break ;
      };

      m_spline = gsl_spline_alloc( T , m_dim ) ;

      gsl_spline_init( m_spline , m_x , m_y , m_dim ) ;

      m_accel  = gsl_interp_accel_alloc() ;

      m_init   = true ;

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

evaluate the integral on [a,b]

Definition at line 180 of file Splines.cpp.

    {
      if ( !m_init ) { initialize() ; }
      return gsl_spline_eval_integ ( m_spline , a , b , m_accel ) ;
    }
SplineBase& Genfun::GaudiMathImplementation::SplineBase::operator= ( const SplineBase  ) [private]

Member Data Documentation

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

Definition at line 136 of file Splines.h.

Definition at line 132 of file Splines.h.

Definition at line 131 of file Splines.h.

Definition at line 135 of file Splines.h.

Definition at line 137 of file Splines.h.

Definition at line 133 of file Splines.h.

Definition at line 134 of file Splines.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Jan 30 2012 13:53:35 for Gaudi Framework, version v23r0 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004