The Gaudi Framework  v30r3 (a5ef0a68)
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 {
24  namespace GaudiMathImplementation
25  {
26 
28  : AbsFunction(), m_function( function ), m_result( std::make_unique<gsl_sf_result>() )
29  {
30  m_result->val = -1.e+10;
31  m_result->err = -1.e+10;
32  }
33 
35  : AbsFunction(), m_function( func.m_function ), m_result( std::make_unique<gsl_sf_result>() )
36  {
37  m_result->val = func.m_result->val;
38  m_result->err = func.m_result->err;
39  }
40 
41  double GSLFunctionWithError::operator()( double x ) const
42  {
43  ( *m_function )( x, m_result.get() );
44  return m_result->val;
45  }
46 
47  double GSLFunctionWithError::operator()( const Genfun::Argument& x ) const
48  {
49  ( *m_function )( x[0], m_result.get() );
50  return m_result->val;
51  }
52 
54  {
55  if ( i >= 1 ) {
56  const AbsFunction& aux = GaudiMath::Constant( 0, 1 );
57  return Genfun::FunctionNoop( &aux );
58  };
59  const AbsFunction& aux = GaudiMath::Derivative( *this, i );
60  return Genfun::FunctionNoop( &aux );
61  }
62 
64 
65  const gsl_sf_result& GSLFunctionWithError::result() const { return *m_result; }
66 
67  double GSLFunctionWithError::error() const { return m_result->err; }
68 
70  : AbsFunction(), m_function( function ), m_mode( std::make_unique<gsl_mode_t>( mod ) )
71  {
72  }
73 
75  : AbsFunction(), m_function( func.m_function ), m_mode( std::make_unique<gsl_mode_t>( *( func.m_mode ) ) )
76  {
77  }
78 
79  double GSLFunctionWithMode::operator()( double x ) const { return ( *m_function )( x, *m_mode ); }
80 
81  double GSLFunctionWithMode::operator()( const Genfun::Argument& x ) const
82  {
83  return ( *m_function )( x[0], *m_mode );
84  }
85 
87  {
88  if ( i >= 1 ) {
89  const AbsFunction& aux = GaudiMath::Constant( 0, 1 );
90  return Genfun::FunctionNoop( &aux );
91  };
92  const AbsFunction& aux = GaudiMath::Derivative( *this, i );
93  return Genfun::FunctionNoop( &aux );
94  }
95 
97 
98  const gsl_mode_t& GSLFunctionWithMode::mode() const { return *m_mode; }
99 
101  const gsl_mode_t& mod )
102  : AbsFunction()
103  , m_function( function )
104  , m_mode( std::make_unique<gsl_mode_t>( mod ) )
105  , m_result( std::make_unique<gsl_sf_result>( gsl_sf_result{-1.e+10, -1.e+10} ) )
106  {
107  }
108 
110  : AbsFunction()
111  , m_function( func.m_function )
112  , m_mode( std::make_unique<gsl_mode_t>( *func.m_mode ) )
113  , m_result( std::make_unique<gsl_sf_result>( *func.m_result ) )
114  {
115  }
116 
118  {
119  ( *m_function )( x, *m_mode, m_result.get() );
120  return m_result->val;
121  }
122 
123  double GSLFunctionWithModeAndError::operator()( const Genfun::Argument& x ) const
124  {
125  ( *m_function )( x[0], *m_mode, m_result.get() );
126  return m_result->val;
127  }
128 
130  {
131  if ( i >= 1 ) {
132  const AbsFunction& aux = GaudiMath::Constant( 0, 1 );
133  return Genfun::FunctionNoop( &aux );
134  };
135  const AbsFunction& aux = GaudiMath::Derivative( *this, i );
136  return Genfun::FunctionNoop( &aux );
137  }
138 
140 
141  const gsl_mode_t& GSLFunctionWithModeAndError::mode() const { return *m_mode; }
142 
143  const gsl_sf_result& GSLFunctionWithModeAndError::result() const { return *m_result; }
144 
145  double GSLFunctionWithModeAndError::error() const { return m_result->err; }
146 
147  } // end of namespace GaudiMathImplementation
148 } // 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:27
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
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:26
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