comp.lang.ada
 help / color / mirror / Atom feed
* Where I find Bessel function for Ada ?
@ 2008-11-26  8:40 reinkor
  2008-11-26 11:05 ` gautier_niouzes
  2008-11-27  3:07 ` Jerry
  0 siblings, 2 replies; 16+ messages in thread
From: reinkor @ 2008-11-26  8:40 UTC (permalink / raw)


Dear All,

I want to use the modified Bessel function of order 0 in my Ada
program.

Where I find it ?

reinert



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

* Re: Where I find Bessel function for Ada ?
  2008-11-26  8:40 Where I find Bessel function for Ada ? reinkor
@ 2008-11-26 11:05 ` gautier_niouzes
  2008-11-26 12:57   ` Dmitry A. Kazakov
  2008-11-26 13:08   ` Paul Cole Gloster
  2008-11-27  3:07 ` Jerry
  1 sibling, 2 replies; 16+ messages in thread
From: gautier_niouzes @ 2008-11-26 11:05 UTC (permalink / raw)


> Dear All,
>
> I want to use the modified Bessel function of order 0 in my Ada
> program.
>
> Where I find it ?
>
> reinert

It is in the Numerical Recipes in Pascal, chapter 6.4, pp 191.
All you need to pick the right Pascal source, like bessj0.pas
and put it through th P2Ada translator: http://p2ada.sf.net/
The NR sources are freely available on the Internet.
HTH
Gautier



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

* Re: Where I find Bessel function for Ada ?
  2008-11-26 11:05 ` gautier_niouzes
@ 2008-11-26 12:57   ` Dmitry A. Kazakov
  2008-12-03  4:18     ` R. B. Love
  2008-11-26 13:08   ` Paul Cole Gloster
  1 sibling, 1 reply; 16+ messages in thread
From: Dmitry A. Kazakov @ 2008-11-26 12:57 UTC (permalink / raw)


On Wed, 26 Nov 2008 03:05:23 -0800 (PST), gautier_niouzes@hotmail.com
wrote:

>> I want to use the modified Bessel function of order 0 in my Ada
>> program.
>>
>> Where I find it ?
> 
> It is in the Numerical Recipes in Pascal, chapter 6.4, pp 191.
> All you need to pick the right Pascal source, like bessj0.pas
> and put it through th P2Ada translator: http://p2ada.sf.net/
> The NR sources are freely available on the Internet.

Well, if there is no Ada code, then I would also consider to implement it
from scrap. There is an excellent book "Mathematical Functions and Their
Approximations" by Yudell L. Luke:

http://www.amazon.com/Mathematical-Functions-Their-Approximations-Yudell/dp/0124599508

If I correctly remember it contains coefficients of Chebyshev polynomial
approximations for various Bessel functions with a huge number of decimal
places. Chebyshev polynomes are fairly simple and efficient to sum.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Where I find Bessel function for Ada ?
  2008-11-26 11:05 ` gautier_niouzes
  2008-11-26 12:57   ` Dmitry A. Kazakov
@ 2008-11-26 13:08   ` Paul Cole Gloster
  2008-11-26 15:09     ` Ken Thomas
  1 sibling, 1 reply; 16+ messages in thread
From: Paul Cole Gloster @ 2008-11-26 13:08 UTC (permalink / raw)


Reinert submitted:

|----------------------------------------------------------------|
|"I want to use the modified Bessel function of order 0 in my Ada| 
 

|program.                                                        | 
 

|                                                                | 
 

|Where I find it ?"                                              |
|----------------------------------------------------------------|

It may be best to write your own version so that you could justifiably
have an accurate level of confidence of it.

Gautier responded:

!---------------------------------------------------------------!
!"It is in the Numerical Recipes in Pascal, chapter 6.4, pp 191.! 
 

!All you need to pick the right Pascal source, like bessj0.pas  ! 
 

!and put it through th P2Ada translator: http://p2ada.sf.net/   ! 
 

!The NR sources are freely available on the Internet."          !
!---------------------------------------------------------------!

I have not thoroughly assessed that particular part of "Numerical 
 

Recipes", but some parts of "Numerical Recipes" are
untrustworthy. Early in 2009 on
WWW.ACCU.org
a review by myself which is almost ready for publication should be
available.



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

