| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GSLFunAdapters.cpp
Go to the documentation of this file.
1 // $Id: GSLFunAdapters.cpp,v 1.2 2005/11/25 10:27:03 mato Exp $
2 // ============================================================================
3 // Include files
4 // ============================================================================
5 // GaudiGSL/GaudiMath
6 // ============================================================================
7 #include "GaudiMath/GSLFunAdapters.h"
8 #include "GaudiMath/GaudiMath.h"
9 // ============================================================================
10 // GSL
11 // ============================================================================
12 #include "gsl/gsl_mode.h"
13 #include "gsl/gsl_sf_result.h"
14 // ============================================================================
15
23 namespace Genfun
24 {
25 namespace GaudiMathImplementation
26 {
27
28 FUNCTION_OBJECT_IMP( GSLFunctionWithError )
29
30 GSLFunctionWithError::GSLFunctionWithError
31 ( GSLFunctionWithError::Function function )
32 : AbsFunction()
33 , m_function ( function )
34 , m_result ( new gsl_sf_result() )
35 {
36 m_result -> val = -1.e+10 ;
37 m_result -> err = -1.e+10 ;
38 }
39
40 GSLFunctionWithError::GSLFunctionWithError
41 ( const GSLFunctionWithError& func )
42 : AbsFunction()
43 , m_function ( func.m_function )
44 , m_result ( new gsl_sf_result() )
45 {
46 m_result -> val = func.m_result -> val ;
47 m_result -> err = func.m_result -> err ;
48 }
49
50 GSLFunctionWithError::~GSLFunctionWithError()
51 { if ( 0 != m_result ) { delete m_result ; } }
52
53 double GSLFunctionWithError::operator()
54 ( double x ) const
55 {
56 (*m_function)( x , m_result ) ;
57 return m_result -> val ;
58 }
59
60 double GSLFunctionWithError::operator()
61 ( const Genfun::Argument& x ) const
62 {
63 (*m_function)( x[0] , m_result ) ;
64 return m_result -> val ;
65 }
66
67 Genfun::Derivative GSLFunctionWithError::partial
68 ( unsigned int i ) const
69 {
70 if( i >= 1 )
71 {
72 const AbsFunction& aux = GaudiMath::Constant( 0 , 1 ) ;
73 return Genfun::FunctionNoop( &aux ) ;
74 };
75 const AbsFunction& aux = GaudiMath::Derivative( *this , i) ;
76 return Genfun::FunctionNoop( &aux ) ;
77 }
78
79 GSLFunctionWithError::Function GSLFunctionWithError::function() const
80 { return m_function ; }
81
82 const gsl_sf_result& GSLFunctionWithError::result () const
83 { return *m_result ; }
84
85 double GSLFunctionWithError::error () const
86 { return m_result -> err ; }
87
88
89 FUNCTION_OBJECT_IMP( GSLFunctionWithMode )
90
91 GSLFunctionWithMode::GSLFunctionWithMode
92 ( GSLFunctionWithMode::Function function ,
93 const gsl_mode_t& mod )
94 : AbsFunction()
95 , m_function ( function )
96 , m_mode ( new gsl_mode_t() )
97 {
98 *m_mode = mod ;
99 }
100
101 GSLFunctionWithMode::GSLFunctionWithMode
102 ( const GSLFunctionWithMode& func )
103 : AbsFunction()
104 , m_function ( func.m_function )
105 , m_mode ( new gsl_mode_t () )
106 {
107 *m_mode = *(func.m_mode) ;
108 }
109
110 GSLFunctionWithMode::~GSLFunctionWithMode()
111 { if ( 0 != m_mode ) { delete m_mode ; } }
112
113 double GSLFunctionWithMode::operator()
114 ( double x ) const
115 { return (*m_function)( x , *m_mode ) ; }
116
117 double GSLFunctionWithMode::operator()
118 ( const Genfun::Argument& x ) const
119 { return (*m_function)( x[0] , *m_mode ) ; }
120
121 Genfun::Derivative GSLFunctionWithMode::partial
122 ( unsigned int i ) const
123 {
124 if( i >= 1 )
125 {
126 const AbsFunction& aux = GaudiMath::Constant( 0 , 1 ) ;
127 return Genfun::FunctionNoop( &aux ) ;
128 };
129 const AbsFunction& aux = GaudiMath::Derivative( *this , i) ;
130 return Genfun::FunctionNoop( &aux ) ;
131 }
132
133 GSLFunctionWithMode::Function GSLFunctionWithMode::function() const
134 { return m_function ; }
135
136 const gsl_mode_t& GSLFunctionWithMode::mode () const
137 { return *m_mode ; }
138
139
140 FUNCTION_OBJECT_IMP( GSLFunctionWithModeAndError )
141
142 GSLFunctionWithModeAndError::GSLFunctionWithModeAndError
143 ( GSLFunctionWithModeAndError::Function function ,
144 const gsl_mode_t& mod )
145 : AbsFunction()
146 , m_function ( function )
147 , m_mode ( new gsl_mode_t() )
148 , m_result ( new gsl_sf_result() )
149 {
150 *m_mode = mod ;
151 m_result -> val = -1.e+10 ;
152 m_result -> err = -1.e+10 ;
153 }
154
155 GSLFunctionWithModeAndError::GSLFunctionWithModeAndError
156 ( const GSLFunctionWithModeAndError& func )
157 : AbsFunction()
158 , m_function ( func.m_function )
159 , m_mode ( new gsl_mode_t () )
160 , m_result ( new gsl_sf_result() )
161 {
162 *m_mode = *(func.m_mode) ;
163 m_result -> val = func.m_result -> val ;
164 m_result -> err = func.m_result -> err ;
165 }
166
167 GSLFunctionWithModeAndError::~GSLFunctionWithModeAndError()
168 {
169 if ( 0 != m_mode ) { delete m_mode ; }
170 if ( 0 != m_result ) { delete m_result ; }
171 }
172
173 double GSLFunctionWithModeAndError::operator()
174 ( double x ) const
175 {
176 (*m_function)( x , *m_mode , m_result ) ;
177 return m_result -> val ;
178 }
179
180 double GSLFunctionWithModeAndError::operator()
181 ( const Genfun::Argument& x ) const
182 {
183 (*m_function)( x[0] , *m_mode , m_result ) ;
184 return m_result -> val ;
185 }
186
187 Genfun::Derivative GSLFunctionWithModeAndError::partial
188 ( unsigned int i ) const
189 {
190 if( i >= 1 )
191 {
192 const AbsFunction& aux = GaudiMath::Constant( 0 , 1 ) ;
193 return Genfun::FunctionNoop( &aux ) ;
194 };
195 const AbsFunction& aux = GaudiMath::Derivative( *this , i) ;
196 return Genfun::FunctionNoop( &aux ) ;
197 }
198
199 GSLFunctionWithModeAndError::Function
200 GSLFunctionWithModeAndError::function() const
201 { return m_function ; }
202
203 const gsl_mode_t&
204 GSLFunctionWithModeAndError::mode () const
205 { return *m_mode ; }
206
207 const gsl_sf_result&
208 GSLFunctionWithModeAndError::result () const
209 { return *m_result ; }
210
211 double
212 GSLFunctionWithModeAndError::error () const
213 { return m_result -> err ; }
214
215 } // end of namespace GaudiMathImplementation
216 } // end of namespace Genfun
217