Re: A ROOT Problem:How to use TF1 to do function integration

From: Jonathan M. Gilligan (jonathan.gilligan@vanderbilt.edu)
Date: Fri Aug 27 1999 - 17:57:12 MEST


I have solved this problem in my code by declaring a simple function that 
calls the member function:

PRCHe3 *obj;
extern const double dNaN;	// initialized elsewhere to 
numeric_limits::signaling_NaN() or such.
Double_t wrapFunc(Double_t *xvec, Double_t *yvec)
{
     if (obj != NULL)
         return obj->IntegrandERT(xvec,yvec);
     return dNaN;	// or perhaps throw an exception...
}

TF1 *f1 =  new TF1("elastic", &wrapFunc, -10, 10, 5);

or if you don't use member variables in IntegrandERT, then you can declare 
it static and define

Double_t wrapFunc(Double_t *xvec, Double_t *yvec)
{
	return PRCHe3::IntegrandERT(xvec,yvec);
}

It's a pain that you have to manually set obj to point to the appropriate 
object of class PRCHe3. Masa Goto convinced me that the lack of general 
compiler standardization for representing the vtbl makes implementing 
pointers to member functions in CINT hard to do in a way that would 
interoperate with precompiled code (see the ARM for details on this 
problem). Such is life.		

Jonathan		

===========================================================================
Jonathan M. Gilligan                     <jonathan.gilligan@vanderbilt.edu>
Research Assistant Professor of Physics                      (615) 343-6252
Dept. of Physics and Astronomy, Box 1807-B                    Fax: 343-7263
6823 Stevenson Center
Vanderbilt University, Nashville, TN 37235           Dep't Office: 322-2828



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:38 MET