1#include "CLHEP/GenericFunctions/EmbeddedRKStepper.hh"
2#include "CLHEP/GenericFunctions/ExtendedButcherTableau.hh"
19 std::vector<double> & errors)
const {
23 if (h<=0)
throw std::runtime_error (
"Runtime error in RKIntegrator (zero or negative stepsize)");
24 unsigned int nvar = (
unsigned int)s.
variable.size();
28 std::vector<std::vector<double> >k(tableau.
nSteps());
29 for (
unsigned int i=0;i<tableau.
nSteps();i++) {
32 for (
unsigned int v=0;v<nvar;v++) arg[v]=s.
variable[v];
33 for (
unsigned int j=0;j<i;j++) {
34 for (
unsigned int v=0;v<nvar;v++) arg[v] += h*tableau.
A(i,j)*k[j][v];
36 for (
unsigned int v=0;v<nvar;v++) k[i][v]=(*data->
_diffEqn[v])(arg);
42 for (
unsigned int i=0;i<tableau.
nSteps();i++) {
43 for (
unsigned int v=0;v<nvar;v++) d.
firstDerivative[v] += tableau.
b(i)*k[i][v];
50 for (
unsigned int v=0;v<nvar;v++) errors[v] = 0;
51 for (
unsigned int i=0;i<tableau.
nSteps();i++) {
52 for (
unsigned int v=0;v<nvar;v++) errors[v] += (h*(tableau.
bHat(i)-tableau.
b(i))*k[i][v]);
62 return tableau.
order();
EmbeddedRKStepper(const ExtendedButcherTableau &tableau=CashKarpXtTableau())
virtual ~EmbeddedRKStepper()
virtual unsigned int order() const
virtual void step(const RKIntegrator::RKData *data, const RKIntegrator::RKData::Data &sdata, RKIntegrator::RKData::Data &ddata, std::vector< double > &errors) const
virtual EmbeddedRKStepper * clone() const
unsigned int nSteps() const
double & A(unsigned int i, unsigned int j)
double & bHat(unsigned int i)
unsigned int order() const
double & b(unsigned int i)
std::vector< const AbsFunction * > _diffEqn
std::vector< double > firstDerivative
std::vector< double > variable