fgsl: single precision float version of gsl

Many of GSL (GNU Scientific Library)’s routines are implemented in double only.  When one needs the additional speed and storage advantage, there wasn’t a quick way to go to float.  Here is a quick hack:

  1. cd gsl-1.15,  edit configure.ac, change
    AC_INIT([gsl],[1.15])
    to
    AC_INIT([fgsl],[1.15])
    Optionally, add an optimization line to make it look like this:
    AC_LANG(C)
    AC_PROG_CC
    AC_PROG_CPP
    CFLAGS="-O3 -mtune=native"
  2. Then, run
    autoconf
    ./configure

    (or, to install to non-default location, ./configure --prefix=/home/me/local)
  3. Now run this cmd to do search and replace
    find . -type f -print0 | xargs -0 perl -pi -e 's/long double/LONG-DOUBLE/g;s/_double/_DOUbLE/g;s/double/float/g;s/_DOUbLE/_double/g;s/LONG-DOUBLE/long double/g;s/libgsl/libfgsl/g;s|<gsl/|<fgsl/|g'
  4. Now you can make and install as normal
    make
    make install

To use it, instead of
#include <gsl/blah.h> 
use:
#include <fgsl/blah.h>

When linking, instead of link with:
-lgsl
or
libgsl.a
use:
-lfgsl
or
libfgsl.a

This entry was posted in programming and tagged , , . Bookmark the permalink.

One Response to fgsl: single precision float version of gsl

Leave a Reply

Your email address will not be published. Required fields are marked *