Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#592 How to pull special functions from a shared library

None
closed-out-of-date
Ethan Merritt
None
5
2014-03-03
2012-08-14
Ethan Merritt
No

This patchset is a proof-of-principle demonstration of detecting special functions (the Airy function in this case) in an external shared library at configuration time. I used -libgsl (the gnu scientific library) because it is easily available on linux systems. If you have libgsl.so installed then running ./configure will set the flag HAVE_GSL, which in turn controls compilation of new table entries in eval.c and wrapper code in new files bessel.c and bessel.h. The wrapper routines in src/bessel.c are called from gnuplot as
Bessel_J0(x) Bessel_J1(x) Bessel_Y0(x) Bessel_Y1(x) Bessel_Jn(x) Bessel_Yn(x)
Airy(x), LambertW(x)
zeta(x) zetai(x)
Note that for the purpose of demonstration the functions pulled from gsl have distinct names from the existing gnuplot functions besj0(), airy(), etc. This allows you to compare the two versions directly as in the attached PDF files.

The immediate motivation for this trial was an observation by Alex van der Spek that the Airy Ai function currently in gnuplot's specfun.c has low precision (up to 2% relative error). You can see this in the comparison plot airy.pdf. The other functions I tried have comparable precision in the gnuplot and libgsl versions. It is worth noting that libgsl provides many functions not currently in gnuplot. This is illustrated by wrappers for the Riemann zeta function.

The use of libgsl in particular has a number of disadvantages, so if there is interest in this approach I think it would be better to aim for linking to some other library. Alex suggested netlib ( http://www.netlib.org/ ). This looks like it would be a better choice except for the fact that it isn't currently packaged for the common linux repositories. Can anyone offer other suggestions?

Discussion

  • Ethan Merritt
    Ethan Merritt
    2012-08-14

    relative error in Airy function

     
    Attachments
  • Ethan Merritt
    Ethan Merritt
    2012-08-14

    relative error in Bessel function Y0

     
    Attachments
  • Ethan Merritt
    Ethan Merritt
    2013-03-27

    • assigned_to: Ethan Merritt
    • milestone: -->
     
  • Ethan Merritt
    Ethan Merritt
    2014-03-03

    Superseded by
    libcerf.c (example of supporting a specific foreign library)
    plugin.dem (example of run-time import from a foreign library)

     
  • Ethan Merritt
    Ethan Merritt
    2014-03-03

    • status: open --> closed-out-of-date