| The Gaudi Framework v30r0 (c919700c)

- 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( GSLFunctionWithError::Function function )
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
34 GSLFunctionWithError::GSLFunctionWithError( const GSLFunctionWithError& func )
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
53 Genfun::Derivative GSLFunctionWithError::partial( unsigned int i ) const
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
63 GSLFunctionWithError::Function GSLFunctionWithError::function() const { return m_function; }
64
65 const gsl_sf_result& GSLFunctionWithError::result() const { return *m_result; }
66
67 double GSLFunctionWithError::error() const { return m_result->err; }
68
69 GSLFunctionWithMode::GSLFunctionWithMode( GSLFunctionWithMode::Function function, const gsl_mode_t& mod )
70 : AbsFunction(), m_function( function ), m_mode( std::make_unique<gsl_mode_t>( mod ) )
71 {
72 }
73
74 GSLFunctionWithMode::GSLFunctionWithMode( const GSLFunctionWithMode& func )
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
86 Genfun::Derivative GSLFunctionWithMode::partial( unsigned int i ) const
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
96 GSLFunctionWithMode::Function GSLFunctionWithMode::function() const { return m_function; }
97
98 const gsl_mode_t& GSLFunctionWithMode::mode() const { return *m_mode; }
99
100 GSLFunctionWithModeAndError::GSLFunctionWithModeAndError( GSLFunctionWithModeAndError::Function function,
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
109 GSLFunctionWithModeAndError::GSLFunctionWithModeAndError( const GSLFunctionWithModeAndError& func )
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
117 double GSLFunctionWithModeAndError::operator()( double x ) const
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
129 Genfun::Derivative GSLFunctionWithModeAndError::partial( unsigned int i ) const
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
139 GSLFunctionWithModeAndError::Function GSLFunctionWithModeAndError::function() const { return m_function; }
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
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::function
Function function() const
get the function itself
Definition: GSLFunAdapters.cpp:139
Genfun::GaudiMathImplementation::GSLFunctionWithMode::function
Function function() const
get the function itself
Definition: GSLFunAdapters.cpp:96
Genfun::GaudiMathImplementation::GSLFunctionWithMode::Function
double(* Function)(double, gsl_mode_t)
the actual type of the function
Definition: GSLFunAdapters.h:87
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::m_mode
std::unique_ptr< gsl_mode_t > m_mode
Definition: GSLFunAdapters.h:162
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::result
const gsl_sf_result & result() const
get the last evaluated result
Definition: GSLFunAdapters.cpp:143
Gaudi.CommonGaudiConfigurables.mod
mod
Definition: CommonGaudiConfigurables.py:22
std
STL namespace.
Genfun::GaudiMathImplementation::GSLFunctionWithError::result
const gsl_sf_result & result() const
get the last evaluated result
Definition: GSLFunAdapters.cpp:65
Genfun::GaudiMathImplementation::GSLFunctionWithError::GSLFunctionWithError
GSLFunctionWithError()
GaudiMath::Derivative
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:27
Genfun::GaudiMathImplementation::GSLFunctionWithError::operator()
double operator()(double x) const override
the main method
Definition: GSLFunAdapters.cpp:41
Genfun::GaudiMathImplementation::GSLFunctionWithMode
mandatory macro from CLHEP/GenericFunctions
Definition: GSLFunAdapters.h:83
Genfun::GaudiMathImplementation::GSLFunctionWithMode::operator()
double operator()(double x) const override
the main method
Definition: GSLFunAdapters.cpp:79
Genfun::GaudiMathImplementation::GSLFunctionWithMode::partial
Genfun::Derivative partial(unsigned int i) const override
Definition: GSLFunAdapters.cpp:86
Genfun::GaudiMathImplementation::GSLFunctionWithError::m_result
std::unique_ptr< gsl_sf_result > m_result
Definition: GSLFunAdapters.h:78
GSLFunAdapters.h
Genfun::GaudiMathImplementation::GSLFunctionWithMode::GSLFunctionWithMode
GSLFunctionWithMode()
GaudiPluginService.cpluginsvc.func
func
Definition: cpluginsvc.py:229
Genfun::GaudiMathImplementation::GSLFunctionWithError::partial
Genfun::Derivative partial(unsigned int i) const override
Definition: GSLFunAdapters.cpp:53
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::operator()
double operator()(double x) const override
the main method
Definition: GSLFunAdapters.cpp:117
Genfun::GaudiMathImplementation::GSLFunctionWithMode::mode
const gsl_mode_t & mode() const
get the current mode
Definition: GSLFunAdapters.cpp:98
Genfun::GaudiMathImplementation::GSLFunctionWithMode::m_mode
std::unique_ptr< gsl_mode_t > m_mode
Definition: GSLFunAdapters.h:118
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::m_result
std::unique_ptr< gsl_sf_result > m_result
Definition: GSLFunAdapters.h:163
Genfun::GaudiMathImplementation::GSLFunctionWithError::function
Function function() const
get the function itself
Definition: GSLFunAdapters.cpp:63
std::unique_ptr::get
T get(T...args)
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::partial
Genfun::Derivative partial(unsigned int i) const override
Definition: GSLFunAdapters.cpp:129
Genfun::GaudiMathImplementation::GSLFunctionWithError::m_function
Function m_function
Definition: GSLFunAdapters.h:77
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::m_function
Function m_function
Definition: GSLFunAdapters.h:161
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:141
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::error
double error() const
get the error in the last estimate of the result
Definition: GSLFunAdapters.cpp:145
Genfun::GaudiMathImplementation::GSLFunctionWithError::Function
int(* Function)(double, gsl_sf_result *)
the actual type of the function
Definition: GSLFunAdapters.h:44
Genfun::GaudiMathImplementation::GSLFunctionWithError
Definition: GSLFunAdapters.h:40
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError
mandatory macro from CLHEP/GenericFunctions
Definition: GSLFunAdapters.h:123
GaudiMath::Constant
Genfun::GaudiMathImplementation::Constant Constant
Definition: GaudiMath.h:26
GaudiMath.h
Genfun::GaudiMathImplementation::GSLFunctionWithError::error
double error() const
get the error in the last estimate of the result
Definition: GSLFunAdapters.cpp:67
Genfun::GaudiMathImplementation::GSLFunctionWithModeAndError::Function
int(* Function)(double, gsl_mode_t, gsl_sf_result *)
the actual type of the function
Definition: GSLFunAdapters.h:127
Genfun::GaudiMathImplementation::GSLFunctionWithMode::m_function
Function m_function
Definition: GSLFunAdapters.h:117