alglib4 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +47 -0
  3. data/ext/alglib/alglib.cpp +537 -0
  4. data/ext/alglib/alglib_array_converters.cpp +86 -0
  5. data/ext/alglib/alglib_array_converters.h +15 -0
  6. data/ext/alglib/alglib_utils.cpp +10 -0
  7. data/ext/alglib/alglib_utils.h +6 -0
  8. data/ext/alglib/alglibinternal.cpp +21749 -0
  9. data/ext/alglib/alglibinternal.h +2168 -0
  10. data/ext/alglib/alglibmisc.cpp +9106 -0
  11. data/ext/alglib/alglibmisc.h +2114 -0
  12. data/ext/alglib/ap.cpp +20094 -0
  13. data/ext/alglib/ap.h +7244 -0
  14. data/ext/alglib/dataanalysis.cpp +52588 -0
  15. data/ext/alglib/dataanalysis.h +10601 -0
  16. data/ext/alglib/diffequations.cpp +1342 -0
  17. data/ext/alglib/diffequations.h +282 -0
  18. data/ext/alglib/extconf.rb +5 -0
  19. data/ext/alglib/fasttransforms.cpp +4696 -0
  20. data/ext/alglib/fasttransforms.h +1018 -0
  21. data/ext/alglib/integration.cpp +4249 -0
  22. data/ext/alglib/integration.h +869 -0
  23. data/ext/alglib/interpolation.cpp +74502 -0
  24. data/ext/alglib/interpolation.h +12264 -0
  25. data/ext/alglib/kernels_avx2.cpp +2171 -0
  26. data/ext/alglib/kernels_avx2.h +201 -0
  27. data/ext/alglib/kernels_fma.cpp +1065 -0
  28. data/ext/alglib/kernels_fma.h +137 -0
  29. data/ext/alglib/kernels_sse2.cpp +735 -0
  30. data/ext/alglib/kernels_sse2.h +100 -0
  31. data/ext/alglib/linalg.cpp +65182 -0
  32. data/ext/alglib/linalg.h +9927 -0
  33. data/ext/alglib/optimization.cpp +135331 -0
  34. data/ext/alglib/optimization.h +19235 -0
  35. data/ext/alglib/solvers.cpp +20488 -0
  36. data/ext/alglib/solvers.h +4781 -0
  37. data/ext/alglib/specialfunctions.cpp +10672 -0
  38. data/ext/alglib/specialfunctions.h +2305 -0
  39. data/ext/alglib/statistics.cpp +19791 -0
  40. data/ext/alglib/statistics.h +1359 -0
  41. data/ext/alglib/stdafx.h +2 -0
  42. data/gpl2.txt +339 -0
  43. data/gpl3.txt +674 -0
  44. data/lib/alglib/version.rb +3 -0
  45. data/lib/alglib.rb +4 -0
  46. metadata +101 -0
