20#ifndef CCGSL_ODEIV2_HPP
21#define CCGSL_ODEIV2_HPP
43 typedef gsl_odeiv2_step_type
type;
61 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
74 explicit step( gsl_odeiv2_step* v ){
111#ifdef __GXX_EXPERIMENTAL_CXX0X__
117 std::swap(
count, v.count );
118 v.ccgsl_pointer =
nullptr;
126 step( std::move( v ) ).swap( *
this );
236#ifdef __GXX_EXPERIMENTAL_CXX0X__
246 int reset(){
return gsl_odeiv2_step_reset(
get() ); }
251 char const*
name()
const {
return gsl_odeiv2_step_name(
get() ); }
256 unsigned int order(){
return gsl_odeiv2_step_order(
get() ); }
269 int apply(
double t,
double h,
double y[],
double yerr[],
double const dydt_in[],
270 double dydt_out[],
system const* sys ){
271 return gsl_odeiv2_step_apply(
get(), t, h, y, yerr, dydt_in, dydt_out, sys ); }
286 template<
typename Y,
typename YERR>
287 int apply(
double t,
double h, Y& y, YERR& yerr,
double const dydt_in[],
288 double dydt_out[], system
const* sys ){
289 return gsl_odeiv2_step_apply(
get(), t, h, y.data(), yerr.data(),
290 dydt_in, dydt_out, sys ); }
303 template<
typename Y,
typename YERR,
typename DYDT_IN>
304 int apply(
double t,
double h, Y& y, YERR& yerr, DYDT_IN
const& dydt_in,
305 double dydt_out[], system
const* sys ){
306 return gsl_odeiv2_step_apply(
get(), t, h, y.data(), yerr.data(),
307 dydt_in.data(), dydt_out, sys ); }
320 template<
typename Y,
typename YERR,
typename DYDT_OUT>
321 int apply(
double t,
double h, Y& y, YERR& yerr,
double const dydt_in[],
322 DYDT_OUT& dydt_out, system
const& sys ){
323 return gsl_odeiv2_step_apply(
get(), t, h, y.data, yerr.data,
324 dydt_in, dydt_out.data(), &sys ); }
338 template<
typename Y,
typename YERR,
typename DYDT_IN,
typename DYDT_OUT>
339 int apply(
double t,
double h, Y& y, YERR& yerr, DYDT_IN
const& dydt_in,
340 DYDT_OUT dydt_out,
system const& sys ){
341 return gsl_odeiv2_step_apply(
get(), t, h, y.data(), yerr.data(),
342 dydt_in.data(), dydt_out.data(), &sys ); }
355 inline static type const*
rk2(){
return gsl_odeiv2_step_rk2; }
360 inline static type const*
rk4(){
return gsl_odeiv2_step_rk4; }
365 inline static type const*
rkf45(){
return gsl_odeiv2_step_rkf45; }
370 inline static type const*
rkck(){
return gsl_odeiv2_step_rkck; }
375 inline static type const*
rk8pd(){
return gsl_odeiv2_step_rk8pd; }
380 inline static type const*
rk2imp(){
return gsl_odeiv2_step_rk2imp; }
385 inline static type const*
rk4imp(){
return gsl_odeiv2_step_rk4imp; }
390 inline static type const*
bsimp(){
return gsl_odeiv2_step_bsimp; }
395 inline static type const*
rk1imp(){
return gsl_odeiv2_step_rk1imp; }
400 inline static type const*
msadams(){
return gsl_odeiv2_step_msadams; }
405 inline static type const*
msbdf(){
return gsl_odeiv2_step_msbdf; }
416 typedef gsl_odeiv2_control_type
type;
434 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
484#ifdef __GXX_EXPERIMENTAL_CXX0X__
490 std::swap(
count, v.count );
491 v.ccgsl_pointer =
nullptr;
499 control( std::move( v ) ).swap( *
this );
609#ifdef __GXX_EXPERIMENTAL_CXX0X__
623 int init(
double eps_abs,
double eps_rel,
double a_y,
double a_dydt ){
624 return gsl_odeiv2_control_init(
get(), eps_abs, eps_rel, a_y, a_dydt ); }
637 double const dydt[],
double* h ){
638 return gsl_odeiv2_control_hadjust(
get(), s.
get(), y, yerr, dydt, h ); }
650 template<
typename Y,
typename YERR,
typename DYDT>
651 int hadjust(
step& s, Y
const& y, YERR
const& yerr, DYDT
const& dydt,
double& h ){
652 return gsl_odeiv2_control_hadjust(
get(), s.
get(), y.data(), yerr.data(), dydt.data(),
659 char const*
name()
const {
return gsl_odeiv2_control_name(
get() ); }
671 int errlevel(
double const y,
double const dydt,
double const h,
672 size_t const ind,
double* errlev ){
673 return gsl_odeiv2_control_errlevel(
get(), y, dydt, h, ind, errlev ); }
684 int errlevel( double const y, double const dydt, double const h,
685 size_t const ind,
double& errlev ){
686 return gsl_odeiv2_control_errlevel(
get(), y, dydt, h, ind, &errlev ); }
705 double a_y,
double a_dydt ){
706 return control( gsl_odeiv2_control_standard_new( eps_abs, eps_rel, a_y, a_dydt ) ); }
715 return control( gsl_odeiv2_control_y_new( eps_abs, eps_rel ) ); }
724 return control( gsl_odeiv2_control_yp_new( eps_abs, eps_rel ) ); }
738 double a_dydt,
double const scale_abs[],
size_t dim ){
739 return control( gsl_odeiv2_control_scaled_new( eps_abs, eps_rel, a_y, a_dydt,
740 scale_abs, dim ) ); }
753 template<typename SCALE_ABS>
755 double a_dydt, SCALE_ABS
const& scale_abs ){
756 return control( gsl_odeiv2_control_scaled_new( eps_abs, eps_rel, a_y, a_dydt,
757 scale_abs.data(), scale_abs.size() ) ); }
781 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
831#ifdef __GXX_EXPERIMENTAL_CXX0X__
837 std::swap(
count, v.count );
838 v.ccgsl_pointer =
nullptr;
846 evolve( std::move( v ) ).swap( *
this );
956#ifdef __GXX_EXPERIMENTAL_CXX0X__
976 double* t,
double t1,
double* h,
double y[] ){
977 return gsl_odeiv2_evolve_apply(
get(), con.
get(),
step.
get(), dydt,
995 double& t,
double t1,
double& h, Y& y ){
996 return gsl_odeiv2_evolve_apply(
get(), con.
get(),
step.
get(), &dydt,
997 &t, t1, &h, y.data() ); }
1011 double* t,
double const h0,
double y[] ){
1012 return gsl_odeiv2_evolve_apply_fixed_step(
get(), con.
get(),
step.
get(), dydt,
1027 template<typename Y>
1029 double& t,
double const h0, Y& y ){
1030 return gsl_odeiv2_evolve_apply_fixed_step(
get(), con.
get(),
step.
get(), &dydt,
1031 &t, h0, y.data() ); }
1037 int reset(){
return gsl_odeiv2_evolve_reset(
get() ); }
1105#ifdef __GXX_EXPERIMENTAL_CXX0X__
1111 std::swap(
count, v.count );
1112 v.ccgsl_pointer =
nullptr;
1120 driver( std::move( v ) ).swap( *
this );
1230#ifdef __GXX_EXPERIMENTAL_CXX0X__
1247 double const hstart,
double const epsabs,
double const epsrel ){
1248 return driver( gsl_odeiv2_driver_alloc_y_new( sys, T, hstart, epsabs, epsrel ) ); }
1261 double const hstart,
double const epsabs,
double const epsrel ){
1262 return driver( gsl_odeiv2_driver_alloc_yp_new( sys, T, hstart, epsabs, epsrel ) ); }
1279 double const epsabs,
1280 double const epsrel,
double const a_y,
double const a_dydt,
1281 double const scale_abs[] ){
1282 return driver( gsl_odeiv2_driver_alloc_scaled_new( &sys, T, hstart, epsabs, epsrel,
1283 a_y, a_dydt, scale_abs ) ); }
1299 template<typename SCALE_ABS>
1302 double const epsabs,
1303 double const epsrel,
double const a_y,
double const a_dydt,
1304 SCALE_ABS
const& scale_abs ){
1305 return driver( gsl_odeiv2_driver_alloc_scaled_new( &sys, T, hstart, epsabs, epsrel,
1306 a_y, a_dydt, scale_abs.data() ) ); }
1321 double const epsabs,
1322 double const epsrel,
double const a_y,
double const a_dydt ){
1323 return driver( gsl_odeiv2_driver_alloc_standard_new( &sys, T, hstart, epsabs,
1324 epsrel, a_y, a_dydt ) ); }
1331 int set_hmin(
double const hmin ){
return gsl_odeiv2_driver_set_hmin(
get(), hmin ); }
1338 int set_hmax(
double const hmax ){
return gsl_odeiv2_driver_set_hmax(
get(), hmax ); }
1346 return gsl_odeiv2_driver_set_nmax(
get(), nmax ); }
1356 int apply(
double* t,
double const t1,
double y[] ){
1357 return gsl_odeiv2_driver_apply(
get(), t, t1, y ); }
1368 template<typename Y>
1369 int apply(
double& t,
double const t1, Y& y ){
1370 return gsl_odeiv2_driver_apply(
get(), &t, t1, y.data() ); }
1381 int apply_fixed_step(
double* t,
double const h,
unsigned long int const n,
double y[] ){
1382 return gsl_odeiv2_driver_apply_fixed_step(
get(), t, h,
n, y ); }
1394 template<typename Y>
1396 return gsl_odeiv2_driver_apply_fixed_step(
get(), &t, h,
n, y.data() ); }
1402 int reset(){
return gsl_odeiv2_driver_reset(
get() ); }
1407 return gsl_odeiv2_step_set_driver(
get(), d.
get() ); }
1409 return gsl_odeiv2_control_set_driver(
get(), d.
get() ); }
1411 return gsl_odeiv2_evolve_set_driver(
get(), d.
get() ); }
Adaptive step size control.
static control standard_new(double eps_abs, double eps_rel, double a_y, double a_dydt)
C++ version of gsl_odeiv2_control_standard_new().
bool operator!=(control const &v) const
Two control are different if their elements are not identical.
gsl_odeiv2_control * ccgsl_pointer
The shared pointer.
static control scaled_new(double eps_abs, double eps_rel, double a_y, double a_dydt, SCALE_ABS const &scale_abs)
C++ version of gsl_odeiv2_control_scaled_new().
bool operator<=(control const &v) const
A container needs to define an ordering for sorting.
int init(double eps_abs, double eps_rel, double a_y, double a_dydt)
C++ version of gsl_odeiv2_control_init().
bool operator==(control const &v) const
Two control are identically equal if their elements are identical.
~control()
The destructor only deletes the pointers if count reaches zero.
void swap(control &v)
Swap two control objects.
size_t * count
The shared reference count.
int errlevel(double const y, double const dydt, double const h, size_t const ind, double &errlev)
C++ version of gsl_odeiv2_control_errlevel().
control & operator=(control &&v)
Move operator.
gsl_odeiv2_control * get() const
Get the gsl_odeiv2_control.
int hadjust(step &s, double const y[], double const yerr[], double const dydt[], double *h)
C++ version of gsl_odeiv2_control_hadjust().
static control yp_new(double eps_abs, double eps_rel)
C++ version of gsl_odeiv2_control_yp_new().
static control y_new(double eps_abs, double eps_rel)
C++ version of gsl_odeiv2_control_y_new().
bool operator<(control const &v) const
A container needs to define an ordering for sorting.
bool empty() const
Find if the control is empty.
size_t use_count() const
Find how many control objects share this pointer.
control(control &&v)
Move constructor.
control(control const &v)
The copy constructor.
bool unique() const
Find if this is the only object sharing the gsl_odeiv2_control.
int set_driver(driver const &d)
C++ version of gsl_odeiv2_control_set_driver().
control(gsl_odeiv2_control *v)
Could construct from a gsl_odeiv2_control.
bool operator>(control const &v) const
A container needs to define an ordering for sorting.
control & operator=(control const &v)
The assignment operator.
bool operator>=(control const &v) const
A container needs to define an ordering for sorting.
char const * name() const
C++ version of gsl_odeiv2_control_name().
gsl_odeiv2_control_type type
Convenience typedef.
control(type const *T)
The constructor creates a new control of type T.
control()
The default constructor is only really useful for assigning to.
int hadjust(step &s, Y const &y, YERR const &yerr, DYDT const &dydt, double &h)
C++ version of gsl_odeiv2_control_hadjust().
gsl_odeiv2_driver * ccgsl_pointer
The shared pointer.
int set_nmax(unsigned long int const nmax)
C++ version of gsl_odeiv2_driver_set_nmax().
static driver yp_new(system const *sys, step::type const *T, double const hstart, double const epsabs, double const epsrel)
C++ version of gsl_odeiv2_driver_alloc_yp_new().
gsl_odeiv2_driver * get() const
Get the gsl_odeiv2_driver.
static driver scaled_new(system const &sys, step::type const *T, double const hstart, double const epsabs, double const epsrel, double const a_y, double const a_dydt, SCALE_ABS const &scale_abs)
C++ version of gsl_odeiv2_driver_alloc_scaled_new().
bool operator>(driver const &v) const
A container needs to define an ordering for sorting.
~driver()
The destructor only deletes the pointers if count reaches zero.
int reset()
C++ version of gsl_odeiv2_driver_reset().
driver & operator=(driver &&v)
Move operator.
driver()
The default constructor is only really useful for assigning to.
int apply_fixed_step(double &t, double const h, unsigned long int const n, Y &y)
C++ version of gsl_odeiv2_driver_apply_fixed_step().
static driver y_new(system const *sys, step::type const *T, double const hstart, double const epsabs, double const epsrel)
C++ version of gsl_odeiv2_driver_alloc_y_new().
bool operator==(driver const &v) const
Two driver are identically equal if their elements are identical.
driver(gsl_odeiv2_driver *v)
Could construct from a gsl_odeiv2_driver.
bool operator>=(driver const &v) const
A container needs to define an ordering for sorting.
bool empty() const
Find if the driver is empty.
bool operator<(driver const &v) const
A container needs to define an ordering for sorting.
bool operator<=(driver const &v) const
A container needs to define an ordering for sorting.
driver(driver &&v)
Move constructor.
bool unique() const
Find if this is the only object sharing the gsl_odeiv2_driver.
int set_hmax(double const hmax)
C++ version of gsl_odeiv2_driver_set_hmax().
int set_hmin(double const hmin)
C++ version of gsl_odeiv2_driver_set_hmin().
int apply(double &t, double const t1, Y &y)
C++ version of gsl_odeiv2_driver_apply().
size_t use_count() const
Find how many driver objects share this pointer.
bool operator!=(driver const &v) const
Two driver are different if their elements are not identical.
void swap(driver &v)
Swap two driver objects.
static driver standard_new(system const &sys, step::type const *T, double const hstart, double const epsabs, double const epsrel, double const a_y, double const a_dydt)
C++ version of gsl_odeiv2_driver_alloc_standard_new().
driver(driver const &v)
The copy constructor.
driver & operator=(driver const &v)
The assignment operator.
size_t * count
The shared reference count.
ODE inintial value evolve.
evolve(evolve const &v)
The copy constructor.
int apply_fixed_step(control &con, step &step, system const &dydt, double &t, double const h0, Y &y)
C++ version of gsl_odeiv2_evolve_apply_fixed_step().
int apply(control &con, step &step, system const &dydt, double &t, double t1, double &h, Y &y)
C++ version of gsl_odeiv2_evolve_apply().
evolve & operator=(evolve &&v)
Move operator.
size_t use_count() const
Find how many evolve objects share this pointer.
evolve & operator=(evolve const &v)
The assignment operator.
int set_driver(driver const &d)
C++ version of gsl_odeiv2_evolve_set_driver().
bool operator<=(evolve const &v) const
A container needs to define an ordering for sorting.
bool empty() const
Find if the evolve is empty.
evolve(evolve &&v)
Move constructor.
bool operator<(evolve const &v) const
A container needs to define an ordering for sorting.
bool operator>=(evolve const &v) const
A container needs to define an ordering for sorting.
bool operator==(evolve const &v) const
Two evolve are identically equal if their elements are identical.
evolve(size_t const dim)
The default constructor creates a new evolve with n elements.
bool operator!=(evolve const &v) const
Two evolve are different if their elements are not identical.
gsl_odeiv2_evolve * get() const
Get the gsl_odeiv2_evolve.
evolve()
The default constructor is only really useful for assigning to.
gsl_odeiv2_evolve * ccgsl_pointer
The shared pointer.
int reset()
C++ version of gsl_odeiv2_evolve_reset().
void swap(evolve &v)
Swap two evolve objects.
bool operator>(evolve const &v) const
A container needs to define an ordering for sorting.
size_t * count
The shared reference count.
bool unique() const
Find if this is the only object sharing the gsl_odeiv2_evolve.
evolve(gsl_odeiv2_evolve *v)
Could construct from a gsl_odeiv2_evolve.
~evolve()
The destructor only deletes the pointers if count reaches zero.
bool unique() const
Find if this is the only object sharing the gsl_odeiv2_step.
static type const * rk4()
Static type.
void swap(step &v)
Swap two step objects.
size_t use_count() const
Find how many step objects share this pointer.
step & operator=(step const &v)
The assignment operator.
bool operator==(step const &v) const
Two step are identically equal if their elements are identical.
static type const * rk2()
Static type.
char const * name() const
C++ version of gsl_odeiv2_step_name().
static type const * rk8pd()
Static type.
int reset()
C++ version of gsl_odeiv2_step_reset().
size_t * count
The shared reference count.
step & operator=(step &&v)
Move operator.
int apply(double t, double h, Y &y, YERR &yerr, DYDT_IN const &dydt_in, DYDT_OUT dydt_out, system const &sys)
C++ version of gsl_odeiv2_step_apply().
static type const * bsimp()
Static type.
bool operator<=(step const &v) const
A container needs to define an ordering for sorting.
bool operator!=(step const &v) const
Two step are different if their elements are not identical.
bool operator>=(step const &v) const
A container needs to define an ordering for sorting.
static type const * rkck()
Static type.
static type const * rk2imp()
Static type.
gsl_odeiv2_step_type type
Convenience typedef.
~step()
The destructor only deletes the pointers if count reaches zero.
static type const * msbdf()
Static type.
bool operator<(step const &v) const
A container needs to define an ordering for sorting.
bool empty() const
Find if the step is empty.
gsl_odeiv2_step * get() const
Get the gsl_odeiv2_step.
unsigned int order()
C++ version of gsl_odeiv2_step_order().
int set_driver(driver const &d)
C++ version of gsl_odeiv2_step_set_driver().
step()
The default constructor is only really useful for assigning to.
gsl_odeiv2_step * ccgsl_pointer
The shared pointer.
step(gsl_odeiv2_step *v)
Could construct from a gsl_odeiv2_step.
static type const * rkf45()
Static type.
static type const * rk4imp()
Static type.
step(step::type const *T, size_t dim)
The standard constructor creates a new step of type T and dimensions dim.
static type const * msadams()
Static type.
step(step &&v)
Move constructor.
static type const * rk1imp()
Static type.
step(step const &v)
The copy constructor.
bool operator>(step const &v) const
A container needs to define an ordering for sorting.
Class that extends gsl_odeiv2_system so that it can be constructed from function objects.
size_t n(workspace const &w)
C++ version of gsl_rstat_n().
The gsl package creates an interface to the GNU Scientific Library for C++.