The Gaudi Framework  v28r3 (cc1cf868)
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 
29  : AbsFunction()
30  , m_function ( function )
31  , m_result ( std::make_unique<gsl_sf_result>() )
32  {
33  m_result -> val = -1.e+10 ;
34  m_result -> err = -1.e+10 ;
35  }
36 
39  : AbsFunction()
40  , m_function ( func.m_function )
41  , m_result ( std::make_unique<gsl_sf_result>() )
42  {
43  m_result -> val = func.m_result -> val ;
44  m_result -> err = func.m_result -> err ;
45  }
46 
47  double GSLFunctionWithError::operator()( double x ) const
48  {
49  (*m_function)( x , m_result.get() ) ;
50  return m_result -> val ;
51  }
52 
53  double GSLFunctionWithError::operator()( const Genfun::Argument& x ) const
54  {
55  (*m_function)( x[0] , m_result.get() ) ;
56  return m_result -> val ;
57  }
58 
60  {
61  if( i >= 1 ) {
62  const AbsFunction& aux = GaudiMath::Constant( 0 , 1 ) ;
63  return Genfun::FunctionNoop( &aux ) ;
64  };
65  const AbsFunction& aux = GaudiMath::Derivative( *this , i) ;
66  return Genfun::FunctionNoop( &aux ) ;
67  }
68 
70  { return m_function ; }
71 
72  const gsl_sf_result& GSLFunctionWithError::result () const
73  { return *m_result ; }
74 
76  { return m_result -> err ; }
77 
78 
81  const gsl_mode_t& mod )
82  : AbsFunction()
83  , m_function ( function )
84  , m_mode ( std::make_unique<gsl_mode_t>(mod) )
85  {
86  }
87 
89  ( const GSLFunctionWithMode& func )
90  : AbsFunction()
91  , m_function ( func.m_function )
92  , m_mode ( std::make_unique<gsl_mode_t>(*(func.m_mode)) )
93  {
94  }
95 
96  double GSLFunctionWithMode::operator()( double x ) const
97  { return (*m_function)( x , *m_mode ) ; }
98 
99  double GSLFunctionWithMode::operator()( const Genfun::Argument& x ) const
100  { return (*m_function)( x[0] , *m_mode ) ; }
101 
103  {
104  if( i >= 1 )
105  {
106  const AbsFunction& aux = GaudiMath::Constant( 0 , 1 ) ;
107  return Genfun::FunctionNoop( &aux ) ;
108  };
109  const AbsFunction& aux = GaudiMath::Derivative( *this , i) ;
110  return Genfun::FunctionNoop( &aux ) ;
111  }
112 
114  { return m_function ; }
115 
116  const gsl_mode_t& GSLFunctionWithMode::mode () const
117  { return *m_mode ; }
118 
119 
122  const gsl_mode_t& mod )
123  : AbsFunction()
124  , m_function ( function )
125  , m_mode ( std::make_unique<gsl_mode_t>(mod) )
126  , m_result ( std::make_unique<gsl_sf_result>( gsl_sf_result{-1.e+10, -1.e+10} ) )
127  {
128  }
129 
132  : AbsFunction()
133  , m_function ( func.m_function )
134  , m_mode ( std::make_unique<gsl_mode_t>(*func.m_mode) )
135  , m_result ( std::make_unique<gsl_sf_result>(*func.m_result) )
136  {
137  }
138 
139  double GSLFunctionWithModeAndError::operator()
140  ( double x ) const
141  {
142  (*m_function)( x , *m_mode , m_result.get() ) ;
143  return m_result -> val ;
144  }
145 
146  double GSLFunctionWithModeAndError::operator()
147  ( const Genfun::Argument& x ) const
148  {
149  (*m_function)( x[0] , *m_mode , m_result.get() ) ;
150  return m_result -> val ;
151  }
152 
154  ( unsigned int i ) const
155  {
156  if( i >= 1 ) {
157  const AbsFunction& aux = GaudiMath::Constant( 0 , 1 ) ;
158  return Genfun::FunctionNoop( &aux ) ;
159  };
160  const AbsFunction& aux = GaudiMath::Derivative( *this , i) ;
161  return Genfun::FunctionNoop( &aux ) ;
162  }
163 
166  { return m_function ; }
167 
168  const gsl_mode_t&
170  { return *m_mode ; }
171 
172  const gsl_sf_result&
174  { return *m_result ; }
175 
176  double
178  { return m_result -> err ; }
179 
180  } // end of namespace GaudiMathImplementation
181 } // end of namespace Genfun
182 
Function function() const
get the function itself
Function function() const
get the function itself
const gsl_sf_result & result() const
get the last evaluated result
double(* Function)(double, gsl_mode_t)
the actual type of the function
const gsl_sf_result & result() const
get the last evaluated result
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:29
double operator()(double x) const override
the main method
int(* Function)(double, gsl_sf_result *)
the actual type of the function
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
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
mandatory macro from CLHEP/GenericFunctions
Genfun::GaudiMathImplementation::Constant Constant
Definition: GaudiMath.h:27
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