GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
base-de.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2023 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_base_de_h)
27 #define octave_base_de_h 1
28 
29 #include "octave-config.h"
30 
31 #include <string>
32 
33 #include "dColVector.h"
34 
35 class
37 {
38 public:
39 
41  : m_x (), m_t (0.0), m_stop_time (0.0), m_stop_time_set (false),
42  m_restart (true), m_integration_error (false), m_istate (0) { }
43 
44  base_diff_eqn (const ColumnVector& xx, double tt)
45  : m_x (xx), m_t (tt), m_stop_time (0.0), m_stop_time_set (false),
46  m_restart (true), m_integration_error (false), m_istate (0) { }
47 
49  : m_x (a.m_x), m_t (a.m_t), m_stop_time (0.0), m_stop_time_set (false),
50  m_restart (true), m_integration_error (false), m_istate (0) { }
51 
52  virtual ~base_diff_eqn (void) = default;
53 
54  base_diff_eqn& operator = (const base_diff_eqn& a)
55  {
56  if (this != &a)
57  {
58  m_x = a.m_x;
59  m_t = a.m_t;
60  m_stop_time = a.m_stop_time;
61  m_stop_time_set = a.m_stop_time_set;
62  m_restart = a.m_restart;
63  m_integration_error = a.m_integration_error;
64  m_istate = a.m_istate;
65  }
66 
67  return *this;
68  }
69 
70  void initialize (const ColumnVector& x0, double t0)
71  {
72  m_x = x0;
73  m_t = t0;
74  m_integration_error = false;
75  m_istate = 0;
76  force_restart ();
77  }
78 
79  octave_idx_type size (void) const { return m_x.numel (); }
80 
81  ColumnVector state (void) const { return m_x; }
82 
83  double time (void) const { return m_t; }
84 
85  void set_stop_time (double tt)
86  {
87  m_stop_time_set = true;
88  m_stop_time = tt;
89  force_restart ();
90  }
91 
92  void clear_stop_time (void)
93  {
94  m_stop_time_set = false;
95  force_restart ();
96  }
97 
98  virtual void force_restart (void) { m_restart = true; }
99 
100  bool integration_ok (void) const { return ! m_integration_error; }
101 
102  octave_idx_type integration_state (void) const { return m_istate; }
103 
104  virtual std::string error_message (void) const = 0;
105 
106 protected:
107 
109 
110  double m_t;
111 
112  double m_stop_time;
113 
115 
116  bool m_restart;
117 
119 
121 };
122 
123 #endif
double time(void) const
Definition: base-de.h:83
base_diff_eqn(const base_diff_eqn &a)
Definition: base-de.h:48
bool integration_ok(void) const
Definition: base-de.h:100
virtual void force_restart(void)
Definition: base-de.h:98
virtual ~base_diff_eqn(void)=default
double m_stop_time
Definition: base-de.h:112
octave_idx_type integration_state(void) const
Definition: base-de.h:102
void initialize(const ColumnVector &x0, double t0)
Definition: base-de.h:70
bool m_restart
Definition: base-de.h:116
double m_t
Definition: base-de.h:110
octave_idx_type size(void) const
Definition: base-de.h:79
octave_idx_type m_istate
Definition: base-de.h:120
bool m_stop_time_set
Definition: base-de.h:114
ColumnVector state(void) const
Definition: base-de.h:81
virtual std::string error_message(void) const =0
bool m_integration_error
Definition: base-de.h:118
ColumnVector m_x
Definition: base-de.h:108
void set_stop_time(double tt)
Definition: base-de.h:85
base_diff_eqn(const ColumnVector &xx, double tt)
Definition: base-de.h:44
void clear_stop_time(void)
Definition: base-de.h:92
base_diff_eqn(void)
Definition: base-de.h:40