Logo ROOT   6.19/01
Reference Guide
GSLMonteFunctionAdapter.h
Go to the documentation of this file.
1 // @(#)root/mathmore:$Id$
2 // Authors: L. Moneta, 08/2007
3 
4  /**********************************************************************
5  * *
6  * Copyright (c) 2004 ROOT Foundation, CERN/PH-SFT *
7  * *
8  * This library is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU General Public License *
10  * as published by the Free Software Foundation; either version 2 *
11  * of the License, or (at your option) any later version. *
12  * *
13  * This library is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16  * General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this library (see file COPYING); if not, write *
20  * to the Free Software Foundation, Inc., 59 Temple Place, Suite *
21  * 330, Boston, MA 02111-1307 USA, or contact the author. *
22  * *
23  **********************************************************************/
24 
25 // Header file for class GSLMultiMinFunctionAdapter
26 //
27 // Generic adapter for gsl_multimin_function signature
28 // usable for any c++ class which defines operator( )
29 //
30 // Created by: Lorenzo Moneta at Fri Nov 12 16:58:51 2004
31 //
32 // Last update: Fri Nov 12 16:58:51 2004
33 //
34 #ifndef ROOT_Math_GSLMonteFunctionAdapter
35 #define ROOT_Math_GSLMonteFunctionAdapter
36 
37 
38 namespace ROOT {
39 namespace Math {
40 
41 
42  /**
43  Class for adapting any multi-dimension C++ functor class to C function pointers used by
44  GSL MonteCarlo integration algorithms.
45  The templated C++ function class must implement:
46 
47  <em> double operator( const double * x)</em>
48 
49  This class defines static methods with will be used to fill the
50  \a gsl_monte_function used by GSL.
51  See for examples the
52  <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Monte-Carlo-Interface.html">GSL online manual</A>
53 
54  @ingroup MCIntegration
55  */
56  typedef double ( * GSLMonteFuncPointer ) ( double *, size_t, void *);
57 
58  template<class UserFunc>
60 
61  static double F( double * x, size_t, void * p) {
62 
63  UserFunc * function = reinterpret_cast< UserFunc *> (p);
64  return (*function)( x );
65  }
66 
67  };
68 
69 
70 
71 } // namespace Math
72 } // namespace ROOT
73 
74 
75 #endif /* ROOT_Math_GSLMonteFunctionAdapter */
VSD Structures.
Definition: StringConv.hxx:21
Double_t x[n]
Definition: legend1.C:17
static double F(double *x, size_t, void *p)
Namespace for new Math classes and functions.
double(* GSLMonteFuncPointer)(double *, size_t, void *)
Class for adapting any multi-dimension C++ functor class to C function pointers used by GSL MonteCarl...