From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,523c3848a9d03183 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!r13g2000vbr.googlegroups.com!not-for-mail From: johnscpg@googlemail.com Newsgroups: comp.lang.ada Subject: Re: ANN: miscellaneous Math routines, GPL'd Date: Wed, 13 May 2009 02:25:30 -0700 (PDT) Organization: http://groups.google.com Message-ID: <46c1db7c-e6b4-48a1-9a4a-a777a1baaf60@r13g2000vbr.googlegroups.com> References: <9dbcdcd0-3c15-4165-9336-3d5778df2ca3@e20g2000vbc.googlegroups.com> <7f7fcafe-189e-423e-a24d-5933bfd6f754@n7g2000prc.googlegroups.com> NNTP-Posting-Host: 143.117.23.126 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1242206730 22027 127.0.0.1 (13 May 2009 09:25:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 13 May 2009 09:25:30 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r13g2000vbr.googlegroups.com; posting-host=143.117.23.126; posting-account=Jzt5lQoAAAB4PhTgRLOPGuTLd_K1LY-C User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.9.0.9) Gecko/2009050519 Iceweasel/3.0.6 (Debian-3.0.6-1),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5804 Date: 2009-05-13T02:25:30-07:00 List-Id: On May 12, 10:02=A0pm, "lancebo...@qwest.net" wrote: > On May 12, 9:38=A0am, johns...@googlemail.com wrote: > > > > > Dear All, > > > For those of you who like Ada with their numerics (is there > > anyone who doesn't?!) I have released a collection of math > > routines under the GPL license. Find them at: > > > =A0http://web.am.qub.ac.uk/users/j.parker/miscellany > > > The full set is tarred in the file: > > > =A0 miscellany.10may09.tar.gz > > > in the directory given above. > > > Most are old classics I have found useful over the years > > (SVD, QR, LU, Runge-Kutta, FFT, Arbitrary precision floating point). > > The random number generators are very new; the documentation > > should explain why I recommend them. The random number generators > > and the Arbitrary precision floating point are designed to > > make good use of the new 64-bit CPU's. > > > Cheers, > > Jonathan > > > j.parker/at/qub/point/ac/point/uk > > Wow--numerical code that I can actually read! This looks awesome. > > I suppose that it would not be hard to adapt the code to use the > vector and matrix declarations in the Annex G.3 part of Ada 2005, e.g. > > type Real_Vector is array (Integer range <>) of Real'Base; > type Real_Matrix is array (Integer range <>, Integer range <>) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0of Real'Base; > > replacing the scattered declarations such as > > type Data_Array is array (Array_Index) of Real; > type A_Matrix is array(R_Index, C_Index) of Real; > > I really like the "standardized" way of these Ada 2005 declarations. > > Jerry To instantiate the lin. alg. generics (in directory linearly) using the unconstrained arrays you typed above, declare a subtype m3: subtype Index is Integer range 1..191; --type Real_Matrix is array (Integer range <>, Integer range <>) of Real; subtype m3 is Real_Matrix (Index, Index); The generics can now be instantiated with m3. Another interesting question is whether the generics (and the subprograms declared by the generic package) should be using unconstrained arrays: generic type Real is digits <>; type Matrix is array (Integer range <>, Integer range <>) of Real; In the old days if I did that the program would run way slow.. seemed to put the compiler under much stress ... maybe ok now but I am not going to be the one to prove it. Here's another problem: Very common for an application to require transformation of an arbitrary diagonal block of a matrix (or any block) rather than the full matrix. Unconstrained arrays don't provide any special benefit here ... you still have to copy the block to another matrix, or handle it the way I do in these routines (tell the routine to operate on a specified block only). Once you've gone to this trouble, the benefit of unconstrained arrays is small. Another irritation: suppose user declares V : Vector (1..10); M : Matrix (0..9, 0..9); or worse M : Matrix (0..9, 2..11); or worse still M : Matrix (0..11, 2..11); How do you handle it? 1. shift indices during iteration inside loops in the lin alg program. 2. slide arrays so indices coincide. 3. Raise constraint_error; 4. Assume they won't do it. I do 3. (See for example procedure Choleski_Decompose at end of Disorderly-Random-Deviates.adb and near bottom of Disorderly-Random-Deviates.ads.) But I'm not sure what to do. (I was going ask here on comp.lang.ada, but got lazy.) Generics with constrained arrays work ok for me here. cheers, jonathan