comp.lang.ada
 help / color / mirror / Atom feed
* fyi, small update to Ada LAPACK and BLAS binding
@ 2012-07-31  6:37 Nasser M. Abbasi
  2012-07-31  8:59 ` Niklas Holsti
  2012-07-31 12:39 ` Ada novice
  0 siblings, 2 replies; 8+ messages in thread
From: Nasser M. Abbasi @ 2012-07-31  6:37 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-08-07  6:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-31  6:37 fyi, small update to Ada LAPACK and BLAS binding Nasser M. Abbasi
2012-07-31  8:59 ` 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

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