views:

79

answers:

2
+1  Q: 

Ada matrix package

Hi, I'm in search for a free package that do most matrix/vector operations. I can write some basic functions myself but for advanced ones like computing eigenvalues and eigenvectors I would prefer robust code and I would like to know if such packages are freely available. If I understand correctly Ada 2005 have more matrix operations facilities but it has a function to calculate the eigenvalues for a symmetric and hermitian matrices only. I'll need a more general packages which can handle any kind of matrix.

An Ada95 matrix package (54KB tar.gz file) from Drexel Fusion Laboratory had the link: http://dflwww.ece.drexel.edu/research/ada/ but the page for this ink is non-existent today.

Thanks a lot...

+3  A: 

I think that the Ada95 package you mean is here -- but it's only 35k, and it seems to have less functionality than the Ada2005 standard library does.

Not sure how this Ada95 binding to BLAS came to be in my browser cache! I see that for general matrix solving you need LAPACK too, I wonder whether the bindings already in GNAT will help? Package System.Generic_Real_LAPACK in file s-gerela.ad[bs]. The comments say

--  LAPACK Computational Routines

--  gerfs  Refines the solution of a system of linear equations with
--         a general matrix and estimates its error
--  getrf  Computes LU factorization of a general m-by-n matrix
--  getri  Computes inverse of an LU-factored general matrix
--         square matrix, with multiple right-hand sides
--  getrs  Solves a system of linear equations with an LU-factored
--         square matrix, with multiple right-hand sides
--  orgtr  Generates the Float orthogonal matrix Q determined by sytrd
--  steqr  Computes all eigenvalues and eigenvectors of a symmetric or
--         Hermitian matrix reduced to tridiagonal form (QR algorithm)
--  sterf  Computes all eigenvalues of a Float symmetric
--         tridiagonal matrix using QR algorithm
--  sytrd  Reduces a Float symmetric matrix to tridiagonal form

which I suspect is a small subset of the full library. Still, could act as a useful springboard for more extensive bindings.

Simon Wright
@yCalleecharan: Your implementation may already link to an external library to implement the standard. http://stackoverflow.com/questions/2662805
trashgod
Thanks. The link you provided was my one of my own questions :). I use the AdaCore libre GNAT compiler. I was just reading the document here: http://libre.adacore.com/wp-content/uploads/2006/02/Ada05_rational_06.pdfand I quote: "Ada predefined numerics library as being in any way in competition with or as a substitute for professional libraries such as the renowned BLAS".I don't know if an Ada implementation does offer advanced numerical analysis packages.
yCalleecharan
@yCalleecharan: The _Ada Rationale_ is more recent; I've elaborated in an adjacent answer.
trashgod
@Simon Wright: Sorry, I didn't mean to snipe your answer.
trashgod
@trashgod: I saw no sniping there!
Simon Wright
Thanks a lot for the additional information. Computation of eigenvalues is provided for symmetric matrices only (real and complex). It would be interesting though to have it for a general matrix. As I mentioned earlier, this link: http://www.martin.dowie.btinternet.co.uk/Numerics/adabrowse/ada-numerics-generic_real_arrays.htmlgives some indication why this is hard-work. Again many thanks for the detailed information. It'll be useful to compare this to what Ada 05 now offers. It does for example offer error estimate for the system Ax=b, which I don't think Ada 05 provides.
yCalleecharan
Here: http://www.sigada.org/ada_95/bindings.html it's mentioned a link to Ada bindings for LAPACK, but unfortunately the link seems dead.
yCalleecharan
I am not a mathematician! but - LAPACK itself seems to provide computation of eigenvalues for non-symmetric matrices: eg http://www.netlib.org/lapack/lug/node50.html, using `GEHRD` and `HSEQR`. So you may be able to construct bindings to these subroutines following the model in GNAT 05's `System.Generic_Real_LAPACK`.
Simon Wright
Thanks. I shall look into it. I am still exploring many things in Ada and this will be on my to-do list. Luckily enough, we have lots of information on the web out there if we spend time searching.
yCalleecharan
To be perfectly honest, I give +1 to **any** Ada question or answer (such as this one) that isn't outright hostile or wrong. There should be more discussion of Ada here, so I do what I can to encourage it. *Free rep for discussing Ada!* :-)
T.E.D.
It's true that we don't have many discussions on Ada here. I've decided to switch from C to Ada and I expect to post more questions along the way...
yCalleecharan
Someone (fitta) on comp.lang.ada was having trouble with the http://www.taygeta.com/ada.html download, there seems to be a problem decompressing it (it's a .tar.Z file, haven't seen one of those for a long time!) Apparently 7-zip worked (but I had no trouble with tar zx on Mac OS X).
Simon Wright
Simon, the link that you provided (http://archive.adaic.com/ase/ase02_02/comps/math1/matpack.zip) is the appropriate one for the Drexel package.
yCalleecharan
Simon has mentioned comp.lang.ada earlier. A good discussion on the matrix package is going on there.
yCalleecharan
+2  A: 

As suggested in John Barnes Rationale for Ada 2005, Ada's Annex G: Numerics is not intended "as a substitute for professional libraries such as the renowned BLAS," but nothing precludes an implementation from using BLAS internally. As a concrete example, the GNAT compiler implements both G.3.1 Real Vectors and Matrices and G.3.2 Complex Vectors and Matrices using BLAS and LAPACK. To see the details, you can examine the relevant package bodies:

$ export ADA_INC = /your/path/to/adinclude
$ view $ADA_INC/$(gnatkr Ada.Numerics.Generic_Real_Arrays.adb)
$ view $ADA_INC/$(gnatkr Ada.Numerics.Generic_Complex_Arrays.adb)
trashgod
This is very useful to know. Thank you very much for the links. I shall read them carefully. Also 1 vote up.
yCalleecharan
These commands that u wrote: are they in unix? I use windows but I'll try and see if I can use these packages.
yCalleecharan
If u have time, maybe u an correct the link to G.3.1. real vectors...Both links that you gave point to G.3.2. But of course it's very easy for someone to navigate to G.3.1 having found the way to G.3.2.
yCalleecharan
I found a link: http://www.martin.dowie.btinternet.co.uk/Numerics/adabrowse/ada-numerics-generic_real_arrays.htmlwhere information is given as to why Ada has no eigenvalue computation facility for a general non-symmetric matrix. In brief, algorithms that cater for a non-symmetric matrix may as not be robust as those for symmetric ones.
yCalleecharan
I believe that a drawback with Ada is that it doesn't have convenient I/O operations for vectors and matrices, for example when it comes to input and output (say on the screen). But of course if a user would write a procedure to display the matrix elements, this drawback would be eliminated.
yCalleecharan
@yCalleecharan: I took care of it. Oh, and +1 for a useful answer.
T.E.D.
@yCalleecharan: Don't the stream I/O operators work on vectors and matrices? Or do you not count those as "convenient"?
T.E.D.
@T.E.D.: Thanks, on both counts! :-)
trashgod
Thanks. I don't know much about the stream I/O operators. I'm thinking of the I/O stream which are used to write to files. Or do you mean something else?
yCalleecharan
@yCalleecharan: You can use real (A.10.9) and complex (G.1.3) I/O to format numbers; You can use streams for arrays http://www.adaic.com/standards/05rm/html/RM-13-13-2.html and structured data http://www.infres.enst.fr/~pautet/Ada95/chap24.htm
trashgod
Thanks Trashgod. I'm a little confused here. Would you be kind enough to provide me with a small example of what you mean? Your help would be much appreciated.
yCalleecharan
trashgod
Ok. I will do as you suggest.
yCalleecharan