Helpers.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // CLHEP
5 // ============================================================================
6 #include "CLHEP/GenericFunctions/AbsFunction.hh"
7 // Handle CLHEP 2.0.x move to CLHEP namespace
8 namespace CLHEP { }
9 using namespace CLHEP;
10 // ============================================================================
11 // local
12 // ============================================================================
13 #include "Helpers.h"
14 // ============================================================================
15 
16 namespace Genfun
17 {
18  namespace GaudiMathImplementation
19  {
20 
21  // ========================================================================
22  GSL_Helper::GSL_Helper
23  ( const Genfun::AbsFunction& function ,
24  Genfun::Argument& argument ,
25  const size_t index )
26  : m_function ( function ) ,
27  m_argument ( argument ) ,
28  m_index ( index )
29  {}
30  // ========================================================================
31 
32  // ========================================================================
34  // ========================================================================
35 
36  // ========================================================================
37  double GSL_Adaptor( double x , void* params )
38  {
39  // get parameters
40  GSL_Helper* aux = (GSL_Helper*) params ;
41  // decode parameters
42  const Genfun::AbsFunction& function = aux -> m_function ;
43  const size_t index = aux -> m_index ;
44  Genfun::Argument& argument = aux -> m_argument ;
45  // save the current value of argument
46  const double x_prev = argument[index] ;
47  // modify the argument
48  argument[index]= x ;
49  // evaluate the function
50  const double fun = function( argument ) ;
51  // restore the argument
52  argument[index] = x_prev ;
53  return fun ;
54  }
55  // ========================================================================
56 
57  } // end of namespace GaudiMathImplementation
58 } // end of namespace Genfun
59 
60 // ============================================================================
61 // The END
62 // ============================================================================
63 
double GSL_Adaptor(double x, void *params)
Definition: Helpers.cpp:37
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
CLHEP.
Definition: IEqSolver.h:13