* Re: Where I find Bessel function for Ada ?
  2008-11-26 13:08   ` Paul Cole Gloster
@ 2008-11-26 15:09     ` Ken Thomas
  2008-11-26 16:12       ` Ludovic Brenta
  0 siblings, 1 reply; 16+ messages in thread
From: Ken Thomas @ 2008-11-26 15:09 UTC (permalink / raw)


On Nov 26, 1:08 pm, Paul Cole Gloster <Colin_Paul_Glos...@ACM.org>
wrote:
> Reinert submitted:
>
> |----------------------------------------------------------------|
> |"I want to use the modified Bessel function of order 0 in my Ada|
>
> |program.                                                        |
>
> |                                                                |
>
> |Where I find it ?"                                              |
> |----------------------------------------------------------------|
>
> It may be best to write your own version so that you could justifiably
> have an accurate level of confidence of it.
>
> Gautier responded:
>
> !---------------------------------------------------------------!
> !"It is in the Numerical Recipes in Pascal, chapter 6.4, pp 191.!
>
> !All you need to pick the right Pascal source, like bessj0.pas  !
>
> !and put it through th P2Ada translator:http://p2ada.sf.net/  !
>
> !The NR sources are freely available on the Internet."          !
> !---------------------------------------------------------------!
>
> I have not thoroughly assessed that particular part of "Numerical
>
> Recipes", but some parts of "Numerical Recipes" are
> untrustworthy. Early in 2009 on
> WWW.ACCU.org
> a review by myself which is almost ready for publication should be
> available.

The source for the Pascal version of Numerical Recipes can be found at
http://archives.math.utk.edu/software/msdos/numerical.analysis/nrpas13/.html

As the code for bessj0 is very short, translation to Ada is a small
exercise. On the other hand, the code seems to deal with only single
precision arithmetic so does not promise high accuracy.

Ken





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

* Re: Where I find Bessel function for Ada ?
  2008-11-26 15:09     ` Ken Thomas
@ 2008-11-26 16:12       ` Ludovic Brenta
  2008-11-26 17:17         ` Dmitry A. Kazakov
  0 siblings, 1 reply; 16+ messages in thread
From: Ludovic Brenta @ 2008-11-26 16:12 UTC (permalink / raw)


On Nov 26, 4:09 pm, Ken Thomas <k...@ecs.soton.ac.uk> wrote:
> On Nov 26, 1:08 pm, Paul Cole Gloster <Colin_Paul_Glos...@ACM.org>
> wrote:
>
>
>
> > Reinert submitted:
>
> > |----------------------------------------------------------------|
> > |"I want to use the modified Bessel function of order 0 in my Ada|
>
> > |program.                                                        |
>
> > |                                                                |
>
> > |Where I find it ?"                                              |
> > |----------------------------------------------------------------|
>
> > It may be best to write your own version so that you could justifiably
> > have an accurate level of confidence of it.
>
> > Gautier responded:
>
> > !---------------------------------------------------------------!
> > !"It is in the Numerical Recipes in Pascal, chapter 6.4, pp 191.!
>
> > !All you need to pick the right Pascal source, like bessj0.pas  !
>
> > !and put it through th P2Ada translator:http://p2ada.sf.net/ !
>
> > !The NR sources are freely available on the Internet."          !
> > !---------------------------------------------------------------!
>
> > I have not thoroughly assessed that particular part of "Numerical
>
> > Recipes", but some parts of "Numerical Recipes" are
> > untrustworthy. Early in 2009 on
> > WWW.ACCU.org
> > a review by myself which is almost ready for publication should be
> > available.
>
> The source for the Pascal version of Numerical Recipes can be found athttp://archives.math.utk.edu/software/msdos/numerical.analysis/nrpas1...
>
> As the code for bessj0 is very short, translation to Ada is a small
> exercise. On the other hand, the code seems to deal with only single
> precision arithmetic so does not promise high accuracy.

I suppose this is easy to fix by making the Ada implementation
generic. The user then instantiates it for any floating-point type
with the required accuracy.

--
Ludovic Brenta.



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

* Re: Where I find Bessel function for Ada ?
  2008-11-26 16:12       ` Ludovic Brenta
@ 2008-11-26 17:17         ` Dmitry A. Kazakov
  0 siblings, 0 replies; 16+ messages in thread
From: Dmitry A. Kazakov @ 2008-11-26 17:17 UTC (permalink / raw)


On Wed, 26 Nov 2008 08:12:21 -0800 (PST), Ludovic Brenta wrote:

> On Nov 26, 4:09 pm, Ken Thomas <k...@ecs.soton.ac.uk> wrote:

