comp.lang.ada
 help / color / mirror / Atom feed
From: "Marc A. Criley" <mcqada@earthlink.net>
Subject: Re: math: passing function to function
Date: Mon, 30 Apr 2001 12:57:19 GMT
Date: 2001-04-30T12:57:19+00:00	[thread overview]
Message-ID: <3AED53F7.FAED7F1@earthlink.net> (raw)
In-Reply-To: 9cjham$lu4$1@eol.dd.chalmers.se

Staffan Dittmer wrote:
> 
> I'm trying to implement a root finder using the Brent method
> but find myself getting stuck.
> I cannot figure  out how to pass a function
> - the function to solve - as a parameter
> to  the solver.
> 
> I've tried using access to subprogram types to make something like
> function solver(fun: access to function to solve; ...) return long_float;
> which usually compiles ok, but exits raising
> constraint error as soon as the code gets more involved than the
> rudimentary examples given in the RM.

The only problems I've ever experienced with passing around access
subprograms have been self-inflicted :-)  I _strongly_ suspect that the
problem lies in the implementation of either the "solver" or the
"function to solve".

Are any global variables being referenced that may not be getting set? 
Or reset between iterations?  Are you sure that the function is being
invoked only with valid values--i.e., that that is not causing a
Constraint_Error?

If you're using GNAT, compile the code with the -g option, then link it
was -largs -gnatE so that you can get an exception traceback.  Then use
addr2line to identify exactly which line is raising the exception.  Or
run it in a debugger and simply "break exception" and look at the
location and values that triggered the situation.

Good luck.

Marc A. Criley
Senior Staff Engineer
Quadrus Corporation
www.quadruscorp.com



  parent reply	other threads:[~2001-04-30 12:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-30 11:12 math: passing function to function Staffan Dittmer
2001-04-30 12:10 ` Jacob Sparre Andersen
2001-04-30 12:57 ` Marc A. Criley [this message]
2001-04-30 13:51   ` Staffan Dittmer
2001-04-30 14:38 ` Ted Dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox