RungeKutta4.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: RungeKutta4.hpp 1957 2009-06-19 14:39:39Z afarris $"
00002 
00003 
00004 
00005 //============================================================================
00006 //
00007 //  This file is part of GPSTk, the GPS Toolkit.
00008 //
00009 //  The GPSTk is free software; you can redistribute it and/or modify
00010 //  it under the terms of the GNU Lesser General Public License as published
00011 //  by the Free Software Foundation; either version 2.1 of the License, or
00012 //  any later version.
00013 //
00014 //  The GPSTk is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 //  GNU Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with GPSTk; if not, write to the Free Software Foundation,
00021 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //  
00023 //  Copyright 2004, The University of Texas at Austin
00024 //
00025 //============================================================================
00026 
00027 
00028 /*
00029  * @file RungeKutta4.hpp
00030  * RungeKutta4 class. Provides several versions of the Runge Kutta integration
00031  * The algorithms are based on Ch.16 of "Numerical Recipes in C" but the
00032  * implementation is entirely independent, i.e., this isn't the source 
00033  * distributed with the text.
00034  */
00035 
00036 #ifndef GPSTK_RUNGEKUTTA4_H
00037 #define GPSTK_RUNGEKUTTA4_H
00038 
00039 #include "Matrix.hpp"
00040 
00041 namespace gpstk
00042 {
00043 
00046 
00050    class RungeKutta4 
00051    {
00052    public:
00060       RungeKutta4(const Matrix<double>& initialState,
00061                   double initialTime=0,
00062                   double timeEpsilon=1e-18)
00063             : currentState(initialState), currentTime(initialTime), 
00064               teps(timeEpsilon), M(initialState.rows()), N(initialState.cols()),
00065               k1(M,N), k2(M,N), k3(M,N), k4(M,N), yn(M,N), tempy(M,N)
00066          { }     
00067 
00074       void integrateTo (double nextTime, 
00075                         double stepSize = 0);
00076 
00087       void integrateTo (double nextTime,
00088                         Matrix<double>& error,
00089                         double stepSize = 0);
00090 
00097       virtual gpstk::Matrix<double>& 
00098       derivative(long double time,
00099                  const gpstk::Matrix<double>& inState,
00100                  gpstk::Matrix<double>& inStateDot) = 0;
00101 
00103       double getTime(void) 
00104       { return currentTime; }
00105 
00107       const Matrix<double>& getState(void) 
00108       { return currentState; }
00109 
00110    protected:
00111       
00113       double currentTime;
00114 
00116       gpstk::Matrix<double> currentState;
00117 
00118       double teps;   //< Precision for time calculations and comparisons
00119       int M;         //< Number of rows in the state
00120       int N;         //< Number of columns in the state
00121 
00122    private:
00123 
00125          RungeKutta4(const RungeKutta4& cloneDonor);
00126 
00128          RungeKutta4& operator= (const RungeKutta4& right);
00129 
00134          Matrix<double> k1, k2, k3, k4, yn, tempy;
00135 
00136    }; // end class RungeKutta4
00137 
00139 
00140 } // end namespace gpstk
00141 
00142 #endif
00143 
00144 

Generated on Wed Feb 8 03:31:02 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1