>> As the code for bessj0 is very short, translation to Ada is a small
>> exercise. On the other hand, the code seems to deal with only single
>> precision arithmetic so does not promise high accuracy.
> 
> I suppose this is easy to fix by making the Ada implementation
> generic. The user then instantiates it for any floating-point type
> with the required accuracy.

An ability to do so depends on the accuracy of the constants used in the
implementation.

A good-designed library should have the accuracy of the result within n *
T'Model_Epsilon or, better, within the range f(x)'Pred..f(x)'Succ. It is
non-trivial to do for a generic package. Short types will suffer accuracy
losses due to insufficient precision. Long precision types will due to
inaccuracy of the coefficients. Most likely in a generic body you will need
some "carrier" type of the precision higher than of the argument type. In
some cases T'Base can help. In others it cannot...

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Where I find Bessel function for Ada ?
  2008-11-26  8:40 Where I find Bessel function for Ada ? reinkor
  2008-11-26 11:05 ` gautier_niouzes
@ 2008-11-27  3:07 ` Jerry
  1 sibling, 0 replies; 16+ messages in thread
From: Jerry @ 2008-11-27  3:07 UTC (permalink / raw)


On Nov 26, 1:40 am, reinkor <rein...@gmail.com> wrote:
> Dear All,
>
> I want to use the modified Bessel function of order 0 in my Ada
> program.
>
> Where I find it ?
>
> reinert

There was a discussion on this on this list about two years ago about
Ada bindings to the GNU Scientific Library, GSL. Maybe someone can
update us. There was one person who had made a tentative effort and
upon Googling just now I found that someone has tried a SWIG binding.

Search comp.lang.ada yourself:
http://groups.google.com/group/comp.lang.ada/search?hl=en&group=comp.lang.ada&q=GNU+Scientific+Library&qt_g=Search+this+group

Here is the GSL manual page for a modified Bessel function:

http://www.network-theory.co.uk/docs/gslref/RegularModifiedCylindricalBesselFunctions.html

Jerry



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

* Re: Where I find Bessel function for Ada ?
  2008-11-26 12:57   ` Dmitry A. Kazakov
@ 2008-12-03  4:18     ` R. B. Love
  2008-12-03 13:22       ` Dmitry A. Kazakov
  2008-12-06 22:02       ` Nasser Abbasi
  0 siblings, 2 replies; 16+ messages in thread
From: R. B. Love @ 2008-12-03  4:18 UTC (permalink / raw)


On 2008-11-26 06:57:09 -0600, "Dmitry A. Kazakov" 
<mailbox@dmitry-kazakov.de> said:

> Well, if there is no Ada code, then I would also consider to implement it
> from scrap. There is an excellent book "Mathematical Functions and Their
> Approximations" by Yudell L. Luke:
> 
> http://www.amazon.com/Mathematical-Functions-Their-Approximations-Yudell/dp/0124599508

If 
> 
> I correctly remember it contains coefficients of Chebyshev polynomial
> approximations for various Bessel functions with a huge number of decimal
> places. Chebyshev polynomes are fairly simple and efficient to sum.

Do you work on comission?  That's a $700 book.




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

* Re: Where I find Bessel function for Ada ?
  2008-12-03  4:18     ` R. B. Love
@ 2008-12-03 13:22       ` Dmitry A. Kazakov
  2008-12-03 14:24         ` Hyman Rosen
  2008-12-06 22:02       ` Nasser Abbasi
  1 sibling, 1 reply; 16+ messages in thread
From: Dmitry A. Kazakov @ 2008-12-03 13:22 UTC (permalink / raw)


On Tue, 2 Dec 2008 22:18:05 -0600, R. B. Love wrote:

> Do you work on comission?  That's a $700 book.

Wow, and these are used books! No, I bought it long time ago in 80's, my
student times. Is it out of print? I cannot imagine that, the book a must
like Janke-Emde-Loesch and Abramowitz-Stegun.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Where I find Bessel function for Ada ?
  2008-12-03 13:22       ` Dmitry A. Kazakov
@ 2008-12-03 14:24         ` Hyman Rosen
  2008-12-03 14:54           ` Dmitry A. Kazakov
  0 siblings, 1 reply; 16+ messages in thread
From: Hyman Rosen @ 2008-12-03 14:24 UTC (permalink / raw)


Dmitry A. Kazakov wrote:
> On Tue, 2 Dec 2008 22:18:05 -0600, R. B. Love wrote:
>> Do you work on comission?  That's a $700 book.
> Wow, and these are used books! No, I bought it long time ago in 80's, my
> student times. Is it out of print? I cannot imagine that, the book a must
> like Janke-Emde-Loesch and Abramowitz-Stegun.

It's publication date is 1976, and it's out of print.

As to the price, read this article in the NY Times:
<http://papercuts.blogs.nytimes.com/2008/07/15/the-13109-perlstein-paperback/>

Online book dealers use pricing algorithms and software to
track prices and sell lots of "rare but not collectible"
books (in the words of the article) at extraordinarily high
prices. The cover price for this book was $44.



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

* Re: Where I find Bessel function for Ada ?
  2008-12-03 14:24         ` Hyman Rosen