@@ -0,0 +1,869 @@
1
+ /*************************************************************************
2
+ ALGLIB 4.04.0 (source code generated 2024-12-21)
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 _integration_pkg_h
21
+ #define _integration_pkg_h
22
+ #include "ap.h"
23
+ #include "alglibinternal.h"
24
+ #include "alglibmisc.h"
25
+ #include "linalg.h"
26
+ #include "specialfunctions.h"
27
+
28
+ /////////////////////////////////////////////////////////////////////////
29
+ //
30
+ // THIS SECTION CONTAINS COMPUTATIONAL CORE DECLARATIONS (DATATYPES)
31
+ //
32
+ /////////////////////////////////////////////////////////////////////////
33
+ namespace alglib_impl
34
+ {
35
+ #if defined(AE_COMPILE_GQ) || !defined(AE_PARTIAL_BUILD)
36
+ #endif
37
+ #if defined(AE_COMPILE_GKQ) || !defined(AE_PARTIAL_BUILD)
38
+ #endif
39
+ #if defined(AE_COMPILE_AUTOGK) || !defined(AE_PARTIAL_BUILD)
40
+ typedef struct
41
+ {
42
+ ae_int_t terminationtype;
43
+ ae_int_t nfev;
44
+ ae_int_t nintervals;
45
+ } autogkreport;
46
+ typedef struct
47
+ {
48
+ double a;
49
+ double b;
50
+ double eps;
51
+ double xwidth;
52
+ double x;
53
+ double f;
54
+ ae_int_t info;
55
+ double r;
56
+ ae_matrix heap;
57
+ ae_int_t heapsize;
58
+ ae_int_t heapwidth;
59
+ ae_int_t heapused;
60
+ double sumerr;
61
+ double sumabs;
62
+ ae_vector qn;
63
+ ae_vector wg;
64
+ ae_vector wk;
65
+ ae_vector wr;
66
+ ae_int_t n;
67
+ rcommstate rstate;
68
+ } autogkinternalstate;
69
+ typedef struct
70
+ {
71
+ double a;
72
+ double b;
73
+ double alpha;
74
+ double beta;
75
+ double xwidth;
76
+ double x;
77
+ double xminusa;
78
+ double bminusx;
79
+ ae_bool needf;
80
+ double f;
81
+ ae_int_t wrappermode;
82
+ autogkinternalstate internalstate;
83
+ rcommstate rstate;
84
+ double v;
85
+ ae_int_t terminationtype;
86
+ ae_int_t nfev;
87
+ ae_int_t nintervals;
88
+ } autogkstate;
89
+ #endif
90
+
91
+ }
92
+
93
+ /////////////////////////////////////////////////////////////////////////
94
+ //
95
+ // THIS SECTION CONTAINS C++ INTERFACE
96
+ //
97
+ /////////////////////////////////////////////////////////////////////////
98
+ namespace alglib
99
+ {
100
+
101
+ #if defined(AE_COMPILE_GQ) || !defined(AE_PARTIAL_BUILD)
102
+
103
+ #endif
104
+
105
+ #if defined(AE_COMPILE_GKQ) || !defined(AE_PARTIAL_BUILD)
106
+
107
+ #endif
108
+
109
+ #if defined(AE_COMPILE_AUTOGK) || !defined(AE_PARTIAL_BUILD)
110
+ /*************************************************************************
111
+ Integration report:
112
+ * TerminationType = completetion code:
113
+ * -5 non-convergence of Gauss-Kronrod nodes
114
+ calculation subroutine.
115
+ * -1 incorrect parameters were specified
116
+ * 1 OK
117
+ * Rep.NFEV countains number of function calculations
118
+ * Rep.NIntervals contains number of intervals [a,b]
119
+ was partitioned into.
120
+ *************************************************************************/
121
+ class _autogkreport_owner
122
+ {
123
+ public:
124
+ _autogkreport_owner();
125
+ _autogkreport_owner(alglib_impl::autogkreport *attach_to);
126
+ _autogkreport_owner(const _autogkreport_owner &rhs);
127
+ _autogkreport_owner& operator=(const _autogkreport_owner &rhs);
128
+ virtual ~_autogkreport_owner();
129
+ alglib_impl::autogkreport* c_ptr();
130
+ const alglib_impl::autogkreport* c_ptr() const;
131
+ protected:
132
+ alglib_impl::autogkreport *p_struct;
133
+ bool is_attached;
134
+ };
135
+ class autogkreport : public _autogkreport_owner
136
+ {
137
+ public:
138
+ autogkreport();
139
+ autogkreport(alglib_impl::autogkreport *attach_to);
140
+ autogkreport(const autogkreport &rhs);
141
+ autogkreport& operator=(const autogkreport &rhs);
142
+ virtual ~autogkreport();
143
+ ae_int_t &terminationtype;
144
+ ae_int_t &nfev;
145
+ ae_int_t &nintervals;
146
+
147
+ };
148
+
149
+
150
+ /*************************************************************************
151
+ This structure stores state of the integration algorithm.
152
+
153
+ Although this class has public fields, they are not intended for external
154
+ use. You should use ALGLIB functions to work with this class:
155
+ * autogksmooth()/AutoGKSmoothW()/... to create objects
156
+ * autogkintegrate() to begin integration
157
+ * autogkresults() to get results
158
+ *************************************************************************/
159
+ class _autogkstate_owner
160
+ {
161
+ public:
162
+ _autogkstate_owner();
163
+ _autogkstate_owner(alglib_impl::autogkstate *attach_to);
164
+ _autogkstate_owner(const _autogkstate_owner &rhs);
165
+ _autogkstate_owner& operator=(const _autogkstate_owner &rhs);
166
+ virtual ~_autogkstate_owner();
167
+ alglib_impl::autogkstate* c_ptr();
168
+ const alglib_impl::autogkstate* c_ptr() const;
169
+ protected:
170
+ alglib_impl::autogkstate *p_struct;
171
+ bool is_attached;
172
+ };
173
+ class autogkstate : public _autogkstate_owner
174
+ {
175
+ public:
176
+ autogkstate();
177
+ autogkstate(alglib_impl::autogkstate *attach_to);
178
+ autogkstate(const autogkstate &rhs);
179
+ autogkstate& operator=(const autogkstate &rhs);
180
+ virtual ~autogkstate();
181
+ ae_bool &needf;
182
+ double &x;
183
+ double &xminusa;
184
+ double &bminusx;
185
+ double &f;
186
+
187
+ };
188
+ #endif
189
+
190
+ #if defined(AE_COMPILE_GQ) || !defined(AE_PARTIAL_BUILD)
191
+ /*************************************************************************
192
+ Computation of nodes and weights for a Gauss quadrature formula
193
+
194
+ The algorithm generates the N-point Gauss quadrature formula with weight
195
+ function given by coefficients alpha and beta of a recurrence relation
196
+ which generates a system of orthogonal polynomials:
197
+
198
+ P-1(x) = 0
199
+ P0(x) = 1
200
+ Pn+1(x) = (x-alpha(n))*Pn(x) - beta(n)*Pn-1(x)
201
+
202
+ and zeroth moment Mu0
203
+
204
+ Mu0 = integral(W(x)dx,a,b)
205
+
206
+ INPUT PARAMETERS:
207
+ Alpha - array[0..N-1], alpha coefficients
208
+ Beta - array[0..N-1], beta coefficients
209
+ Zero-indexed element is not used and may be arbitrary.
210
+ Beta[I]>0.
211
+ Mu0 - zeroth moment of the weight function.
212
+ N - number of nodes of the quadrature formula, N>=1
213
+
214
+ OUTPUT PARAMETERS:
215
+ Info - error code:
216
+ * -3 internal eigenproblem solver hasn't converged
217
+ * -2 Beta[i]<=0
218
+ * -1 incorrect N was passed
219
+ * 1 OK
220
+ X - array[0..N-1] - array of quadrature nodes,
221
+ in ascending order.
222
+ W - array[0..N-1] - array of quadrature weights.
223
+
224
+ -- ALGLIB --
225
+ Copyright 2005-2009 by Bochkanov Sergey
226
+ *************************************************************************/
227
+ void gqgeneraterec(const real_1d_array &alpha, const real_1d_array &beta, const double mu0, const ae_int_t n, ae_int_t &info, real_1d_array &x, real_1d_array &w, const xparams _xparams = alglib::xdefault);
228
+
229
+
230
+ /*************************************************************************
231
+ Computation of nodes and weights for a Gauss-Lobatto quadrature formula
232
+
233
+ The algorithm generates the N-point Gauss-Lobatto quadrature formula with
234
+ weight function given by coefficients alpha and beta of a recurrence which
235
+ generates a system of orthogonal polynomials.
236
+
237
+ P-1(x) = 0
238
+ P0(x) = 1
239
+ Pn+1(x) = (x-alpha(n))*Pn(x) - beta(n)*Pn-1(x)
240
+
241
+ and zeroth moment Mu0
242
+
243
+ Mu0 = integral(W(x)dx,a,b)
244
+
245
+ INPUT PARAMETERS:
246
+ Alpha - array[0..N-2], alpha coefficients
247
+ Beta - array[0..N-2], beta coefficients.
248
+ Zero-indexed element is not used, may be arbitrary.
249
+ Beta[I]>0
250
+ Mu0 - zeroth moment of the weighting function.
251
+ A - left boundary of the integration interval.
252
+ B - right boundary of the integration interval.
253
+ N - number of nodes of the quadrature formula, N>=3
254
+ (including the left and right boundary nodes).
255
+
256
+ OUTPUT PARAMETERS:
257
+ Info - error code:
258
+ * -3 internal eigenproblem solver hasn't converged
259
+ * -2 Beta[i]<=0
260
+ * -1 incorrect N was passed
261
+ * 1 OK
262
+ X - array[0..N-1] - array of quadrature nodes,
263
+ in ascending order.
264
+ W - array[0..N-1] - array of quadrature weights.
265
+
266
+ -- ALGLIB --
267
+ Copyright 2005-2009 by Bochkanov Sergey
268
+ *************************************************************************/
269
+ void gqgenerategausslobattorec(const real_1d_array &alpha, const real_1d_array &beta, const double mu0, const double a, const double b, const ae_int_t n, ae_int_t &info, real_1d_array &x, real_1d_array &w, const xparams _xparams = alglib::xdefault);
270
+
271
+
272
+ /*************************************************************************
273
+ Computation of nodes and weights for a Gauss-Radau quadrature formula
274
+
275
+ The algorithm generates the N-point Gauss-Radau quadrature formula with
276
+ weight function given by the coefficients alpha and beta of a recurrence
277
+ which generates a system of orthogonal polynomials.
278
+
279
+ P-1(x) = 0
280
+ P0(x) = 1
281
+ Pn+1(x) = (x-alpha(n))*Pn(x) - beta(n)*Pn-1(x)
282
+
283
+ and zeroth moment Mu0
284
+
285
+ Mu0 = integral(W(x)dx,a,b)
286
+
287
+ INPUT PARAMETERS:
288
+ Alpha - array[0..N-2], alpha coefficients.
289
+ Beta - array[0..N-1], beta coefficients
290
+ Zero-indexed element is not used.
291
+ Beta[I]>0
292
+ Mu0 - zeroth moment of the weighting function.
293
+ A - left boundary of the integration interval.
294
+ N - number of nodes of the quadrature formula, N>=2
295
+ (including the left boundary node).
296
+
297
+ OUTPUT PARAMETERS:
298
+ Info - error code:
299
+ * -3 internal eigenproblem solver hasn't converged
300
+ * -2 Beta[i]<=0
301
+ * -1 incorrect N was passed
302
+ * 1 OK
303
+ X - array[0..N-1] - array of quadrature nodes,
304
+ in ascending order.
305
+ W - array[0..N-1] - array of quadrature weights.
306
+
307
+
308
+ -- ALGLIB --
309
+ Copyright 2005-2009 by Bochkanov Sergey
310
+ *************************************************************************/
311
+ void gqgenerategaussradaurec(const real_1d_array &alpha, const real_1d_array &beta, const double mu0, const double a, const ae_int_t n, ae_int_t &info, real_1d_array &x, real_1d_array &w, const xparams _xparams = alglib::xdefault);
312
+
313
+
314
+ /*************************************************************************
315
+ Returns nodes/weights for Gauss-Legendre quadrature on [-1,1] with N
316
+ nodes.
317
+
318
+ INPUT PARAMETERS:
319
+ N - number of nodes, >=1
320
+
321
+ OUTPUT PARAMETERS:
322
+ Info - error code:
323
+ * -4 an error was detected when calculating
324
+ weights/nodes. N is too large to obtain
325
+ weights/nodes with high enough accuracy.
326
+ Try to use multiple precision version.
327
+ * -3 internal eigenproblem solver hasn't converged
328
+ * -1 incorrect N was passed
329
+ * +1 OK
330
+ X - array[0..N-1] - array of quadrature nodes,
331
+ in ascending order.
332
+ W - array[0..N-1] - array of quadrature weights.
333
+
334
+
335
+ -- ALGLIB --
336
+ Copyright 12.05.2009 by Bochkanov Sergey
337
+ *************************************************************************/
338
+ void gqgenerategausslegendre(const ae_int_t n, ae_int_t &info, real_1d_array &x, real_1d_array &w, const xparams _xparams = alglib::xdefault);
339
+
340
+
341
+ /*************************************************************************
342
+ Returns nodes/weights for Gauss-Jacobi quadrature on [-1,1] with weight
343
+ function W(x)=Power(1-x,Alpha)*Power(1+x,Beta).
344
+
345
+ INPUT PARAMETERS:
346
+ N - number of nodes, >=1
347
+ Alpha - power-law coefficient, Alpha>-1
348
+ Beta - power-law coefficient, Beta>-1
349
+
350
+ OUTPUT PARAMETERS:
351
+ Info - error code:
352
+ * -4 an error was detected when calculating
353
+ weights/nodes. Alpha or Beta are too close
354
+ to -1 to obtain weights/nodes with high enough
355
+ accuracy, or, may be, N is too large. Try to
356
+ use multiple precision version.
357
+ * -3 internal eigenproblem solver hasn't converged
358
+ * -1 incorrect N/Alpha/Beta was passed
359
+ * +1 OK
360
+ X - array[0..N-1] - array of quadrature nodes,
361
+ in ascending order.
362
+ W - array[0..N-1] - array of quadrature weights.
363
+
364
+
365
+ -- ALGLIB --
366
+ Copyright 12.05.2009 by Bochkanov Sergey
367
+ *************************************************************************/
368
+ void gqgenerategaussjacobi(const ae_int_t n, const double alpha, const double beta, ae_int_t &info, real_1d_array &x, real_1d_array &w, const xparams _xparams = alglib::xdefault);
369
+
370
+
371
+ /*************************************************************************
372
+ Returns nodes/weights for Gauss-Laguerre quadrature on [0,+inf) with
373
+ weight function W(x)=Power(x,Alpha)*Exp(-x)
374
+
375
+ INPUT PARAMETERS:
376
+ N - number of nodes, >=1
377
+ Alpha - power-law coefficient, Alpha>-1
378
+
379
+ OUTPUT PARAMETERS:
380
+ Info - error code:
381
+ * -4 an error was detected when calculating
382
+ weights/nodes. Alpha is too close to -1 to
383
+ obtain weights/nodes with high enough accuracy
384
+ or, may be, N is too large. Try to use
385
+ multiple precision version.
386
+ * -3 internal eigenproblem solver hasn't converged
387
+ * -1 incorrect N/Alpha was passed
388
+ * +1 OK
389
+ X - array[0..N-1] - array of quadrature nodes,
390
+ in ascending order.
391
+ W - array[0..N-1] - array of quadrature weights.
392
+
393
+
394
+ -- ALGLIB --
395
+ Copyright 12.05.2009 by Bochkanov Sergey
396
+ *************************************************************************/
397
+ void gqgenerategausslaguerre(const ae_int_t n, const double alpha, ae_int_t &info, real_1d_array &x, real_1d_array &w, const xparams _xparams = alglib::xdefault);
398
+
399
+
400
+ /*************************************************************************
401
+ Returns nodes/weights for Gauss-Hermite quadrature on (-inf,+inf) with
402
+ weight function W(x)=Exp(-x*x)
403
+
404
+ INPUT PARAMETERS:
405
+ N - number of nodes, >=1
406
+
407
+ OUTPUT PARAMETERS:
408
+ Info - error code:
409
+ * -4 an error was detected when calculating
410
+ weights/nodes. May be, N is too large. Try to
411
+ use multiple precision version.
412
+ * -3 internal eigenproblem solver hasn't converged
413
+ * -1 incorrect N/Alpha was passed
414
+ * +1 OK
415
+ X - array[0..N-1] - array of quadrature nodes,
416
+ in ascending order.
417
+ W - array[0..N-1] - array of quadrature weights.
418
+
419
+
420
+ -- ALGLIB --
421
+ Copyright 12.05.2009 by Bochkanov Sergey
422
+ *************************************************************************/
423
+ void gqgenerategausshermite(const ae_int_t n, ae_int_t &info, real_1d_array &x, real_1d_array &w, const xparams _xparams = alglib::xdefault);
424
+ #endif
425
+
426
+ #if defined(AE_COMPILE_GKQ) || !defined(AE_PARTIAL_BUILD)
427
+ /*************************************************************************
428
+ Computation of nodes and weights of a Gauss-Kronrod quadrature formula
429
+
430
+ The algorithm generates the N-point Gauss-Kronrod quadrature formula with
431
+ weight function given by coefficients alpha and beta of a recurrence
432
+ relation which generates a system of orthogonal polynomials:
433
+
434
+ P-1(x) = 0
435
+ P0(x) = 1
436
+ Pn+1(x) = (x-alpha(n))*Pn(x) - beta(n)*Pn-1(x)
437
+
438
+ and zero moment Mu0
439
+
440
+ Mu0 = integral(W(x)dx,a,b)
441
+
442
+
443
+ INPUT PARAMETERS:
444
+ Alpha - alpha coefficients, array[0..floor(3*K/2)].
445
+ Beta - beta coefficients, array[0..ceil(3*K/2)].
446
+ Beta[0] is not used and may be arbitrary.
447
+ Beta[I]>0.
448
+ Mu0 - zeroth moment of the weight function.
449
+ N - number of nodes of the Gauss-Kronrod quadrature formula,
450
+ N >= 3,
451
+ N = 2*K+1.
452
+
453
+ OUTPUT PARAMETERS:
454
+ Info - error code:
455
+ * -5 no real and positive Gauss-Kronrod formula can
456
+ be created for such a weight function with a
457
+ given number of nodes.
458
+ * -4 N is too large, task may be ill conditioned -
459
+ x[i]=x[i+1] found.
460
+ * -3 internal eigenproblem solver hasn't converged
461
+ * -2 Beta[i]<=0
462
+ * -1 incorrect N was passed
463
+ * +1 OK
464
+ X - array[0..N-1] - array of quadrature nodes,
465
+ in ascending order.
466
+ WKronrod - array[0..N-1] - Kronrod weights
467
+ WGauss - array[0..N-1] - Gauss weights (interleaved with zeros
468
+ corresponding to extended Kronrod nodes).
469
+
470
+ -- ALGLIB --
471
+ Copyright 08.05.2009 by Bochkanov Sergey
472
+ *************************************************************************/
473
+ void gkqgeneraterec(const real_1d_array &alpha, const real_1d_array &beta, const double mu0, const ae_int_t n, ae_int_t &info, real_1d_array &x, real_1d_array &wkronrod, real_1d_array &wgauss, const xparams _xparams = alglib::xdefault);
474
+
475
+
476
+ /*************************************************************************
477
+ Returns Gauss and Gauss-Kronrod nodes/weights for Gauss-Legendre
478
+ quadrature with N points.
479
+
480
+ GKQLegendreCalc (calculation) or GKQLegendreTbl (precomputed table) is
481
+ used depending on machine precision and number of nodes.
482
+
483
+ INPUT PARAMETERS:
484
+ N - number of Kronrod nodes, must be odd number, >=3.
485
+
486
+ OUTPUT PARAMETERS:
487
+ Info - error code:
488
+ * -4 an error was detected when calculating
489
+ weights/nodes. N is too large to obtain
490
+ weights/nodes with high enough accuracy.
491
+ Try to use multiple precision version.
492
+ * -3 internal eigenproblem solver hasn't converged
493
+ * -1 incorrect N was passed
494
+ * +1 OK
495
+ X - array[0..N-1] - array of quadrature nodes, ordered in
496
+ ascending order.
497
+ WKronrod - array[0..N-1] - Kronrod weights
498
+ WGauss - array[0..N-1] - Gauss weights (interleaved with zeros
499
+ corresponding to extended Kronrod nodes).
500
+
501
+
502
+ -- ALGLIB --
503
+ Copyright 12.05.2009 by Bochkanov Sergey
504
+ *************************************************************************/
505
+ void gkqgenerategausslegendre(const ae_int_t n, ae_int_t &info, real_1d_array &x, real_1d_array &wkronrod, real_1d_array &wgauss, const xparams _xparams = alglib::xdefault);
506
+
507
+
508
+ /*************************************************************************
509
+ Returns Gauss and Gauss-Kronrod nodes/weights for Gauss-Jacobi
510
+ quadrature on [-1,1] with weight function
511
+
512
+ W(x)=Power(1-x,Alpha)*Power(1+x,Beta).
513
+
514
+ INPUT PARAMETERS:
515
+ N - number of Kronrod nodes, must be odd number, >=3.
516
+ Alpha - power-law coefficient, Alpha>-1
517
+ Beta - power-law coefficient, Beta>-1
518
+
519
+ OUTPUT PARAMETERS:
520
+ Info - error code:
521
+ * -5 no real and positive Gauss-Kronrod formula can
522
+ be created for such a weight function with a
523
+ given number of nodes.
524
+ * -4 an error was detected when calculating
525
+ weights/nodes. Alpha or Beta are too close
526
+ to -1 to obtain weights/nodes with high enough
527
+ accuracy, or, may be, N is too large. Try to
528
+ use multiple precision version.
529
+ * -3 internal eigenproblem solver hasn't converged
530
+ * -1 incorrect N was passed
531
+ * +1 OK
532
+ * +2 OK, but quadrature rule have exterior nodes,
533
+ x[0]<-1 or x[n-1]>+1
534
+ X - array[0..N-1] - array of quadrature nodes, ordered in
535
+ ascending order.
536
+ WKronrod - array[0..N-1] - Kronrod weights
537
+ WGauss - array[0..N-1] - Gauss weights (interleaved with zeros
538
+ corresponding to extended Kronrod nodes).
539
+
540
+
541
+ -- ALGLIB --
542
+ Copyright 12.05.2009 by Bochkanov Sergey
543
+ *************************************************************************/
544
+ void gkqgenerategaussjacobi(const ae_int_t n, const double alpha, const double beta, ae_int_t &info, real_1d_array &x, real_1d_array &wkronrod, real_1d_array &wgauss, const xparams _xparams = alglib::xdefault);
545
+
546
+
547
+ /*************************************************************************
548
+ Returns Gauss and Gauss-Kronrod nodes for quadrature with N points.
549
+
550
+ Reduction to tridiagonal eigenproblem is used.
551
+
552
+ INPUT PARAMETERS:
553
+ N - number of Kronrod nodes, must be odd number, >=3.
554
+
555
+ OUTPUT PARAMETERS:
556
+ Info - error code:
557
+ * -4 an error was detected when calculating
558
+ weights/nodes. N is too large to obtain
559
+ weights/nodes with high enough accuracy.
560
+ Try to use multiple precision version.
561
+ * -3 internal eigenproblem solver hasn't converged
562
+ * -1 incorrect N was passed
563
+ * +1 OK
564
+ X - array[0..N-1] - array of quadrature nodes, ordered in
565
+ ascending order.
566
+ WKronrod - array[0..N-1] - Kronrod weights
567
+ WGauss - array[0..N-1] - Gauss weights (interleaved with zeros
568
+ corresponding to extended Kronrod nodes).
569
+
570
+ -- ALGLIB --
571
+ Copyright 12.05.2009 by Bochkanov Sergey
572
+ *************************************************************************/
573
+ void gkqlegendrecalc(const ae_int_t n, ae_int_t &info, real_1d_array &x, real_1d_array &wkronrod, real_1d_array &wgauss, const xparams _xparams = alglib::xdefault);
574
+
575
+
576
+ /*************************************************************************
577
+ Returns Gauss and Gauss-Kronrod nodes for quadrature with N points using
578
+ pre-calculated table. Nodes/weights were computed with accuracy up to
579
+ 1.0E-32 (if MPFR version of ALGLIB is used). In standard double precision
580
+ accuracy reduces to something about 2.0E-16 (depending on your compiler's
581
+ handling of long floating point constants).
582
+
583
+ INPUT PARAMETERS:
584
+ N - number of Kronrod nodes.
585
+ N can be 15, 21, 31, 41, 51, 61.
586
+
587
+ OUTPUT PARAMETERS:
588
+ X - array[0..N-1] - array of quadrature nodes, ordered in
589
+ ascending order.
590
+ WKronrod - array[0..N-1] - Kronrod weights
591
+ WGauss - array[0..N-1] - Gauss weights (interleaved with zeros
592
+ corresponding to extended Kronrod nodes).
593
+
594
+
595
+ -- ALGLIB --
596
+ Copyright 12.05.2009 by Bochkanov Sergey
597
+ *************************************************************************/
598
+ void gkqlegendretbl(const ae_int_t n, real_1d_array &x, real_1d_array &wkronrod, real_1d_array &wgauss, double &eps, const xparams _xparams = alglib::xdefault);
599
+ #endif
600
+
601
+ #if defined(AE_COMPILE_AUTOGK) || !defined(AE_PARTIAL_BUILD)
602
+ /*************************************************************************
603
+ Integration of a smooth function F(x) on a finite interval [a,b].
604
+
605
+ Fast-convergent algorithm based on a Gauss-Kronrod formula is used. Result
606
+ is calculated with accuracy close to the machine precision.
607
+
608
+ Algorithm works well only with smooth integrands. It may be used with
609
+ continuous non-smooth integrands, but with less performance.
610
+
611
+ It should never be used with integrands which have integrable singularities
612
+ at lower or upper limits - algorithm may crash. Use AutoGKSingular in such
613
+ cases.
614
+
615
+ INPUT PARAMETERS:
616
+ A, B - interval boundaries (A<B, A=B or A>B)
617
+
618
+ OUTPUT PARAMETERS
619
+ State - structure which stores algorithm state
620
+
621
+ SEE ALSO
622
+ AutoGKSmoothW, AutoGKSingular, AutoGKResults.
623
+
624
+
625
+ -- ALGLIB --
626
+ Copyright 06.05.2009 by Bochkanov Sergey
627
+ *************************************************************************/
628
+ void autogksmooth(const double a, const double b, autogkstate &state, const xparams _xparams = alglib::xdefault);
629
+
630
+
631
+ /*************************************************************************
632
+ Integration of a smooth function F(x) on a finite interval [a,b].
633
+
634
+ This subroutine is same as AutoGKSmooth(), but it guarantees that interval
635
+ [a,b] is partitioned into subintervals which have width at most XWidth.
636
+
637
+ Subroutine can be used when integrating nearly-constant function with
638
+ narrow "bumps" (about XWidth wide). If "bumps" are too narrow, AutoGKSmooth
639
+ subroutine can overlook them.
640
+
641
+ INPUT PARAMETERS:
642
+ A, B - interval boundaries (A<B, A=B or A>B)
643
+
644
+ OUTPUT PARAMETERS
645
+ State - structure which stores algorithm state
646
+
647
+ SEE ALSO
648
+ AutoGKSmooth, AutoGKSingular, AutoGKResults.
649
+
650
+
651
+ -- ALGLIB --
652
+ Copyright 06.05.2009 by Bochkanov Sergey
653
+ *************************************************************************/
654
+ void autogksmoothw(const double a, const double b, const double xwidth, autogkstate &state, const xparams _xparams = alglib::xdefault);
655
+
656
+
657
+ /*************************************************************************
658
+ Integration on a finite interval [A,B].
659
+ Integrand have integrable singularities at A/B.
660
+
661
+ F(X) must diverge as "(x-A)^alpha" at A, as "(B-x)^beta" at B, with known
662
+ alpha/beta (alpha>-1, beta>-1). If alpha/beta are not known, estimates
663
+ from below can be used (but these estimates should be greater than -1 too).
664
+
665
+ One of alpha/beta variables (or even both alpha/beta) may be equal to 0,
666
+ which means than function F(x) is non-singular at A/B. Anyway (singular at
667
+ bounds or not), function F(x) is supposed to be continuous on (A,B).
668
+
669
+ Fast-convergent algorithm based on a Gauss-Kronrod formula is used. Result
670
+ is calculated with accuracy close to the machine precision.
671
+
672
+ INPUT PARAMETERS:
673
+ A, B - interval boundaries (A<B, A=B or A>B)
674
+ Alpha - power-law coefficient of the F(x) at A,
675
+ Alpha>-1
676
+ Beta - power-law coefficient of the F(x) at B,
677
+ Beta>-1
678
+
679
+ OUTPUT PARAMETERS
680
+ State - structure which stores algorithm state
681
+
682
+ SEE ALSO
683
+ AutoGKSmooth, AutoGKSmoothW, AutoGKResults.
684
+
685
+
686
+ -- ALGLIB --
687
+ Copyright 06.05.2009 by Bochkanov Sergey
688
+ *************************************************************************/
689
+ void autogksingular(const double a, const double b, const double alpha, const double beta, autogkstate &state, const xparams _xparams = alglib::xdefault);
690
+
691
+
692
+ /*************************************************************************
693
+ This function provides reverse communication interface
694
+ Reverse communication interface is not documented or recommended to use.
695
+ See below for functions which provide better documented API
696
+ *************************************************************************/
697
+ bool autogkiteration(autogkstate &state, const xparams _xparams = alglib::xdefault);
698
+
699
+
700
+ /*************************************************************************
701
+ This function is used to launcn iterations of the 1-dimensional integrator
702
+
703
+ It accepts following parameters:
704
+ func - callback which calculates f(x) for given x
705
+ ptr - optional pointer which is passed to func; can be NULL
706
+
707
+
708
+ -- ALGLIB --
709
+ Copyright 07.05.2009 by Bochkanov Sergey
710
+
711
+ *************************************************************************/
712
+ void autogkintegrate(autogkstate &state,
713
+ void (*func)(double x, double xminusa, double bminusx, double &y, void *ptr),
714
+ void *ptr = NULL, const xparams _xparams = alglib::xdefault);
715
+
716
+
717
+ /*************************************************************************
718
+ Adaptive integration results
719
+
720
+ Called after AutoGKIteration returned False.
721
+
722
+ Input parameters:
723
+ State - algorithm state (used by AutoGKIteration).
724
+
725
+ Output parameters:
726
+ V - integral(f(x)dx,a,b)
727
+ Rep - optimization report (see AutoGKReport description)
728
+
729
+ -- ALGLIB --
730
+ Copyright 14.11.2007 by Bochkanov Sergey
731
+ *************************************************************************/
732
+ void autogkresults(const autogkstate &state, double &v, autogkreport &rep, const xparams _xparams = alglib::xdefault);
733
+ #endif
734
+ }
735
+
736
+ /////////////////////////////////////////////////////////////////////////
737
+ //
738
+ // THIS SECTION CONTAINS COMPUTATIONAL CORE DECLARATIONS (FUNCTIONS)
739
+ //
740
+ /////////////////////////////////////////////////////////////////////////
741
+ namespace alglib_impl
742
+ {
743
+ #if defined(AE_COMPILE_GQ) || !defined(AE_PARTIAL_BUILD)
744
+ void gqgeneraterec(/* Real */ const ae_vector* alpha,
745
+ /* Real */ const ae_vector* beta,
746
+ double mu0,
747
+ ae_int_t n,
748
+ ae_int_t* info,
749
+ /* Real */ ae_vector* x,
750
+ /* Real */ ae_vector* w,
751
+ ae_state *_state);
752
+ void gqgenerategausslobattorec(/* Real */ const ae_vector* _alpha,
753
+ /* Real */ const ae_vector* _beta,
754
+ double mu0,
755
+ double a,
756
+ double b,
757
+ ae_int_t n,
758
+ ae_int_t* info,
759
+ /* Real */ ae_vector* x,
760
+ /* Real */ ae_vector* w,
761
+ ae_state *_state);
762
+ void gqgenerategaussradaurec(/* Real */ const ae_vector* _alpha,
763
+ /* Real */ const ae_vector* _beta,
764
+ double mu0,
765
+ double a,
766
+ ae_int_t n,
767
+ ae_int_t* info,
768
+ /* Real */ ae_vector* x,
769
+ /* Real */ ae_vector* w,
770
+ ae_state *_state);
771
+ void gqgenerategausslegendre(ae_int_t n,
772
+ ae_int_t* info,
773
+ /* Real */ ae_vector* x,
774
+ /* Real */ ae_vector* w,
775
+ ae_state *_state);
776
+ void gqgenerategaussjacobi(ae_int_t n,
777
+ double alpha,
778
+ double beta,
779
+ ae_int_t* info,
780
+ /* Real */ ae_vector* x,
781
+ /* Real */ ae_vector* w,
782
+ ae_state *_state);
783
+ void gqgenerategausslaguerre(ae_int_t n,
784
+ double alpha,
785
+ ae_int_t* info,
786
+ /* Real */ ae_vector* x,
787
+ /* Real */ ae_vector* w,
788
+ ae_state *_state);
789
+ void gqgenerategausshermite(ae_int_t n,
790
+ ae_int_t* info,
791
+ /* Real */ ae_vector* x,
792
+ /* Real */ ae_vector* w,
793
+ ae_state *_state);
794
+ #endif
795
+ #if defined(AE_COMPILE_GKQ) || !defined(AE_PARTIAL_BUILD)
796
+ void gkqgeneraterec(/* Real */ const ae_vector* _alpha,
797
+ /* Real */ const ae_vector* _beta,
798
+ double mu0,
799
+ ae_int_t n,
800
+ ae_int_t* info,
801
+ /* Real */ ae_vector* x,
802
+ /* Real */ ae_vector* wkronrod,
803
+ /* Real */ ae_vector* wgauss,
804
+ ae_state *_state);
805
+ void gkqgenerategausslegendre(ae_int_t n,
806
+ ae_int_t* info,
807
+ /* Real */ ae_vector* x,
808
+ /* Real */ ae_vector* wkronrod,
809
+ /* Real */ ae_vector* wgauss,
810
+ ae_state *_state);
811
+ void gkqgenerategaussjacobi(ae_int_t n,
812
+ double alpha,
813
+ double beta,
814
+ ae_int_t* info,
815
+ /* Real */ ae_vector* x,
816
+ /* Real */ ae_vector* wkronrod,
817
+ /* Real */ ae_vector* wgauss,
818
+ ae_state *_state);
819
+ void gkqlegendrecalc(ae_int_t n,
820
+ ae_int_t* info,
821
+ /* Real */ ae_vector* x,
822
+ /* Real */ ae_vector* wkronrod,
823
+ /* Real */ ae_vector* wgauss,
824
+ ae_state *_state);
825
+ void gkqlegendretbl(ae_int_t n,
826
+ /* Real */ ae_vector* x,
827
+ /* Real */ ae_vector* wkronrod,
828
+ /* Real */ ae_vector* wgauss,
829
+ double* eps,
830
+ ae_state *_state);
831
+ #endif
832
+ #if defined(AE_COMPILE_AUTOGK) || !defined(AE_PARTIAL_BUILD)
833
+ void autogksmooth(double a,
834
+ double b,
835
+ autogkstate* state,
836
+ ae_state *_state);
837
+ void autogksmoothw(double a,
838
+ double b,
839
+ double xwidth,
840
+ autogkstate* state,
841
+ ae_state *_state);
842
+ void autogksingular(double a,
843
+ double b,
844
+ double alpha,
845
+ double beta,
846
+ autogkstate* state,
847
+ ae_state *_state);
848
+ ae_bool autogkiteration(autogkstate* state, ae_state *_state);
849
+ void autogkresults(const autogkstate* state,
850
+ double* v,
851
+ autogkreport* rep,
852
+ ae_state *_state);
853
+ void _autogkreport_init(void* _p, ae_state *_state, ae_bool make_automatic);
854
+ void _autogkreport_init_copy(void* _dst, const void* _src, ae_state *_state, ae_bool make_automatic);
855
+ void _autogkreport_clear(void* _p);
856
+ void _autogkreport_destroy(void* _p);
857
+ void _autogkinternalstate_init(void* _p, ae_state *_state, ae_bool make_automatic);
858
+ void _autogkinternalstate_init_copy(void* _dst, const void* _src, ae_state *_state, ae_bool make_automatic);
859
+ void _autogkinternalstate_clear(void* _p);
860
+ void _autogkinternalstate_destroy(void* _p);
861
+ void _autogkstate_init(void* _p, ae_state *_state, ae_bool make_automatic);
862
+ void _autogkstate_init_copy(void* _dst, const void* _src, ae_state *_state, ae_bool make_automatic);
863
+ void _autogkstate_clear(void* _p);
864
+ void _autogkstate_destroy(void* _p);
865
+ #endif
866
+
867
+ }
868
+ #endif
869
+