* Linear Algebra package for Ada ? @ 2000-04-23 0:00 Reinert Korsnes 2000-04-24 0:00 ` Robert Dewar 2000-04-25 0:00 ` Gautier 0 siblings, 2 replies; 11+ messages in thread From: Reinert Korsnes @ 2000-04-23 0:00 UTC (permalink / raw) Hi, Could anybody recommend me an Ada95 package for linear algebra (including manipulation of vectors/matrices ?) reinert -- Norwegian Polar Institute Polar Environment Center N-9296 Tromso Norway Fax: +47 77750501 http://geophys.npolar.no/~reinert/personal.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Linear Algebra package for Ada ? 2000-04-23 0:00 Linear Algebra package for Ada ? Reinert Korsnes @ 2000-04-24 0:00 ` Robert Dewar 2000-04-24 0:00 ` David Starner ` (2 more replies) 2000-04-25 0:00 ` Gautier 1 sibling, 3 replies; 11+ messages in thread From: Robert Dewar @ 2000-04-24 0:00 UTC (permalink / raw) In article <8dv75n$qi1$1@news.uit.no>, Reinert.Korsnes@npolar.no wrote: > Hi, > > Could anybody recommend me an Ada95 package for linear algebra > (including manipulation of vectors/matrices ?) Why not use the interface to Linpack (is that the right spelling -- I refer to the standard Fortran linear algebra package) Sent via Deja.com http://www.deja.com/ Before you buy. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Linear Algebra package for Ada ? 2000-04-24 0:00 ` Robert Dewar @ 2000-04-24 0:00 ` David Starner 2000-04-24 0:00 ` Reinert Korsnes 2000-04-24 0:00 ` Laurent GASSER 2000-04-24 0:00 ` Reinert Korsnes 2 siblings, 1 reply; 11+ messages in thread From: David Starner @ 2000-04-24 0:00 UTC (permalink / raw) On Mon, 24 Apr 2000 00:47:27 GMT, Robert Dewar <robert_dewar@my-deja.com> wrote: >In article <8dv75n$qi1$1@news.uit.no>, > Reinert.Korsnes@npolar.no wrote: >> Hi, >> >> Could anybody recommend me an Ada95 package for linear algebra >> (including manipulation of vectors/matrices ?) > >Why not use the interface to Linpack (is that the right spelling >-- I refer to the standard Fortran linear algebra package) Linpack is going to be about the fastest option, but you may not have a Fortran compiler*, and a native generic designed linear algebra package is probably going to be easier to use and almost as fast as linpack. * Yes, I know about g77, but there are situations where installing a new compiler may not be possible, and computers that g77 hasn't been ported to yet. -- David Starner - dstarner98@aasaa.ofe.org Finger dvdeug@x8b4e53cd.dhcp.okstate.edu for more information. Only a nerd would worry about wrong parentheses with square brackets. But that's what mathematicians are. -- Dr. Burchard, math professor at OSU ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Linear Algebra package for Ada ? 2000-04-24 0:00 ` David Starner @ 2000-04-24 0:00 ` Reinert Korsnes 0 siblings, 0 replies; 11+ messages in thread From: Reinert Korsnes @ 2000-04-24 0:00 UTC (permalink / raw) In article <8e0aqf$9281@news.cis.okstate.edu>, dvdeug@x8b4e53cd.dhcp.okstate.edu (David Starner) writes: |> On Mon, 24 Apr 2000 00:47:27 GMT, Robert Dewar <robert_dewar@my-deja.com> wrote: |> >In article <8dv75n$qi1$1@news.uit.no>, |> > Reinert.Korsnes@npolar.no wrote: |> >> Hi, |> >> |> >> Could anybody recommend me an Ada95 package for linear algebra |> >> (including manipulation of vectors/matrices ?) |> > |> >Why not use the interface to Linpack (is that the right spelling |> >-- I refer to the standard Fortran linear algebra package) |> |> Linpack is going to be about the fastest option, but you may not |> have a Fortran compiler*, and a native generic designed linear |> algebra package is probably going to be easier to use and almost |> as fast as linpack. What I thought about. And where ? reinert ...snip... -- Norwegian Polar Institute Polar Environment Center N-9296 Tromso Norway Fax: +47 77750501 http://geophys.npolar.no/~reinert/personal.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Linear Algebra package for Ada ? 2000-04-24 0:00 ` Robert Dewar 2000-04-24 0:00 ` David Starner @ 2000-04-24 0:00 ` Laurent GASSER 2000-04-25 0:00 ` Robert A Duff 2000-04-24 0:00 ` Reinert Korsnes 2 siblings, 1 reply; 11+ messages in thread From: Laurent GASSER @ 2000-04-24 0:00 UTC (permalink / raw) Beware that Fortran is one of the rare language to store matrix entries column-wise. Most of the others do it row-wise. So you may have to work with transposed matrices somewhere... An older book has elementary solvers: Jean-Etienne Rombaldi Algorithmique num\'erique et Ada Masson (1994) ISBN 2-225-84384-8 This is a book entierly dedicated to numerical analysis in Ada 83. The book goes through the topics of solving linear systems, of eigenvalues, of approximations and interpolations, of numerical integration, of differential equations (ODE) and finite differences (with an example of finite elements). The approach is rather about introducing the theory and the usage of the code on disc. The book is in French, with a code not so independent of the compiler OpenAda for PC-DOS. A very complete library, and I know that the author (now in Corse) works at making a Window interface to it. I played a little with conjugate gradient algorithms in Ada. With the proper declarations of operators, you end up writing exactly the formulas found in math books. I wish I had the time to make a true package out of it. Surely sometimes in the future, when I have spare time... ;-) I also found in my old mails the following: Title: Ada-95 for numerics? Date: April 2, 1996 From: rodemann@mathematik.uni-ulm.de Newsgroup: com.lang.ada Hello again! Thanks for all your postings. First I want to make the following clear: I am not criticizing the GNAT compiler --- sadly it is the only Ada-95 compiler I am able to use by now. And it is a fine thing to use. Since I am now working at a theoretical physics department and lots of the software written here is still done in Fortran-77. Many of our problems need quite a lot computing time. I guess for some applications, especially matrices Fortran may be still the best choice. At least for there are already many routines available (Numerical Recipes, Nag, EISPACK,...). But there are other applications that may be done better in another language...perhaps Ada-95 (complex and dynamic data structures, usage of generics and OO- techniques). So I started coding some of _my_ problems in Ada-95 and check for the speed. Yet, I am still a beginner in Ada-95, so maybe the coding style is somewhat unlucky... Some of you wanted to look at my code, so I appended it to this article. Thanks and greetings George ----------------------------------------------------------------------------- -- -- matrices.ads -- -- A generic matrix package (only a few functions shown...) -- ----------------------------------------------------------------------------- generic type Floating is digits <>; package Matrices is type Matrix is array (integer range <>, integer range <>) of Floating; pragma Convention (Fortran, Matrix); function Unit (n : integer) return matrix; procedure Get (a : out Matrix); procedure Put (a : Matrix); end Matrices; ----------------------------------------------------------------------------- -- -- eigensystems.ads -- -- A generic library of routines taken from "Numerical Recipes in C" -- The code ist strongly oriented at the C version, only the generic character -- has been added. -- ----------------------------------------------------------------------------- with vectors; with matrices; generic type Floating is digits <>; with function sqrt (x : Floating) return Floating; with package v is new vectors (Floating); with package m is new matrices (Floating); use v, m; package eigensystems is procedure tred2 (a : in out Matrix; d, e : out vector); end eigensystems; ----------------------------------------------------------------------------- -- -- vectors.ads -- ----------------------------------------------------------------------------- generic type Floating is digits <>; package Vectors is type Vector is array (integer range <>) of Floating; procedure Get (x : out Vector); procedure Put (x : Vector); end Vectors; ----------------------------------------------------------------------------- -- -- matrices.adb -- -- A generic matrix package (only a few functions shown here...) -- ----------------------------------------------------------------------------- with Ada.Text_Io; use Ada.Text_Io; package body Matrices is function Unit (n : Integer) return Matrix is C : Matrix (1..N, 1..N); begin for i in C'range(1) loop for j in C'first(2)..i loop C(i,j) := 0.0; C(j,i) := 0.0; end loop; C(i,i) := 1.0; end loop; return (C); end Unit; package Floating_Io is new Float_io (Floating); use Floating_Io; procedure Get (a : out matrix) is begin for i in a'Range(1) loop for j in a'Range(2) loop Get (a(i,j)); end loop; end loop; end Get; procedure Put (a : matrix) is begin for i in a'Range(1) loop for j in a'Range(2) loop Put (a(i,j)); New_Line; end loop; New_Line; end loop; end Put; end Matrices; ----------------------------------------------------------------------------- -- -- mytest.adb -- -- Main program: read in a symmetric matrix and brings it to tridiagonal form -- ----------------------------------------------------------------------------- with Vectors; with Matrices; with Eigensystems; with Ada.Text_Io; with Ada.Numerics.Aux; use Ada.Text_Io; use Ada.Numerics.Aux; procedure mytest is package MyVectors is new Vectors (Double); use MyVectors; package MyMatrices is new Matrices (Double); use MyMatrices; package MyEigensystems is new Eigensystems (Double, Sqrt, MyVectors, MyMatrices); N : integer := 5; package Int_Io is new Integer_Io(integer); use Int_Io; begin Get (N); declare a, b : Matrix (1..N,1..N); d, e : Vector (1..N); begin Get (b); for i in 1..100000 loop a := b; MyEigensystems.Tred2 (a, d, e); end loop; Put (d); Put (e); end; end mytest; ----------------------------------------------------------------------------- -- -- eigensystems.adb -- -- Contains the tred2 routine from "Numerical Recipes in C" -- ----------------------------------------------------------------------------- package body eigensystems is pragma Optimize (Time); pragma Suppress (All_Checks); procedure tred2 (a : in out Matrix; d, e : out vector) is scale : Floating; hh : Floating; h : Floating; g : Floating; f : Floating; n : constant integer := a'Last(1); l : integer range 0..n; i, j, k : integer range 1..n; begin for i in reverse 2..n loop l := i-1; h := 0.0; scale := 0.0; if l > 1 then for k in 1..l loop scale := scale + abs (a(i,k)); end loop; if scale = 0.0 then e(i) := a(i,l); else for k in 1..l loop a(i,k) := a(i,k) / scale; h := h + a(i,k) * a(i,k); end loop; f := a(i,l); if f >= 0.0 then g := -sqrt(h); else g := sqrt(h); end if; e(i) := scale * g; h := h - f*g; a(i,l) := f - g; f := 0.0; for j in 1..l loop a(j,i) := a(i,j) / h; g := 0.0; for k in 1..j loop g := g + a(j,k) * a(i,k); end loop; for k in j+1..l loop g := g + a(k,j)*a(i,k); end loop; e(j) := g / h; f := f + e(j) * a(i,j); end loop; hh := f / (h+h); for j in 1..l loop f := a(i,j); e(j) := e(j) - hh*f; g := e(j); for k in 1..j loop a(j,k) := a(j,k) - (f*e(k) + g*a(i,k)); end loop; end loop; end if; else e(i) := a(i,l); end if; d(i) := h; end loop; d(1) := 0.0; e(1) := 0.0; for i in 1..n loop l := i - 1; if d(i) /= 0.0 then for j in 1..l loop g := 0.0; for k in 1..l loop g := g + a(i,k)*a(k,j); end loop; for k in 1..l loop a(k,j) := a(k,j) - g*a(k,i); end loop; end loop; end if; d(i) := a(i,i); a(i,i) := 1.0; for j in 1..l loop a(j,i) := 0.0; a(i,j) := 0.0; end loop; end loop; end tred2; end eigensystems; ----------------------------------------------------------------------------- -- -- vectors.adb -- -- A generic Vector package (This is just a stripped version -- ----------------------------------------------------------------------------- with Ada.Text_Io; use Ada.Text_Io; package body vectors is package Floating_Io is new Float_Io (Floating); use Floating_Io; procedure Get (x : out Vector) is begin for i in x'Range loop Get (x(i)); end loop; end Get; procedure Put (x : Vector) is begin for i in x'Range loop Put (x(i)); New_Line; end loop; end Put; end vectors; Robert Dewar wrote: > > In article <8dv75n$qi1$1@news.uit.no>, > Reinert.Korsnes@npolar.no wrote: > > Hi, > > > > Could anybody recommend me an Ada95 package for linear algebra > > (including manipulation of vectors/matrices ?) > > Why not use the interface to Linpack (is that the right spelling > -- I refer to the standard Fortran linear algebra package) > > Sent via Deja.com http://www.deja.com/ > Before you buy. -- Laurent GASSER (gasser@hirondelle-lumineuse.ch) http://www.hirondelle-lumineuse.ch Computers do not solve problems, they execute solutions. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Linear Algebra package for Ada ? 2000-04-24 0:00 ` Laurent GASSER @ 2000-04-25 0:00 ` Robert A Duff 2000-04-25 0:00 ` Robert Dewar 0 siblings, 1 reply; 11+ messages in thread From: Robert A Duff @ 2000-04-25 0:00 UTC (permalink / raw) Laurent GASSER <lgasser@freesurf.fr> writes: > Beware that Fortran is one of the rare language to store > matrix entries column-wise. Most of the others do it > row-wise. So you may have to work with transposed matrices > somewhere... You can use pragma Convention(Fortran) to cause the Ada compiler to store matrices column-wise. - Bob ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Linear Algebra package for Ada ? 2000-04-25 0:00 ` Robert A Duff @ 2000-04-25 0:00 ` Robert Dewar 0 siblings, 0 replies; 11+ messages in thread From: Robert Dewar @ 2000-04-25 0:00 UTC (permalink / raw) In article <wccaeiicnay.fsf@world.std.com>, Robert A Duff <bobduff@world.std.com> wrote: > You can use pragma Convention(Fortran) to cause the Ada > compiler to store matrices column-wise. GNAT certainly implements this, and any Ada 95 compiler providing pragma Import (Fortran, ...) should do so too! Sent via Deja.com http://www.deja.com/ Before you buy. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Linear Algebra package for Ada ? 2000-04-24 0:00 ` Robert Dewar 2000-04-24 0:00 ` David Starner 2000-04-24 0:00 ` Laurent GASSER @ 2000-04-24 0:00 ` Reinert Korsnes 2000-04-24 0:00 ` Marin D. Condic 2000-04-25 0:00 ` Gisle S�lensminde 2 siblings, 2 replies; 11+ messages in thread From: Reinert Korsnes @ 2000-04-24 0:00 UTC (permalink / raw) In article <8e05ir$lc$1@nnrp1.deja.com>, Robert Dewar <robert_dewar@my-deja.com> writes: |> In article <8dv75n$qi1$1@news.uit.no>, |> Reinert.Korsnes@npolar.no wrote: |> > Hi, |> > |> > Could anybody recommend me an Ada95 package for linear algebra |> > (including manipulation of vectors/matrices ?) |> |> Why not use the interface to Linpack (is that the right spelling |> -- I refer to the standard Fortran linear algebra package) What about any native Ada95 open source code available ? reinert |> |> |> Sent via Deja.com http://www.deja.com/ |> Before you buy. -- Norwegian Polar Institute Polar Environment Center N-9296 Tromso Norway Fax: +47 77750501 http://geophys.npolar.no/~reinert/personal.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Linear Algebra package for Ada ? 2000-04-24 0:00 ` Reinert Korsnes @ 2000-04-24 0:00 ` Marin D. Condic 2000-04-25 0:00 ` Gisle S�lensminde 1 sibling, 0 replies; 11+ messages in thread From: Marin D. Condic @ 2000-04-24 0:00 UTC (permalink / raw) Reinert Korsnes wrote: > What about any native Ada95 open source code available ? I thought there was some Linear A code on the Public Ada Library at one time: http://wuarchive.wustl.edu/languages/ada/ Mats Weber has some math code that *may* be appropriate: http://lglwww.epfl.ch/Team/MW/mw_components.html MDC -- ====================================================================== Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/ Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m Visit my web site at: http://www.mcondic.com/ "I'd trade it all for just a little more" -- Charles Montgomery Burns, [4F10] ====================================================================== ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Linear Algebra package for Ada ? 2000-04-24 0:00 ` Reinert Korsnes 2000-04-24 0:00 ` Marin D. Condic @ 2000-04-25 0:00 ` Gisle S�lensminde 1 sibling, 0 replies; 11+ messages in thread From: Gisle S�lensminde @ 2000-04-25 0:00 UTC (permalink / raw) In article <8e0qit$77a$1@news.uit.no>, Reinert Korsnes wrote: >In article <8e05ir$lc$1@nnrp1.deja.com>, > Robert Dewar <robert_dewar@my-deja.com> writes: >|> In article <8dv75n$qi1$1@news.uit.no>, >|> Reinert.Korsnes@npolar.no wrote: >|> > Hi, >|> > >|> > Could anybody recommend me an Ada95 package for linear algebra >|> > (including manipulation of vectors/matrices ?) >|> >|> Why not use the interface to Linpack (is that the right spelling >|> -- I refer to the standard Fortran linear algebra package) > >What about any native Ada95 open source code available ? Martin Stift has made numeric code for use in astrophysics, which he presents at his homepage. http://fedelma.astro.univie.ac.at/web/home.html Also, as other pointed out. The Ada binding to Lapack can be found at ftp://ftp.cs.nyu.edu/pub/gnat/contrib/lapack-ada/ > >reinert > >|> >|> >|> Sent via Deja.com http://www.deja.com/ >|> Before you buy. > >-- >Norwegian Polar Institute >Polar Environment Center >N-9296 Tromso >Norway >Fax: +47 77750501 > >http://geophys.npolar.no/~reinert/personal.html -- -- Gisle S�lensminde ( gisle@ii.uib.no ) ln -s /dev/null ~/.netscape/cookies ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Linear Algebra package for Ada ? 2000-04-23 0:00 Linear Algebra package for Ada ? Reinert Korsnes 2000-04-24 0:00 ` Robert Dewar @ 2000-04-25 0:00 ` Gautier 1 sibling, 0 replies; 11+ messages in thread From: Gautier @ 2000-04-25 0:00 UTC (permalink / raw) To: Reinert.Korsnes Reinert Korsnes wrote: > Could anybody recommend me an Ada95 package for linear algebra > (including manipulation of vectors/matrices ?) There is a binding Lapack-Ada (Lapada ?); if you are interested I have here - a generic package for band matrices (just extracted from a current program, see PS) and some bindings to LU, Cholesky, solvers (DGBTRF etc.) - a generic package for sparse matrices in CRS format with symmetric and asymmetric iterative solvers (stabilized conjuguate gradient) with an optional binding to BLAS. BTW: a true, reference, Lapack in Ada (with generics for hitting single/double/etc. in one move would be _very_ nice! A thesis project maybe ?...) _____________________________________________ Gautier -- http://members.xoom.com/gdemont/ generic type real is digits <>; type index is range <>; type vector is array(index range <>) of real; type matrix is array(index range <>, index range <>) of real; package BandMatr is -------------------------- -- Define a band matrix -- -------------------------- type Band_matrix( max_size, -- size of actual matrix band, -- bandwidth multi_band -- n-uple of bandwidth : index ) is record val: matrix(1..max_size, 1..multi_band); -- transposed w/r Lapack due to Fortran symmetric: boolean; size: index:= max_size; end record; (...) ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2000-04-25 0:00 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2000-04-23 0:00 Linear Algebra package for Ada ? Reinert Korsnes 2000-04-24 0:00 ` Robert Dewar 2000-04-24 0:00 ` David Starner 2000-04-24 0:00 ` Reinert Korsnes 2000-04-24 0:00 ` Laurent GASSER 2000-04-25 0:00 ` Robert A Duff 2000-04-25 0:00 ` Robert Dewar 2000-04-24 0:00 ` Reinert Korsnes 2000-04-24 0:00 ` Marin D. Condic 2000-04-25 0:00 ` Gisle S�lensminde 2000-04-25 0:00 ` Gautier
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox