Xmipp  v3.23.11-Nereus
diffequations.cpp
Go to the documentation of this file.
1 /*************************************************************************
2 Copyright (c) Sergey Bochkanov (ALGLIB project).
3 
4 >>> SOURCE LICENSE >>>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation (www.fsf.org); either version 2 of the
8 License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 A copy of the GNU General Public License is available at
16 http://www.fsf.org/licensing/licenses
17 >>> END OF LICENSE >>>
18 *************************************************************************/
19 #include "stdafx.h"
20 #include "diffequations.h"
21 
22 // disable some irrelevant warnings
23 #if (AE_COMPILER==AE_MSVC)
24 #pragma warning(disable:4100)
25 #pragma warning(disable:4127)
26 #pragma warning(disable:4702)
27 #pragma warning(disable:4996)
28 #endif
29 using namespace std;
30 
32 //
33 // THIS SECTION CONTAINS IMPLEMENTATION OF C++ INTERFACE
34 //
36 namespace alglib
37 {
38 
39 
40 /*************************************************************************
41 
42 *************************************************************************/
43 _odesolverstate_owner::_odesolverstate_owner()
44 {
46  if( p_struct==NULL )
47  throw ap_error("ALGLIB: malloc error");
48  if( !alglib_impl::_odesolverstate_init(p_struct, NULL, ae_false) )
49  throw ap_error("ALGLIB: malloc error");
50 }
51 
52 _odesolverstate_owner::_odesolverstate_owner(const _odesolverstate_owner &rhs)
53 {
55  if( p_struct==NULL )
56  throw ap_error("ALGLIB: malloc error");
57  if( !alglib_impl::_odesolverstate_init_copy(p_struct, const_cast<alglib_impl::odesolverstate*>(rhs.p_struct), NULL, ae_false) )
58  throw ap_error("ALGLIB: malloc error");
59 }
60 
61 _odesolverstate_owner& _odesolverstate_owner::operator=(const _odesolverstate_owner &rhs)
62 {
63  if( this==&rhs )
64  return *this;
66  if( !alglib_impl::_odesolverstate_init_copy(p_struct, const_cast<alglib_impl::odesolverstate*>(rhs.p_struct), NULL, ae_false) )
67  throw ap_error("ALGLIB: malloc error");
68  return *this;
69 }
70 
71 _odesolverstate_owner::~_odesolverstate_owner()
72 {
74  ae_free(p_struct);
75 }
76 
77 alglib_impl::odesolverstate* _odesolverstate_owner::c_ptr()
78 {
79  return p_struct;
80 }
81 
82 alglib_impl::odesolverstate* _odesolverstate_owner::c_ptr() const
83 {
84  return const_cast<alglib_impl::odesolverstate*>(p_struct);
85 }
86 odesolverstate::odesolverstate() : _odesolverstate_owner() ,needdy(p_struct->needdy),y(&p_struct->y),dy(&p_struct->dy),x(p_struct->x)
87 {
88 }
89 
91 {
92 }
93 
95 {
96  if( this==&rhs )
97  return *this;
99  return *this;
100 }
101 
103 {
104 }
105 
106 
107 /*************************************************************************
108 
109 *************************************************************************/
111 {
113  if( p_struct==NULL )
114  throw ap_error("ALGLIB: malloc error");
116  throw ap_error("ALGLIB: malloc error");
117 }
118 
120 {
122  if( p_struct==NULL )
123  throw ap_error("ALGLIB: malloc error");
124  if( !alglib_impl::_odesolverreport_init_copy(p_struct, const_cast<alglib_impl::odesolverreport*>(rhs.p_struct), NULL, ae_false) )
125  throw ap_error("ALGLIB: malloc error");
126 }
127 
129 {
130  if( this==&rhs )
131  return *this;
133  if( !alglib_impl::_odesolverreport_init_copy(p_struct, const_cast<alglib_impl::odesolverreport*>(rhs.p_struct), NULL, ae_false) )
134  throw ap_error("ALGLIB: malloc error");
135  return *this;
136 }
137 
139 {
141  ae_free(p_struct);
142 }
143 
145 {
146  return p_struct;
147 }
148 
150 {
151  return const_cast<alglib_impl::odesolverreport*>(p_struct);
152 }
153 odesolverreport::odesolverreport() : _odesolverreport_owner() ,nfev(p_struct->nfev),terminationtype(p_struct->terminationtype)
154 {
155 }
156 
158 {
159 }
160 
162 {
163  if( this==&rhs )
164  return *this;
166  return *this;
167 }
168 
170 {
171 }
172 
173 /*************************************************************************
174 Cash-Karp adaptive ODE solver.
175 
176 This subroutine solves ODE Y'=f(Y,x) with initial conditions Y(xs)=Ys
177 (here Y may be single variable or vector of N variables).
178 
179 INPUT PARAMETERS:
180  Y - initial conditions, array[0..N-1].
181  contains values of Y[] at X[0]
182  N - system size
183  X - points at which Y should be tabulated, array[0..M-1]
184  integrations starts at X[0], ends at X[M-1], intermediate
185  values at X[i] are returned too.
186  SHOULD BE ORDERED BY ASCENDING OR BY DESCENDING!!!!
187  M - number of intermediate points + first point + last point:
188  * M>2 means that you need both Y(X[M-1]) and M-2 values at
189  intermediate points
190  * M=2 means that you want just to integrate from X[0] to
191  X[1] and don't interested in intermediate values.
192  * M=1 means that you don't want to integrate :)
193  it is degenerate case, but it will be handled correctly.
194  * M<1 means error
195  Eps - tolerance (absolute/relative error on each step will be
196  less than Eps). When passing:
197  * Eps>0, it means desired ABSOLUTE error
198  * Eps<0, it means desired RELATIVE error. Relative errors
199  are calculated with respect to maximum values of Y seen
200  so far. Be careful to use this criterion when starting
201  from Y[] that are close to zero.
202  H - initial step lenth, it will be adjusted automatically
203  after the first step. If H=0, step will be selected
204  automatically (usually it will be equal to 0.001 of
205  min(x[i]-x[j])).
206 
207 OUTPUT PARAMETERS
208  State - structure which stores algorithm state between subsequent
209  calls of OdeSolverIteration. Used for reverse communication.
210  This structure should be passed to the OdeSolverIteration
211  subroutine.
212 
213 SEE ALSO
214  AutoGKSmoothW, AutoGKSingular, AutoGKIteration, AutoGKResults.
215 
216 
217  -- ALGLIB --
218  Copyright 01.09.2009 by Bochkanov Sergey
219 *************************************************************************/
220 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)
221 {
222  alglib_impl::ae_state _alglib_env_state;
223  alglib_impl::ae_state_init(&_alglib_env_state);
224  try
225  {
226  alglib_impl::odesolverrkck(const_cast<alglib_impl::ae_vector*>(y.c_ptr()), n, const_cast<alglib_impl::ae_vector*>(x.c_ptr()), m, eps, h, const_cast<alglib_impl::odesolverstate*>(state.c_ptr()), &_alglib_env_state);
227  alglib_impl::ae_state_clear(&_alglib_env_state);
228  return;
229  }
231  {
232  throw ap_error(_alglib_env_state.error_msg);
233  }
234 }
235 
236 /*************************************************************************
237 Cash-Karp adaptive ODE solver.
238 
239 This subroutine solves ODE Y'=f(Y,x) with initial conditions Y(xs)=Ys
240 (here Y may be single variable or vector of N variables).
241 
242 INPUT PARAMETERS:
243  Y - initial conditions, array[0..N-1].
244  contains values of Y[] at X[0]
245  N - system size
246  X - points at which Y should be tabulated, array[0..M-1]
247  integrations starts at X[0], ends at X[M-1], intermediate
248  values at X[i] are returned too.
249  SHOULD BE ORDERED BY ASCENDING OR BY DESCENDING!!!!
250  M - number of intermediate points + first point + last point:
251  * M>2 means that you need both Y(X[M-1]) and M-2 values at
252  intermediate points
253  * M=2 means that you want just to integrate from X[0] to
254  X[1] and don't interested in intermediate values.
255  * M=1 means that you don't want to integrate :)
256  it is degenerate case, but it will be handled correctly.
257  * M<1 means error
258  Eps - tolerance (absolute/relative error on each step will be
259  less than Eps). When passing:
260  * Eps>0, it means desired ABSOLUTE error
261  * Eps<0, it means desired RELATIVE error. Relative errors
262  are calculated with respect to maximum values of Y seen
263  so far. Be careful to use this criterion when starting
264  from Y[] that are close to zero.
265  H - initial step lenth, it will be adjusted automatically
266  after the first step. If H=0, step will be selected
267  automatically (usually it will be equal to 0.001 of
268  min(x[i]-x[j])).
269 
270 OUTPUT PARAMETERS
271  State - structure which stores algorithm state between subsequent
272  calls of OdeSolverIteration. Used for reverse communication.
273  This structure should be passed to the OdeSolverIteration
274  subroutine.
275 
276 SEE ALSO
277  AutoGKSmoothW, AutoGKSingular, AutoGKIteration, AutoGKResults.
278 
279 
280  -- ALGLIB --
281  Copyright 01.09.2009 by Bochkanov Sergey
282 *************************************************************************/
283 void odesolverrkck(const real_1d_array &y, const real_1d_array &x, const double eps, const double h, odesolverstate &state)
284 {
285  alglib_impl::ae_state _alglib_env_state;
286  ae_int_t n;
287  ae_int_t m;
288 
289  n = y.length();
290  m = x.length();
291  alglib_impl::ae_state_init(&_alglib_env_state);
292  try
293  {
294  alglib_impl::odesolverrkck(const_cast<alglib_impl::ae_vector*>(y.c_ptr()), n, const_cast<alglib_impl::ae_vector*>(x.c_ptr()), m, eps, h, const_cast<alglib_impl::odesolverstate*>(state.c_ptr()), &_alglib_env_state);
295 
296  alglib_impl::ae_state_clear(&_alglib_env_state);
297  return;
298  }
300  {
301  throw ap_error(_alglib_env_state.error_msg);
302  }
303 }
304 
305 /*************************************************************************
306 This function provides reverse communication interface
307 Reverse communication interface is not documented or recommended to use.
308 See below for functions which provide better documented API
309 *************************************************************************/
311 {
312  alglib_impl::ae_state _alglib_env_state;
313  alglib_impl::ae_state_init(&_alglib_env_state);
314  try
315  {
316  ae_bool result = alglib_impl::odesolveriteration(const_cast<alglib_impl::odesolverstate*>(state.c_ptr()), &_alglib_env_state);
317  alglib_impl::ae_state_clear(&_alglib_env_state);
318  return *(reinterpret_cast<bool*>(&result));
319  }
321  {
322  throw ap_error(_alglib_env_state.error_msg);
323  }
324 }
325 
326 
328  void (*diff)(const real_1d_array &y, double x, real_1d_array &dy, void *ptr),
329  void *ptr){
330  alglib_impl::ae_state _alglib_env_state;
331  if( diff==NULL )
332  throw ap_error("ALGLIB: error in 'odesolversolve()' (diff is NULL)");
333  alglib_impl::ae_state_init(&_alglib_env_state);
334  try
335  {
336  while( alglib_impl::odesolveriteration(state.c_ptr(), &_alglib_env_state) )
337  {
338  if( state.needdy )
339  {
340  diff(state.y, state.x, state.dy, ptr);
341  continue;
342  }
343  throw ap_error("ALGLIB: unexpected error in 'odesolversolve'");
344  }
345  alglib_impl::ae_state_clear(&_alglib_env_state);
346  }
348  {
349  throw ap_error(_alglib_env_state.error_msg);
350  }
351 }
352 
353 
354 
355 /*************************************************************************
356 ODE solver results
357 
358 Called after OdeSolverIteration returned False.
359 
360 INPUT PARAMETERS:
361  State - algorithm state (used by OdeSolverIteration).
362 
363 OUTPUT PARAMETERS:
364  M - number of tabulated values, M>=1
365  XTbl - array[0..M-1], values of X
366  YTbl - array[0..M-1,0..N-1], values of Y in X[i]
367  Rep - solver report:
368  * Rep.TerminationType completion code:
369  * -2 X is not ordered by ascending/descending or
370  there are non-distinct X[], i.e. X[i]=X[i+1]
371  * -1 incorrect parameters were specified
372  * 1 task has been solved
373  * Rep.NFEV contains number of function calculations
374 
375  -- ALGLIB --
376  Copyright 01.09.2009 by Bochkanov Sergey
377 *************************************************************************/
379 {
380  alglib_impl::ae_state _alglib_env_state;
381  alglib_impl::ae_state_init(&_alglib_env_state);
382  try
383  {
384  alglib_impl::odesolverresults(const_cast<alglib_impl::odesolverstate*>(state.c_ptr()), &m, const_cast<alglib_impl::ae_vector*>(xtbl.c_ptr()), const_cast<alglib_impl::ae_matrix*>(ytbl.c_ptr()), const_cast<alglib_impl::odesolverreport*>(rep.c_ptr()), &_alglib_env_state);
385  alglib_impl::ae_state_clear(&_alglib_env_state);
386  return;
387  }
389  {
390  throw ap_error(_alglib_env_state.error_msg);
391  }
392 }
393 }
394 
396 //
397 // THIS SECTION CONTAINS IMPLEMENTATION OF COMPUTATIONAL CORE
398 //
400 namespace alglib_impl
401 {
402 static double odesolver_odesolvermaxgrow = 3.0;
403 static double odesolver_odesolvermaxshrink = 10.0;
404 static void odesolver_odesolverinit(ae_int_t solvertype,
405  /* Real */ ae_vector* y,
406  ae_int_t n,
407  /* Real */ ae_vector* x,
408  ae_int_t m,
409  double eps,
410  double h,
411  odesolverstate* state,
412  ae_state *_state);
413 
414 
415 
416 
417 
418 /*************************************************************************
419 Cash-Karp adaptive ODE solver.
420 
421 This subroutine solves ODE Y'=f(Y,x) with initial conditions Y(xs)=Ys
422 (here Y may be single variable or vector of N variables).
423 
424 INPUT PARAMETERS:
425  Y - initial conditions, array[0..N-1].
426  contains values of Y[] at X[0]
427  N - system size
428  X - points at which Y should be tabulated, array[0..M-1]
429  integrations starts at X[0], ends at X[M-1], intermediate
430  values at X[i] are returned too.
431  SHOULD BE ORDERED BY ASCENDING OR BY DESCENDING!!!!
432  M - number of intermediate points + first point + last point:
433  * M>2 means that you need both Y(X[M-1]) and M-2 values at
434  intermediate points
435  * M=2 means that you want just to integrate from X[0] to
436  X[1] and don't interested in intermediate values.
437  * M=1 means that you don't want to integrate :)
438  it is degenerate case, but it will be handled correctly.
439  * M<1 means error
440  Eps - tolerance (absolute/relative error on each step will be
441  less than Eps). When passing:
442  * Eps>0, it means desired ABSOLUTE error
443  * Eps<0, it means desired RELATIVE error. Relative errors
444  are calculated with respect to maximum values of Y seen
445  so far. Be careful to use this criterion when starting
446  from Y[] that are close to zero.
447  H - initial step lenth, it will be adjusted automatically
448  after the first step. If H=0, step will be selected
449  automatically (usually it will be equal to 0.001 of
450  min(x[i]-x[j])).
451 
452 OUTPUT PARAMETERS
453  State - structure which stores algorithm state between subsequent
454  calls of OdeSolverIteration. Used for reverse communication.
455  This structure should be passed to the OdeSolverIteration
456  subroutine.
457 
458 SEE ALSO
459  AutoGKSmoothW, AutoGKSingular, AutoGKIteration, AutoGKResults.
460 
461 
462  -- ALGLIB --
463  Copyright 01.09.2009 by Bochkanov Sergey
464 *************************************************************************/
465 void odesolverrkck(/* Real */ ae_vector* y,
466  ae_int_t n,
467  /* Real */ ae_vector* x,
468  ae_int_t m,
469  double eps,
470  double h,
471  odesolverstate* state,
472  ae_state *_state)
473 {
474 
475  _odesolverstate_clear(state);
476 
477  ae_assert(n>=1, "ODESolverRKCK: N<1!", _state);
478  ae_assert(m>=1, "ODESolverRKCK: M<1!", _state);
479  ae_assert(y->cnt>=n, "ODESolverRKCK: Length(Y)<N!", _state);
480  ae_assert(x->cnt>=m, "ODESolverRKCK: Length(X)<M!", _state);
481  ae_assert(isfinitevector(y, n, _state), "ODESolverRKCK: Y contains infinite or NaN values!", _state);
482  ae_assert(isfinitevector(x, m, _state), "ODESolverRKCK: Y contains infinite or NaN values!", _state);
483  ae_assert(ae_isfinite(eps, _state), "ODESolverRKCK: Eps is not finite!", _state);
484  ae_assert(ae_fp_neq(eps,0), "ODESolverRKCK: Eps is zero!", _state);
485  ae_assert(ae_isfinite(h, _state), "ODESolverRKCK: H is not finite!", _state);
486  odesolver_odesolverinit(0, y, n, x, m, eps, h, state, _state);
487 }
488 
489 
490 /*************************************************************************
491 
492  -- ALGLIB --
493  Copyright 01.09.2009 by Bochkanov Sergey
494 *************************************************************************/
496 {
497  ae_int_t n;
498  ae_int_t m;
499  ae_int_t i;
500  ae_int_t j;
501  ae_int_t k;
502  double xc;
503  double v;
504  double h;
505  double h2;
506  ae_bool gridpoint;
507  double err;
508  double maxgrowpow;
509  ae_int_t klimit;
510  ae_bool result;
511 
512 
513 
514  /*
515  * Reverse communication preparations
516  * I know it looks ugly, but it works the same way
517  * anywhere from C++ to Python.
518  *
519  * This code initializes locals by:
520  * * random values determined during code
521  * generation - on first subroutine call
522  * * values from previous call - on subsequent calls
523  */
524  if( state->rstate.stage>=0 )
525  {
526  n = state->rstate.ia.ptr.p_int[0];
527  m = state->rstate.ia.ptr.p_int[1];
528  i = state->rstate.ia.ptr.p_int[2];
529  j = state->rstate.ia.ptr.p_int[3];
530  k = state->rstate.ia.ptr.p_int[4];
531  klimit = state->rstate.ia.ptr.p_int[5];
532  gridpoint = state->rstate.ba.ptr.p_bool[0];
533  xc = state->rstate.ra.ptr.p_double[0];
534  v = state->rstate.ra.ptr.p_double[1];
535  h = state->rstate.ra.ptr.p_double[2];
536  h2 = state->rstate.ra.ptr.p_double[3];
537  err = state->rstate.ra.ptr.p_double[4];
538  maxgrowpow = state->rstate.ra.ptr.p_double[5];
539  }
540  else
541  {
542  n = -983;
543  m = -989;
544  i = -834;
545  j = 900;
546  k = -287;
547  klimit = 364;
548  gridpoint = ae_false;
549  xc = -338;
550  v = -686;
551  h = 912;
552  h2 = 585;
553  err = 497;
554  maxgrowpow = -271;
555  }
556  if( state->rstate.stage==0 )
557  {
558  goto lbl_0;
559  }
560 
561  /*
562  * Routine body
563  */
564 
565  /*
566  * prepare
567  */
568  if( state->repterminationtype!=0 )
569  {
570  result = ae_false;
571  return result;
572  }
573  n = state->n;
574  m = state->m;
575  h = state->h;
576  maxgrowpow = ae_pow(odesolver_odesolvermaxgrow, 5, _state);
577  state->repnfev = 0;
578 
579  /*
580  * some preliminary checks for internal errors
581  * after this we assume that H>0 and M>1
582  */
583  ae_assert(ae_fp_greater(state->h,0), "ODESolver: internal error", _state);
584  ae_assert(m>1, "ODESolverIteration: internal error", _state);
585 
586  /*
587  * choose solver
588  */
589  if( state->solvertype!=0 )
590  {
591  goto lbl_1;
592  }
593 
594  /*
595  * Cask-Karp solver
596  * Prepare coefficients table.
597  * Check it for errors
598  */
599  ae_vector_set_length(&state->rka, 6, _state);
600  state->rka.ptr.p_double[0] = 0;
601  state->rka.ptr.p_double[1] = (double)1/(double)5;
602  state->rka.ptr.p_double[2] = (double)3/(double)10;
603  state->rka.ptr.p_double[3] = (double)3/(double)5;
604  state->rka.ptr.p_double[4] = 1;
605  state->rka.ptr.p_double[5] = (double)7/(double)8;
606  ae_matrix_set_length(&state->rkb, 6, 5, _state);
607  state->rkb.ptr.pp_double[1][0] = (double)1/(double)5;
608  state->rkb.ptr.pp_double[2][0] = (double)3/(double)40;
609  state->rkb.ptr.pp_double[2][1] = (double)9/(double)40;
610  state->rkb.ptr.pp_double[3][0] = (double)3/(double)10;
611  state->rkb.ptr.pp_double[3][1] = -(double)9/(double)10;
612  state->rkb.ptr.pp_double[3][2] = (double)6/(double)5;
613  state->rkb.ptr.pp_double[4][0] = -(double)11/(double)54;
614  state->rkb.ptr.pp_double[4][1] = (double)5/(double)2;
615  state->rkb.ptr.pp_double[4][2] = -(double)70/(double)27;
616  state->rkb.ptr.pp_double[4][3] = (double)35/(double)27;
617  state->rkb.ptr.pp_double[5][0] = (double)1631/(double)55296;
618  state->rkb.ptr.pp_double[5][1] = (double)175/(double)512;
619  state->rkb.ptr.pp_double[5][2] = (double)575/(double)13824;
620  state->rkb.ptr.pp_double[5][3] = (double)44275/(double)110592;
621  state->rkb.ptr.pp_double[5][4] = (double)253/(double)4096;
622  ae_vector_set_length(&state->rkc, 6, _state);
623  state->rkc.ptr.p_double[0] = (double)37/(double)378;
624  state->rkc.ptr.p_double[1] = 0;
625  state->rkc.ptr.p_double[2] = (double)250/(double)621;
626  state->rkc.ptr.p_double[3] = (double)125/(double)594;
627  state->rkc.ptr.p_double[4] = 0;
628  state->rkc.ptr.p_double[5] = (double)512/(double)1771;
629  ae_vector_set_length(&state->rkcs, 6, _state);
630  state->rkcs.ptr.p_double[0] = (double)2825/(double)27648;
631  state->rkcs.ptr.p_double[1] = 0;
632  state->rkcs.ptr.p_double[2] = (double)18575/(double)48384;
633  state->rkcs.ptr.p_double[3] = (double)13525/(double)55296;
634  state->rkcs.ptr.p_double[4] = (double)277/(double)14336;
635  state->rkcs.ptr.p_double[5] = (double)1/(double)4;
636  ae_matrix_set_length(&state->rkk, 6, n, _state);
637 
638  /*
639  * Main cycle consists of two iterations:
640  * * outer where we travel from X[i-1] to X[i]
641  * * inner where we travel inside [X[i-1],X[i]]
642  */
643  ae_matrix_set_length(&state->ytbl, m, n, _state);
644  ae_vector_set_length(&state->escale, n, _state);
645  ae_vector_set_length(&state->yn, n, _state);
646  ae_vector_set_length(&state->yns, n, _state);
647  xc = state->xg.ptr.p_double[0];
648  ae_v_move(&state->ytbl.ptr.pp_double[0][0], 1, &state->yc.ptr.p_double[0], 1, ae_v_len(0,n-1));
649  for(j=0; j<=n-1; j++)
650  {
651  state->escale.ptr.p_double[j] = 0;
652  }
653  i = 1;
654 lbl_3:
655  if( i>m-1 )
656  {
657  goto lbl_5;
658  }
659 
660  /*
661  * begin inner iteration
662  */
663 lbl_6:
664  if( ae_false )
665  {
666  goto lbl_7;
667  }
668 
669  /*
670  * truncate step if needed (beyond right boundary).
671  * determine should we store X or not
672  */
673  if( ae_fp_greater_eq(xc+h,state->xg.ptr.p_double[i]) )
674  {
675  h = state->xg.ptr.p_double[i]-xc;
676  gridpoint = ae_true;
677  }
678  else
679  {
680  gridpoint = ae_false;
681  }
682 
683  /*
684  * Update error scale maximums
685  *
686  * These maximums are initialized by zeros,
687  * then updated every iterations.
688  */
689  for(j=0; j<=n-1; j++)
690  {
691  state->escale.ptr.p_double[j] = ae_maxreal(state->escale.ptr.p_double[j], ae_fabs(state->yc.ptr.p_double[j], _state), _state);
692  }
693 
694  /*
695  * make one step:
696  * 1. calculate all info needed to do step
697  * 2. update errors scale maximums using values/derivatives
698  * obtained during (1)
699  *
700  * Take into account that we use scaling of X to reduce task
701  * to the form where x[0] < x[1] < ... < x[n-1]. So X is
702  * replaced by x=xscale*t, and dy/dx=f(y,x) is replaced
703  * by dy/dt=xscale*f(y,xscale*t).
704  */
705  ae_v_move(&state->yn.ptr.p_double[0], 1, &state->yc.ptr.p_double[0], 1, ae_v_len(0,n-1));
706  ae_v_move(&state->yns.ptr.p_double[0], 1, &state->yc.ptr.p_double[0], 1, ae_v_len(0,n-1));
707  k = 0;
708 lbl_8:
709  if( k>5 )
710  {
711  goto lbl_10;
712  }
713 
714  /*
715  * prepare data for the next update of YN/YNS
716  */
717  state->x = state->xscale*(xc+state->rka.ptr.p_double[k]*h);
718  ae_v_move(&state->y.ptr.p_double[0], 1, &state->yc.ptr.p_double[0], 1, ae_v_len(0,n-1));
719  for(j=0; j<=k-1; j++)
720  {
721  v = state->rkb.ptr.pp_double[k][j];
722  ae_v_addd(&state->y.ptr.p_double[0], 1, &state->rkk.ptr.pp_double[j][0], 1, ae_v_len(0,n-1), v);
723  }
724  state->needdy = ae_true;
725  state->rstate.stage = 0;
726  goto lbl_rcomm;
727 lbl_0:
728  state->needdy = ae_false;
729  state->repnfev = state->repnfev+1;
730  v = h*state->xscale;
731  ae_v_moved(&state->rkk.ptr.pp_double[k][0], 1, &state->dy.ptr.p_double[0], 1, ae_v_len(0,n-1), v);
732 
733  /*
734  * update YN/YNS
735  */
736  v = state->rkc.ptr.p_double[k];
737  ae_v_addd(&state->yn.ptr.p_double[0], 1, &state->rkk.ptr.pp_double[k][0], 1, ae_v_len(0,n-1), v);
738  v = state->rkcs.ptr.p_double[k];
739  ae_v_addd(&state->yns.ptr.p_double[0], 1, &state->rkk.ptr.pp_double[k][0], 1, ae_v_len(0,n-1), v);
740  k = k+1;
741  goto lbl_8;
742 lbl_10:
743 
744  /*
745  * estimate error
746  */
747  err = 0;
748  for(j=0; j<=n-1; j++)
749  {
750  if( !state->fraceps )
751  {
752 
753  /*
754  * absolute error is estimated
755  */
756  err = ae_maxreal(err, ae_fabs(state->yn.ptr.p_double[j]-state->yns.ptr.p_double[j], _state), _state);
757  }
758  else
759  {
760 
761  /*
762  * Relative error is estimated
763  */
764  v = state->escale.ptr.p_double[j];
765  if( ae_fp_eq(v,0) )
766  {
767  v = 1;
768  }
769  err = ae_maxreal(err, ae_fabs(state->yn.ptr.p_double[j]-state->yns.ptr.p_double[j], _state)/v, _state);
770  }
771  }
772 
773  /*
774  * calculate new step, restart if necessary
775  */
776  if( ae_fp_less_eq(maxgrowpow*err,state->eps) )
777  {
778  h2 = odesolver_odesolvermaxgrow*h;
779  }
780  else
781  {
782  h2 = h*ae_pow(state->eps/err, 0.2, _state);
783  }
784  if( ae_fp_less(h2,h/odesolver_odesolvermaxshrink) )
785  {
786  h2 = h/odesolver_odesolvermaxshrink;
787  }
788  if( ae_fp_greater(err,state->eps) )
789  {
790  h = h2;
791  goto lbl_6;
792  }
793 
794  /*
795  * advance position
796  */
797  xc = xc+h;
798  ae_v_move(&state->yc.ptr.p_double[0], 1, &state->yn.ptr.p_double[0], 1, ae_v_len(0,n-1));
799 
800  /*
801  * update H
802  */
803  h = h2;
804 
805  /*
806  * break on grid point
807  */
808  if( gridpoint )
809  {
810  goto lbl_7;
811  }
812  goto lbl_6;
813 lbl_7:
814 
815  /*
816  * save result
817  */
818  ae_v_move(&state->ytbl.ptr.pp_double[i][0], 1, &state->yc.ptr.p_double[0], 1, ae_v_len(0,n-1));
819  i = i+1;
820  goto lbl_3;
821 lbl_5:
822  state->repterminationtype = 1;
823  result = ae_false;
824  return result;
825 lbl_1:
826  result = ae_false;
827  return result;
828 
829  /*
830  * Saving state
831  */
832 lbl_rcomm:
833  result = ae_true;
834  state->rstate.ia.ptr.p_int[0] = n;
835  state->rstate.ia.ptr.p_int[1] = m;
836  state->rstate.ia.ptr.p_int[2] = i;
837  state->rstate.ia.ptr.p_int[3] = j;
838  state->rstate.ia.ptr.p_int[4] = k;
839  state->rstate.ia.ptr.p_int[5] = klimit;
840  state->rstate.ba.ptr.p_bool[0] = gridpoint;
841  state->rstate.ra.ptr.p_double[0] = xc;
842  state->rstate.ra.ptr.p_double[1] = v;
843  state->rstate.ra.ptr.p_double[2] = h;
844  state->rstate.ra.ptr.p_double[3] = h2;
845  state->rstate.ra.ptr.p_double[4] = err;
846  state->rstate.ra.ptr.p_double[5] = maxgrowpow;
847  return result;
848 }
849 
850 
851 /*************************************************************************
852 ODE solver results
853 
854 Called after OdeSolverIteration returned False.
855 
856 INPUT PARAMETERS:
857  State - algorithm state (used by OdeSolverIteration).
858 
859 OUTPUT PARAMETERS:
860  M - number of tabulated values, M>=1
861  XTbl - array[0..M-1], values of X
862  YTbl - array[0..M-1,0..N-1], values of Y in X[i]
863  Rep - solver report:
864  * Rep.TerminationType completion code:
865  * -2 X is not ordered by ascending/descending or
866  there are non-distinct X[], i.e. X[i]=X[i+1]
867  * -1 incorrect parameters were specified
868  * 1 task has been solved
869  * Rep.NFEV contains number of function calculations
870 
871  -- ALGLIB --
872  Copyright 01.09.2009 by Bochkanov Sergey
873 *************************************************************************/
875  ae_int_t* m,
876  /* Real */ ae_vector* xtbl,
877  /* Real */ ae_matrix* ytbl,
878  odesolverreport* rep,
879  ae_state *_state)
880 {
881  double v;
882  ae_int_t i;
883 
884  *m = 0;
885  ae_vector_clear(xtbl);
886  ae_matrix_clear(ytbl);
888 
889  rep->terminationtype = state->repterminationtype;
890  if( rep->terminationtype>0 )
891  {
892  *m = state->m;
893  rep->nfev = state->repnfev;
894  ae_vector_set_length(xtbl, state->m, _state);
895  v = state->xscale;
896  ae_v_moved(&xtbl->ptr.p_double[0], 1, &state->xg.ptr.p_double[0], 1, ae_v_len(0,state->m-1), v);
897  ae_matrix_set_length(ytbl, state->m, state->n, _state);
898  for(i=0; i<=state->m-1; i++)
899  {
900  ae_v_move(&ytbl->ptr.pp_double[i][0], 1, &state->ytbl.ptr.pp_double[i][0], 1, ae_v_len(0,state->n-1));
901  }
902  }
903  else
904  {
905  rep->nfev = 0;
906  }
907 }
908 
909 
910 /*************************************************************************
911 Internal initialization subroutine
912 *************************************************************************/
913 static void odesolver_odesolverinit(ae_int_t solvertype,
914  /* Real */ ae_vector* y,
915  ae_int_t n,
916  /* Real */ ae_vector* x,
917  ae_int_t m,
918  double eps,
919  double h,
920  odesolverstate* state,
921  ae_state *_state)
922 {
923  ae_int_t i;
924  double v;
925 
926  _odesolverstate_clear(state);
927 
928 
929  /*
930  * Prepare RComm
931  */
932  ae_vector_set_length(&state->rstate.ia, 5+1, _state);
933  ae_vector_set_length(&state->rstate.ba, 0+1, _state);
934  ae_vector_set_length(&state->rstate.ra, 5+1, _state);
935  state->rstate.stage = -1;
936  state->needdy = ae_false;
937 
938  /*
939  * check parameters.
940  */
941  if( (n<=0||m<1)||ae_fp_eq(eps,0) )
942  {
943  state->repterminationtype = -1;
944  return;
945  }
946  if( ae_fp_less(h,0) )
947  {
948  h = -h;
949  }
950 
951  /*
952  * quick exit if necessary.
953  * after this block we assume that M>1
954  */
955  if( m==1 )
956  {
957  state->repnfev = 0;
958  state->repterminationtype = 1;
959  ae_matrix_set_length(&state->ytbl, 1, n, _state);
960  ae_v_move(&state->ytbl.ptr.pp_double[0][0], 1, &y->ptr.p_double[0], 1, ae_v_len(0,n-1));
961  ae_vector_set_length(&state->xg, m, _state);
962  ae_v_move(&state->xg.ptr.p_double[0], 1, &x->ptr.p_double[0], 1, ae_v_len(0,m-1));
963  return;
964  }
965 
966  /*
967  * check again: correct order of X[]
968  */
969  if( ae_fp_eq(x->ptr.p_double[1],x->ptr.p_double[0]) )
970  {
971  state->repterminationtype = -2;
972  return;
973  }
974  for(i=1; i<=m-1; i++)
975  {
976  if( (ae_fp_greater(x->ptr.p_double[1],x->ptr.p_double[0])&&ae_fp_less_eq(x->ptr.p_double[i],x->ptr.p_double[i-1]))||(ae_fp_less(x->ptr.p_double[1],x->ptr.p_double[0])&&ae_fp_greater_eq(x->ptr.p_double[i],x->ptr.p_double[i-1])) )
977  {
978  state->repterminationtype = -2;
979  return;
980  }
981  }
982 
983  /*
984  * auto-select H if necessary
985  */
986  if( ae_fp_eq(h,0) )
987  {
988  v = ae_fabs(x->ptr.p_double[1]-x->ptr.p_double[0], _state);
989  for(i=2; i<=m-1; i++)
990  {
991  v = ae_minreal(v, ae_fabs(x->ptr.p_double[i]-x->ptr.p_double[i-1], _state), _state);
992  }
993  h = 0.001*v;
994  }
995 
996  /*
997  * store parameters
998  */
999  state->n = n;
1000  state->m = m;
1001  state->h = h;
1002  state->eps = ae_fabs(eps, _state);
1003  state->fraceps = ae_fp_less(eps,0);
1004  ae_vector_set_length(&state->xg, m, _state);
1005  ae_v_move(&state->xg.ptr.p_double[0], 1, &x->ptr.p_double[0], 1, ae_v_len(0,m-1));
1006  if( ae_fp_greater(x->ptr.p_double[1],x->ptr.p_double[0]) )
1007  {
1008  state->xscale = 1;
1009  }
1010  else
1011  {
1012  state->xscale = -1;
1013  ae_v_muld(&state->xg.ptr.p_double[0], 1, ae_v_len(0,m-1), -1);
1014  }
1015  ae_vector_set_length(&state->yc, n, _state);
1016  ae_v_move(&state->yc.ptr.p_double[0], 1, &y->ptr.p_double[0], 1, ae_v_len(0,n-1));
1017  state->solvertype = solvertype;
1018  state->repterminationtype = 0;
1019 
1020  /*
1021  * Allocate arrays
1022  */
1023  ae_vector_set_length(&state->y, n, _state);
1024  ae_vector_set_length(&state->dy, n, _state);
1025 }
1026 
1027 
1028 ae_bool _odesolverstate_init(void* _p, ae_state *_state, ae_bool make_automatic)
1029 {
1030  odesolverstate *p = (odesolverstate*)_p;
1031  ae_touch_ptr((void*)p);
1032  if( !ae_vector_init(&p->yc, 0, DT_REAL, _state, make_automatic) )
1033  return ae_false;
1034  if( !ae_vector_init(&p->escale, 0, DT_REAL, _state, make_automatic) )
1035  return ae_false;
1036  if( !ae_vector_init(&p->xg, 0, DT_REAL, _state, make_automatic) )
1037  return ae_false;
1038  if( !ae_vector_init(&p->y, 0, DT_REAL, _state, make_automatic) )
1039  return ae_false;
1040  if( !ae_vector_init(&p->dy, 0, DT_REAL, _state, make_automatic) )
1041  return ae_false;
1042  if( !ae_matrix_init(&p->ytbl, 0, 0, DT_REAL, _state, make_automatic) )
1043  return ae_false;
1044  if( !ae_vector_init(&p->yn, 0, DT_REAL, _state, make_automatic) )
1045  return ae_false;
1046  if( !ae_vector_init(&p->yns, 0, DT_REAL, _state, make_automatic) )
1047  return ae_false;
1048  if( !ae_vector_init(&p->rka, 0, DT_REAL, _state, make_automatic) )
1049  return ae_false;
1050  if( !ae_vector_init(&p->rkc, 0, DT_REAL, _state, make_automatic) )
1051  return ae_false;
1052  if( !ae_vector_init(&p->rkcs, 0, DT_REAL, _state, make_automatic) )
1053  return ae_false;
1054  if( !ae_matrix_init(&p->rkb, 0, 0, DT_REAL, _state, make_automatic) )
1055  return ae_false;
1056  if( !ae_matrix_init(&p->rkk, 0, 0, DT_REAL, _state, make_automatic) )
1057  return ae_false;
1058  if( !_rcommstate_init(&p->rstate, _state, make_automatic) )
1059  return ae_false;
1060  return ae_true;
1061 }
1062 
1063 
1064 ae_bool _odesolverstate_init_copy(void* _dst, void* _src, ae_state *_state, ae_bool make_automatic)
1065 {
1066  odesolverstate *dst = (odesolverstate*)_dst;
1067  odesolverstate *src = (odesolverstate*)_src;
1068  dst->n = src->n;
1069  dst->m = src->m;
1070  dst->xscale = src->xscale;
1071  dst->h = src->h;
1072  dst->eps = src->eps;
1073  dst->fraceps = src->fraceps;
1074  if( !ae_vector_init_copy(&dst->yc, &src->yc, _state, make_automatic) )
1075  return ae_false;
1076  if( !ae_vector_init_copy(&dst->escale, &src->escale, _state, make_automatic) )
1077  return ae_false;
1078  if( !ae_vector_init_copy(&dst->xg, &src->xg, _state, make_automatic) )
1079  return ae_false;
1080  dst->solvertype = src->solvertype;
1081  dst->needdy = src->needdy;
1082  dst->x = src->x;
1083  if( !ae_vector_init_copy(&dst->y, &src->y, _state, make_automatic) )
1084  return ae_false;
1085  if( !ae_vector_init_copy(&dst->dy, &src->dy, _state, make_automatic) )
1086  return ae_false;
1087  if( !ae_matrix_init_copy(&dst->ytbl, &src->ytbl, _state, make_automatic) )
1088  return ae_false;
1090  dst->repnfev = src->repnfev;
1091  if( !ae_vector_init_copy(&dst->yn, &src->yn, _state, make_automatic) )
1092  return ae_false;
1093  if( !ae_vector_init_copy(&dst->yns, &src->yns, _state, make_automatic) )
1094  return ae_false;
1095  if( !ae_vector_init_copy(&dst->rka, &src->rka, _state, make_automatic) )
1096  return ae_false;
1097  if( !ae_vector_init_copy(&dst->rkc, &src->rkc, _state, make_automatic) )
1098  return ae_false;
1099  if( !ae_vector_init_copy(&dst->rkcs, &src->rkcs, _state, make_automatic) )
1100  return ae_false;
1101  if( !ae_matrix_init_copy(&dst->rkb, &src->rkb, _state, make_automatic) )
1102  return ae_false;
1103  if( !ae_matrix_init_copy(&dst->rkk, &src->rkk, _state, make_automatic) )
1104  return ae_false;
1105  if( !_rcommstate_init_copy(&dst->rstate, &src->rstate, _state, make_automatic) )
1106  return ae_false;
1107  return ae_true;
1108 }
1109 
1110 
1112 {
1113  odesolverstate *p = (odesolverstate*)_p;
1114  ae_touch_ptr((void*)p);
1115  ae_vector_clear(&p->yc);
1116  ae_vector_clear(&p->escale);
1117  ae_vector_clear(&p->xg);
1118  ae_vector_clear(&p->y);
1119  ae_vector_clear(&p->dy);
1120  ae_matrix_clear(&p->ytbl);
1121  ae_vector_clear(&p->yn);
1122  ae_vector_clear(&p->yns);
1123  ae_vector_clear(&p->rka);
1124  ae_vector_clear(&p->rkc);
1125  ae_vector_clear(&p->rkcs);
1126  ae_matrix_clear(&p->rkb);
1127  ae_matrix_clear(&p->rkk);
1128  _rcommstate_clear(&p->rstate);
1129 }
1130 
1131 
1133 {
1134  odesolverstate *p = (odesolverstate*)_p;
1135  ae_touch_ptr((void*)p);
1136  ae_vector_destroy(&p->yc);
1137  ae_vector_destroy(&p->escale);
1138  ae_vector_destroy(&p->xg);
1139  ae_vector_destroy(&p->y);
1140  ae_vector_destroy(&p->dy);
1141  ae_matrix_destroy(&p->ytbl);
1142  ae_vector_destroy(&p->yn);
1143  ae_vector_destroy(&p->yns);
1144  ae_vector_destroy(&p->rka);
1145  ae_vector_destroy(&p->rkc);
1146  ae_vector_destroy(&p->rkcs);
1147  ae_matrix_destroy(&p->rkb);
1148  ae_matrix_destroy(&p->rkk);
1149  _rcommstate_destroy(&p->rstate);
1150 }
1151 
1152 
1153 ae_bool _odesolverreport_init(void* _p, ae_state *_state, ae_bool make_automatic)
1154 {
1155  odesolverreport *p = (odesolverreport*)_p;
1156  ae_touch_ptr((void*)p);
1157  return ae_true;
1158 }
1159 
1160 
1161 ae_bool _odesolverreport_init_copy(void* _dst, void* _src, ae_state *_state, ae_bool make_automatic)
1162 {
1163  odesolverreport *dst = (odesolverreport*)_dst;
1164  odesolverreport *src = (odesolverreport*)_src;
1165  dst->nfev = src->nfev;
1166  dst->terminationtype = src->terminationtype;
1167  return ae_true;
1168 }
1169 
1170 
1172 {
1173  odesolverreport *p = (odesolverreport*)_p;
1174  ae_touch_ptr((void*)p);
1175 }
1176 
1177 
1179 {
1180  odesolverreport *p = (odesolverreport*)_p;
1181  ae_touch_ptr((void*)p);
1182 }
1183 
1184 
1185 
1186 }
1187 
struct alglib_impl::ae_state ae_state
ae_bool ae_fp_greater_eq(double v1, double v2)
Definition: ap.cpp:1351
void ae_v_moved(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n, double alpha)
Definition: ap.cpp:4425
void ae_v_muld(double *vdst, ae_int_t stride_dst, ae_int_t n, double alpha)
Definition: ap.cpp:4538
double ae_fabs(double x, ae_state *state)
Definition: ap.cpp:1520
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)
double ae_pow(double x, double y, ae_state *state)
Definition: ap.cpp:1684
#define ae_false
Definition: ap.h:196
void * ae_malloc(size_t size, ae_state *state)
Definition: ap.cpp:222
ae_bool _odesolverstate_init_copy(void *_dst, void *_src, ae_state *_state, ae_bool make_automatic)
union alglib_impl::ae_matrix::@12 ptr
bool odesolveriteration(const odesolverstate &state)
static double * y
ae_bool _odesolverreport_init_copy(void *_dst, void *_src, ae_state *_state, ae_bool make_automatic)
odesolverreport & operator=(const odesolverreport &rhs)
ae_vector ia
Definition: ap.h:837
void odesolverresults(odesolverstate *state, ae_int_t *m, ae_vector *xtbl, ae_matrix *ytbl, odesolverreport *rep, ae_state *_state)
double * p_double
Definition: ap.h:437
void ae_state_clear(ae_state *state)
Definition: ap.cpp:373
const alglib_impl::ae_matrix * c_ptr() const
Definition: ap.cpp:6463
void _odesolverstate_clear(void *_p)
ae_bool ae_fp_eq(double v1, double v2)
Definition: ap.cpp:1313
cmache_1 eps
alglib_impl::odesolverreport * p_struct
ae_bool ae_matrix_init_copy(ae_matrix *dst, ae_matrix *src, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:801
ae_bool ae_matrix_init(ae_matrix *dst, ae_int_t rows, ae_int_t cols, ae_datatype datatype, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:756
doublereal * x
void ae_matrix_destroy(ae_matrix *dst)
Definition: ap.cpp:909
#define i
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
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)
alglib_impl::odesolverstate * c_ptr()
void _rcommstate_destroy(rcommstate *p)
Definition: ap.cpp:4605
ae_int_t ae_v_len(ae_int_t a, ae_int_t b)
Definition: ap.cpp:4562
void ae_vector_destroy(ae_vector *dst)
Definition: ap.cpp:707
ae_bool _rcommstate_init(rcommstate *p, ae_state *_state, ae_bool make_automatic)
Definition: ap.cpp:4570
odesolverstate & operator=(const odesolverstate &rhs)
ae_bool _rcommstate_init_copy(rcommstate *dst, rcommstate *src, ae_state *_state, ae_bool make_automatic)
Definition: ap.cpp:4583
void ae_v_move(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n)
Definition: ap.cpp:4371
void _odesolverreport_destroy(void *_p)
void ae_vector_clear(ae_vector *dst)
Definition: ap.cpp:692
ae_bool _odesolverreport_init(void *_p, ae_state *_state, ae_bool make_automatic)
ae_int_t length() const
Definition: ap.cpp:5882
ae_bool ae_fp_less(double v1, double v2)
Definition: ap.cpp:1327
ae_bool odesolveriteration(odesolverstate *state, ae_state *_state)
ae_vector ra
Definition: ap.h:839
#define ae_bool
Definition: ap.h:194
ae_bool ae_fp_neq(double v1, double v2)
Definition: ap.cpp:1321
ae_bool isfinitevector(ae_vector *x, ae_int_t n, ae_state *_state)
void ae_touch_ptr(void *p)
Definition: ap.cpp:294
void _odesolverreport_clear(void *_p)
alglib_impl::odesolverreport * c_ptr()
double ae_maxreal(double m1, double m2, ae_state *state)
Definition: ap.cpp:1577
ae_error_type
Definition: ap.h:201
ae_bool ae_vector_set_length(ae_vector *dst, ae_int_t newsize, ae_state *state)
Definition: ap.cpp:658
struct alglib_impl::ae_vector ae_vector
_odesolverstate_owner & operator=(const _odesolverstate_owner &rhs)
const alglib_impl::ae_vector * c_ptr() const
Definition: ap.cpp:5907
#define j
double ae_minreal(double m1, double m2, ae_state *state)
Definition: ap.cpp:1582
alglib_impl::odesolverstate * p_struct
Definition: diffequations.h:88
int m
ae_vector ba
Definition: ap.h:838
double ** pp_double
Definition: ap.h:455
void ae_state_init(ae_state *state)
Definition: ap.cpp:309
void ae_assert(ae_bool cond, const char *msg, ae_state *state)
Definition: ap.cpp:1227
union alglib_impl::ae_vector::@11 ptr
const char *volatile error_msg
Definition: ap.h:389
void _rcommstate_clear(rcommstate *p)
Definition: ap.cpp:4597
ptrdiff_t ae_int_t
Definition: ap.h:186
_odesolverreport_owner & operator=(const _odesolverreport_owner &rhs)
ae_bool ae_vector_init(ae_vector *dst, ae_int_t size, ae_datatype datatype, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:580
ae_bool ae_isfinite(double x, ae_state *state)
Definition: ap.cpp:1495
void odesolversolve(odesolverstate &state, void(*diff)(const real_1d_array &y, double x, real_1d_array &dy, void *ptr), void *ptr)
ae_int_t * p_int
Definition: ap.h:436
void ae_v_addd(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n, double alpha)
Definition: ap.cpp:4479
ae_bool ae_vector_init_copy(ae_vector *dst, ae_vector *src, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:614
ae_bool ae_fp_less_eq(double v1, double v2)
Definition: ap.cpp:1335
void odesolverresults(const odesolverstate &state, ae_int_t &m, real_1d_array &xtbl, real_2d_array &ytbl, odesolverreport &rep)
alglib_impl::ae_int_t ae_int_t
Definition: ap.h:889
ae_bool * p_bool
Definition: ap.h:435
void ae_matrix_clear(ae_matrix *dst)
Definition: ap.cpp:891
#define ae_true
Definition: ap.h:195
int * n
ae_bool ae_fp_greater(double v1, double v2)
Definition: ap.cpp:1343
ae_int_t cnt
Definition: ap.h:429
ae_bool ae_matrix_set_length(ae_matrix *dst, ae_int_t rows, ae_int_t cols, ae_state *state)
Definition: ap.cpp:854
void _odesolverstate_destroy(void *_p)
ae_bool _odesolverstate_init(void *_p, ae_state *_state, ae_bool make_automatic)
void ae_free(void *p)
Definition: ap.cpp:237
#define xc