Monday, May 21, 2012

Static Virtual workaround in GSL

Hello I am trying to write a small program to simulate dynamical systems using the differential equation package from the GNU Scientific Library. The problem is not specific to the GSL but I am just giving you all the details



In the current design I want to have an abstract Experiment class, where all the complex functions will be called by the gsl library. The dynamics of the explicit system will be defined by two functions, i.e., func and jacob, that define the specific motion equations and the jacobian respectively. Thus, I want to do all the simulation in the Experiment class and only override the two virtual functions with the specific class which will be inherited by the Experiment.



The problem I have is that as virtual these methods do not compile



error: argument of type 'int (Experiment::)(double, const double*, double*, void*)' does not match 'int (*)(double, const double*, double*, void*)'



If I make these two functions static the program compiles but I am losing the functionality that I want to achieve for specific problems.



Apparently, they cannot be both static and virtual, so does anyone know any workaround to this problem? Are there any suggestions to better approach it?



Thanks in advance.





No comments:

Post a Comment