@ 2008-12-03 14:54           ` Dmitry A. Kazakov
  0 siblings, 0 replies; 16+ messages in thread
From: Dmitry A. Kazakov @ 2008-12-03 14:54 UTC (permalink / raw)


On Wed, 03 Dec 2008 09:24:42 -0500, Hyman Rosen wrote:

> Dmitry A. Kazakov wrote:
>> On Tue, 2 Dec 2008 22:18:05 -0600, R. B. Love wrote:
>>> Do you work on comission?  That's a $700 book.
>> Wow, and these are used books! No, I bought it long time ago in 80's, my
>> student times. Is it out of print? I cannot imagine that, the book a must
>> like Janke-Emde-Loesch and Abramowitz-Stegun.
> 
> It's publication date is 1976, and it's out of print.
> 
> As to the price, read this article in the NY Times:
> <http://papercuts.blogs.nytimes.com/2008/07/15/the-13109-perlstein-paperback/>

Interesting.

IMO such important fundamental books should be made public.
 
> Online book dealers use pricing algorithms and software to
> track prices and sell lots of "rare but not collectible"
> books (in the words of the article) at extraordinarily high
> prices. The cover price for this book was $44.

A did a quick search, a used German edition is about 100 EUR

http://www.amazon.de/Mathematical-Functions-and-Their-Approximations/dp/0124599508

a used Russian one is just $12

http://www.alib.ru/bs.php4?uid=10010dbf3635e2cc97c468bcaf2a5f0c6d38

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Where I find Bessel function for Ada ?
  2008-12-03  4:18     ` R. B. Love
  2008-12-03 13:22       ` Dmitry A. Kazakov
@ 2008-12-06 22:02       ` Nasser Abbasi
  2008-12-06 22:37         ` Per Sandberg
  2008-12-19 12:39         ` Colin Paul Gloster
  1 sibling, 2 replies; 16+ messages in thread
From: Nasser Abbasi @ 2008-12-06 22:02 UTC (permalink / raw)



"R. B. Love" <rblove@airmail.net> wrote in message 
news:2008120222180516807-rblove@airmailnet...
> On 2008-11-26 06:57:09 -0600, "Dmitry A. Kazakov" 
> <mailbox@dmitry-kazakov.de> said:
>
>> Well, if there is no Ada code, then I would also consider to implement it
>> from scrap. There is an excellent book "Mathematical Functions and Their
>> Approximations" by Yudell L. Luke:
>>
....
>
> Do you work on comission?  That's a $700 book.
>

That is the problem with using Ada for scientific software.

The language is great for scientific software implementation, but it comes 
with limited number of related functions ready to use.

It is not practical for someone to implement these functions from scratch 
each time they want to use one in their scientific application. It takes a 
long time to develop robust mathematical functions.

Is it not possible to link to some C library which has the implementation of 
this function? I am sure there is some C code out there which does this. 
Write a binding to it?

Nasser





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

