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