| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

GSLFunAdapters.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // GaudiGSL/GaudiMath
5 // ============================================================================
6 #include "GaudiMath/GSLFunAdapters.h"
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
27 GSLFunctionWithError::GSLFunctionWithError
28 ( GSLFunctionWithError::Function function )
29 : AbsFunction()
30 , m_function ( function )
31 , m_result ( new gsl_sf_result() )
32 {
33 m_result -> val = -1.e+10 ;
34 m_result -> err = -1.e+10 ;
35 }
36
37 GSLFunctionWithError::GSLFunctionWithError
38 ( const GSLFunctionWithError& func )
39 : AbsFunction()
40 , m_function ( func.m_function )
41 , m_result ( new 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()
48 ( double x ) const
49 {
50 (*m_function)( x , m_result.get() ) ;
51 return m_result -> val ;
52 }
53
54 double GSLFunctionWithError::operator()
55 ( const Genfun::Argument& x ) const
56 {
57 (*m_function)( x[0] , m_result.get() ) ;
58 return m_result -> val ;
59 }
60
61 Genfun::Derivative GSLFunctionWithError::partial
62 ( unsigned int i ) const
63 {
64 if( i >= 1 )
65 {
66 const AbsFunction& aux = GaudiMath::Constant( 0 , 1 ) ;
67 return Genfun::FunctionNoop( &aux ) ;
68 };
69 const AbsFunction& aux = GaudiMath::Derivative( *this , i) ;
70 return Genfun::FunctionNoop( &aux ) ;
71 }
72
73 GSLFunctionWithError::Function GSLFunctionWithError::function() const
74 { return m_function ; }
75
76 const gsl_sf_result& GSLFunctionWithError::result () const
77 { return *m_result ; }
78
79 double GSLFunctionWithError::error () const
80 { return m_result -> err ; }
81
82
83 GSLFunctionWithMode::GSLFunctionWithMode
84 ( GSLFunctionWithMode::Function function ,
85 const gsl_mode_t& mod )
86 : AbsFunction()
87 , m_function ( function )
88 , m_mode ( new gsl_mode_t() )
89 {
90 *m_mode = mod ;
91 }
92
93 GSLFunctionWithMode::GSLFunctionWithMode
94 ( const GSLFunctionWithMode& func )
95 : AbsFunction()
96 , m_function ( func.m_function )
97 , m_mode ( new gsl_mode_t () )
98 {
99 *m_mode = *(func.m_mode) ;
100 }
101
102 double GSLFunctionWithMode::operator()
103 ( double x ) const
104 { return (*m_function)( x , *m_mode ) ; }
105
106 double GSLFunctionWithMode::operator()
107 ( const Genfun::Argument& x ) const
108 { return (*m_function)( x[0] , *m_mode ) ; }
109
110 Genfun::Derivative GSLFunctionWithMode::partial
111 ( unsigned int i ) const
112 {
113 if( i >= 1 )
114 {
115 const AbsFunction& aux = GaudiMath::Constant( 0 , 1 ) ;
116 return Genfun::FunctionNoop( &aux ) ;
117 };
118 const AbsFunction& aux = GaudiMath::Derivative( *this , i) ;
119 return Genfun::FunctionNoop( &aux ) ;
120 }
121
122 GSLFunctionWithMode::Function GSLFunctionWithMode::function() const
123 { return m_function ; }
124
125 const gsl_mode_t& GSLFunctionWithMode::mode () const
126 { return *m_mode ; }
127
128
129 GSLFunctionWithModeAndError::GSLFunctionWithModeAndError
130 ( GSLFunctionWithModeAndError::Function function ,
131 const gsl_mode_t& mod )
132 : AbsFunction()
133 , m_function ( function )
134 , m_mode ( new gsl_mode_t() )
135 , m_result ( new gsl_sf_result() )
136 {
137 *m_mode = mod ;
138 m_result -> val = -1.e+10 ;
139 m_result -> err = -1.e+10 ;
140 }
141
142 GSLFunctionWithModeAndError::GSLFunctionWithModeAndError
143 ( const GSLFunctionWithModeAndError& func )
144 : AbsFunction()
145 , m_function ( func.m_function )
146 , m_mode ( new gsl_mode_t () )
147 , m_result ( new gsl_sf_result() )
148 {
149 *m_mode = *(func.m_mode) ;
150 m_result -> val = func.m_result -> val ;
151 m_result -> err = func.m_result -> err ;
152 }
153
154 double GSLFunctionWithModeAndError::operator()
155 ( double x ) const
156 {
157 (*m_function)( x , *m_mode , m_result.get() ) ;
158 return m_result -> val ;
159 }
160
161 double GSLFunctionWithModeAndError::operator()
162 ( const Genfun::Argument& x ) const
163 {
164 (*m_function)( x[0] , *m_mode , m_result.get() ) ;
165 return m_result -> val ;
166 }
167
168 Genfun::Derivative GSLFunctionWithModeAndError::partial
169 ( unsigned int i ) const
170 {
171 if( i >= 1 )
172 {
173 const AbsFunction& aux = GaudiMath::Constant( 0 , 1 ) ;
174 return Genfun::FunctionNoop( &aux ) ;
175 };
176 const AbsFunction& aux = GaudiMath::Derivative( *this , i) ;
177 return Genfun::FunctionNoop( &aux ) ;
178 }
179
180 GSLFunctionWithModeAndError::Function
181 GSLFunctionWithModeAndError::function() const
182 { return m_function ; }
183
184 const gsl_mode_t&
185 GSLFunctionWithModeAndError::mode () const
186 { return *m_mode ; }
187
188 const gsl_sf_result&
189 GSLFunctionWithModeAndError::result () const
190 { return *m_result ; }
191
192 double
193 GSLFunctionWithModeAndError::error () const
194 { return m_result -> err ; }
195
196 } // end of namespace GaudiMathImplementation
197 } // end of namespace Genfun
198
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::function
Function function() const
get the function itself
Definition: GSLFunAdapters.cpp:181
Genfun::GaudiMathImplementation::GSLFunctionWithMode::m_mode
gsl_mode_t * m_mode
Definition: GSLFunAdapters.h:113
Genfun::GaudiMathImplementation::GSLFunctionWithMode::function
Function function() const
get the function itself
Definition: GSLFunAdapters.cpp:122
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::m_mode
std::unique_ptr< gsl_mode_t > m_mode
Definition: GSLFunAdapters.h:158
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::result
const gsl_sf_result & result() const
get the last evaluated result
Definition: GSLFunAdapters.cpp:189
Genfun::GaudiMathImplementation::GSLFunctionWithMode::Function
double(* Function)(double, gsl_mode_t)
the actual type of the function
Definition: GSLFunAdapters.h:84
Gaudi.CommonGaudiConfigurables.mod
mod
Definition: CommonGaudiConfigurables.py:22
Genfun::GaudiMathImplementation::GSLFunctionWithError::result
const gsl_sf_result & result() const
get the last evaluated result
Definition: GSLFunAdapters.cpp:76
Genfun::GaudiMathImplementation::GSLFunctionWithError::GSLFunctionWithError
GSLFunctionWithError()
GaudiMath::Derivative
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:29
Genfun::GaudiMathImplementation::GSLFunctionWithError::Function
int(* Function)(double, gsl_sf_result *)
the actual type of the function
Definition: GSLFunAdapters.h:44
Genfun::GaudiMathImplementation::GSLFunctionWithMode
mandatory macro from CLHEP/GenericFunctions
Definition: GSLFunAdapters.h:80
Genfun::GaudiMathImplementation::GSLFunctionWithMode::partial
Genfun::Derivative partial(unsigned int i) const override
Definition: GSLFunAdapters.cpp:111
Genfun::GaudiMathImplementation::GSLFunctionWithError::m_result
std::unique_ptr< gsl_sf_result > m_result
Definition: GSLFunAdapters.h:75
GSLFunAdapters.h
Genfun::GaudiMathImplementation::GSLFunctionWithMode::GSLFunctionWithMode
GSLFunctionWithMode()
GaudiPluginService.cpluginsvc.func
func
Definition: cpluginsvc.py:218
Genfun::GaudiMathImplementation::GSLFunctionWithError::partial
Genfun::Derivative partial(unsigned int i) const override
Definition: GSLFunAdapters.cpp:62
Genfun::GaudiMathImplementation::GSLFunctionWithMode::mode
const gsl_mode_t & mode() const
get the current mode
Definition: GSLFunAdapters.cpp:125
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::m_result
std::unique_ptr< gsl_sf_result > m_result
Definition: GSLFunAdapters.h:159
Genfun::GaudiMathImplementation::GSLFunctionWithError::function
Function function() const
get the function itself
Definition: GSLFunAdapters.cpp:73
std::unique_ptr::get
T get(T...args)
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::partial
Genfun::Derivative partial(unsigned int i) const override
Definition: GSLFunAdapters.cpp:169
Genfun::GaudiMathImplementation::GSLFunctionWithError::m_function
Function m_function
Definition: GSLFunAdapters.h:74
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::m_function
Function m_function
Definition: GSLFunAdapters.h:157
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::GSLFunctionWithModeAndError
GSLFunctionWithModeAndError()
Genfun
CLHEP.
Definition: IEqSolver.h:13
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::mode
const gsl_mode_t & mode() const
get the current mode
Definition: GSLFunAdapters.cpp:185
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::error
double error() const
get the error in the last estimate of the result
Definition: GSLFunAdapters.cpp:193
Genfun::GaudiMathImplementation::GSLFunctionWithError
Definition: GSLFunAdapters.h:40
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError
mandatory macro from CLHEP/GenericFunctions
Definition: GSLFunAdapters.h:118
GaudiMath::Constant
Genfun::GaudiMathImplementation::Constant Constant
Definition: GaudiMath.h:27
GaudiMath.h
Genfun::GaudiMathImplementation::GSLFunctionWithError::error
double error() const
get the error in the last estimate of the result
Definition: GSLFunAdapters.cpp:79
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::Function
int(* Function)(double, gsl_mode_t, gsl_sf_result *)
the actual type of the function
Definition: GSLFunAdapters.h:122
Genfun::GaudiMathImplementation::GSLFunctionWithMode::m_function
Function m_function
Definition: GSLFunAdapters.h:112