From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a277322e4aa032bf X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-30 05:57:17 PST Path: newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3AED53F7.FAED7F1@earthlink.net> From: "Marc A. Criley" Organization: Quadrus Corporation X-Mailer: Mozilla 4.73 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: math: passing function to function References: <9cjham$lu4$1@eol.dd.chalmers.se> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 30 Apr 2001 12:57:19 GMT NNTP-Posting-Host: 63.178.180.34 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 988635439 63.178.180.34 (Mon, 30 Apr 2001 05:57:19 PDT) NNTP-Posting-Date: Mon, 30 Apr 2001 05:57:19 PDT X-Received-Date: Mon, 30 Apr 2001 05:55:48 PDT (newsmaster1.prod.itd.earthlink.net) Xref: newsfeed.google.com comp.lang.ada:7046 Date: 2001-04-30T12:57:19+00:00 List-Id: 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