comp.lang.ada
 help / color / mirror / Atom feed
From: "Nasser M. Abbasi" <nma@12000.org>
Subject: fyi, small update to Ada LAPACK and BLAS binding
Date: Tue, 31 Jul 2012 01:37:05 -0500
Date: 2012-07-31T01:37:05-05:00	[thread overview]
Message-ID: <jv7uei$2jl$1@speranza.aioe.org> (raw)


FYI;

I've added  more documentation and made a little cleanup of the
current Ada LAPACK and BLAS bindings.

As per earlier thread, this snap shot of the LAPACK binding now
uses one package to interface to LAPACK so it is easier to use.

The location is still the same as before, and with more
documentation now how to use the bindings.

http://12000.org/my_notes/ada/index.htm

I have a zip file the the LAPACK and BLAS updates I made there
with links to the original versions

Here is a complete example using LAPACK from Ada, with the gnatmake
command to build it:

gnatmake -Iada_lapack/binding mysolve.adb -largs -L/usr/lib -lblas -llapack

------ mysolve.adb -------------------------------------
with Ada.Text_IO; use Ada.Text_IO;

with Interfaces.Fortran; use Interfaces.Fortran;
with lapack;

procedure mysolve is

    A    : lapack.Fortran_Real_Matrix (1 .. 3, 1 .. 3);
    b    : lapack.Fortran_Real_Matrix (1 .. 3, 1 .. 1);
    info : Fortran_Integer;
    ipiv : lapack.Fortran_Integer_Vector (1 .. A'Last (2));

begin -- solve A x=b

    A := ((2.0, 3.0, 1.0), (2.0, 1.0, 1.0), (4.0, -1.0, 6.0));
    b := ((1 => 9.0), (1 => 2.0), (1 => -2.0));

    lapack.SGESV
      (N    => A'Last (2),
       NRHS => b'Last (2),
       A    => A,
       LDA  => A'Last (1),
       IPIV => ipiv,
       B    => b,
       LDB  => b'Last (1),
       INFO => info);

    if (info /= 0) then
       raise Program_Error;
    end if;

    declare
       package real_IO is new Ada.Text_IO.Float_IO (Real);
    begin
       for I in b'Range (1) loop
          real_IO.Put (b (I, 1));
          New_Line;
       end loop;
    end;

end mysolve;
-----------------------

--Nasser



             reply	other threads:[~2012-08-02 18:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-31  6:37 Nasser M. Abbasi [this message]
2012-07-31  8:59 ` fyi, small update to Ada LAPACK and BLAS binding Niklas Holsti
2012-07-31 10:53   ` Nasser M. Abbasi
2012-07-31 12:39 ` Ada novice
2012-07-31 13:00   ` Nasser M. Abbasi
2012-07-31 13:37     ` Ada novice
     [not found]       ` <8r5g18h74q8mpqubmu93d5d1ubkmeoepjr@invalid.netcom.com>
2012-07-31 18:35         ` Ada novice
2012-07-31 19:40         ` Simon Wright
replies disabled

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