base-de.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1996-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_base_de_h)
00024 #define octave_base_de_h 1
00025 
00026 #include <string>
00027 
00028 #include "dColVector.h"
00029 #include "dMatrix.h"
00030 
00031 class
00032 base_diff_eqn
00033 {
00034 public:
00035 
00036   base_diff_eqn (void)
00037     : x (), t (0.0), stop_time (0.0), stop_time_set (false),
00038       restart (true), integration_error (false), istate (0) { }
00039 
00040   base_diff_eqn (const ColumnVector& xx, double tt)
00041     : x (xx), t (tt), stop_time (0.0), stop_time_set (false),
00042       restart (true), integration_error (false), istate (0) { }
00043 
00044   base_diff_eqn (const base_diff_eqn& a)
00045     : x (a.x), t (a.t), stop_time (0.0), stop_time_set (false),
00046       restart (true), integration_error (false), istate (0) { }
00047 
00048   virtual ~base_diff_eqn (void) { }
00049 
00050   base_diff_eqn& operator = (const base_diff_eqn& a)
00051     {
00052       if (this != &a)
00053         {
00054           x = a.x;
00055           t = a.t;
00056           stop_time = a.stop_time;
00057           stop_time_set = a.stop_time_set;
00058           restart = a.restart;
00059           integration_error = a.integration_error;
00060           istate = a.istate;
00061         }
00062 
00063       return *this;
00064     }
00065 
00066   void initialize (const ColumnVector& x0, double t0)
00067     {
00068       x = x0;
00069       t = t0;
00070       integration_error = false;
00071       istate = 0;
00072       force_restart ();
00073     }
00074 
00075   octave_idx_type size (void) const { return x.capacity (); }
00076 
00077   ColumnVector state (void) const { return x; }
00078 
00079   double time (void) const { return t; }
00080 
00081   void set_stop_time (double tt)
00082     {
00083       stop_time_set = true;
00084       stop_time = tt;
00085       force_restart ();
00086     }
00087 
00088   void clear_stop_time (void)
00089     {
00090       stop_time_set = false;
00091       force_restart ();
00092     }
00093 
00094   virtual void force_restart (void) { restart = true; }
00095 
00096   bool integration_ok (void) const { return ! integration_error; }
00097 
00098   octave_idx_type integration_state (void) const { return istate; }
00099 
00100   virtual std::string error_message (void) const = 0;
00101 
00102 protected:
00103 
00104   ColumnVector x;
00105 
00106   double t;
00107 
00108   double stop_time;
00109 
00110   bool stop_time_set;
00111 
00112   bool restart;
00113 
00114   bool integration_error;
00115 
00116   octave_idx_type istate;
00117 };
00118 
00119 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines