Question

I want to enhance the gsl-functions (e.g. gls_vector) by overloading several operators. My idea was to create a new class in a separate namespace:

namespace gsl
{
    class gsl_vector : public gsl_vector
    {

    };
}

Now my problem is that I need a constructor. The original gsl_vector doesn't have such a constructor because it is completely written in C (according to http://www.boost.org/doc/libs/1_53_0/libs/numeric/odeint/doc/html/boost_numeric_odeint/odeint_in_detail/state_types__algebras_and_operations.html#boost_numeric_odeint.odeint_in_detail.state_types__algebras_and_operations.construction_resizing). So, how can I write a suitable constructor for this operation, or is my idea not possible?
Thank you!

Was it helpful?

Solution

I think it is not a good idea to deriv a new type from gsl_vector. It adds more problems then it helps. One point is that gsl_vector is a C-struct. You can not easily get an instance of it, because one usually needs to call gsl_vector_alloc. Another point is, that you can not use your new vector as an replacement for the other gsl functions. They are purely written in C and you can not pass pointers of derived classes.

Nevertheless, if you really need to build this kind of vector you need to look at the code of gsl_vector_alloc and gsl_vector_free to create the constructors and destructor.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top