[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] setting function of gsl_odeiv_system structure to a C++ class
From: |
Luke |
Subject: |
[Help-gsl] setting function of gsl_odeiv_system structure to a C++ class member function |
Date: |
Tue, 20 Apr 2010 10:09:18 -0700 |
I am trying to create a C++ class to organize the various functions I have
generated for my system. Here is my class definition:
class
Torus
{
private:
const gsl_odeiv_step_type *
T;
gsl_odeiv_step *
s;
gsl_odeiv_control *
c;
gsl_odeiv_evolve *
e;
gsl_odeiv_system sys;
public:
Torus();
~Torus();
int eoms(double t, const double x[8], double f[8], void *params);
};
Then, in the constructor, I have:
Torus::Torus()
{
t =
0.0;
T =
gsl_odeiv_step_rk8pd;
s = gsl_odeiv_step_alloc(T,
8);
c = gsl_odeiv_control_y_new(1e-6,
0.0);
e = gsl_odeiv_evolve_alloc(8);
// Can't get the following to work:
//sys = {eoms, NULL, 8, NULL}; // doesn't work
sys.function = &eoms; // doesn't work
sys.function = eoms; // doesn't work
sys.function = this.eoms; // doesn't work
sys.function = Torus::eoms; // doesn't work
sys.jacobian = NULL; // works
sys.dimension = 8; // works
sys.params= NULL; // works
}
right now, I just have a stub for my eoms function:
int Torus::eoms(double t, const double x[8], double f[8], void *params)
{
return GSL_SUCCESS;
}
Here are the errors I have receive when I try to compile (g++ -Wall -lgsl -c
torus.cpp):
With sys.function = &eoms; :
torus.cpp: In constructor ‘Torus::Torus()’:
torus.cpp:12: error: ISO C++ forbids taking the address of an unqualified or
parenthesized non-static member function to form a pointer to member
function. Say ‘&Torus::eoms’
torus.cpp:12: error: cannot convert ‘int (Torus::*)(double, const double*,
double*, void*)’ to ‘int (*)(double, const double*, double*, void*)’ in
assignment
With sys.function = eoms; :
torus.cpp: In constructor ‘Torus::Torus()’:
torus.cpp:12: error: argument of type ‘int (Torus::)(double, const double*,
double*, void*)’ does not match ‘int (*)(double, const double*, double*,
void*)’
With sys.function = this.eoms;
torus.cpp: In constructor ‘Torus::Torus()’:
torus.cpp:12: error: request for member ‘eoms’ in ‘this’, which is of
non-class type ‘Torus* const’
With sys.function = this->eoms;
torus.cpp: In constructor ‘Torus::Torus()’:
torus.cpp:12: error: argument of type ‘int (Torus::)(double, const double*,
double*, void*)’ does not match ‘int (*)(double, const double*, double*,
void*)’
With sys.function = &Torus::eoms;
torus.cpp: In constructor ‘Torus::Torus()’:
torus.cpp:12: error: cannot convert ‘int (Torus::*)(double, const double*,
double*, void*)’ to ‘int (*)(double, const double*, double*, void*)’ in
assignment
Is there something simple that I haven't tried to get this assignment to
work? Or is there a different way I should be doing it?
Thanks,
~Luke Peterson
- [Help-gsl] setting function of gsl_odeiv_system structure to a C++ class member function,
Luke <=
- Message not available
- Message not available
- Message not available
- Re: [Help-gsl] setting function of gsl_odeiv_system structure to a C++ class member function, Luke, 2010/04/20
- Message not available
- Re: [Help-gsl] setting function of gsl_odeiv_system structure to a C++ class member function, Luke, 2010/04/20
- Re: [Help-gsl] setting function of gsl_odeiv_system structure to a C++ class member function, Omar Andrés Zapata Mesa, 2010/04/20
- Message not available
- Re: [Help-gsl] setting function of gsl_odeiv_system structure to a C++ class member function, Luke, 2010/04/20
- Message not available
- Re: [Help-gsl] setting function of gsl_odeiv_system structure to a C++ class member function, Luke, 2010/04/20
- [Help-gsl] Re: setting function of gsl_odeiv_system structure to a C++ class member function, Rodney Sparapani, 2010/04/20
- Re: [Help-gsl] setting function of gsl_odeiv_system structure to a C++ class member function, Andrew W. Steiner, 2010/04/20