00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 00024 #ifndef O2SCL_ODESTEP_H 00025 #define O2SCL_ODESTEP_H 00026 00027 #include <o2scl/ovector_tlate.h> 00028 00029 #ifndef DOXYGENP 00030 namespace o2scl { 00031 #endif 00032 00033 /** \brief ODE stepper base 00034 */ 00035 template<class param_t, class func_t, class vec_t=ovector_view> 00036 class odestep { 00037 00038 #ifndef DOXGYENP 00039 00040 protected: 00041 00042 int order; 00043 00044 #endif 00045 00046 public: 00047 00048 odestep() { 00049 order=4; 00050 } 00051 00052 virtual ~odestep() {} 00053 00054 /// Return the order of the ODE stepper 00055 virtual int get_order() { 00056 return order; 00057 } 00058 00059 /** 00060 \brief Perform an integration step 00061 00062 Given initial value of the n-dimensional function in \c y 00063 and the derivative in \c dydx (which must generally be 00064 computed beforehand) at the point \c x, take a step of size 00065 \c h giving the result in \c yout, the uncertainty in \c 00066 yerr, and the new derivative in \c dydx_out (at \c x+h) 00067 using function \c derivs to calculate derivatives. 00068 Implementations which do not calculate \c yerr and/or \c 00069 dydx_out do not reference these variables so that a blank \c 00070 vec_t can be given. All of the implementations allow \c 00071 yout=y and \c dydx_out=dydx if necessary. 00072 */ 00073 virtual int step(double x, double h, size_t n, vec_t &y, vec_t &dydx, 00074 vec_t &yout, vec_t &yerr, vec_t &dydx_out, param_t &pa, 00075 func_t &derivs) 00076 { 00077 set_err_ret("No step_mem() function specified.",o2scl::gsl_nobase); 00078 } 00079 00080 }; 00081 00082 #ifndef DOXYGENP 00083 } 00084 #endif 00085 00086 #endif