I get a compilatio error when trying to call the rk4 numerical recipes 3 function

13 Views Asked by At

in rk4.h numerical recipes 3), there is this function void rk4(VecDoub_I &y, VecDoub_I &dydx, const Doub x, const Doub h, VecDoub_O &yout, void derivs(const Doub, VecDoub_I &, VecDoub_O &)) {

To use it, I created a structure

struct dens_mat_BAP_I {
    const BAP_struct_I *param ;
    dens_mat_BAP_I (const BAP_struct_I *par) : param (par) {}
    void operator () (const Doub t, VecDoub_I &r, VecDoub_O &drdt) {
        const double Rabi = param -> Rabi_0 ;
        drdt [0] = -param -> Gamma_u * r [0] - 2. * Rabi * r [3] + param -> Lambda_u ;
        drdt [1] = -param -> Gamma_l * r [1] + 2. * Rabi * r [3] + param -> Lambda_l ;
        drdt [2] = -param -> Gamma_ul * r [2] - param -> Delta_ul * r [3] ;
        drdt [3] = Rabi * (r [0] - r [1]) ;
    }
} ;

in my program I set dens_mat_BAP_I dens_mat (param) ; I can call the function dens_mat (t, rho, drdt) ;

but how can I call rk4 ? rk4 (rho, drdt, t, dt, rout, dens_mat) ; does not work

error: cannot convert ‘dens_mat_BAP_I’ to ‘void ()(Doub, VecDoub_I&, VecDoub_O&)’ {aka ‘void ()(double, const NRvector&, NRvector&)’} 43 | rk4 (rho, drdt, t, dt, rout, dens_mat) ; | ^~~~~~~~ | | | dens_mat_BAP_I `` Thank

Compilation OK with gcc or g++

0

There are 0 best solutions below