Read Me
Your are probably reading this because you want to know what the ccgsl package is
and how you should go about installing it.
First, the ccgsl package is a set of C++ wrappers for many of the functions and
structs of the GNU Scientific Library (http://www.gnu.org/software/gsl/). To use
it you must also install the GNU Scientific Library (GSL). The package is not an
object-oriented version of the GSL. Rather, it provides some features that are
often used in C++ but not available in the C code that GSL uses. First, it avoids
allocating and freeing structs such as gsl_vector and gsl_rng by reïmplementing
them as classes that can be used as if they were automatic variables. The main
effect of this is that, for example, instead of
gsl_vector* v = gsl_vector_alloc( n );
/* lots of code using v */
gsl_vector_free( v );
you can use
gsl::vector v;
/* lots of code using v */
because the memory allocated for v is automatically freed when v goes out of
scope and no other vector is sharing it. Internally, the classes behave like
boost (http://www.boost.org/) shared pointers, but object-creation is simpler.
Second, ccgsl provides easier interaction with the Standard Template Library
(STL). The classes it provides are designed so that, for example,
std::list<gsl::vector> v;
works efficiently. Two sets of classes, gsl::block* and gsl::vector* are also
set up as STL containers. This means that you can use STL algorithms with them.
So, for example, for a gsl::vector object v, algorithms like the following work.
std::sort( v.begin(), v.end() );
std::copy( v.begin(), v.end(), std::ostream_iterator<double>( std::cout, " " ) );
Third, ccgsl optionally lets you use C++ exception handling by using the
gsl::exception class to turn GSL errors into exceptions. This lets you use, for
example, the simpler form of most gsl::sf functions within a try block rather than
use the only method available in C: call a function returning an integer that
indicates an error value and pass the function value back through a pointer to a
double.
Since you only need the .hpp header files of the ccgsl package to us it, you can,
if you like, just copy these to a convenient location such as
/usr/local/include/ccgsl. The ccgsl package also includes a standard GNU build
system, which will install the header files for you. It can also build some test
programmes and doxygen documentation. Here is a typical install from the
ccgsl-*.tar.gz file. The INSTALL file gives more detail.
$ tar zcvf ccgsl-*.tar.gz
$ cd ccgsl-*
$ ./bootstrap
$ ./configure
$ sudo make install
You can also build documentation if you have doxygen
(http://www.stack.nl/~dimitri/doxygen/) installed and some test programmes using:
$ make doc
$ make check
The test programmes contain some examples of how to use ccgsl. Note that
$ make
on its own does nothing because there is nothing to make. You can build the
documentation and test programmes in a directory other than the source
directory.
Using ccgsl should be straightforward. Most functions look and behave very much
like the GSL equivalents. So the GSL documentation should be enough for most
purposes. The ccgsl documentation gives a little more information on individual
classes and functions. Typically, instead of using a GSL header you use as ccgsl
one. Then you compile and link exactly as if you were compiling and linking
with GSL in C++.