Blame doc/usage.rst

Packit 67cb25
.. index::
Packit 67cb25
   single: standards conformance, ANSI C
Packit 67cb25
   single: ANSI C, use of
Packit 67cb25
   single: C extensions, compatible use of
Packit 67cb25
   single: compatibility
Packit 67cb25
Packit 67cb25
*****************
Packit 67cb25
Using the Library
Packit 67cb25
*****************
Packit 67cb25
Packit 67cb25
.. include:: include.rst
Packit 67cb25
Packit 67cb25
This chapter describes how to compile programs that use GSL, and
Packit 67cb25
introduces its conventions.  
Packit 67cb25
Packit 67cb25
An Example Program
Packit 67cb25
==================
Packit 67cb25
Packit 67cb25
The following short program demonstrates the use of the library by
Packit 67cb25
computing the value of the Bessel function :math:`J_0(x)` for :math:`x=5`:
Packit 67cb25
Packit 67cb25
.. include:: examples/intro.c
Packit 67cb25
   :code:
Packit 67cb25
Packit 67cb25
The output is shown below, and should be correct to double-precision
Packit 67cb25
accuracy [#f1]_,
Packit 67cb25
Packit 67cb25
.. include:: examples/intro.txt
Packit 67cb25
   :code:
Packit 67cb25
Packit 67cb25
The steps needed to compile this program are described
Packit 67cb25
in the following sections.
Packit 67cb25
Packit 67cb25
.. index::
Packit 67cb25
   single: compiling programs, include paths
Packit 67cb25
   single: including GSL header files
Packit 67cb25
   single: header files, including
Packit 67cb25
Packit 67cb25
Compiling and Linking
Packit 67cb25
=====================
Packit 67cb25
Packit 67cb25
The library header files are installed in their own :file:`gsl`
Packit 67cb25
directory.  You should write any preprocessor include statements with a
Packit 67cb25
:file:`gsl/` directory prefix thus::
Packit 67cb25
Packit 67cb25
    #include <gsl/gsl_math.h>
Packit 67cb25
Packit 67cb25
If the directory is not installed on the standard search path of your
Packit 67cb25
compiler you will also need to provide its location to the preprocessor
Packit 67cb25
as a command line flag.  The default location of the :file:`gsl`
Packit 67cb25
directory is :file:`/usr/local/include/gsl`.  A typical compilation
Packit 67cb25
command for a source file :file:`example.c` with the GNU C compiler
Packit 67cb25
:code:`gcc` is::
Packit 67cb25
Packit 67cb25
    $ gcc -Wall -I/usr/local/include -c example.c
Packit 67cb25
Packit 67cb25
This results in an object file :file:`example.o`. The default
Packit 67cb25
include path for :code:`gcc` searches :file:`/usr/local/include` automatically so
Packit 67cb25
the :code:`-I` option can actually be omitted when GSL is installed 
Packit 67cb25
in its default location.
Packit 67cb25
Packit 67cb25
.. index::
Packit 67cb25
   single: compiling programs, library paths
Packit 67cb25
   single: linking with GSL libraries
Packit 67cb25
   single: libraries, linking with
Packit 67cb25
Packit 67cb25
Linking programs with the library
Packit 67cb25
---------------------------------
Packit 67cb25
Packit 67cb25
The library is installed as a single file, :file:`libgsl.a`.  A shared
Packit 67cb25
version of the library :file:`libgsl.so` is also installed on systems
Packit 67cb25
that support shared libraries.  The default location of these files is
Packit 67cb25
:file:`/usr/local/lib`.  If this directory is not on the standard search
Packit 67cb25
path of your linker you will also need to provide its location as a
Packit 67cb25
command line flag.
Packit 67cb25
Packit 67cb25
To link against the library you need to specify
Packit 67cb25
both the main library and a supporting |cblas| library, which
Packit 67cb25
provides standard basic linear algebra subroutines.  A suitable
Packit 67cb25
|cblas| implementation is provided in the library
Packit 67cb25
:file:`libgslcblas.a` if your system does not provide one.  The following
Packit 67cb25
example shows how to link an application with the library::
Packit 67cb25
Packit 67cb25
    $ gcc -L/usr/local/lib example.o -lgsl -lgslcblas -lm
Packit 67cb25
Packit 67cb25
The default library path for :code:`gcc` searches :file:`/usr/local/lib`
Packit 67cb25
automatically so the :code:`-L` option can be omitted when GSL is
Packit 67cb25
installed in its default location.  
Packit 67cb25
Packit 67cb25
The option :code:`-lm` links with the system math library. On some
Packit 67cb25
systems it is not needed. [#f2]_
Packit 67cb25
Packit 67cb25
For a tutorial introduction to the GNU C Compiler and related programs,
Packit 67cb25
see "An Introduction to GCC" (ISBN 0954161793). [#f3]_
Packit 67cb25
Packit 67cb25
Linking with an alternative BLAS library
Packit 67cb25
----------------------------------------
Packit 67cb25
Packit 67cb25
The following command line shows how you would link the same application
Packit 67cb25
with an alternative |cblas| library :file:`libcblas.a`::
Packit 67cb25
Packit 67cb25
    $ gcc example.o -lgsl -lcblas -lm
Packit 67cb25
Packit 67cb25
For the best performance an optimized platform-specific |cblas|
Packit 67cb25
library should be used for :code:`-lcblas`.  The library must conform to
Packit 67cb25
the |cblas| standard.  The |atlas| package provides a portable
Packit 67cb25
high-performance |blas| library with a |cblas| interface.  It is
Packit 67cb25
free software and should be installed for any work requiring fast vector
Packit 67cb25
and matrix operations.  The following command line will link with the
Packit 67cb25
|atlas| library and its |cblas| interface::
Packit 67cb25
Packit 67cb25
    $ gcc example.o -lgsl -lcblas -latlas -lm
Packit 67cb25
Packit 67cb25
If the |atlas| library is installed in a non-standard directory use
Packit 67cb25
the :code:`-L` option to add it to the search path, as described above.  
Packit 67cb25
Packit 67cb25
For more information about |blas| functions see :ref:`chap_blas-support`.
Packit 67cb25
Packit 67cb25
.. index::
Packit 67cb25
   single: shared libraries
Packit 67cb25
   single: libraries, shared
Packit 67cb25
   single: LD_LIBRARY_PATH
Packit 67cb25
Packit 67cb25
Shared Libraries
Packit 67cb25
================
Packit 67cb25
Packit 67cb25
To run a program linked with the shared version of the library the
Packit 67cb25
operating system must be able to locate the corresponding :file:`.so`
Packit 67cb25
file at runtime.  If the library cannot be found, the following error
Packit 67cb25
will occur::
Packit 67cb25
Packit 67cb25
    $ ./a.out 
Packit 67cb25
    ./a.out: error while loading shared libraries: 
Packit 67cb25
    libgsl.so.0: cannot open shared object file: No such file or directory
Packit 67cb25
Packit 67cb25
To avoid this error, either modify the system dynamic linker
Packit 67cb25
configuration [#f4]_ or
Packit 67cb25
define the shell variable :code:`LD_LIBRARY_PATH` to include the
Packit 67cb25
directory where the library is installed.
Packit 67cb25
Packit 67cb25
For example, in the Bourne shell (:code:`/bin/sh` or :code:`/bin/bash`),
Packit 67cb25
the library search path can be set with the following commands::
Packit 67cb25
Packit 67cb25
    $ LD_LIBRARY_PATH=/usr/local/lib
Packit 67cb25
    $ export LD_LIBRARY_PATH
Packit 67cb25
    $ ./example
Packit 67cb25
Packit 67cb25
In the C-shell (:code:`/bin/csh` or :code:`/bin/tcsh`) the equivalent
Packit 67cb25
command is::
Packit 67cb25
Packit 67cb25
    % setenv LD_LIBRARY_PATH /usr/local/lib
Packit 67cb25
Packit 67cb25
The standard prompt for the C-shell in the example above is the percent
Packit 67cb25
character %, and should not be typed as part of the command.
Packit 67cb25
Packit 67cb25
To save retyping these commands each session they can be placed in an
Packit 67cb25
individual or system-wide login file.
Packit 67cb25
Packit 67cb25
To compile a statically linked version of the program, use the
Packit 67cb25
:code:`-static` flag in :code:`gcc`::
Packit 67cb25
Packit 67cb25
    $ gcc -static example.o -lgsl -lgslcblas -lm
Packit 67cb25
Packit 67cb25
ANSI C Compliance
Packit 67cb25
=================
Packit 67cb25
Packit 67cb25
The library is written in ANSI C and is intended to conform to the ANSI
Packit 67cb25
C standard (C89).  It should be portable to any system with a working
Packit 67cb25
ANSI C compiler.
Packit 67cb25
Packit 67cb25
The library does not rely on any non-ANSI extensions in the interface it
Packit 67cb25
exports to the user.  Programs you write using GSL can be ANSI
Packit 67cb25
compliant.  Extensions which can be used in a way compatible with pure
Packit 67cb25
ANSI C are supported, however, via conditional compilation.  This allows
Packit 67cb25
the library to take advantage of compiler extensions on those platforms
Packit 67cb25
which support them.
Packit 67cb25
Packit 67cb25
When an ANSI C feature is known to be broken on a particular system the
Packit 67cb25
library will exclude any related functions at compile-time.  This should
Packit 67cb25
make it impossible to link a program that would use these functions and
Packit 67cb25
give incorrect results.
Packit 67cb25
Packit 67cb25
To avoid namespace conflicts all exported function names and variables
Packit 67cb25
have the prefix :code:`gsl_`, while exported macros have the prefix
Packit 67cb25
:code:`GSL_`.
Packit 67cb25
Packit 67cb25
.. index::
Packit 67cb25
   single: inline functions
Packit 67cb25
   single: HAVE_INLINE
Packit 67cb25
   single: GSL_C99_INLINE
Packit 67cb25
   single: C99, inline keyword
Packit 67cb25
   single: extern inline
Packit 67cb25
Packit 67cb25
.. _sec_inline-functions:
Packit 67cb25
Packit 67cb25
Inline functions
Packit 67cb25
================
Packit 67cb25
Packit 67cb25
The :code:`inline` keyword is not part of the original ANSI C standard
Packit 67cb25
(C89) so the library does not export any inline function definitions
Packit 67cb25
by default.  Inline functions were introduced officially in the newer
Packit 67cb25
C99 standard but most C89 compilers have also included :code:`inline` as
Packit 67cb25
an extension for a long time.
Packit 67cb25
Packit 67cb25
To allow the use of inline functions, the library provides optional
Packit 67cb25
inline versions of performance-critical routines by conditional
Packit 67cb25
compilation in the exported header files.  The inline versions of these
Packit 67cb25
functions can be included by defining the macro :code:`HAVE_INLINE`
Packit 67cb25
when compiling an application::
Packit 67cb25
Packit 67cb25
    $ gcc -Wall -c -DHAVE_INLINE example.c
Packit 67cb25
Packit 67cb25
If you use :code:`autoconf` this macro can be defined automatically.  If
Packit 67cb25
you do not define the macro :code:`HAVE_INLINE` then the slower
Packit 67cb25
non-inlined versions of the functions will be used instead.
Packit 67cb25
Packit 67cb25
By default, the actual form of the inline keyword is :code:`extern
Packit 67cb25
inline`, which is a :code:`gcc` extension that eliminates unnecessary
Packit 67cb25
function definitions.  If the form :code:`extern inline` causes
Packit 67cb25
problems with other compilers a stricter autoconf test can be used,
Packit 67cb25
see :ref:`chap_autoconf-macros`.
Packit 67cb25
Packit 67cb25
When compiling with :code:`gcc` in C99 mode (:code:`gcc -std=c99`) the
Packit 67cb25
header files automatically switch to C99-compatible inline function
Packit 67cb25
declarations instead of :code:`extern inline`.  With other C99
Packit 67cb25
compilers, define the macro :code:`GSL_C99_INLINE` to use these
Packit 67cb25
declarations.
Packit 67cb25
Packit 67cb25
Long double
Packit 67cb25
===========
Packit 67cb25
.. index:
Packit 67cb25
   long double
Packit 67cb25
Packit 67cb25
In general, the algorithms in the library are written for double
Packit 67cb25
precision only.  The :code:`long double` type is not supported for
Packit 67cb25
actual computation.
Packit 67cb25
Packit 67cb25
One reason for this choice is that the precision of :code:`long double`
Packit 67cb25
is platform dependent.  The IEEE standard only specifies the minimum
Packit 67cb25
precision of extended precision numbers, while the precision of
Packit 67cb25
:code:`double` is the same on all platforms.
Packit 67cb25
Packit 67cb25
However, it is sometimes necessary to interact with external data in
Packit 67cb25
long-double format, so the vector and matrix datatypes include
Packit 67cb25
long-double versions.
Packit 67cb25
Packit 67cb25
It should be noted that in some system libraries the :code:`stdio.h`
Packit 67cb25
formatted input/output functions :code:`printf` and :code:`scanf` are
Packit 67cb25
not implemented correctly for :code:`long double`.  Undefined or
Packit 67cb25
incorrect results are avoided by testing these functions during the
Packit 67cb25
:code:`configure` stage of library compilation and eliminating certain
Packit 67cb25
GSL functions which depend on them if necessary.  The corresponding
Packit 67cb25
line in the :code:`configure` output looks like this::
Packit 67cb25
Packit 67cb25
    checking whether printf works with long double... no
Packit 67cb25
Packit 67cb25
Consequently when :code:`long double` formatted input/output does not
Packit 67cb25
work on a given system it should be impossible to link a program which
Packit 67cb25
uses GSL functions dependent on this.
Packit 67cb25
Packit 67cb25
If it is necessary to work on a system which does not support formatted
Packit 67cb25
:code:`long double` input/output then the options are to use binary
Packit 67cb25
formats or to convert :code:`long double` results into :code:`double` for
Packit 67cb25
reading and writing.
Packit 67cb25
Packit 67cb25
.. _portability-functions:
Packit 67cb25
Packit 67cb25
Portability functions
Packit 67cb25
=====================
Packit 67cb25
Packit 67cb25
To help in writing portable applications GSL provides some
Packit 67cb25
implementations of functions that are found in other libraries, such as
Packit 67cb25
the BSD math library.  You can write your application to use the native
Packit 67cb25
versions of these functions, and substitute the GSL versions via a
Packit 67cb25
preprocessor macro if they are unavailable on another platform. 
Packit 67cb25
Packit 67cb25
For example, after determining whether the BSD function :func:`hypot` is
Packit 67cb25
available you can include the following macro definitions in a file
Packit 67cb25
:file:`config.h` with your application::
Packit 67cb25
Packit 67cb25
    /* Substitute gsl_hypot for missing system hypot */
Packit 67cb25
Packit 67cb25
    #ifndef HAVE_HYPOT
Packit 67cb25
    #define hypot gsl_hypot
Packit 67cb25
    #endif
Packit 67cb25
Packit 67cb25
The application source files can then use the include command
Packit 67cb25
:code:`#include <config.h>` to replace each occurrence of :func:`hypot` by
Packit 67cb25
:func:`gsl_hypot` when :func:`hypot` is not available.  This substitution
Packit 67cb25
can be made automatically if you use :code:`autoconf`, see :ref:`chap_autoconf-macros`.
Packit 67cb25
Packit 67cb25
In most circumstances the best strategy is to use the native versions of
Packit 67cb25
these functions when available, and fall back to GSL versions otherwise,
Packit 67cb25
since this allows your application to take advantage of any
Packit 67cb25
platform-specific optimizations in the system library.  This is the
Packit 67cb25
strategy used within GSL itself.
Packit 67cb25
Packit 67cb25
.. index::
Packit 67cb25
   single: alternative optimized functions
Packit 67cb25
   single: optimized functions, alternatives
Packit 67cb25
Packit 67cb25
Alternative optimized functions
Packit 67cb25
===============================
Packit 67cb25
Packit 67cb25
The main implementation of some functions in the library will not be
Packit 67cb25
optimal on all architectures.  For example, there are several ways to
Packit 67cb25
compute a Gaussian random variate and their relative speeds are
Packit 67cb25
platform-dependent.  In cases like this the library provides alternative
Packit 67cb25
implementations of these functions with the same interface.  If you
Packit 67cb25
write your application using calls to the standard implementation you
Packit 67cb25
can select an alternative version later via a preprocessor definition.
Packit 67cb25
It is also possible to introduce your own optimized functions this way
Packit 67cb25
while retaining portability.  The following lines demonstrate the use of
Packit 67cb25
a platform-dependent choice of methods for sampling from the Gaussian
Packit 67cb25
distribution::
Packit 67cb25
Packit 67cb25
    #ifdef SPARC
Packit 67cb25
    #define gsl_ran_gaussian gsl_ran_gaussian_ratio_method
Packit 67cb25
    #endif
Packit 67cb25
    #ifdef INTEL
Packit 67cb25
    #define gsl_ran_gaussian my_gaussian
Packit 67cb25
    #endif
Packit 67cb25
Packit 67cb25
These lines would be placed in the configuration header file
Packit 67cb25
:file:`config.h` of the application, which should then be included by all
Packit 67cb25
the source files.  Note that the alternative implementations will not
Packit 67cb25
produce bit-for-bit identical results, and in the case of random number
Packit 67cb25
distributions will produce an entirely different stream of random
Packit 67cb25
variates.
Packit 67cb25
Packit 67cb25
Support for different numeric types
Packit 67cb25
===================================
Packit 67cb25
Packit 67cb25
Many functions in the library are defined for different numeric types.
Packit 67cb25
This feature is implemented by varying the name of the function with a
Packit 67cb25
type-related modifier---a primitive form of C++ templates.  The
Packit 67cb25
modifier is inserted into the function name after the initial module
Packit 67cb25
prefix.  The following table shows the function names defined for all
Packit 67cb25
the numeric types of an imaginary module :code:`gsl_foo` with function
Packit 67cb25
:func:`fn`::
Packit 67cb25
Packit 67cb25
    gsl_foo_fn               double        
Packit 67cb25
    gsl_foo_long_double_fn   long double   
Packit 67cb25
    gsl_foo_float_fn         float         
Packit 67cb25
    gsl_foo_long_fn          long          
Packit 67cb25
    gsl_foo_ulong_fn         unsigned long 
Packit 67cb25
    gsl_foo_int_fn           int           
Packit 67cb25
    gsl_foo_uint_fn          unsigned int  
Packit 67cb25
    gsl_foo_short_fn         short         
Packit 67cb25
    gsl_foo_ushort_fn        unsigned short
Packit 67cb25
    gsl_foo_char_fn          char          
Packit 67cb25
    gsl_foo_uchar_fn         unsigned char 
Packit 67cb25
Packit 67cb25
The normal numeric precision :code:`double` is considered the default and
Packit 67cb25
does not require a suffix.  For example, the function
Packit 67cb25
:func:`gsl_stats_mean` computes the mean of double precision numbers,
Packit 67cb25
while the function :func:`gsl_stats_int_mean` computes the mean of
Packit 67cb25
integers.
Packit 67cb25
Packit 67cb25
A corresponding scheme is used for library defined types, such as
Packit 67cb25
:code:`gsl_vector` and :code:`gsl_matrix`.  In this case the modifier is
Packit 67cb25
appended to the type name.  For example, if a module defines a new
Packit 67cb25
type-dependent struct or typedef :code:`gsl_foo` it is modified for other
Packit 67cb25
types in the following way::
Packit 67cb25
Packit 67cb25
    gsl_foo                  double        
Packit 67cb25
    gsl_foo_long_double      long double   
Packit 67cb25
    gsl_foo_float            float         
Packit 67cb25
    gsl_foo_long             long          
Packit 67cb25
    gsl_foo_ulong            unsigned long 
Packit 67cb25
    gsl_foo_int              int           
Packit 67cb25
    gsl_foo_uint             unsigned int  
Packit 67cb25
    gsl_foo_short            short         
Packit 67cb25
    gsl_foo_ushort           unsigned short
Packit 67cb25
    gsl_foo_char             char          
Packit 67cb25
    gsl_foo_uchar            unsigned char 
Packit 67cb25
Packit 67cb25
When a module contains type-dependent definitions the library provides
Packit 67cb25
individual header files for each type.  The filenames are modified as
Packit 67cb25
shown in the below.  For convenience the default header includes the
Packit 67cb25
definitions for all the types.  To include only the double precision
Packit 67cb25
header file, or any other specific type, use its individual filename::
Packit 67cb25
Packit 67cb25
    #include <gsl/gsl_foo.h>               All types
Packit 67cb25
    #include <gsl/gsl_foo_double.h>        double        
Packit 67cb25
    #include <gsl/gsl_foo_long_double.h>   long double   
Packit 67cb25
    #include <gsl/gsl_foo_float.h>         float         
Packit 67cb25
    #include <gsl/gsl_foo_long.h>          long          
Packit 67cb25
    #include <gsl/gsl_foo_ulong.h>         unsigned long 
Packit 67cb25
    #include <gsl/gsl_foo_int.h>           int           
Packit 67cb25
    #include <gsl/gsl_foo_uint.h>          unsigned int  
Packit 67cb25
    #include <gsl/gsl_foo_short.h>         short         
Packit 67cb25
    #include <gsl/gsl_foo_ushort.h>        unsigned short
Packit 67cb25
    #include <gsl/gsl_foo_char.h>          char          
Packit 67cb25
    #include <gsl/gsl_foo_uchar.h>         unsigned char 
Packit 67cb25
Packit 67cb25
.. index::
Packit 67cb25
   single: C++, compatibility
Packit 67cb25
   single: exceptions, C++
Packit 67cb25
Packit 67cb25
Compatibility with C++
Packit 67cb25
======================
Packit 67cb25
Packit 67cb25
The library header files automatically define functions to have
Packit 67cb25
:code:`extern "C"` linkage when included in C++ programs.  This allows
Packit 67cb25
the functions to be called directly from C++.
Packit 67cb25
Packit 67cb25
To use C++ exception handling within user-defined functions passed to
Packit 67cb25
the library as parameters, the library must be built with the
Packit 67cb25
additional :code:`CFLAGS` compilation option :code:`-fexceptions`.
Packit 67cb25
Packit 67cb25
.. index:: aliasing of arrays
Packit 67cb25
Packit 67cb25
.. _aliasing-of-arrays:
Packit 67cb25
Packit 67cb25
Aliasing of arrays
Packit 67cb25
==================
Packit 67cb25
Packit 67cb25
The library assumes that arrays, vectors and matrices passed as
Packit 67cb25
modifiable arguments are not aliased and do not overlap with each other.
Packit 67cb25
This removes the need for the library to handle overlapping memory
Packit 67cb25
regions as a special case, and allows additional optimizations to be
Packit 67cb25
used.  If overlapping memory regions are passed as modifiable arguments
Packit 67cb25
then the results of such functions will be undefined.  If the arguments
Packit 67cb25
will not be modified (for example, if a function prototype declares them
Packit 67cb25
as :code:`const` arguments) then overlapping or aliased memory regions
Packit 67cb25
can be safely used.
Packit 67cb25
Packit 67cb25
Thread-safety
Packit 67cb25
=============
Packit 67cb25
Packit 67cb25
The library can be used in multi-threaded programs.  All the functions
Packit 67cb25
are thread-safe, in the sense that they do not use static variables.
Packit 67cb25
Memory is always associated with objects and not with functions.  For
Packit 67cb25
functions which use *workspace* objects as temporary storage the
Packit 67cb25
workspaces should be allocated on a per-thread basis.  For functions
Packit 67cb25
which use *table* objects as read-only memory the tables can be used
Packit 67cb25
by multiple threads simultaneously.  Table arguments are always declared
Packit 67cb25
:code:`const` in function prototypes, to indicate that they may be
Packit 67cb25
safely accessed by different threads.
Packit 67cb25
Packit 67cb25
There are a small number of static global variables which are used to
Packit 67cb25
control the overall behavior of the library (e.g. whether to use
Packit 67cb25
range-checking, the function to call on fatal error, etc).  These
Packit 67cb25
variables are set directly by the user, so they should be initialized
Packit 67cb25
once at program startup and not modified by different threads.
Packit 67cb25
Packit 67cb25
.. index:: deprecated functions
Packit 67cb25
Packit 67cb25
Deprecated Functions
Packit 67cb25
====================
Packit 67cb25
Packit 67cb25
From time to time, it may be necessary for the definitions of some
Packit 67cb25
functions to be altered or removed from the library.  In these
Packit 67cb25
circumstances the functions will first be declared *deprecated* and
Packit 67cb25
then removed from subsequent versions of the library.  Functions that
Packit 67cb25
are deprecated can be disabled in the current release by setting the
Packit 67cb25
preprocessor definition :code:`GSL_DISABLE_DEPRECATED`.  This allows
Packit 67cb25
existing code to be tested for forwards compatibility.
Packit 67cb25
Packit 67cb25
.. index::
Packit 67cb25
   single: code reuse in applications
Packit 67cb25
   single: source code, reuse in applications
Packit 67cb25
Packit 67cb25
Code Reuse
Packit 67cb25
==========
Packit 67cb25
Packit 67cb25
Where possible the routines in the library have been written to avoid
Packit 67cb25
dependencies between modules and files.  This should make it possible to
Packit 67cb25
extract individual functions for use in your own applications, without
Packit 67cb25
needing to have the whole library installed.  You may need to define
Packit 67cb25
certain macros such as :code:`GSL_ERROR` and remove some :code:`#include`
Packit 67cb25
statements in order to compile the files as standalone units. Reuse of
Packit 67cb25
the library code in this way is encouraged, subject to the terms of the
Packit 67cb25
GNU General Public License.
Packit 67cb25
Packit 67cb25
.. rubric:: Footnotes
Packit 67cb25
Packit 67cb25
.. [#f1] The last few digits may vary slightly depending on the compiler and platform used---this is normal
Packit 67cb25
.. [#f2] It is not needed on MacOS X
Packit 67cb25
.. [#f3] http://www.network-theory.co.uk/gcc/intro/
Packit 67cb25
.. [#f4] :file:`/etc/ld.so.conf` on GNU/Linux systems