The Gaudi Framework  v31r0 (aeb156f0)
GSLFunAdapters.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // GaudiGSL/GaudiMath
5 // ============================================================================
7 #include "GaudiMath/GaudiMath.h"
8 // ============================================================================
9 // GSL
10 // ============================================================================
11 #include "gsl/gsl_mode.h"
12 #include "gsl/gsl_sf_result.h"
13 // ============================================================================
14 
22 namespace Genfun {
23  namespace GaudiMathImplementation {
24 
26  : AbsFunction(), m_function( function ), m_result( std::make_unique<gsl_sf_result>() ) {
27  m_result->val = -1.e+10;
28  m_result->err = -1.e+10;
29  }
30 
32  : AbsFunction(), m_function( func.m_function ), m_result( std::make_unique<gsl_sf_result>() ) {
33  m_result->val = func.m_result->val;
34  m_result->err = func.m_result->err;
35  }
36 
37  double GSLFunctionWithError::operator()( double x ) const {
38  ( *m_function )( x, m_result.get() );
39  return m_result->val;
40  }
41 
42  double GSLFunctionWithError::operator()( const Genfun::Argument& x ) const {
43  ( *m_function )( x[0], m_result.get() );
44  return m_result->val;
45  }
46 
48  if ( i >= 1 ) {
49  const AbsFunction& aux = GaudiMath::Constant( 0, 1 );
50  return Genfun::FunctionNoop( &aux );
51  };
52  const AbsFunction& aux = GaudiMath::Derivative( *this, i );
53  return Genfun::FunctionNoop( &aux );
54  }
55 
57 
58  const gsl_sf_result& GSLFunctionWithError::result() const { return *m_result; }
59 
60  double GSLFunctionWithError::error() const { return m_result->err; }
61 
63  : AbsFunction(), m_function( function ), m_mode( std::make_unique<gsl_mode_t>( mod ) ) {}
64 
66  : AbsFunction(), m_function( func.m_function ), m_mode( std::make_unique<gsl_mode_t>( *( func.m_mode ) ) ) {}
67 
68  double GSLFunctionWithMode::operator()( double x ) const { return ( *m_function )( x, *m_mode ); }
69 
70  double GSLFunctionWithMode::operator()( const Genfun::Argument& x ) const {
71  return ( *m_function )( x[0], *m_mode );
72  }
73 
75  if ( i >= 1 ) {
76  const AbsFunction& aux = GaudiMath::Constant( 0, 1 );
77  return Genfun::FunctionNoop( &aux );
78  };
79  const AbsFunction& aux = GaudiMath::Derivative( *this, i );
80  return Genfun::FunctionNoop( &aux );
81  }
82 
84 
85  const gsl_mode_t& GSLFunctionWithMode::mode() const { return *m_mode; }
86 
88  const gsl_mode_t& mod )
89  : AbsFunction()
90  , m_function( function )
91  , m_mode( std::make_unique<gsl_mode_t>( mod ) )
92  , m_result( std::make_unique<gsl_sf_result>( gsl_sf_result{-1.e+10, -1.e+10} ) ) {}
93 
95  : AbsFunction()
96  , m_function( func.m_function )
97  , m_mode( std::make_unique<gsl_mode_t>( *func.m_mode ) )
98  , m_result( std::make_unique<gsl_sf_result>( *func.m_result ) ) {}
99 
100  double GSLFunctionWithModeAndError::operator()( double x ) const {
101  ( *m_function )( x, *m_mode, m_result.get() );
102  return m_result->val;
103  }
104 
105  double GSLFunctionWithModeAndError::operator()( const Genfun::Argument& x ) const {
106  ( *m_function )( x[0], *m_mode, m_result.get() );
107  return m_result->val;
108  }
109 
111  if ( i >= 1 ) {
112  const AbsFunction& aux = GaudiMath::Constant( 0, 1 );
113  return Genfun::FunctionNoop( &aux );
114  };
115  const AbsFunction& aux = GaudiMath::Derivative( *this, i );
116  return Genfun::FunctionNoop( &aux );
117  }
118 
120 
121  const gsl_mode_t& GSLFunctionWithModeAndError::mode() const { return *m_mode; }
122 
123  const gsl_sf_result& GSLFunctionWithModeAndError::result() const { return *m_result; }
124 
125  double GSLFunctionWithModeAndError::error() const { return m_result->err; }
126 
127  } // end of namespace GaudiMathImplementation
128 } // end of namespace Genfun
Function function() const
get the function itself
Function function() const
get the function itself
double(* Function)(double, gsl_mode_t)
the actual type of the function
const gsl_sf_result & result() const
get the last evaluated result
STL namespace.
const gsl_sf_result & result() const
get the last evaluated result
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:26
double operator()(double x) const override
the main method
mandatory macro from CLHEP/GenericFunctions
double operator()(double x) const override
the main method
Genfun::Derivative partial(unsigned int i) const override
Genfun::Derivative partial(unsigned int i) const override
double operator()(double x) const override
the main method
const gsl_mode_t & mode() const
get the current mode
Function function() const
get the function itself
T get(T...args)
Genfun::Derivative partial(unsigned int i) const override
CLHEP.
Definition: IEqSolver.h:13
const gsl_mode_t & mode() const
get the current mode
double error() const
get the error in the last estimate of the result
int(* Function)(double, gsl_sf_result *)
the actual type of the function
mandatory macro from CLHEP/GenericFunctions
Genfun::GaudiMathImplementation::Constant Constant
Definition: GaudiMath.h:25
double error() const
get the error in the last estimate of the result
int(* Function)(double, gsl_mode_t, gsl_sf_result *)
the actual type of the function