* Re: Where I find Bessel function for Ada ?
  2008-12-06 22:02       ` Nasser Abbasi
@ 2008-12-06 22:37         ` Per Sandberg
  2008-12-19 12:39         ` Colin Paul Gloster
  1 sibling, 0 replies; 16+ messages in thread
From: Per Sandberg @ 2008-12-06 22:37 UTC (permalink / raw)


Had to do a bit of looking around before saying anything but after some 
looking and a bit of hacking a may say this:
* The GSL library contains what you are looking for.
* It is fairly simple to write a medium level binding to that library, 
especially using GCC/GNAT.
I could post my small experiments if there is any interest.
/Per


Nasser Abbasi wrote:
> "R. B. Love" <rblove@airmail.net> wrote in message 
> news:2008120222180516807-rblove@airmailnet...
>> On 2008-11-26 06:57:09 -0600, "Dmitry A. Kazakov" 
>> <mailbox@dmitry-kazakov.de> said:
>>
>>> Well, if there is no Ada code, then I would also consider to implement it
>>> from scrap. There is an excellent book "Mathematical Functions and Their
>>> Approximations" by Yudell L. Luke:
>>>
> .....
>> Do you work on comission?  That's a $700 book.
>>
> 
> That is the problem with using Ada for scientific software.
> 
> The language is great for scientific software implementation, but it comes 
> with limited number of related functions ready to use.
> 
> It is not practical for someone to implement these functions from scratch 
> each time they want to use one in their scientific application. It takes a 
> long time to develop robust mathematical functions.
> 
> Is it not possible to link to some C library which has the implementation of 
> this function? I am sure there is some C code out there which does this. 
> Write a binding to it?
> 
> Nasser
> 
> 



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

* Re: Where I find Bessel function for Ada ?
  2008-12-06 22:02       ` Nasser Abbasi
  2008-12-06 22:37         ` Per Sandberg
@ 2008-12-19 12:39         ` Colin Paul Gloster
  2008-12-19 23:30           ` Jerry
  1 sibling, 1 reply; 16+ messages in thread
From: Colin Paul Gloster @ 2008-12-19 12:39 UTC (permalink / raw)


On Sat, 6 Dec 2008, Nasser Abbasi wrote:

|-----------------------------------------------------------------------------|
|"[..]                                                                        |
|> On 2008-11-26 06:57:09 -0600, "Dmitry A. Kazakov"                          |
|> <mailbox@dmitry-kazakov.de> said:                                          |
|>                                                                            |
|>> Well, if there is no Ada code, then I would also consider to implement it |
|>> from scrap. There is an excellent book "Mathematical Functions and Their  |
|>> Approximations" by Yudell L. Luke:                                        |
|>>                                                                           |
|....                                                                         |
|[..]                                                                         |
|                                                                             |
|That is the problem with using Ada for scientific software.                  |
|                                                                             |
|The language is great for scientific software implementation, but it comes   |
|with limited number of related functions ready to use.                       |
|                                                                             |
|It is not practical for someone to implement these functions from scratch    |
|each time they want to use one in their scientific application. It takes a   |
|long time to develop robust mathematical functions.                          |
|                                                                             |
|Is it not possible to link to some C library which has the implementation of |
|this function? I am sure there is some C code out there which does this.     |
|Write a binding to it?"                                                      |
|-----------------------------------------------------------------------------|

It is possible to link Ada code to code written in another
language. However widely used C and FORTRAN code from for example
"Numerical Recipes" is not robust, so to write robust scientific
software one would need to find a robust implementation. If a robust
implementation has not already been found, then writing it yourself is
not so much a drawback of Ada because you would need to do it anyway
no matter what language you would be using.

When using C or FORTRAN, which libraries have you found to be robust?
(I do not need to ask you which libraries have you used for
Mathematica; Maple; nor MATLAB. ;) )



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

* Re: Where I find Bessel function for Ada ?
  2008-12-19 12:39         ` Colin Paul Gloster
@ 2008-12-19 23:30           ` Jerry
  0 siblings, 0 replies; 16+ messages in thread
From: Jerry @ 2008-12-19 23:30 UTC (permalink / raw)


> |Is it not possible to link to some C library which has the implementation of |
> |this function? I am sure there is some C code out there which does this.     |
> |Write a binding to it?"                                                      |

Earlier in this thread I mentioned the GNU Scientific Library. Look at
my posting for November 26, 2008.

It would be great to have a concerted effort to port write Ada
bindings to that library. Check out the links in my original post for
efforts in that direction.

Jerry



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

end of thread, other threads:[~2008-12-19 23:30 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-26  8:40 Where I find Bessel function for Ada ? reinkor
2008-11-26 11:05 ` gautier_niouzes
2008-11-26 12:57   ` Dmitry A. Kazakov
2008-12-03  4:18     ` R. B. Love
2008-12-03 13:22       ` Dmitry A. Kazakov
2008-12-03 14:24         ` Hyman Rosen
2008-12-03 14:54           ` Dmitry A. Kazakov
2008-12-06 22:02       ` Nasser Abbasi
2008-12-06 22:37         ` Per Sandberg
2008-12-19 12:39         ` Colin Paul Gloster
2008-12-19 23:30           ` Jerry
2008-11-26 13:08   ` Paul Cole Gloster
2008-11-26 15:09     ` Ken Thomas
2008-11-26 16:12       ` Ludovic Brenta
2008-11-26 17:17         ` Dmitry A. Kazakov
2008-11-27  3:07 ` Jerry

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