| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

# GSLFunAdapters.cpp

Go to the documentation of this file.

    00001 // $Id: GSLFunAdapters.cpp,v 1.2 2005/11/25 10:27:03 mato Exp $
    00002 // ============================================================================
    00003 // Include files
    00004 // ============================================================================
    00005 // GaudiGSL/GaudiMath
    00006 // ============================================================================
    00007 #include "GaudiMath/GSLFunAdapters.h"
    00008 #include "GaudiMath/GaudiMath.h"
    00009 // ============================================================================
    00010 // GSL
    00011 // ============================================================================
    00012 #include "gsl/gsl_mode.h"
    00013 #include "gsl/gsl_sf_result.h"
    00014 // ============================================================================
    00015
    00023 namespace Genfun
    00024 {
    00025   namespace GaudiMathImplementation
    00026   {
    00027
    00028     FUNCTION_OBJECT_IMP( GSLFunctionWithError )
    00029
    00030     GSLFunctionWithError::GSLFunctionWithError
    00031     ( GSLFunctionWithError::Function function )
    00032       : AbsFunction()
    00033       , m_function ( function )
    00034       , m_result ( new gsl_sf_result() )
    00035     {
    00036       m_result -> val = -1.e+10 ;
    00037       m_result -> err = -1.e+10 ;
    00038     }
    00039
    00040     GSLFunctionWithError::GSLFunctionWithError
    00041     ( const GSLFunctionWithError& func  )
    00042       : AbsFunction()
    00043       , m_function ( func.m_function    )
    00044       , m_result   ( new gsl_sf_result() )
    00045     {
    00046       m_result -> val = func.m_result -> val ;
    00047       m_result -> err = func.m_result -> err ;
    00048     }
    00049
    00050     GSLFunctionWithError::~GSLFunctionWithError()
    00051     { if ( 0 != m_result ) { delete m_result  ; } }
    00052
    00053     double GSLFunctionWithError::operator()
    00054       (       double    x ) const
    00055     {
    00056       (*m_function)( x , m_result ) ;
    00057       return m_result -> val ;
    00058     }
    00059
    00060     double GSLFunctionWithError::operator()
    00061       ( const Genfun::Argument& x ) const
    00062     {
    00063       (*m_function)( x[0] , m_result ) ;
    00064       return m_result -> val ;
    00065     }
    00066
    00067     Genfun::Derivative GSLFunctionWithError::partial
    00068     ( unsigned int i ) const
    00069     {
    00070       if( i >= 1 )
    00071       {
    00072         const AbsFunction& aux = GaudiMath::Constant( 0 , 1 ) ;
    00073         return Genfun::FunctionNoop( &aux ) ;
    00074       };
    00075       const AbsFunction& aux = GaudiMath::Derivative( *this , i) ;
    00076       return Genfun::FunctionNoop( &aux ) ;
    00077     }
    00078
    00079     GSLFunctionWithError::Function GSLFunctionWithError::function() const
    00080     { return  m_function      ; }
    00081
    00082     const gsl_sf_result& GSLFunctionWithError::result () const
    00083     { return *m_result        ; }
    00084
    00085     double               GSLFunctionWithError::error  () const
    00086     { return  m_result -> err ; }
    00087
    00088
    00089     FUNCTION_OBJECT_IMP( GSLFunctionWithMode )
    00090
    00091     GSLFunctionWithMode::GSLFunctionWithMode
    00092     ( GSLFunctionWithMode::Function  function ,
    00093       const gsl_mode_t&              mod      )
    00094       : AbsFunction()
    00095       , m_function ( function )
    00096       , m_mode     ( new gsl_mode_t() )
    00097     {
    00098       *m_mode = mod ;
    00099     }
    00100
    00101     GSLFunctionWithMode::GSLFunctionWithMode
    00102     ( const GSLFunctionWithMode& func  )
    00103       : AbsFunction()
    00104       , m_function ( func.m_function   )
    00105       , m_mode     ( new gsl_mode_t () )
    00106     {
    00107       *m_mode = *(func.m_mode) ;
    00108     }
    00109
    00110     GSLFunctionWithMode::~GSLFunctionWithMode()
    00111     { if ( 0 != m_mode ) { delete m_mode  ; } }
    00112
    00113     double GSLFunctionWithMode::operator()
    00114       (       double    x ) const
    00115     { return (*m_function)( x , *m_mode ) ; }
    00116
    00117     double GSLFunctionWithMode::operator()
    00118       ( const Genfun::Argument& x ) const
    00119     { return (*m_function)( x[0] , *m_mode ) ; }
    00120
    00121     Genfun::Derivative GSLFunctionWithMode::partial
    00122     ( unsigned int i ) const
    00123     {
    00124       if( i >= 1 )
    00125       {
    00126         const AbsFunction& aux = GaudiMath::Constant( 0 , 1 ) ;
    00127         return Genfun::FunctionNoop( &aux ) ;
    00128       };
    00129       const AbsFunction& aux = GaudiMath::Derivative( *this , i) ;
    00130       return Genfun::FunctionNoop( &aux ) ;
    00131     }
    00132
    00133     GSLFunctionWithMode::Function GSLFunctionWithMode::function() const
    00134     { return  m_function      ; }
    00135
    00136     const gsl_mode_t&             GSLFunctionWithMode::mode    () const
    00137     { return *m_mode          ; }
    00138
    00139
    00140     FUNCTION_OBJECT_IMP( GSLFunctionWithModeAndError )
    00141
    00142     GSLFunctionWithModeAndError::GSLFunctionWithModeAndError
    00143     ( GSLFunctionWithModeAndError::Function  function ,
    00144       const gsl_mode_t&              mod      )
    00145       : AbsFunction()
    00146       , m_function ( function )
    00147       , m_mode     ( new gsl_mode_t() )
    00148       , m_result   ( new gsl_sf_result() )
    00149     {
    00150       *m_mode = mod ;
    00151       m_result -> val = -1.e+10 ;
    00152       m_result -> err = -1.e+10 ;
    00153     }
    00154
    00155     GSLFunctionWithModeAndError::GSLFunctionWithModeAndError
    00156     ( const GSLFunctionWithModeAndError& func  )
    00157       : AbsFunction()
    00158       , m_function ( func.m_function     )
    00159       , m_mode     ( new gsl_mode_t ()   )
    00160       , m_result   ( new gsl_sf_result() )
    00161     {
    00162       *m_mode         = *(func.m_mode)         ;
    00163       m_result -> val =   func.m_result -> val ;
    00164       m_result -> err =   func.m_result -> err ;
    00165     }
    00166
    00167     GSLFunctionWithModeAndError::~GSLFunctionWithModeAndError()
    00168     {
    00169       if ( 0 != m_mode   ) { delete m_mode    ; }
    00170       if ( 0 != m_result ) { delete m_result  ; }
    00171     }
    00172
    00173     double GSLFunctionWithModeAndError::operator()
    00174       (       double    x ) const
    00175     {
    00176       (*m_function)( x , *m_mode , m_result ) ;
    00177       return m_result -> val ;
    00178     }
    00179
    00180     double GSLFunctionWithModeAndError::operator()
    00181       ( const Genfun::Argument& x ) const
    00182     {
    00183       (*m_function)( x[0] , *m_mode , m_result ) ;
    00184       return m_result -> val ;
    00185     }
    00186
    00187     Genfun::Derivative GSLFunctionWithModeAndError::partial
    00188     ( unsigned int i ) const
    00189     {
    00190       if( i >= 1 )
    00191       {
    00192         const AbsFunction& aux = GaudiMath::Constant( 0 , 1 ) ;
    00193         return Genfun::FunctionNoop( &aux ) ;
    00194       };
    00195       const AbsFunction& aux = GaudiMath::Derivative( *this , i) ;
    00196       return Genfun::FunctionNoop( &aux ) ;
    00197     }
    00198
    00199     GSLFunctionWithModeAndError::Function
    00200     GSLFunctionWithModeAndError::function() const
    00201     { return  m_function      ; }
    00202
    00203     const gsl_mode_t&
    00204     GSLFunctionWithModeAndError::mode    () const
    00205     { return *m_mode          ; }
    00206
    00207     const gsl_sf_result&
    00208     GSLFunctionWithModeAndError::result  () const
    00209     { return *m_result        ; }
    00210
    00211     double
    00212     GSLFunctionWithModeAndError::error   () const
    00213     { return  m_result -> err ; }
    00214
    00215   } // end of namespace GaudiMathImplementation
    00216 } // end of namespace Genfun
    00217

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines