CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RK4OneStepTempl.h
Go to the documentation of this file.
1 #ifndef RK4OneStepTempl_H
2 #define RK4OneStepTempl_H
3 
6 
7 template <typename T, int N>
9  public:
10 
11  typedef T Scalar;
13 
14 
15  Vector operator()( Scalar startPar, const Vector& startState,
16  const RKDerivative<T,N>& deriv, Scalar step) const {
17 
18  // cout << "RK4OneStepTempl: starting from " << startPar << startState << endl;
19 
20  Vector k1 = step * deriv( startPar, startState);
21  Vector k2 = step * deriv( startPar+step/2, startState+k1/2);
22  Vector k3 = step * deriv( startPar+step/2, startState+k2/2);
23  Vector k4 = step * deriv( startPar+step, startState+k3);
24 
25  Vector result = startState + k1/6 + k2/3 + k3/3 + k4/6;
26 
27  // cout << "RK4OneStepTempl: result for step " << step << " is " << result << endl;
28 
29  return result;
30  }
31 };
32 
33 #endif
Vector operator()(Scalar startPar, const Vector &startState, const RKDerivative< T, N > &deriv, Scalar step) const
tuple result
Definition: query.py:137
Base class for derivative calculation.
Definition: RKDerivative.h:9
RKSmallVector< T, N > Vector