Re: Calling a function from a script

From: Roger Mason <rmason_at_esd.mun.ca>
Date: Mon, 03 Oct 2005 08:24:47 -0230


Hello David, Phillippe & Daniel,

dac36_at_buffalo.edu writes:

> I'm not on the message board, but I said i'd respond quickly... I get
> that particular error alot when I write to an undefined element in an
> array. I see you have an array or two defined, so you might want to
> check see if you are not doing just this. Try increasing the size of all
> your arrays as a debug test. Good luck.

Philippe Canal <pcanal_at_fnal.gov> writes:

> All the function have the signature:
> Double_t name(Double_t *x, Double_t *par);
> note that both argument are arrays.
> It seems that you use those argument correctly but
> you do not pass them back to the subfunction correctly.
> So instead of
> Double_t gsum = gpeaks(x[0],&par);// Gaussians first
> Double_t lsum = lpeaks(x[0],&par[3*ngpeaks]);
> do
> Double_t gsum = gpeaks(x,par);// Gaussians first
> Double_t lsum = lpeaks(x,&par[3*ngpeaks]);
> OR
> Double_t gsum = gpeaks(&x[0],&par[0]);// Gaussians first
> Double_t lsum = lpeaks(&x[0],&par[3*ngpeaks]);

"daniel cussol" <cussol_at_ccimap.in2p3.fr> writes:

> The prblem is in the way you call your user-defined function. The
> system waits a pointer to a Double _t as a first argument of gpeaks,
> lpeaks and background, but you give a Double_t when you call
> them. Additionnaly, the second argument in your call og gpeks is also
> incorrect.

[snip]

> When you have an array, the type of variable you give to a function
> depends on the way you give it. Here is an exemple:
>
> Double_t dum[10];
> dum is a Double_t*
> dum[0] is a Double_t
> &dum[5] is a Double_t* which points to the 6th element of the array.

Yes, it turned out to be the way I was calling the function. My C skills are (to put it politely) rusty. Clearly I need to spend a bit more time cleaning off the rust and less time coding.

Thanks very much to all of you.

Roger Received on Mon Oct 03 2005 - 12:55:16 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:12 MET