ODEFunc.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_ODEFunc_h)
00024 #define octave_ODEFunc_h 1
00025 
00026 class Matrix;
00027 class ColumnVector;
00028 
00029 class
00030 ODEFunc
00031 {
00032 public:
00033 
00034   typedef ColumnVector (*ODERHSFunc) (const ColumnVector&, double);
00035   typedef Matrix (*ODEJacFunc) (const ColumnVector&, double);
00036 
00037   ODEFunc (void)
00038     : fun (0), jac (0), reset (true) { }
00039 
00040   ODEFunc (ODERHSFunc f)
00041     : fun (f), jac (0), reset (true) { }
00042 
00043   ODEFunc (ODERHSFunc f, ODEJacFunc j)
00044     : fun (f), jac (j), reset (true) { }
00045 
00046   ODEFunc (const ODEFunc& a)
00047     : fun (a.fun), jac (a.jac), reset (true) { }
00048 
00049   ODEFunc& operator = (const ODEFunc& a)
00050     {
00051       if (this != &a)
00052         {
00053           fun = a.fun;
00054           jac = a.jac;
00055           reset = a.reset;
00056         }
00057       return *this;
00058     }
00059 
00060   virtual ~ODEFunc (void) { }
00061 
00062   ODERHSFunc function (void) const { return fun; }
00063 
00064   ODEFunc& set_function (ODERHSFunc f)
00065     {
00066       fun = f;
00067       reset = true;
00068       return *this;
00069     }
00070 
00071   ODEJacFunc jacobian_function (void) const { return jac; }
00072 
00073   ODEFunc& set_jacobian_function (ODEJacFunc j)
00074     {
00075       jac = j;
00076       reset = true;
00077       return *this;
00078     }
00079 
00080 protected:
00081 
00082   ODERHSFunc fun;
00083   ODEJacFunc jac;
00084 
00085   // This variable is TRUE when this object is constructed, and also
00086   // after any internal data has changed.  Derived classes may use
00087   // this information (and change it) to know when to (re)initialize
00088   // their own internal data related to this object.
00089 
00090   bool reset;
00091 };
00092 
00093 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines