Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
42namespace ROOT {
43namespace 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
59public:
60
62 {
63 fFunc.f = nullptr;
64 fFunc.dim = 0;
65 fFunc.params = nullptr;
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 != nullptr);
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 */
#define f(i)
Definition RSha256.hxx:104
winID h TVirtualViewer3D TVirtualGLPainter p
wrapper to a multi-dim function withtout derivatives for Monte Carlo multi-dimensional integration al...
void SetFunction(const FuncType &f)
Fill gsl function structure from a C++ Function class.
double operator()(const double *x)
evaluate the function and derivatives
void SetFuncPointer(GSLMonteFuncPointer f)
double(* GSLMonteFuncPointer)(double *, size_t, void *)
Class for adapting any multi-dimension C++ functor class to C function pointers used by GSL MonteCarl...
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Namespace for new Math classes and functions.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.