[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] C++ interface/wrapper for gsl
From: |
John D Lamb |
Subject: |
Re: [Help-gsl] C++ interface/wrapper for gsl |
Date: |
Tue, 27 Apr 2010 06:21:35 +0100 |
I have some C++ wrappers I use. I could publish them if anyone is
interested in using them.
Essentially I’m not interested in changing GSL. I just want to take
advantage of some features of C++:
1. Objects can be created as shared-pointer-like handles (avoiding
new/delete/malloc/free) and runtime problems.
2. Objects can be stored in STL containers. For example, I sometimes
create a std::list<ccgsl::vector> object that stores a list of GSL
vectors.
3. Occasionally it’s useful to treat GSL vectors as STL containers. For
example std::copy( vector.begin(), vector.end(),
std::ostream_iterator<double>( std::cout, " " ) copies a vector to
standard output.
4. I want the option to use C++ exception handling instead of GSL error
handling.
I’ve wrappers for a few classes. For example, the vector class provides
a handle, adds all the STL container properties, and provides all the
standard GSL vector functions. Typically I would use, for example,
vector.set( i, value ) instead of gsl_vector_set( vector, i, value).
I put everything in a header file so that I don’t add additional
libraries and don’t slow GSL unnecessarily — all the member functions
are inline so that the compiler can replace them with the same code it
would create from GSL. I generate most of the header file by running a
Ruby script on the GSL header file.
I haven’t added, for example, vector addition through operator
overloading.
On Mon, 2010-04-26 at 09:38 -0400, Forest Yang wrote:
> Can you say more about why you need a C++ wrapper ?
> I have been using C++ and happy with linking to original GSL, no extra
> work needed at all (maybe some in the OO design part).
>
> > I would like to know if there is an up-to-date free (i.e. GPLed) C++
> > interface to (most of) GSL.
--
JDL