diffequations.h

Go to the documentation of this file.
1 /*************************************************************************
2 ALGLIB 3.11.0 (source code generated 2017-05-11)
3 Copyright (c) Sergey Bochkanov (ALGLIB project).
4 
5 >>> SOURCE LICENSE >>>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation (www.fsf.org); either version 2 of the
9 License, or (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 A copy of the GNU General Public License is available at
17 http://www.fsf.org/licensing/licenses
18 >>> END OF LICENSE >>>
19 *************************************************************************/
20 #ifndef _diffequations_pkg_h
21 #define _diffequations_pkg_h
22 #include "ap.h"
23 #include "alglibinternal.h"
24 
26 //
27 // THIS SECTION CONTAINS COMPUTATIONAL CORE DECLARATIONS (DATATYPES)
28 //
30 namespace alglib_impl
31 {
32 typedef struct
33 {
34  ae_int_t n;
35  ae_int_t m;
36  double xscale;
37  double h;
38  double eps;
39  ae_bool fraceps;
40  ae_vector yc;
41  ae_vector escale;
42  ae_vector xg;
43  ae_int_t solvertype;
44  ae_bool needdy;
45  double x;
46  ae_vector y;
47  ae_vector dy;
48  ae_matrix ytbl;
49  ae_int_t repterminationtype;
50  ae_int_t repnfev;
51  ae_vector yn;
52  ae_vector yns;
53  ae_vector rka;
54  ae_vector rkc;
55  ae_vector rkcs;
56  ae_matrix rkb;
57  ae_matrix rkk;
58  rcommstate rstate;
60 typedef struct
61 {
62  ae_int_t nfev;
63  ae_int_t terminationtype;
64 } odesolverreport;
65 
66 }
67 
69 //
70 // THIS SECTION CONTAINS C++ INTERFACE
71 //
73 namespace alglib
74 {
75 
76 /*************************************************************************
77 
78 *************************************************************************/
79 class _odesolverstate_owner
80 {
81 public:
88 protected:
90 };
91 class odesolverstate : public _odesolverstate_owner
92 {
93 public:
97  virtual ~odesolverstate();
101  double &x;
102 
103 };
104 
105 
106 /*************************************************************************
107 
108 *************************************************************************/
110 {
111 public:
118 protected:
120 };
122 {
123 public:
127  virtual ~odesolverreport();
130 
131 };
132 
133 /*************************************************************************
134 Cash-Karp adaptive ODE solver.
135 
136 This subroutine solves ODE Y'=f(Y,x) with initial conditions Y(xs)=Ys
137 (here Y may be single variable or vector of N variables).
138 
139 INPUT PARAMETERS:
140  Y - initial conditions, array[0..N-1].
141  contains values of Y[] at X[0]
142  N - system size
143  X - points at which Y should be tabulated, array[0..M-1]
144  integrations starts at X[0], ends at X[M-1], intermediate
145  values at X[i] are returned too.
146  SHOULD BE ORDERED BY ASCENDING OR BY DESCENDING!
147  M - number of intermediate points + first point + last point:
148  * M>2 means that you need both Y(X[M-1]) and M-2 values at
149  intermediate points
150  * M=2 means that you want just to integrate from X[0] to
151  X[1] and don't interested in intermediate values.
152  * M=1 means that you don't want to integrate :)
153  it is degenerate case, but it will be handled correctly.
154  * M<1 means error
155  Eps - tolerance (absolute/relative error on each step will be
156  less than Eps). When passing:
157  * Eps>0, it means desired ABSOLUTE error
158  * Eps<0, it means desired RELATIVE error. Relative errors
159  are calculated with respect to maximum values of Y seen
160  so far. Be careful to use this criterion when starting
161  from Y[] that are close to zero.
162  H - initial step lenth, it will be adjusted automatically
163  after the first step. If H=0, step will be selected
164  automatically (usualy it will be equal to 0.001 of
165  min(x[i]-x[j])).
166 
167 OUTPUT PARAMETERS
168  State - structure which stores algorithm state between subsequent
169  calls of OdeSolverIteration. Used for reverse communication.
170  This structure should be passed to the OdeSolverIteration
171  subroutine.
172 
173 SEE ALSO
174  AutoGKSmoothW, AutoGKSingular, AutoGKIteration, AutoGKResults.
175 
176 
177  -- ALGLIB --
178  Copyright 01.09.2009 by Bochkanov Sergey
179 *************************************************************************/
180 void odesolverrkck(const real_1d_array &y, const ae_int_t n, const real_1d_array &x, const ae_int_t m, const double eps, const double h, odesolverstate &state);
181 void odesolverrkck(const real_1d_array &y, const real_1d_array &x, const double eps, const double h, odesolverstate &state);
182 
183 
184 /*************************************************************************
185 This function provides reverse communication interface
186 Reverse communication interface is not documented or recommended to use.
187 See below for functions which provide better documented API
188 *************************************************************************/
190 
191 
192 /*************************************************************************
193 This function is used to launcn iterations of ODE solver
194 
195 It accepts following parameters:
196  diff - callback which calculates dy/dx for given y and x
197  ptr - optional pointer which is passed to diff; can be NULL
198 
199 
200  -- ALGLIB --
201  Copyright 01.09.2009 by Bochkanov Sergey
202 
203 *************************************************************************/
205  void (*diff)(const real_1d_array &y, double x, real_1d_array &dy, void *ptr),
206  void *ptr = NULL);
207 
208 
209 /*************************************************************************
210 ODE solver results
211 
212 Called after OdeSolverIteration returned False.
213 
214 INPUT PARAMETERS:
215  State - algorithm state (used by OdeSolverIteration).
216 
217 OUTPUT PARAMETERS:
218  M - number of tabulated values, M>=1
219  XTbl - array[0..M-1], values of X
220  YTbl - array[0..M-1,0..N-1], values of Y in X[i]
221  Rep - solver report:
222  * Rep.TerminationType completetion code:
223  * -2 X is not ordered by ascending/descending or
224  there are non-distinct X[], i.e. X[i]=X[i+1]
225  * -1 incorrect parameters were specified
226  * 1 task has been solved
227  * Rep.NFEV contains number of function calculations
228 
229  -- ALGLIB --
230  Copyright 01.09.2009 by Bochkanov Sergey
231 *************************************************************************/
233 }
234 
236 //
237 // THIS SECTION CONTAINS COMPUTATIONAL CORE DECLARATIONS (FUNCTIONS)
238 //
240 namespace alglib_impl
241 {
242 void odesolverrkck(/* Real */ ae_vector* y,
243  ae_int_t n,
244  /* Real */ ae_vector* x,
245  ae_int_t m,
246  double eps,
247  double h,
248  odesolverstate* state,
249  ae_state *_state);
252  ae_int_t* m,
253  /* Real */ ae_vector* xtbl,
254  /* Real */ ae_matrix* ytbl,
255  odesolverreport* rep,
256  ae_state *_state);
257 void _odesolverstate_init(void* _p, ae_state *_state);
258 void _odesolverstate_init_copy(void* _dst, void* _src, ae_state *_state);
259 void _odesolverstate_clear(void* _p);
260 void _odesolverstate_destroy(void* _p);
261 void _odesolverreport_init(void* _p, ae_state *_state);
262 void _odesolverreport_init_copy(void* _dst, void* _src, ae_state *_state);
263 void _odesolverreport_clear(void* _p);
265 
266 }
267 #endif
268 
_odesolverreport_owner & operator=(const _odesolverreport_owner &rhs)
void _odesolverstate_init_copy(void *_dst, void *_src, ae_state *_state)
void odesolverresults(odesolverstate *state, ae_int_t *m, ae_vector *xtbl, ae_matrix *ytbl, odesolverreport *rep, ae_state *_state)
odesolverstate(const odesolverstate &rhs)
alglib_impl::odesolverstate * c_ptr()
_odesolverstate_owner & operator=(const _odesolverstate_owner &rhs)
void _odesolverstate_clear(void *_p)
void odesolverrkck(const real_1d_array &y, const ae_int_t n, const real_1d_array &x, const ae_int_t m, const double eps, const double h, odesolverstate &state)
odesolverreport & operator=(const odesolverreport &rhs)
alglib_impl::odesolverreport * c_ptr()
#define ae_bool
Definition: ap.h:193
void _odesolverreport_init_copy(void *_dst, void *_src, ae_state *_state)
void odesolverrkck(ae_vector *y, ae_int_t n, ae_vector *x, ae_int_t m, double eps, double h, odesolverstate *state, ae_state *_state)
odesolverstate & operator=(const odesolverstate &rhs)
void _odesolverreport_destroy(void *_p)
void odesolversolve(odesolverstate &state, void(*diff)(const real_1d_array &y, double x, real_1d_array &dy, void *ptr), void *ptr=NULL)
bool odesolveriteration(const odesolverstate &state)
struct alglib_impl::ae_vector ae_vector
void _odesolverreport_clear(void *_p)
void _odesolverreport_init(void *_p, ae_state *_state)
void odesolverresults(const odesolverstate &state, ae_int_t &m, real_1d_array &xtbl, real_2d_array &ytbl, odesolverreport &rep)
ae_bool odesolveriteration(odesolverstate *state, ae_state *_state)
alglib_impl::ae_int_t ae_int_t
Definition: ap.h:965
alglib_impl::odesolverstate * p_struct
Definition: diffequations.h:91
void _odesolverstate_init(void *_p, ae_state *_state)
struct alglib_impl::ae_matrix ae_matrix
odesolverreport(const odesolverreport &rhs)
alglib_impl::odesolverreport * p_struct
ptrdiff_t ae_int_t
Definition: ap.h:185
void _odesolverstate_destroy(void *_p)
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich