comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Any good package for mathematical function in Ada?
Date: Mon, 1 Jun 2020 12:19:14 +0200
Date: 2020-06-01T12:19:14+02:00	[thread overview]
Message-ID: <rb2kn1$hru$1@gioia.aioe.org> (raw)
In-Reply-To: 835a8c6a-54a8-4157-bcf1-e889d18b1b46@googlegroups.com

On 01/06/2020 10:24, reinert wrote:

> Anybody having a simple (complete - runable) code example using GSL from Ada?

Assuming Windows.

Install MSYS2 if you did not already. [64-bit, GNAT GPL is not available 
for 32-bit anymore.]

Install GSL mingw-w64-x86_64-gsl under MSYS.

Now, assuming that MSYS2 is under C:\MSYS64\MinGW, here you go:

---gsl.gpr--------------
project GSL is
    for Main use ("test.adb");

    package Linker is
       for Default_Switches ("ada")
          use ("-L/c/msys64/mingw/lib", "-lgsl");
    end Linker;

end GSL;

---gsl.ads-------------
with Interfaces.C;  use Interfaces.C;

package GSL is
   function Bessel_J0 (X : double) return double;

private
    pragma Import (C, Bessel_J0, "gsl_sf_bessel_J0");
end GSL;

---test.adb------------>
with Ada.Text_IO;   use Ada.Text_IO;
with GSL;           use GSL;
with Interfaces.C;  use Interfaces.C;

procedure Test is
begin
    Put_Line ("J0(1)=" & double'Image (Bessel_J0 (1.0)));
end Test;
-----------------------

The test produces:

J0(1)= 7.65197686557967E-01

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2020-06-01 10:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-31 10:46 Any good package for mathematical function in Ada? reinert
2020-05-31 11:26 ` Dmitry A. Kazakov
2020-06-01  8:17   ` reinert
2020-05-31 23:25 ` Jerry
2020-06-01  8:24   ` reinert
2020-06-01 10:19     ` Dmitry A. Kazakov [this message]
2020-06-01 10:48       ` Nasser M. Abbasi
2020-06-01 11:34         ` Dmitry A. Kazakov
2020-06-01 11:52           ` Nasser M. Abbasi
2020-06-01 13:37             ` Dmitry A. Kazakov
2020-06-02  1:48             ` Jerry
2020-06-05 22:49           ` Randy Brukardt
2020-06-05 22:54           ` Paul Rubin
2020-06-06  7:06             ` Dmitry A. Kazakov
2020-06-06 13:58               ` AdaMagica
2020-06-01 10:43   ` Dmitry A. Kazakov
2020-06-02  1:51     ` Jerry
2020-06-03 15:07     ` reinert
replies disabled

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