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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a37:7105:: with SMTP id m5mr19743511qkc.370.1590999895327; Mon, 01 Jun 2020 01:24:55 -0700 (PDT) X-Received: by 2002:a9d:12a4:: with SMTP id g33mr11081826otg.342.1590999895071; Mon, 01 Jun 2020 01:24:55 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!fdn.fr!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 1 Jun 2020 01:24:54 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=212.251.152.55; posting-account=bPTmZAoAAAC_6HP9XLKB9aAAxBa6BuOR NNTP-Posting-Host: 212.251.152.55 References: <45af26dc-c35f-4a01-8115-7b30021cc064@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <835a8c6a-54a8-4157-bcf1-e889d18b1b46@googlegroups.com> Subject: Re: Any good package for mathematical function in Ada? From: reinert Injection-Date: Mon, 01 Jun 2020 08:24:55 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:58916 Date: 2020-06-01T01:24:54-07:00 List-Id: Thanks for the hints, Anybody having a simple (complete -=C2=A0runable) code example using GSL fr= om Ada? reinert mandag 1. juni 2020 01.25.32 UTC+2 skrev Jerry f=C3=B8lgende: > On Sunday, May 31, 2020 at 3:46:47 AM UTC-7, reinert wrote: > > Hello, > >=20 > > I would like to use for example the bessel function from Ada. > > I need in case to program it from scratch? > >=20 > > Any hint? > >=20 > > reinert >=20 > You have hit on what, for me, is a PITA for Ada, generally speaking, and = that is a lack of broad numerical functions. >=20 > You can link to the GNU Scientific Library (GSL) or the Octave binary lib= rary (I have also once written a very simple special-case Octave code gener= ator to run interpreter code since some functionality is not available as c= ompiled code). You might also enjoy ALGLIB, IMSL, NAG, and NetLib depending= on the licenses. You might be able to link to the Python libraries scipy a= nd numpy if, as I _suppose_ ,they are written in C. Consult this list if yo= u like:=20 >=20 > https://en.wikipedia.org/wiki/List_of_numerical_libraries >=20 > BTW if you have access to Numerical Recipes it can be a lifesaver sometim= es. I have an early book with Pascal code in an appendix. >=20 > If the binary you are linking to is in C or Fortran your job as an Ada pr= ogrammer isn't too bad but if you have never done it, it will take you a wh= ile to figure it out. Just remember that Ada is built to do this. I did a c= omplete thick binding for PLplot a few years ago. It was lot of work to mak= e it Ada-friendly but in large part because I didn't know C. And in a small= er part because it seems that programming in a crappy language spawns crapp= y programming techniques. Some of the things C programmers do are abominabl= e and not required by the language. Sorry for the OT rant. >=20 > I just remembered that I did this (Bessel) for GSL--I'm on a Mac and I go= t GSL via MacPorts. Note well that you don't have to link to the whole libr= ary, only the function(s) that you need. I'll paste the Ada with my comment= s which might be superfluous for you, and a gpr file as well; the gpr is in= cluded in a larger gpr. >=20 > I really wish Ada had a good binding to at least one of these libraries. >=20 > Jerry >=20 >=20 > library project GSL_Library is > for Externally_Built use "true"; > for Library_Dir use "/opt/local/lib/"; > for Library_Name use "gsl"; -- Delete "lib" from front of file name, = .dylib from end. > for Library_Kind use "dynamic"; > end GSL_Library; >=20 >=20 >=20 >=20 > -- Partial Ada binding to the GNU Scientific Library aka GSL library, lib= gsl.dylib. > -- See http://www.gnu.org/software/gsl/. > -- Use $nm library_name | grep symbol_name to find if symbol_name is in a= library. > -- This binding will be developed as needed. See build.gpr and GSL_Librar= y.gpr. > -- Consider this binding as an adjunct to e.g. Octave binding and Numeric= al Recipes. >=20 > package GSL_Thin is > =20 > ---------------------------------------------------------------------= ------ > -- CHAPTER 7: SPECIAL FUNCTIONS = -- > ---------------------------------------------------------------------= ------ > =20 > -- See GSL Reference 7.3 about modes. _Apparently_ double precision i= s the default and no > -- mode flag (argument) is necessary. The Reference could be less amb= iguous about this. >=20 > -- Regular cylindrical Bessel function of zeroth order, J_0(x). > function gsl_sf_bessel_J0(x : Long_Float) return Long_Float; > pragma Import(C, gsl_sf_bessel_J0, "gsl_sf_bessel_J0"); > =20 > -- Complete elliptical integral of the first kind, K(k). GSL Referenc= e 7.13.3. > -- Mathematica EllipticK and Abramowitz & Stegun 17.3 use argument m = =3D k^2. > -- As far as I can tell, this returns correct results only for 0 < k = < 1, and then only if > -- sqrt(k) is given as the argument. I have contacted the list (April= , 2015) about this and got > -- no response. I am using this for the PDF of the sum of two unit-am= plitude sine random > -- variables where this limitation is not a problem. Otherwise, I don= 't see how to use this to > -- get results such as returned by A&S or Octave. (The Octave functio= n is coded as Octave code, > -- not a compiled library.) > function gsl_sf_ellint_Kcomp(k : Long_Float) return Long_Float; > pragma Import(C, gsl_sf_ellint_Kcomp, "gsl_sf_ellint_Kcomp"); > =20 > end GSL_Thin;