Re: script fails to compile

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Mon, 17 May 2010 14:34:01 -0500


Hi,

I think you meant:

   TF1* decay = new TF1("decay",myfunction,0,10,2);

i.e. passing the pointer to your function rather than a string containing its name.

Cheers,
Philippe.

On 5/17/10 2:29 PM, Roger Mason wrote:
> hello,
>
> I defined the following named script (hl.C):
>
>
> #include<TMath.h>
> #include<TF1.h>
>
> Double_t myfunction(Double_t *x,Double_t *par) {
> Double_t arg = 0;
>
> Double_t arg = x[0]/par[1];
>
> Double_t result = par[0]*TMath::Exp(-arg);
> return result;
> }
>
> void hl() {
> TF1* decay = new TF1("decay","myfunction",0,10,2);
>
> decay->SetParameters(10,1);
> decay->Draw("AL");
> }
>
> The script won't compile:
>
> root [0] .L hl.C+
> Info in<TUnixSystem::ACLiC>: creating shared library
> /home/rmason/Teaching/ES1002/Notes/Intersession_10/DatingEarth/scripts/./hl_C.so
> In file included from
> /home/rmason/Teaching/ES1002/Notes/Intersession_10/DatingEarth/scripts/./hl_C_ACLiC_dict.h:33,
> from
> /home/rmason/Teaching/ES1002/Notes/Intersession_10/DatingEarth/scripts/./hl_C_ACLiC_dict.cxx:16:
> /home/rmason/Teaching/ES1002/Notes/Intersession_10/DatingEarth/scripts/./hl.C:
> In function 'Double_t myfunction(Double_t*, Double_t*)':
> /home/rmason/Teaching/ES1002/Notes/Intersession_10/DatingEarth/scripts/./hl.C:10:
> warning: unused variable 'arg'
> /usr/include/root/Math/ParamFunctor.h: In static member function 'static
> double ROOT::Math::ParamFunctorHandler<ParentFunctor,
> Func>::FuncEvaluator<F*>::Eval(F*, double*, double*) [with F = const
> char, ParentFunctor = ROOT::Math::ParamFunctor, Func = const char*]':
> /usr/include/root/Math/ParamFunctor.h:88: instantiated from 'double
> ROOT::Math::ParamFunctorHandler<ParentFunctor,
> Func>::operator()(double*, double*) [with ParentFunctor =
> ROOT::Math::ParamFunctor, Func = const char*]'
> /home/rmason/Teaching/ES1002/Notes/Intersession_10/DatingEarth/scripts/./hl_C_ACLiC_dict.cxx:301:
> instantiated from here
> /usr/include/root/Math/ParamFunctor.h:109: error: '* f' cannot be used
> as a function
> g++:
> /home/rmason/Teaching/ES1002/Notes/Intersession_10/DatingEarth/scripts/./hl_C_ACLiC_dict.o:
> No such file or directory
> Error in<ACLiC>: Compilation failed!
>
> I can't see what I did wrong.
>
> Thanks for any help.
>
> Roger
>
> ROOT 5.26/00b (branches/v5-26-00-patches_at_32288, Apr 23 2010, 09:32:00 on
> linuxx8664gcc)
>
>
Received on Mon May 17 2010 - 21:34:05 CEST

This archive was generated by hypermail 2.2.0 : Mon May 17 2010 - 23:50:02 CEST