| The Gaudi Framework v27r1

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