ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
odeiv2.hpp
Go to the documentation of this file.
1/*
2 * $Id: odeiv2.hpp 293 2012-12-17 20:27:36Z jdl3 $
3 * Copyright (C) 2012, 2020 John D Lamb
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20#ifndef CCGSL_ODEIV2_HPP
21#define CCGSL_ODEIV2_HPP
22
23#include<new>
24#include<string>
25#include"odeiv2_system.hpp"
26
27namespace gsl {
32 namespace odeiv2 {
33 class driver;
38 class step {
39 public:
43 typedef gsl_odeiv2_step_type type;
48 ccgsl_pointer = 0;
49 count = 0; // initially nullptr will do
50 }
51 // Refines random access container
52 // Refines assignable
58 step( step::type const* T, size_t dim ){
59 ccgsl_pointer = gsl_odeiv2_step_alloc( T, dim );
60 // just plausibly we could allocate step but not count
61 try { count = new size_t; } catch( std::bad_alloc& e ){
62 // try to tidy up before rethrowing
63 gsl_odeiv2_step_free( ccgsl_pointer );
64 throw e;
65 }
66 *count = 1; // initially there is just one reference to ccgsl_pointer
67 }
74 explicit step( gsl_odeiv2_step* v ){
75 ccgsl_pointer = v;
76 // just plausibly we could fail to allocate count: no further action needed.
77 count = new size_t;
78 *count = 1; // initially there is just one reference to ccgsl_pointer
79 }
80 // copy constructor
86 count = v.count; if( count != 0 ) ++*count; }
87 // assignment operator
92 step& operator=( step const& v ){
93 // first, possibly delete anything pointed to by this
94 if( count == 0 or --*count == 0 ){
95 if( ccgsl_pointer != 0 ) gsl_odeiv2_step_free( ccgsl_pointer );
96 delete count;
97 } // Then copy
98 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
99 }
100 // destructor
105 if( count == 0 or --*count == 0 ){
106 // could have allocated null pointer
107 if( ccgsl_pointer != 0 ) gsl_odeiv2_step_free( ccgsl_pointer );
108 delete count;
109 }
110 }
111#ifdef __GXX_EXPERIMENTAL_CXX0X__
116 step( step&& v ) : ccgsl_pointer( v.ccgsl_pointer ), count( nullptr ){
117 std::swap( count, v.count );
118 v.ccgsl_pointer = nullptr;
119 }
126 step( std::move( v ) ).swap( *this );
127 return *this;
128 }
129#endif
130 // Refines equality comparable
131 // == operator
138 bool operator==( step const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
139 // != operator
146 bool operator!=( step const& v ) const { return not operator==( v ); }
147 // Refines forward container
148 // Refines less than comparable
149 // operator<
158 bool operator<( step const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
159 // operator>
168 bool operator>( step const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
169 // operator<=
178 bool operator<=( step const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
179 // operator>=
188 bool operator>=( step const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
193 bool empty() const { return ccgsl_pointer == 0; }
194 // swap() --- should work even if sizes don't match
200 void swap( step& v ){
201 std::swap( ccgsl_pointer, v.ccgsl_pointer );
202 std::swap( count, v.count );
203 }
204 private:
208 gsl_odeiv2_step* ccgsl_pointer;
212 size_t* count;
213 public:
214 // shared reference functions
219 gsl_odeiv2_step* get() const { return ccgsl_pointer; }
225 bool unique() const { return count != 0 and *count == 1; }
230 size_t use_count() const { return count == 0 ? 0 : *count; }
236#ifdef __GXX_EXPERIMENTAL_CXX0X__
237 explicit
238#endif
239 operator bool() const { return ccgsl_pointer != 0; }
240
241 // Step-specific functions
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() ); }
257#ifndef DOXYGEN_SKIP
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 ); }
272#endif // DOXYGEN_SKIP
273#ifndef DOXYGEN_SKIP
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 ); }
325#endif
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 ); }
348 int set_driver( driver const& d );//{ return gsl_odeiv2_step_set_driver( get(), d.get() ); }
349
350 // Step types
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; }
406 };
407
411 class control {
412 public:
416 typedef gsl_odeiv2_control_type type;
421 ccgsl_pointer = 0;
422 count = 0; // initially nullptr will do
423 }
424 // Refines random access container
425 // Refines assignable
431 explicit control( type const* T ){
432 ccgsl_pointer = gsl_odeiv2_control_alloc( T );
433 // just plausibly we could allocate control but not count
434 try { count = new size_t; } catch( std::bad_alloc& e ){
435 // try to tidy up before rethrowing
436 gsl_odeiv2_control_free( ccgsl_pointer );
437 throw e;
438 }
439 *count = 1; // initially there is just one reference to ccgsl_pointer
440 }
447 explicit control( gsl_odeiv2_control* v ){
448 ccgsl_pointer = v;
449 // just plausibly we could fail to allocate count: no further action needed.
450 count = new size_t;
451 *count = 1; // initially there is just one reference to ccgsl_pointer
452 }
453 // copy constructor
459 count = v.count; if( count != 0 ) ++*count; }
460 // assignment operator
466 // first, possibly delete anything pointed to by this
467 if( count == 0 or --*count == 0 ){
468 if( ccgsl_pointer != 0 ) gsl_odeiv2_control_free( ccgsl_pointer );
469 delete count;
470 } // Then copy
471 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
472 }
473 // destructor
478 if( count == 0 or --*count == 0 ){
479 // could have allocated null pointer
480 if( ccgsl_pointer != 0 ) gsl_odeiv2_control_free( ccgsl_pointer );
481 delete count;
482 }
483 }
484#ifdef __GXX_EXPERIMENTAL_CXX0X__
490 std::swap( count, v.count );
491 v.ccgsl_pointer = nullptr;
492 }
499 control( std::move( v ) ).swap( *this );
500 return *this;
501 }
502#endif
503 // Refines equality comparable
504 // == operator
511 bool operator==( control const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
512 // != operator
519 bool operator!=( control const& v ) const { return not operator==( v ); }
520 // Refines forward container
521 // Refines less than comparable
522 // operator<
531 bool operator<( control const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
532 // operator>
541 bool operator>( control const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
542 // operator<=
551 bool operator<=( control const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
552 // operator>=
561 bool operator>=( control const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
566 bool empty() const { return ccgsl_pointer == 0; }
567 // swap() --- should work even if sizes don't match
573 void swap( control& v ){
574 std::swap( ccgsl_pointer, v.ccgsl_pointer );
575 std::swap( count, v.count );
576 }
577 private:
581 gsl_odeiv2_control* ccgsl_pointer;
585 size_t* count;
586 public:
587 // shared reference functions
592 gsl_odeiv2_control* get() const { return ccgsl_pointer; }
598 bool unique() const { return count != 0 and *count == 1; }
603 size_t use_count() const { return count == 0 ? 0 : *count; }
609#ifdef __GXX_EXPERIMENTAL_CXX0X__
610 explicit
611#endif
612 operator bool() const { return ccgsl_pointer != 0; }
613
614 // Extra functions
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 ); }
625
636 int hadjust( step& s, double const y[], double const yerr[],
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(),
653 &h ); }
654
659 char const* name() const { return gsl_odeiv2_control_name( get() ); }
660
661#ifndef DOXYGEN_SKIP
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 ); }
674#endif // DOXYGEN_SKIP
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 ); }
687
693 int set_driver( driver const& d );
694 //{ return gsl_odeiv2_control_set_driver( get(), d.get() ); }
695
704 inline static control standard_new( double eps_abs, double eps_rel,
705 double a_y, double a_dydt ){
706 return control( gsl_odeiv2_control_standard_new( eps_abs, eps_rel, a_y, a_dydt ) ); }
707
714 inline static control y_new( double eps_abs, double eps_rel ){
715 return control( gsl_odeiv2_control_y_new( eps_abs, eps_rel ) ); }
716
723 inline static control yp_new( double eps_abs, double eps_rel ){
724 return control( gsl_odeiv2_control_yp_new( eps_abs, eps_rel ) ); }
725
726#ifndef DOXYGEN_SKIP
737 inline static control scaled_new( double eps_abs, double eps_rel, double a_y,
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 ) ); }
741#endif // DOXYGEN_SKIP
753 template<typename SCALE_ABS>
754 inline static control scaled_new( double eps_abs, double eps_rel, double a_y,
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() ) ); }
758 };
759
763 class evolve {
764 public:
769 ccgsl_pointer = 0;
770 count = 0; // initially nullptr will do
771 }
772 // Refines random access container
773 // Refines assignable
778 explicit evolve( size_t const dim ){
779 ccgsl_pointer = gsl_odeiv2_evolve_alloc( dim );
780 // just plausibly we could allocate evolve but not count
781 try { count = new size_t; } catch( std::bad_alloc& e ){
782 // try to tidy up before rethrowing
783 gsl_odeiv2_evolve_free( ccgsl_pointer );
784 throw e;
785 }
786 *count = 1; // initially there is just one reference to ccgsl_pointer
787 }
794 explicit evolve( gsl_odeiv2_evolve* v ){
795 ccgsl_pointer = v;
796 // just plausibly we could fail to allocate count: no further action needed.
797 count = new size_t;
798 *count = 1; // initially there is just one reference to ccgsl_pointer
799 }
800 // copy constructor
806 count = v.count; if( count != 0 ) ++*count; }
807 // assignment operator
812 evolve& operator=( evolve const& v ){
813 // first, possibly delete anything pointed to by this
814 if( count == 0 or --*count == 0 ){
815 if( ccgsl_pointer != 0 ) gsl_odeiv2_evolve_free( ccgsl_pointer );
816 delete count;
817 } // Then copy
818 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
819 }
820 // destructor
825 if( count == 0 or --*count == 0 ){
826 // could have allocated null pointer
827 if( ccgsl_pointer != 0 ) gsl_odeiv2_evolve_free( ccgsl_pointer );
828 delete count;
829 }
830 }
831#ifdef __GXX_EXPERIMENTAL_CXX0X__
836 evolve( evolve&& v ) : ccgsl_pointer( v.ccgsl_pointer ), count( nullptr ){
837 std::swap( count, v.count );
838 v.ccgsl_pointer = nullptr;
839 }
846 evolve( std::move( v ) ).swap( *this );
847 return *this;
848 }
849#endif
850 // Refines equality comparable
851 // == operator
858 bool operator==( evolve const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
859 // != operator
866 bool operator!=( evolve const& v ) const { return not operator==( v ); }
867 // Refines forward container
868 // Refines less than comparable
869 // operator<
878 bool operator<( evolve const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
879 // operator>
888 bool operator>( evolve const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
889 // operator<=
898 bool operator<=( evolve const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
899 // operator>=
908 bool operator>=( evolve const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
913 bool empty() const { return ccgsl_pointer == 0; }
914 // swap() --- should work even if sizes don't match
920 void swap( evolve& v ){
921 std::swap( ccgsl_pointer, v.ccgsl_pointer );
922 std::swap( count, v.count );
923 }
924 private:
928 gsl_odeiv2_evolve* ccgsl_pointer;
932 size_t* count;
933 public:
934 // shared reference functions
939 gsl_odeiv2_evolve* get() const { return ccgsl_pointer; }
945 bool unique() const { return count != 0 and *count == 1; }
950 size_t use_count() const { return count == 0 ? 0 : *count; }
956#ifdef __GXX_EXPERIMENTAL_CXX0X__
957 explicit
958#endif
959 operator bool() const { return ccgsl_pointer != 0; }
960
961 // extra functions
962
963#ifndef DOXYGEN_SKIP
975 int apply( control& con, step& step, system const* dydt,
976 double* t, double t1, double* h, double y[] ){
977 return gsl_odeiv2_evolve_apply( get(), con.get(), step.get(), dydt,
978 t, t1, h, y ); }
979#endif // DOXYGEN_SKIP
993 template<typename Y>
994 int apply( control& con, step& step, system const& 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() ); }
998
999#ifndef DOXYGEN_SKIP
1010 int apply_fixed_step( control& con, step& step, system const* dydt,
1011 double* t, double const h0, double y[] ){
1012 return gsl_odeiv2_evolve_apply_fixed_step( get(), con.get(), step.get(), dydt,
1013 t, h0, y ); }
1014#endif // DOXYGEN_SKIP
1027 template<typename Y>
1028 int apply_fixed_step( control& con, step& step, system const& dydt,
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() ); }
1032
1037 int reset(){ return gsl_odeiv2_evolve_reset( get() ); }
1038
1044 int set_driver( driver const& d );
1045 //{ return gsl_odeiv2_evolve_set_driver( get(), d.get() ); }
1046 };
1047
1051 class driver {
1052 public:
1057 ccgsl_pointer = 0;
1058 count = 0; // initially nullptr will do
1059 }
1060 // Refines random access container
1061 // Refines assignable
1068 explicit driver( gsl_odeiv2_driver* v ){
1069 ccgsl_pointer = v;
1070 // just plausibly we could fail to allocate count: no further action needed.
1071 count = new size_t;
1072 *count = 1; // initially there is just one reference to ccgsl_pointer
1073 }
1074 // copy constructor
1080 count = v.count; if( count != 0 ) ++*count; }
1081 // assignment operator
1087 // first, possibly delete anything pointed to by this
1088 if( count == 0 or --*count == 0 ){
1089 if( ccgsl_pointer != 0 ) gsl_odeiv2_driver_free( ccgsl_pointer );
1090 delete count;
1091 } // Then copy
1092 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
1093 }
1094 // destructor
1099 if( count == 0 or --*count == 0 ){
1100 // could have allocated null pointer
1101 if( ccgsl_pointer != 0 ) gsl_odeiv2_driver_free( ccgsl_pointer );
1102 delete count;
1103 }
1104 }
1105#ifdef __GXX_EXPERIMENTAL_CXX0X__
1110 driver( driver&& v ) : ccgsl_pointer( v.ccgsl_pointer ), count( nullptr ){
1111 std::swap( count, v.count );
1112 v.ccgsl_pointer = nullptr;
1113 }
1120 driver( std::move( v ) ).swap( *this );
1121 return *this;
1122 }
1123#endif
1124 // Refines equality comparable
1125 // == operator
1132 bool operator==( driver const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
1133 // != operator
1140 bool operator!=( driver const& v ) const { return not operator==( v ); }
1141 // Refines forward container
1142 // Refines less than comparable
1143 // operator<
1152 bool operator<( driver const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
1153 // operator>
1162 bool operator>( driver const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
1163 // operator<=
1172 bool operator<=( driver const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
1173 // operator>=
1182 bool operator>=( driver const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
1187 bool empty() const { return ccgsl_pointer == 0; }
1188 // swap() --- should work even if sizes don't match
1194 void swap( driver& v ){
1195 std::swap( ccgsl_pointer, v.ccgsl_pointer );
1196 std::swap( count, v.count );
1197 }
1198 private:
1202 gsl_odeiv2_driver* ccgsl_pointer;
1206 size_t* count;
1207 public:
1208 // shared reference functions
1213 gsl_odeiv2_driver* get() const { return ccgsl_pointer; }
1219 bool unique() const { return count != 0 and *count == 1; }
1224 size_t use_count() const { return count == 0 ? 0 : *count; }
1230#ifdef __GXX_EXPERIMENTAL_CXX0X__
1231 explicit
1232#endif
1233 operator bool() const { return ccgsl_pointer != 0; }
1234
1235 // Extra functions
1236
1246 inline static driver y_new( system const* sys, step::type const* T,
1247 double const hstart, double const epsabs, double const epsrel ){
1248 return driver( gsl_odeiv2_driver_alloc_y_new( sys, T, hstart, epsabs, epsrel ) ); }
1249
1259 inline static driver
1260 yp_new( system const* sys, step::type const* T,
1261 double const hstart, double const epsabs, double const epsrel ){
1262 return driver( gsl_odeiv2_driver_alloc_yp_new( sys, T, hstart, epsabs, epsrel ) ); }
1263
1264#ifndef DOXYGEN_SKIP
1277 inline static driver
1278 scaled_new( system const& sys, step::type const* T, double const hstart,
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 ) ); }
1284#endif // DOXYGEN_SKIP
1299 template<typename SCALE_ABS>
1300 inline static driver
1301 scaled_new( system const& sys, step::type const* T, double const hstart,
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() ) ); }
1307
1319 inline static driver
1320 standard_new( system const& sys, step::type const* T, double const hstart,
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 ) ); }
1325
1331 int set_hmin( double const hmin ){ return gsl_odeiv2_driver_set_hmin( get(), hmin ); }
1332
1338 int set_hmax( double const hmax ){ return gsl_odeiv2_driver_set_hmax( get(), hmax ); }
1339
1345 int set_nmax( unsigned long int const nmax ){
1346 return gsl_odeiv2_driver_set_nmax( get(), nmax ); }
1347
1348#ifndef DOXYGEN_SKIP
1356 int apply( double* t, double const t1, double y[] ){
1357 return gsl_odeiv2_driver_apply( get(), t, t1, y ); }
1358#endif // DOXYGEN_SKIP
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() ); }
1371
1372#ifndef DOXYGEN_SKIP
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 ); }
1383#endif // DOXYGEN_SKIP
1394 template<typename Y>
1395 int apply_fixed_step( double& t, double const h, unsigned long int const n, Y& y ){
1396 return gsl_odeiv2_driver_apply_fixed_step( get(), &t, h, n, y.data() ); }
1397
1402 int reset(){ return gsl_odeiv2_driver_reset( get() ); }
1403
1404 };
1405
1406 inline int step::set_driver( driver const& d ){
1407 return gsl_odeiv2_step_set_driver( get(), d.get() ); }
1408 inline int control::set_driver( driver const& d ){
1409 return gsl_odeiv2_control_set_driver( get(), d.get() ); }
1410 inline int evolve::set_driver( driver const& d ){
1411 return gsl_odeiv2_evolve_set_driver( get(), d.get() ); }
1412 }
1413}
1414#endif
Adaptive step size control.
Definition: odeiv2.hpp:411
static control standard_new(double eps_abs, double eps_rel, double a_y, double a_dydt)
C++ version of gsl_odeiv2_control_standard_new().
Definition: odeiv2.hpp:704
bool operator!=(control const &v) const
Two control are different if their elements are not identical.
Definition: odeiv2.hpp:519
gsl_odeiv2_control * ccgsl_pointer
The shared pointer.
Definition: odeiv2.hpp:581
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().
Definition: odeiv2.hpp:754
bool operator<=(control const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:551
int init(double eps_abs, double eps_rel, double a_y, double a_dydt)
C++ version of gsl_odeiv2_control_init().
Definition: odeiv2.hpp:623
bool operator==(control const &v) const
Two control are identically equal if their elements are identical.
Definition: odeiv2.hpp:511
~control()
The destructor only deletes the pointers if count reaches zero.
Definition: odeiv2.hpp:477
void swap(control &v)
Swap two control objects.
Definition: odeiv2.hpp:573
size_t * count
The shared reference count.
Definition: odeiv2.hpp:585
int errlevel(double const y, double const dydt, double const h, size_t const ind, double &errlev)
C++ version of gsl_odeiv2_control_errlevel().
Definition: odeiv2.hpp:684
control & operator=(control &&v)
Move operator.
Definition: odeiv2.hpp:498
gsl_odeiv2_control * get() const
Get the gsl_odeiv2_control.
Definition: odeiv2.hpp:592
int hadjust(step &s, double const y[], double const yerr[], double const dydt[], double *h)
C++ version of gsl_odeiv2_control_hadjust().
Definition: odeiv2.hpp:636
static control yp_new(double eps_abs, double eps_rel)
C++ version of gsl_odeiv2_control_yp_new().
Definition: odeiv2.hpp:723
static control y_new(double eps_abs, double eps_rel)
C++ version of gsl_odeiv2_control_y_new().
Definition: odeiv2.hpp:714
bool operator<(control const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:531
bool empty() const
Find if the control is empty.
Definition: odeiv2.hpp:566
size_t use_count() const
Find how many control objects share this pointer.
Definition: odeiv2.hpp:603
control(control &&v)
Move constructor.
Definition: odeiv2.hpp:489
control(control const &v)
The copy constructor.
Definition: odeiv2.hpp:458
bool unique() const
Find if this is the only object sharing the gsl_odeiv2_control.
Definition: odeiv2.hpp:598
int set_driver(driver const &d)
C++ version of gsl_odeiv2_control_set_driver().
Definition: odeiv2.hpp:1408
control(gsl_odeiv2_control *v)
Could construct from a gsl_odeiv2_control.
Definition: odeiv2.hpp:447
bool operator>(control const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:541
control & operator=(control const &v)
The assignment operator.
Definition: odeiv2.hpp:465
bool operator>=(control const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:561
char const * name() const
C++ version of gsl_odeiv2_control_name().
Definition: odeiv2.hpp:659
gsl_odeiv2_control_type type
Convenience typedef.
Definition: odeiv2.hpp:416
control(type const *T)
The constructor creates a new control of type T.
Definition: odeiv2.hpp:431
control()
The default constructor is only really useful for assigning to.
Definition: odeiv2.hpp:420
int hadjust(step &s, Y const &y, YERR const &yerr, DYDT const &dydt, double &h)
C++ version of gsl_odeiv2_control_hadjust().
Definition: odeiv2.hpp:651
ODE driver.
Definition: odeiv2.hpp:1051
gsl_odeiv2_driver * ccgsl_pointer
The shared pointer.
Definition: odeiv2.hpp:1202
int set_nmax(unsigned long int const nmax)
C++ version of gsl_odeiv2_driver_set_nmax().
Definition: odeiv2.hpp:1345
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().
Definition: odeiv2.hpp:1260
gsl_odeiv2_driver * get() const
Get the gsl_odeiv2_driver.
Definition: odeiv2.hpp:1213
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().
Definition: odeiv2.hpp:1301
bool operator>(driver const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:1162
~driver()
The destructor only deletes the pointers if count reaches zero.
Definition: odeiv2.hpp:1098
int reset()
C++ version of gsl_odeiv2_driver_reset().
Definition: odeiv2.hpp:1402
driver & operator=(driver &&v)
Move operator.
Definition: odeiv2.hpp:1119
driver()
The default constructor is only really useful for assigning to.
Definition: odeiv2.hpp:1056
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().
Definition: odeiv2.hpp:1395
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().
Definition: odeiv2.hpp:1246
bool operator==(driver const &v) const
Two driver are identically equal if their elements are identical.
Definition: odeiv2.hpp:1132
driver(gsl_odeiv2_driver *v)
Could construct from a gsl_odeiv2_driver.
Definition: odeiv2.hpp:1068
bool operator>=(driver const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:1182
bool empty() const
Find if the driver is empty.
Definition: odeiv2.hpp:1187
bool operator<(driver const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:1152
bool operator<=(driver const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:1172
driver(driver &&v)
Move constructor.
Definition: odeiv2.hpp:1110
bool unique() const
Find if this is the only object sharing the gsl_odeiv2_driver.
Definition: odeiv2.hpp:1219
int set_hmax(double const hmax)
C++ version of gsl_odeiv2_driver_set_hmax().
Definition: odeiv2.hpp:1338
int set_hmin(double const hmin)
C++ version of gsl_odeiv2_driver_set_hmin().
Definition: odeiv2.hpp:1331
int apply(double &t, double const t1, Y &y)
C++ version of gsl_odeiv2_driver_apply().
Definition: odeiv2.hpp:1369
size_t use_count() const
Find how many driver objects share this pointer.
Definition: odeiv2.hpp:1224
bool operator!=(driver const &v) const
Two driver are different if their elements are not identical.
Definition: odeiv2.hpp:1140
void swap(driver &v)
Swap two driver objects.
Definition: odeiv2.hpp:1194
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().
Definition: odeiv2.hpp:1320
driver(driver const &v)
The copy constructor.
Definition: odeiv2.hpp:1079
driver & operator=(driver const &v)
The assignment operator.
Definition: odeiv2.hpp:1086
size_t * count
The shared reference count.
Definition: odeiv2.hpp:1206
ODE inintial value evolve.
Definition: odeiv2.hpp:763
evolve(evolve const &v)
The copy constructor.
Definition: odeiv2.hpp:805
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().
Definition: odeiv2.hpp:1028
int apply(control &con, step &step, system const &dydt, double &t, double t1, double &h, Y &y)
C++ version of gsl_odeiv2_evolve_apply().
Definition: odeiv2.hpp:994
evolve & operator=(evolve &&v)
Move operator.
Definition: odeiv2.hpp:845
size_t use_count() const
Find how many evolve objects share this pointer.
Definition: odeiv2.hpp:950
evolve & operator=(evolve const &v)
The assignment operator.
Definition: odeiv2.hpp:812
int set_driver(driver const &d)
C++ version of gsl_odeiv2_evolve_set_driver().
Definition: odeiv2.hpp:1410
bool operator<=(evolve const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:898
bool empty() const
Find if the evolve is empty.
Definition: odeiv2.hpp:913
evolve(evolve &&v)
Move constructor.
Definition: odeiv2.hpp:836
bool operator<(evolve const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:878
bool operator>=(evolve const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:908
bool operator==(evolve const &v) const
Two evolve are identically equal if their elements are identical.
Definition: odeiv2.hpp:858
evolve(size_t const dim)
The default constructor creates a new evolve with n elements.
Definition: odeiv2.hpp:778
bool operator!=(evolve const &v) const
Two evolve are different if their elements are not identical.
Definition: odeiv2.hpp:866
gsl_odeiv2_evolve * get() const
Get the gsl_odeiv2_evolve.
Definition: odeiv2.hpp:939
evolve()
The default constructor is only really useful for assigning to.
Definition: odeiv2.hpp:768
gsl_odeiv2_evolve * ccgsl_pointer
The shared pointer.
Definition: odeiv2.hpp:928
int reset()
C++ version of gsl_odeiv2_evolve_reset().
Definition: odeiv2.hpp:1037
void swap(evolve &v)
Swap two evolve objects.
Definition: odeiv2.hpp:920
bool operator>(evolve const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:888
size_t * count
The shared reference count.
Definition: odeiv2.hpp:932
bool unique() const
Find if this is the only object sharing the gsl_odeiv2_evolve.
Definition: odeiv2.hpp:945
evolve(gsl_odeiv2_evolve *v)
Could construct from a gsl_odeiv2_evolve.
Definition: odeiv2.hpp:794
~evolve()
The destructor only deletes the pointers if count reaches zero.
Definition: odeiv2.hpp:824
Stepping functions.
Definition: odeiv2.hpp:38
bool unique() const
Find if this is the only object sharing the gsl_odeiv2_step.
Definition: odeiv2.hpp:225
static type const * rk4()
Static type.
Definition: odeiv2.hpp:360
void swap(step &v)
Swap two step objects.
Definition: odeiv2.hpp:200
size_t use_count() const
Find how many step objects share this pointer.
Definition: odeiv2.hpp:230
step & operator=(step const &v)
The assignment operator.
Definition: odeiv2.hpp:92
bool operator==(step const &v) const
Two step are identically equal if their elements are identical.
Definition: odeiv2.hpp:138
static type const * rk2()
Static type.
Definition: odeiv2.hpp:355
char const * name() const
C++ version of gsl_odeiv2_step_name().
Definition: odeiv2.hpp:251
static type const * rk8pd()
Static type.
Definition: odeiv2.hpp:375
int reset()
C++ version of gsl_odeiv2_step_reset().
Definition: odeiv2.hpp:246
size_t * count
The shared reference count.
Definition: odeiv2.hpp:212
step & operator=(step &&v)
Move operator.
Definition: odeiv2.hpp:125
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().
Definition: odeiv2.hpp:339
static type const * bsimp()
Static type.
Definition: odeiv2.hpp:390
bool operator<=(step const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:178
bool operator!=(step const &v) const
Two step are different if their elements are not identical.
Definition: odeiv2.hpp:146
bool operator>=(step const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:188
static type const * rkck()
Static type.
Definition: odeiv2.hpp:370
static type const * rk2imp()
Static type.
Definition: odeiv2.hpp:380
gsl_odeiv2_step_type type
Convenience typedef.
Definition: odeiv2.hpp:43
~step()
The destructor only deletes the pointers if count reaches zero.
Definition: odeiv2.hpp:104
static type const * msbdf()
Static type.
Definition: odeiv2.hpp:405
bool operator<(step const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:158
bool empty() const
Find if the step is empty.
Definition: odeiv2.hpp:193
gsl_odeiv2_step * get() const
Get the gsl_odeiv2_step.
Definition: odeiv2.hpp:219
unsigned int order()
C++ version of gsl_odeiv2_step_order().
Definition: odeiv2.hpp:256
int set_driver(driver const &d)
C++ version of gsl_odeiv2_step_set_driver().
Definition: odeiv2.hpp:1406
step()
The default constructor is only really useful for assigning to.
Definition: odeiv2.hpp:47
gsl_odeiv2_step * ccgsl_pointer
The shared pointer.
Definition: odeiv2.hpp:208
step(gsl_odeiv2_step *v)
Could construct from a gsl_odeiv2_step.
Definition: odeiv2.hpp:74
static type const * rkf45()
Static type.
Definition: odeiv2.hpp:365
static type const * rk4imp()
Static type.
Definition: odeiv2.hpp:385
step(step::type const *T, size_t dim)
The standard constructor creates a new step of type T and dimensions dim.
Definition: odeiv2.hpp:58
static type const * msadams()
Static type.
Definition: odeiv2.hpp:400
step(step &&v)
Move constructor.
Definition: odeiv2.hpp:116
static type const * rk1imp()
Static type.
Definition: odeiv2.hpp:395
step(step const &v)
The copy constructor.
Definition: odeiv2.hpp:85
bool operator>(step const &v) const
A container needs to define an ordering for sorting.
Definition: odeiv2.hpp:168
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().
Definition: rstat.hpp:299
The gsl package creates an interface to the GNU Scientific Library for C++.
Definition: blas.hpp:34