GNU Octave  6.2.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-2021 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  : x (), t (0.0), stop_time (0.0), stop_time_set (false),
42  restart (true), integration_error (false), istate (0) { }
43 
44  base_diff_eqn (const ColumnVector& xx, double tt)
45  : x (xx), t (tt), stop_time (0.0), stop_time_set (false),
46  restart (true), integration_error (false), istate (0) { }
47 
49  : x (a.x), t (a.t), stop_time (0.0), stop_time_set (false),
50  restart (true), integration_error (false), 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  x = a.x;
59  t = a.t;
60  stop_time = a.stop_time;
61  stop_time_set = a.stop_time_set;
62  restart = a.restart;
63  integration_error = a.integration_error;
64  istate = a.istate;
65  }
66 
67  return *this;
68  }
69 
70  void initialize (const ColumnVector& x0, double t0)
71  {
72  x = x0;
73  t = t0;
74  integration_error = false;
75  istate = 0;
76  force_restart ();
77  }
78 
79  octave_idx_type size (void) const { return x.numel (); }
80 
81  ColumnVector state (void) const { return x; }
82 
83  double time (void) const { return t; }
84 
85  void set_stop_time (double tt)
86  {
87  stop_time_set = true;
88  stop_time = tt;
89  force_restart ();
90  }
91 
92  void clear_stop_time (void)
93  {
94  stop_time_set = false;
95  force_restart ();
96  }
97 
98  virtual void force_restart (void) { restart = true; }
99 
100  bool integration_ok (void) const { return ! integration_error; }
101 
102  octave_idx_type integration_state (void) const { return istate; }
103 
104  virtual std::string error_message (void) const = 0;
105 
106 protected:
107 
109 
110  double t;
111 
112  double stop_time;
113 
115 
116  bool 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
bool restart
Definition: base-de.h:116
virtual void force_restart(void)
Definition: base-de.h:98
virtual ~base_diff_eqn(void)=default
double t
Definition: base-de.h:110
bool integration_error
Definition: base-de.h:118
octave_idx_type integration_state(void) const
Definition: base-de.h:102
void initialize(const ColumnVector &x0, double t0)
Definition: base-de.h:70
double stop_time
Definition: base-de.h:112
octave_idx_type size(void) const
Definition: base-de.h:79
octave_idx_type istate
Definition: base-de.h:120
ColumnVector state(void) const
Definition: base-de.h:81
virtual std::string error_message(void) const =0
ColumnVector x
Definition: base-de.h:108
void set_stop_time(double tt)
Definition: base-de.h:85
bool stop_time_set
Definition: base-de.h:114
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
F77_RET_T const F77_DBLE * x