ODE.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1993-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (octave_ODE_h)
00024 #define octave_ODE_h 1
00025 
00026 #include "ODEFunc.h"
00027 #include "base-de.h"
00028 
00029 class
00030 ODE : public base_diff_eqn, public ODEFunc
00031 {
00032 public:
00033 
00034   ODE (void)
00035     : base_diff_eqn (), ODEFunc () { }
00036 
00037   ODE (const ColumnVector& s, double tm, const ODEFunc& f)
00038     : base_diff_eqn (s, tm), ODEFunc (f) { }
00039 
00040   ODE (const ODE& a)
00041     : base_diff_eqn (a), ODEFunc (a) { }
00042 
00043   ODE& operator = (const ODE& a)
00044     {
00045       if (this != &a)
00046         {
00047           base_diff_eqn::operator = (a);
00048           ODEFunc::operator = (a);
00049         }
00050       return *this;
00051     }
00052 
00053   virtual ~ODE (void) { }
00054 
00055   // Derived classes must provide functions to actually do the
00056   // integration.
00057 
00058   // Return the vector of states at output time t.
00059   virtual ColumnVector do_integrate (double tt) = 0;
00060 
00061   // Return a matrix of states at each output time specified by t.
00062   // The rows of the result matrix should each correspond to a new
00063   // output time.
00064   virtual Matrix do_integrate (const ColumnVector& tt) = 0;
00065 
00066   virtual Matrix do_integrate (const ColumnVector& tt,
00067                                const ColumnVector& ttcrit) = 0;
00068 
00069   // Lots of ways to call the single function and optionally set and
00070   // get additional information.
00071 
00072   // Integrate to t from current point.
00073   virtual ColumnVector integrate (double tt)
00074     { return do_integrate (tt); }
00075 
00076   // Set new x0, t0 and integrate to t.
00077   virtual ColumnVector integrate (const ColumnVector& x0, double t0, double tt)
00078     {
00079       initialize (x0, t0);
00080       return do_integrate (tt);
00081     }
00082 
00083   // Integrate from current point and return output at all points
00084   // specified by t.
00085   virtual Matrix integrate (const ColumnVector& tt)
00086     { return do_integrate (tt); }
00087 
00088   // Set new x0, t0 and integrate to return output at all points
00089   // specified by t.
00090   virtual Matrix integrate (const ColumnVector& x0, double t0,
00091                             const ColumnVector& tt)
00092     {
00093       initialize (x0, t0);
00094       return do_integrate (tt);
00095     }
00096 
00097   // Integrate from current point and return output at all points
00098   // specified by t.
00099   virtual Matrix integrate (const ColumnVector& tt,
00100                             const ColumnVector& ttcrit)
00101     { return do_integrate (tt, ttcrit); }
00102 
00103   // Set new x0, t0 and integrate to return output at all points
00104   // specified by t.
00105   virtual Matrix integrate (const ColumnVector& x0, double t0,
00106                             const ColumnVector& tt,
00107                             const ColumnVector& ttcrit)
00108     {
00109       initialize (x0, t0);
00110       return do_integrate (tt, ttcrit);
00111     }
00112 };
00113 
00114 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines