Class documentation of Concepts

Loading...
Searching...
No Matches
diffequations.h
1/*************************************************************************
2ALGLIB 3.11.0 (source code generated 2017-05-11)
3Copyright (c) Sergey Bochkanov (ALGLIB project).
4
5>>> SOURCE LICENSE >>>
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation (www.fsf.org); either version 2 of the
9License, or (at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16A copy of the GNU General Public License is available at
17http://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//
30namespace alglib_impl
31{
32typedef 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;
60typedef struct
61{
62 ae_int_t nfev;
63 ae_int_t terminationtype;
65
66}
67
69//
70// THIS SECTION CONTAINS C++ INTERFACE
71//
73namespace alglib
74{
75
76/*************************************************************************
77
78*************************************************************************/
80{
81public:
84 _odesolverstate_owner& operator=(const _odesolverstate_owner &rhs);
85 virtual ~_odesolverstate_owner();
87 alglib_impl::odesolverstate* c_ptr() const;
88protected:
90};
92{
93public:
96 odesolverstate& operator=(const odesolverstate &rhs);
97 virtual ~odesolverstate();
98 ae_bool &needdy;
100 real_1d_array dy;
101 double &x;
102
103};
104
105
106/*************************************************************************
107
108*************************************************************************/
110{
111public:
114 _odesolverreport_owner& operator=(const _odesolverreport_owner &rhs);
115 virtual ~_odesolverreport_owner();
117 alglib_impl::odesolverreport* c_ptr() const;
118protected:
120};
122{
123public:
126 odesolverreport& operator=(const odesolverreport &rhs);
127 virtual ~odesolverreport();
128 ae_int_t &nfev;
129 ae_int_t &terminationtype;
130
131};
132
133/*************************************************************************
134Cash-Karp adaptive ODE solver.
135
136This 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
139INPUT 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
167OUTPUT 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
173SEE ALSO
174 AutoGKSmoothW, AutoGKSingular, AutoGKIteration, AutoGKResults.
175
176
177 -- ALGLIB --
178 Copyright 01.09.2009 by Bochkanov Sergey
179*************************************************************************/
180void 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);
181void odesolverrkck(const real_1d_array &y, const real_1d_array &x, const double eps, const double h, odesolverstate &state);
182
183
184/*************************************************************************
185This function provides reverse communication interface
186Reverse communication interface is not documented or recommended to use.
187See below for functions which provide better documented API
188*************************************************************************/
189bool odesolveriteration(const odesolverstate &state);
190
191
192/*************************************************************************
193This function is used to launcn iterations of ODE solver
194
195It 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*************************************************************************/
204void odesolversolve(odesolverstate &state,
205 void (*diff)(const real_1d_array &y, double x, real_1d_array &dy, void *ptr),
206 void *ptr = NULL);
207
208
209/*************************************************************************
210ODE solver results
211
212Called after OdeSolverIteration returned False.
213
214INPUT PARAMETERS:
215 State - algorithm state (used by OdeSolverIteration).
216
217OUTPUT 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*************************************************************************/
232void odesolverresults(const odesolverstate &state, ae_int_t &m, real_1d_array &xtbl, real_2d_array &ytbl, odesolverreport &rep);
233}
234
236//
237// THIS SECTION CONTAINS COMPUTATIONAL CORE DECLARATIONS (FUNCTIONS)
238//
240namespace alglib_impl
241{
242void 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);
250ae_bool odesolveriteration(odesolverstate* state, ae_state *_state);
251void odesolverresults(odesolverstate* state,
252 ae_int_t* m,
253 /* Real */ ae_vector* xtbl,
254 /* Real */ ae_matrix* ytbl,
255 odesolverreport* rep,
256 ae_state *_state);
257void _odesolverstate_init(void* _p, ae_state *_state);
258void _odesolverstate_init_copy(void* _dst, void* _src, ae_state *_state);
259void _odesolverstate_clear(void* _p);
260void _odesolverstate_destroy(void* _p);
261void _odesolverreport_init(void* _p, ae_state *_state);
262void _odesolverreport_init_copy(void* _dst, void* _src, ae_state *_state);
263void _odesolverreport_clear(void* _p);
264void _odesolverreport_destroy(void* _p);
265
266}
267#endif
268