3 ButcherTableau::ButcherTableau(
const std::string &xname,
unsigned int xorder):_name(xname),_order(xorder){
7 const std::string & ButcherTableau::name()
const {
13 unsigned int ButcherTableau::order()
const{
19 unsigned int ButcherTableau::nSteps()
const{
20 return (
unsigned int)_A.size();
25 #if __GNUC__ > 3 && __GNUC_MINOR__ > 6 26 #pragma GCC diagnostic push 27 #pragma GCC diagnostic ignored "-Wshadow" 30 #pragma GCC diagnostic push 31 #pragma GCC diagnostic ignored "-Wshadow" 34 #if defined __INTEL_COMPILER 36 #pragma warning disable 1599 39 #pragma clang diagnostic push 40 #pragma clang diagnostic ignored "-Wshadow" 43 double & ButcherTableau::A(
unsigned int i,
unsigned int j) {
45 if (i>=(
unsigned int)_A.size()) {
46 unsigned int newSize=i+1;
47 for (
unsigned long ii=0;ii<_A.size();ii++) {
48 _A[ii].resize(newSize,0.0);
50 for (
unsigned int ii=(
unsigned int)_A.size();ii<newSize;ii++) {
51 _A.push_back(std::vector<double>(newSize,0));
54 if (j>=(
unsigned int)_A[i].size()) {
55 unsigned int newSize=j+1;
56 for (
unsigned long ii=0;ii<_A.size();ii++) {
57 _A[ii].resize(newSize,0.0);
65 #if __GNUC__ > 3 && __GNUC_MINOR__ > 6 66 #pragma GCC diagnostic pop 69 #pragma GCC diagnostic pop 72 #if defined __INTEL_COMPILER 76 #pragma clang diagnostic pop 79 double & ButcherTableau::b(
unsigned int i){
80 if (i>=(
unsigned int)_b.size()) _b.resize(i+1);
84 double & ButcherTableau::c(
unsigned int i){
85 if (i>=(
unsigned int)_c.size()) _c.resize(i+1);
89 const double & ButcherTableau::A(
unsigned int i,
unsigned int j)
const{
93 const double & ButcherTableau::b(
unsigned int i)
const{
97 const double & ButcherTableau::c(
unsigned int i)
const{
102 std::ostream &
operator << (std::ostream & o,
const Genfun::ButcherTableau & b) {
103 o <<
"Name " << b.name() <<
" of order " << b.order() << std::endl;
104 o <<
"A" << std::endl;
105 for (
unsigned int i=0;i<b.nSteps();i++) {
106 for (
unsigned int j=0;j<b.nSteps();j++) {
107 o << b.A(i,j) <<
" ";
112 o <<
"c" << std::endl;
113 for (
unsigned int j=0;j<b.nSteps();j++) {
114 o << b.c(j) << std::endl;
117 o <<
"b" << std::endl;
118 for (
unsigned int j=0;j<b.nSteps();j++) {
126 EulerTableau::EulerTableau():
127 ButcherTableau(
"Euler Method", 1)
134 MidpointTableau::MidpointTableau():
135 ButcherTableau(
"Midpoint Method", 2)
145 TrapezoidTableau::TrapezoidTableau():
146 ButcherTableau(
"Trapezoid Method", 2)
156 RK31Tableau::RK31Tableau():
157 ButcherTableau(
"RK31 Method", 3)
159 A(0,0) ; A(0,1) ; A(0,2);
160 A(1,0)=2/3.0; A(1,1) ; A(1,2);
161 A(2,0)=1/3.0; A(2,1)=1/3.0; A(2,2);
172 RK32Tableau::RK32Tableau():
173 ButcherTableau(
"RK32 Method", 3)
175 A(0,0) ; A(0,1) ; A(0,2);
176 A(1,0)=1/2.0; A(1,1) ; A(1,2);
177 A(2,0)=-1 ; A(2,1)= 2 ; A(2,2);
188 ClassicalRungeKuttaTableau::ClassicalRungeKuttaTableau():
189 ButcherTableau(
"Classical Runge Kutta Method", 4)
191 A(0,0) ; A(0,1) ; A(0,2) ; A(0,3);
192 A(1,0)=1/2.0; A(1,1) ; A(1,2) ; A(1,3);
193 A(2,0)=0 ; A(2,1)=1/2.0 ; A(2,2) ; A(2,3);
194 A(3,0)=0 ; A(3,1)=0 ; A(3,2)=1 ; A(3,3);
206 ThreeEighthsRuleTableau::ThreeEighthsRuleTableau():
207 ButcherTableau(
"Three-Eighths Rule Method", 4)
209 A(0,0) ; A(0,1) ; A(0,2) ; A(0,3);
210 A(1,0)=1/3.0 ; A(1,1) ; A(1,2) ; A(1,3);
211 A(2,0)=-1/3.0 ; A(2,1)=1 ; A(2,2) ; A(2,3);
212 A(3,0)=1 ; A(3,1)=-1 ; A(3,2)=1 ; A(3,3);
std::ostream & operator<<(std::ostream &o, const Genfun::ButcherTableau &b)