| The Gaudi Framework v29r1 (5cd95fa2)

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

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Private Attributes | List of all members
Genfun::GaudiMathImplementation::SimpleFunction Class Reference

mandatory macro from CLHEP/GenericFunctions More...

`#include <GaudiMath/Adapters.h>`

Inheritance diagram for Genfun::GaudiMathImplementation::SimpleFunction:
[legend]
Collaboration diagram for Genfun::GaudiMathImplementation::SimpleFunction:
[legend]

## Public Types
typedef double(* | Function1) (const double)
typedef double(* | Function2) (const double *)
typedef double(* | Function3) (const std::vector< double > &)

## Public Member Functions
| SimpleFunction (Function1 func)
| From CLHEP/GenericFunctions. More...
| SimpleFunction (Function2 func, const size_t dim)
| constructor from the simple function with array-like argument More...
| SimpleFunction (Function3 func, const size_t dim)
| constructor from the simple function with vector argument More...
unsigned int | dimensionality () const override
| dimensionality of the problem More...
bool | hasAnalyticDerivative () const override
| Does this function have an analytic derivative? More...
double | operator() (double) const override
| Function value. More...
double | operator() (const Argument &) const override
| Function value. More...
Genfun::Derivative | partial (unsigned int i) const override
| Derivatives. More...

## Private Attributes
boost::variant< Function1, Function2, Function3 > | m_func
std::vector< double > | m_arg

## Detailed Description

mandatory macro from CLHEP/GenericFunctions

Author
  Ivan BELYAEV

Date
  2003-08-31

Definition at line 268 of file FunAdapters.h.

## Member Typedef Documentation

typedef double( * Genfun::GaudiMathImplementation::SimpleFunction::Function1) (const double)

Definition at line 271 of file FunAdapters.h.

typedef double( * Genfun::GaudiMathImplementation::SimpleFunction::Function2) (const double *)

Definition at line 272 of file FunAdapters.h.

typedef double( * Genfun::GaudiMathImplementation::SimpleFunction::Function3) (const std::vector< double > &)

Definition at line 273 of file FunAdapters.h.

## Constructor & Destructor Documentation

Genfun::GaudiMathImplementation::SimpleFunction::SimpleFunction | ( | SimpleFunction::Function1 | func | ) |

From CLHEP/GenericFunctions.

constructor from the trivial function

constructor from the trivial function

Parameters

  func | pointer to trivial function
  func | pointer to trivial function

Definition at line 98 of file Adapter.cpp.

98 : m_func( func ) {}
GaudiPluginService.cpluginsvc.func
func
Definition: cpluginsvc.py:229
Genfun::GaudiMathImplementation::SimpleFunction::m_func
boost::variant< Function1, Function2, Function3 > m_func
Definition: FunAdapters.h:314

Genfun::GaudiMathImplementation::SimpleFunction::SimpleFunction | ( | SimpleFunction::Function2 | func,
|  | const size_t | dim
| ) |  |

constructor from the simple function with array-like argument

Parameters

  func | pointer to trivial function
  dim | dimension of the argument

Definition at line 107 of file Adapter.cpp.

107 : m_func( func ), m_arg( dim, 0 )
108 {
109 }
Genfun::GaudiMathImplementation::SimpleFunction::m_arg
std::vector< double > m_arg
Definition: FunAdapters.h:315
GaudiPluginService.cpluginsvc.func
func
Definition: cpluginsvc.py:229
Genfun::GaudiMathImplementation::SimpleFunction::m_func
boost::variant< Function1, Function2, Function3 > m_func
Definition: FunAdapters.h:314

Genfun::GaudiMathImplementation::SimpleFunction::SimpleFunction | ( | SimpleFunction::Function3 | func,
|  | const size_t | dim
| ) |  |

constructor from the simple function with vector argument

constructor from the simple function with array-like argument

Parameters

  func | pointer to trivial function
  dim | dimension of the argument

Definition at line 118 of file Adapter.cpp.

118 : m_func( func ), m_arg( dim, 0 )
119 {
120 }
Genfun::GaudiMathImplementation::SimpleFunction::m_arg
std::vector< double > m_arg
Definition: FunAdapters.h:315
GaudiPluginService.cpluginsvc.func
func
Definition: cpluginsvc.py:229
Genfun::GaudiMathImplementation::SimpleFunction::m_func
boost::variant< Function1, Function2, Function3 > m_func
Definition: FunAdapters.h:314

## Member Function Documentation

unsigned int Genfun::GaudiMathImplementation::SimpleFunction::dimensionality | ( |  | ) | const
| inline override

dimensionality of the problem

Definition at line 299 of file FunAdapters.h.

300 {
301 return detail::dispatch_variant( m_func, []( Function1 ) { return 1ul; },
302 [&]( auto ) { return m_arg.size(); } );
303 }
detail::dispatch_variant
auto dispatch_variant
Definition: FunAdapters.h:77
Genfun::GaudiMathImplementation::SimpleFunction::Function1
double(* Function1)(const double)
Definition: FunAdapters.h:271
Genfun::GaudiMathImplementation::SimpleFunction::m_arg
std::vector< double > m_arg
Definition: FunAdapters.h:315
Genfun::GaudiMathImplementation::SimpleFunction::m_func
boost::variant< Function1, Function2, Function3 > m_func
Definition: FunAdapters.h:314
std::vector::size
T size(T...args)

