CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/TrackPropagation/RungeKutta/interface/RK4OneStepTempl.h

Go to the documentation of this file.
00001 #ifndef RK4OneStepTempl_H
00002 #define RK4OneStepTempl_H
00003 
00004 #include "TrackPropagation/RungeKutta/interface/RKSmallVector.h"
00005 #include "TrackPropagation/RungeKutta/interface/RKDerivative.h"
00006 
00007 template <typename T, int N>
00008 class RK4OneStepTempl {
00009  public:
00010 
00011     typedef T                                   Scalar;
00012     typedef RKSmallVector<T,N>                  Vector;
00013 
00014   
00015     Vector operator()( Scalar startPar, const Vector& startState,
00016                        const RKDerivative<T,N>& deriv, Scalar step) const {
00017 
00018         // cout << "RK4OneStepTempl: starting from " << startPar << startState << endl;
00019 
00020         Vector k1 = step * deriv( startPar, startState);
00021         Vector k2 = step * deriv( startPar+step/2, startState+k1/2);
00022         Vector k3 = step * deriv( startPar+step/2, startState+k2/2);
00023         Vector k4 = step * deriv( startPar+step, startState+k3);
00024 
00025         Vector result = startState + k1/6 + k2/3 + k3/3 + k4/6;
00026 
00027         // cout << "RK4OneStepTempl: result for step " << step << " is " << result << endl;
00028 
00029         return result;
00030     }
00031 };
00032 
00033 #endif