Logo ROOT   6.13/01
Reference Guide
GSLMonteFunctionWrapper.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 GSLMonteFunctionWrapper
26 //
27 // Created by: moneta at Sat Nov 13 14:54:41 2004
28 //
29 // Last update: Sat Nov 13 14:54:41 2004
30 //
31 #ifndef ROOT_Math_GSLMonteFunctionWrapper
32 #define ROOT_Math_GSLMonteFunctionWrapper
33 
34 #include "gsl/gsl_monte.h"
35 #include "gsl/gsl_multimin.h"
36 
38 
39 
40 #include <cassert>
41 
42 namespace ROOT {
43 namespace Math {
44 
45 
46 
47  typedef double ( * GSLMonteFuncPointer ) ( double *, size_t, void *);
48 
49 
50 /**
51  wrapper to a multi-dim function withtout derivatives for Monte Carlo multi-dimensional
52  integration algorithm
53 
54  @ingroup MCIntegration
55 */
56 
58 
59 public:
60 
62  {
63  fFunc.f = 0;
64  fFunc.dim = 0;
65  fFunc.params = 0;
66  }
67 
69  void SetDim ( unsigned int n ) { fFunc.dim = n; }
70  void SetParams ( void * p) { fFunc.params = p; }
71 
72  /// Fill gsl function structure from a C++ Function class
73  template<class FuncType>
74  void SetFunction(const FuncType &f) {
75  const void * p = &f;
76  assert (p != 0);
78  SetDim( f.NDim() );
79  SetParams(const_cast<void *>(p));
80  }
81 
82  gsl_monte_function * GetFunc() { return &fFunc; }
83 
84  // evaluate the function and derivatives
85  double operator() (const double * x) { return GSL_MONTE_FN_EVAL(&fFunc, const_cast<double *>(x) ); }
86 
87 
88  private:
89  gsl_monte_function fFunc;
90 
91  };
92 
93 
94 
95 
96 
97 } // namespace Math
98 } // namespace ROOT
99 
100 #endif /* ROOT_Math_GSLMonteFunctionWrapper */
Namespace for new ROOT classes and functions.
Definition: TFoamSampler.h:19
void SetFuncPointer(GSLMonteFuncPointer f)
void SetFunction(const FuncType &f)
Fill gsl function structure from a C++ Function class.
* x
Deprecated and error prone model selection interface.
Definition: TRolke.cxx:630
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...
wrapper to a multi-dim function withtout derivatives for Monte Carlo multi-dimensional integration al...