bool Genfun::GaudiMathImplementation::SimpleFunction::hasAnalyticDerivative | ( |  | ) | const
| inline override

Does this function have an analytic derivative?

Definition at line 305 of file FunAdapters.h.

305 { return true; }

double Genfun::GaudiMathImplementation::SimpleFunction::operator() | ( | double | value | ) | const
| override

Function value.

Definition at line 140 of file Adapter.cpp.

141 {
142 return detail::dispatch_variant( m_func, [&]( const Function1& fun ) { return ( *fun )( value ); },
143 [&]( const Function2& fun ) {
144 m_arg[0] = value;
145 std::fill( std::next( m_arg.begin() ), m_arg.end(), 0.0 );
146 return ( *fun )( m_arg.data() );
147 },
148 [&]( const Function3& fun ) {
149 m_arg[0] = value;
150 std::fill( std::next( m_arg.begin() ), m_arg.end(), 0.0 );
151 return ( *fun )( m_arg );
152 } );
153 }
Genfun::GaudiMathImplementation::SimpleFunction::Function3
double(* Function3)(const std::vector< double > &)
Definition: FunAdapters.h:273
detail::dispatch_variant
auto dispatch_variant
Definition: FunAdapters.h:77
std::vector::end
T end(T...args)
Genfun::GaudiMathImplementation::SimpleFunction::Function1
double(* Function1)(const double)
Definition: FunAdapters.h:271
std::vector::data
T data(T...args)
Genfun::GaudiMathImplementation::SimpleFunction::m_arg
std::vector< double > m_arg
Definition: FunAdapters.h:315
std::next
T next(T...args)
Genfun::GaudiMathImplementation::SimpleFunction::m_func
boost::variant< Function1, Function2, Function3 > m_func
Definition: FunAdapters.h:314
std::vector::begin
T begin(T...args)
fun
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
std::fill
T fill(T...args)
Genfun::GaudiMathImplementation::SimpleFunction::Function2
double(* Function2)(const double *)
Definition: FunAdapters.h:272

double Genfun::GaudiMathImplementation::SimpleFunction::operator() | ( | const Argument & | argument | ) | const
| override

Function value.

Definition at line 159 of file Adapter.cpp.

160 {
161 return detail::dispatch_variant( m_func, [&]( const Function1& f ) { return ( *f )( argument[0] ); },
162 [&]( const Function2& f ) {
163 for ( size_t i = 0; i < m_arg.size(); ++i ) {
164 m_arg[i] = argument[i];
165 }
166 return ( *f )( m_arg.data() );
167 },
168 [&]( const Function3& f ) {
169 for ( size_t i = 0; i < m_arg.size(); ++i ) {
170 m_arg[i] = argument[i];
171 }
172 return ( *f )( m_arg );
173 } );
174 }
Genfun::GaudiMathImplementation::SimpleFunction::Function3
double(* Function3)(const std::vector< double > &)
Definition: FunAdapters.h:273
detail::dispatch_variant
auto dispatch_variant
Definition: FunAdapters.h:77
Genfun::GaudiMathImplementation::SimpleFunction::Function1
double(* Function1)(const double)
Definition: FunAdapters.h:271
std::vector::data
T data(T...args)
Genfun::GaudiMathImplementation::SimpleFunction::m_arg
std::vector< double > m_arg
Definition: FunAdapters.h:315
Genfun::GaudiMathImplementation::SimpleFunction::m_func
boost::variant< Function1, Function2, Function3 > m_func
Definition: FunAdapters.h:314
std::vector::size
T size(T...args)
Genfun::GaudiMathImplementation::SimpleFunction::Function2
double(* Function2)(const double *)
Definition: FunAdapters.h:272

Genfun::Derivative Genfun::GaudiMathImplementation::SimpleFunction::partial | ( | unsigned int | i | ) | const
| override

Derivatives.

Definition at line 126 of file Adapter.cpp.

127 {
128 const auto dim = dimensionality();
129 if ( i >= dim ) {
130 GaudiMath::Constant aux{0, dim};
131 return Genfun::FunctionNoop( &aux );
132 }
133 GaudiMath::Derivative aux{*this, i};
134 return Genfun::FunctionNoop( &aux );
135 }
Genfun::GaudiMathImplementation::Constant
Fixed constant function.
Definition: Constant.h:31
Genfun::GaudiMathImplementation::SimpleFunction::dimensionality
unsigned int dimensionality() const override
dimensionality of the problem
Definition: FunAdapters.h:299
Genfun::GaudiMathImplementation::NumericalDerivative
Numerical derivative (using GSL adaptive numerical differentiation)
Definition: NumericalDerivative.h:42

## Member Data Documentation

std::vector<double> Genfun::GaudiMathImplementation::SimpleFunction::m_arg
| mutable private

Definition at line 315 of file FunAdapters.h.

boost::variant<Function1, Function2, Function3> Genfun::GaudiMathImplementation::SimpleFunction::m_func
| private

Definition at line 314 of file FunAdapters.h.

The documentation for this class was generated from the following files:

- GaudiGSL/GaudiMath/FunAdapters.h
- GaudiGSL/src/Lib/Adapter.cpp