* ANN: miscellaneous Math routines, GPL'd @ 2009-05-12 16:38 johnscpg 2009-05-12 18:45 ` John B. Matthews ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: johnscpg @ 2009-05-12 16:38 UTC (permalink / raw) 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: http://web.am.qub.ac.uk/users/j.parker/miscellany The full set is tarred in the file: 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ANN: miscellaneous Math routines, GPL'd 2009-05-12 16:38 ANN: miscellaneous Math routines, GPL'd johnscpg @ 2009-05-12 18:45 ` John B. Matthews 2009-05-13 9:39 ` johnscpg 2009-05-12 19:03 ` Dmitry A. Kazakov 2009-05-12 21:02 ` lanceboyle 2 siblings, 1 reply; 9+ messages in thread From: John B. Matthews @ 2009-05-12 18:45 UTC (permalink / raw) In article <9dbcdcd0-3c15-4165-9336-3d5778df2ca3@e20g2000vbc.googlegroups.com>, johnscpg@googlemail.com wrote: > 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: > > http://web.am.qub.ac.uk/users/j.parker/miscellany > > The full set is tarred in the file: > > 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. Excellent. You might like to see my experimental implementation of Generic_Roots, using the Durand-Kerner-Weierstrass method and distributed under the GNAT modified GPL: <http://home.roadrunner.com/~jbmatthews/misc/groots.html> -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ANN: miscellaneous Math routines, GPL'd 2009-05-12 18:45 ` John B. Matthews @ 2009-05-13 9:39 ` johnscpg 2009-05-13 13:40 ` John B. Matthews 0 siblings, 1 reply; 9+ messages in thread From: johnscpg @ 2009-05-13 9:39 UTC (permalink / raw) On May 12, 7:45 pm, "John B. Matthews" <nos...@nospam.invalid> wrote: > In article > <9dbcdcd0-3c15-4165-9336-3d5778df2...@e20g2000vbc.googlegroups.com>, > > > > johns...@googlemail.com wrote: > > 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: > > > http://web.am.qub.ac.uk/users/j.parker/miscellany > > > The full set is tarred in the file: > > > 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. > > Excellent. You might like to see my experimental implementation of > Generic_Roots, using the Durand-Kerner-Weierstrass method and > distributed under the GNAT modified GPL: > > <http://home.roadrunner.com/~jbmatthews/misc/groots.html> > > -- > John B. Matthews > trashgod at gmail dot com > <http://sites.google.com/site/drjohnbmatthews> Thanks for the pointer. Root finding BTW is one of those problems that cries out for extended precision floating pt. Its rarely time-sensitive (rarely in inner loops), but very sensitive to precision ... last time I did it, it was on mathematica in extended precision .. I prefer Ada! If I did in Fortran I'ld always use REAL*16 (Quad-precision, 32 digit floats) but only one Fortran (intel ifort) supports this as far as I know (except IBM's fortran on powerpc). If I ever find the time I'll hook up your root finder to my Extended Precision package. cheers jonathan ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ANN: miscellaneous Math routines, GPL'd 2009-05-13 9:39 ` johnscpg @ 2009-05-13 13:40 ` John B. Matthews 0 siblings, 0 replies; 9+ messages in thread From: John B. Matthews @ 2009-05-13 13:40 UTC (permalink / raw) In article <cb936fa3-df11-4563-b283-b0bfed0ba070@o27g2000vbd.googlegroups.com>, johnscpg@googlemail.com wrote: > On May 12, 7:45 pm, "John B. Matthews" <nos...@nospam.invalid> wrote: > > In article > > <9dbcdcd0-3c15-4165-9336-3d5778df2...@e20g2000vbc.googlegroups.com>, > > > > johns...@googlemail.com wrote: > > > 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: > > > > > http://web.am.qub.ac.uk/users/j.parker/miscellany > > > > > The full set is tarred in the file: > > > > > 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. > > > > Excellent. You might like to see my experimental implementation of > > Generic_Roots, using the Durand-Kerner-Weierstrass method and > > distributed under the GNAT modified GPL: > > > > <http://home.roadrunner.com/~jbmatthews/misc/groots.html> [...] > Thanks for the pointer. Root finding BTW is one of those problems > that cries out for extended precision floating pt. Its rarely > time-sensitive (rarely in inner loops), but very sensitive to > precision ... last time I did it, it was on mathematica in extended > precision .. I prefer Ada! If I did in Fortran I'ld always use > REAL*16 (Quad-precision, 32 digit floats) but only one Fortran (intel > ifort) supports this as far as I know (except IBM's fortran on > powerpc). Ah, yes. I noticed the difference running examples on PPC & x86. IIUC, the latter uses an 80-bit format internally. > If I ever find the time I'll hook up your root finder to my > Extended Precision package. Outstanding. As both are GMGPL, please feel free to incorporate any of my work in your project. -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ANN: miscellaneous Math routines, GPL'd 2009-05-12 16:38 ANN: miscellaneous Math routines, GPL'd johnscpg 2009-05-12 18:45 ` John B. Matthews @ 2009-05-12 19:03 ` Dmitry A. Kazakov 2009-05-12 21:02 ` lanceboyle 2 siblings, 0 replies; 9+ messages in thread From: Dmitry A. Kazakov @ 2009-05-12 19:03 UTC (permalink / raw) On Tue, 12 May 2009 09:38:49 -0700 (PDT), johnscpg@googlemail.com wrote: > 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: > > http://web.am.qub.ac.uk/users/j.parker/miscellany Many thanks for a great contribution! -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ANN: miscellaneous Math routines, GPL'd 2009-05-12 16:38 ANN: miscellaneous Math routines, GPL'd johnscpg 2009-05-12 18:45 ` John B. Matthews 2009-05-12 19:03 ` Dmitry A. Kazakov @ 2009-05-12 21:02 ` lanceboyle 2009-05-13 9:25 ` johnscpg 2 siblings, 1 reply; 9+ messages in thread From: lanceboyle @ 2009-05-12 21:02 UTC (permalink / raw) On May 12, 9:38 am, 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: > > http://web.am.qub.ac.uk/users/j.parker/miscellany > > The full set is tarred in the file: > > 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 <>) of 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ANN: miscellaneous Math routines, GPL'd 2009-05-12 21:02 ` lanceboyle @ 2009-05-13 9:25 ` johnscpg 2009-05-13 11:52 ` gautier_niouzes 0 siblings, 1 reply; 9+ messages in thread From: johnscpg @ 2009-05-13 9:25 UTC (permalink / raw) On May 12, 10:02 pm, "lancebo...@qwest.net" <lancebo...@qwest.net> wrote: > On May 12, 9:38 am, 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: > > > http://web.am.qub.ac.uk/users/j.parker/miscellany > > > The full set is tarred in the file: > > > 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 <>) > of 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ANN: miscellaneous Math routines, GPL'd 2009-05-13 9:25 ` johnscpg @ 2009-05-13 11:52 ` gautier_niouzes 2009-05-13 13:43 ` johnscpg 0 siblings, 1 reply; 9+ messages in thread From: gautier_niouzes @ 2009-05-13 11:52 UTC (permalink / raw) On 13 Mai, 11:25, johns...@googlemail.com wrote: > 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. It's done here: http://www.cs.umbc.edu/~squire/adaclass/gnatmath95 , generic_real_linear_equations.ads . For using with Ada 2005's matrices, all you need is to replace package Generic_Real_Arrays by Ada.Numerics.Generic_Real_Arrays :-) _________________________________________________________ Gautier's Ada programming -- http://sf.net/users/gdemont/ NB: For a direct answer, e-mail address on the Web site! ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ANN: miscellaneous Math routines, GPL'd 2009-05-13 11:52 ` gautier_niouzes @ 2009-05-13 13:43 ` johnscpg 0 siblings, 0 replies; 9+ messages in thread From: johnscpg @ 2009-05-13 13:43 UTC (permalink / raw) On May 13, 12:52 pm, gautier_niou...@hotmail.com wrote: > On 13 Mai, 11:25, johns...@googlemail.com wrote: > > > > > 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. > > It's done here:http://www.cs.umbc.edu/~squire/adaclass/gnatmath95, > generic_real_linear_equations.ads . > > For using with Ada 2005's matrices, all you need is to replace > package Generic_Real_Arrays by Ada.Numerics.Generic_Real_Arrays > :-) > _________________________________________________________ > Gautier's Ada programming --http://sf.net/users/gdemont/ > > NB: For a direct answer, e-mail address on the Web site! Thanks Gautier! After a quick inspection, I notice a lot of method 1, (shifting indices inside loops), but sometimes the author copies the entire input array over to a new local array with the desired indices (usually 1..N). Also raises an exception if there's a length mismatch. cheers, jonathan ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-05-13 13:43 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-05-12 16:38 ANN: miscellaneous Math routines, GPL'd johnscpg 2009-05-12 18:45 ` John B. Matthews 2009-05-13 9:39 ` johnscpg 2009-05-13 13:40 ` John B. Matthews 2009-05-12 19:03 ` Dmitry A. Kazakov 2009-05-12 21:02 ` lanceboyle 2009-05-13 9:25 ` johnscpg 2009-05-13 11:52 ` gautier_niouzes 2009-05-13 13:43 ` johnscpg
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox