alglib4 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,2305 @@
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 _specialfunctions_pkg_h
21
+ #define _specialfunctions_pkg_h
22
+ #include "ap.h"
23
+ #include "alglibinternal.h"
24
+ #include "alglibmisc.h"
25
+
26
+ /////////////////////////////////////////////////////////////////////////
27
+ //
28
+ // THIS SECTION CONTAINS COMPUTATIONAL CORE DECLARATIONS (DATATYPES)
29
+ //
30
+ /////////////////////////////////////////////////////////////////////////
31
+ namespace alglib_impl
32
+ {
33
+ #if defined(AE_COMPILE_GAMMAFUNC) || !defined(AE_PARTIAL_BUILD)
34
+ #endif
35
+ #if defined(AE_COMPILE_NORMALDISTR) || !defined(AE_PARTIAL_BUILD)
36
+ #endif
37
+ #if defined(AE_COMPILE_IBETAF) || !defined(AE_PARTIAL_BUILD)
38
+ #endif
39
+ #if defined(AE_COMPILE_STUDENTTDISTR) || !defined(AE_PARTIAL_BUILD)
40
+ #endif
41
+ #if defined(AE_COMPILE_FDISTR) || !defined(AE_PARTIAL_BUILD)
42
+ #endif
43
+ #if defined(AE_COMPILE_IGAMMAF) || !defined(AE_PARTIAL_BUILD)
44
+ #endif
45
+ #if defined(AE_COMPILE_CHISQUAREDISTR) || !defined(AE_PARTIAL_BUILD)
46
+ #endif
47
+ #if defined(AE_COMPILE_BINOMIALDISTR) || !defined(AE_PARTIAL_BUILD)
48
+ #endif
49
+ #if defined(AE_COMPILE_EXPINTEGRALS) || !defined(AE_PARTIAL_BUILD)
50
+ #endif
51
+ #if defined(AE_COMPILE_JACOBIANELLIPTIC) || !defined(AE_PARTIAL_BUILD)
52
+ #endif
53
+ #if defined(AE_COMPILE_TRIGINTEGRALS) || !defined(AE_PARTIAL_BUILD)
54
+ #endif
55
+ #if defined(AE_COMPILE_CHEBYSHEV) || !defined(AE_PARTIAL_BUILD)
56
+ #endif
57
+ #if defined(AE_COMPILE_POISSONDISTR) || !defined(AE_PARTIAL_BUILD)
58
+ #endif
59
+ #if defined(AE_COMPILE_BETAF) || !defined(AE_PARTIAL_BUILD)
60
+ #endif
61
+ #if defined(AE_COMPILE_FRESNEL) || !defined(AE_PARTIAL_BUILD)
62
+ #endif
63
+ #if defined(AE_COMPILE_PSIF) || !defined(AE_PARTIAL_BUILD)
64
+ #endif
65
+ #if defined(AE_COMPILE_AIRYF) || !defined(AE_PARTIAL_BUILD)
66
+ #endif
67
+ #if defined(AE_COMPILE_DAWSON) || !defined(AE_PARTIAL_BUILD)
68
+ #endif
69
+ #if defined(AE_COMPILE_HERMITE) || !defined(AE_PARTIAL_BUILD)
70
+ #endif
71
+ #if defined(AE_COMPILE_LEGENDRE) || !defined(AE_PARTIAL_BUILD)
72
+ #endif
73
+ #if defined(AE_COMPILE_BESSEL) || !defined(AE_PARTIAL_BUILD)
74
+ #endif
75
+ #if defined(AE_COMPILE_LAGUERRE) || !defined(AE_PARTIAL_BUILD)
76
+ #endif
77
+ #if defined(AE_COMPILE_ELLIPTIC) || !defined(AE_PARTIAL_BUILD)
78
+ #endif
79
+
80
+ }
81
+
82
+ /////////////////////////////////////////////////////////////////////////
83
+ //
84
+ // THIS SECTION CONTAINS C++ INTERFACE
85
+ //
86
+ /////////////////////////////////////////////////////////////////////////
87
+ namespace alglib
88
+ {
89
+
90
+ #if defined(AE_COMPILE_GAMMAFUNC) || !defined(AE_PARTIAL_BUILD)
91
+
92
+ #endif
93
+
94
+ #if defined(AE_COMPILE_NORMALDISTR) || !defined(AE_PARTIAL_BUILD)
95
+
96
+ #endif
97
+
98
+ #if defined(AE_COMPILE_IBETAF) || !defined(AE_PARTIAL_BUILD)
99
+
100
+ #endif
101
+
102
+ #if defined(AE_COMPILE_STUDENTTDISTR) || !defined(AE_PARTIAL_BUILD)
103
+
104
+ #endif
105
+
106
+ #if defined(AE_COMPILE_FDISTR) || !defined(AE_PARTIAL_BUILD)
107
+
108
+ #endif
109
+
110
+ #if defined(AE_COMPILE_IGAMMAF) || !defined(AE_PARTIAL_BUILD)
111
+
112
+ #endif
113
+
114
+ #if defined(AE_COMPILE_CHISQUAREDISTR) || !defined(AE_PARTIAL_BUILD)
115
+
116
+ #endif
117
+
118
+ #if defined(AE_COMPILE_BINOMIALDISTR) || !defined(AE_PARTIAL_BUILD)
119
+
120
+ #endif
121
+
122
+ #if defined(AE_COMPILE_EXPINTEGRALS) || !defined(AE_PARTIAL_BUILD)
123
+
124
+ #endif
125
+
126
+ #if defined(AE_COMPILE_JACOBIANELLIPTIC) || !defined(AE_PARTIAL_BUILD)
127
+
128
+ #endif
129
+
130
+ #if defined(AE_COMPILE_TRIGINTEGRALS) || !defined(AE_PARTIAL_BUILD)
131
+
132
+ #endif
133
+
134
+ #if defined(AE_COMPILE_CHEBYSHEV) || !defined(AE_PARTIAL_BUILD)
135
+
136
+ #endif
137
+
138
+ #if defined(AE_COMPILE_POISSONDISTR) || !defined(AE_PARTIAL_BUILD)
139
+
140
+ #endif
141
+
142
+ #if defined(AE_COMPILE_BETAF) || !defined(AE_PARTIAL_BUILD)
143
+
144
+ #endif
145
+
146
+ #if defined(AE_COMPILE_FRESNEL) || !defined(AE_PARTIAL_BUILD)
147
+
148
+ #endif
149
+
150
+ #if defined(AE_COMPILE_PSIF) || !defined(AE_PARTIAL_BUILD)
151
+
152
+ #endif
153
+
154
+ #if defined(AE_COMPILE_AIRYF) || !defined(AE_PARTIAL_BUILD)
155
+
156
+ #endif
157
+
158
+ #if defined(AE_COMPILE_DAWSON) || !defined(AE_PARTIAL_BUILD)
159
+
160
+ #endif
161
+
162
+ #if defined(AE_COMPILE_HERMITE) || !defined(AE_PARTIAL_BUILD)
163
+
164
+ #endif
165
+
166
+ #if defined(AE_COMPILE_LEGENDRE) || !defined(AE_PARTIAL_BUILD)
167
+
168
+ #endif
169
+
170
+ #if defined(AE_COMPILE_BESSEL) || !defined(AE_PARTIAL_BUILD)
171
+
172
+ #endif
173
+
174
+ #if defined(AE_COMPILE_LAGUERRE) || !defined(AE_PARTIAL_BUILD)
175
+
176
+ #endif
177
+
178
+ #if defined(AE_COMPILE_ELLIPTIC) || !defined(AE_PARTIAL_BUILD)
179
+
180
+ #endif
181
+
182
+ #if defined(AE_COMPILE_GAMMAFUNC) || !defined(AE_PARTIAL_BUILD)
183
+ /*************************************************************************
184
+ Gamma function
185
+
186
+ Input parameters:
187
+ X - argument
188
+
189
+ Domain:
190
+ 0 < X < 171.6
191
+ -170 < X < 0, X is not an integer.
192
+
193
+ Relative error:
194
+ arithmetic domain # trials peak rms
195
+ IEEE -170,-33 20000 2.3e-15 3.3e-16
196
+ IEEE -33, 33 20000 9.4e-16 2.2e-16
197
+ IEEE 33, 171.6 20000 2.3e-15 3.2e-16
198
+
199
+ Cephes Math Library Release 2.8: June, 2000
200
+ Original copyright 1984, 1987, 1989, 1992, 2000 by Stephen L. Moshier
201
+ Translated to AlgoPascal by Bochkanov Sergey (2005, 2006, 2007).
202
+ *************************************************************************/
203
+ double gammafunction(const double x, const xparams _xparams = alglib::xdefault);
204
+
205
+
206
+ /*************************************************************************
207
+ Natural logarithm of gamma function
208
+
209
+ Input parameters:
210
+ X - argument
211
+
212
+ Result:
213
+ logarithm of the absolute value of the Gamma(X).
214
+
215
+ Output parameters:
216
+ SgnGam - sign(Gamma(X))
217
+
218
+ Domain:
219
+ 0 < X < 2.55e305
220
+ -2.55e305 < X < 0, X is not an integer.
221
+
222
+ ACCURACY:
223
+ arithmetic domain # trials peak rms
224
+ IEEE 0, 3 28000 5.4e-16 1.1e-16
225
+ IEEE 2.718, 2.556e305 40000 3.5e-16 8.3e-17
226
+ The error criterion was relative when the function magnitude
227
+ was greater than one but absolute when it was less than one.
228
+
229
+ The following test used the relative error criterion, though
230
+ at certain points the relative error could be much higher than
231
+ indicated.
232
+ IEEE -200, -4 10000 4.8e-16 1.3e-16
233
+
234
+ Cephes Math Library Release 2.8: June, 2000
235
+ Copyright 1984, 1987, 1989, 1992, 2000 by Stephen L. Moshier
236
+ Translated to AlgoPascal by Bochkanov Sergey (2005, 2006, 2007).
237
+ *************************************************************************/
238
+ double lngamma(const double x, double &sgngam, const xparams _xparams = alglib::xdefault);
239
+ #endif
240
+
241
+ #if defined(AE_COMPILE_NORMALDISTR) || !defined(AE_PARTIAL_BUILD)
242
+ /*************************************************************************
243
+ Error function
244
+
245
+ The integral is
246
+
247
+ x
248
+ -
249
+ 2 | | 2
250
+ erf(x) = -------- | exp( - t ) dt.
251
+ sqrt(pi) | |
252
+ -
253
+ 0
254
+
255
+ For 0 <= |x| < 1, erf(x) = x * P4(x**2)/Q5(x**2); otherwise
256
+ erf(x) = 1 - erfc(x).
257
+
258
+
259
+ ACCURACY:
260
+
261
+ Relative error:
262
+ arithmetic domain # trials peak rms
263
+ IEEE 0,1 30000 3.7e-16 1.0e-16
264
+
265
+ Cephes Math Library Release 2.8: June, 2000
266
+ Copyright 1984, 1987, 1988, 1992, 2000 by Stephen L. Moshier
267
+ *************************************************************************/
268
+ double errorfunction(const double x, const xparams _xparams = alglib::xdefault);
269
+
270
+
271
+ /*************************************************************************
272
+ Complementary error function
273
+
274
+ 1 - erf(x) =
275
+
276
+ inf.
277
+ -
278
+ 2 | | 2
279
+ erfc(x) = -------- | exp( - t ) dt
280
+ sqrt(pi) | |
281
+ -
282
+ x
283
+
284
+
285
+ For small x, erfc(x) = 1 - erf(x); otherwise rational
286
+ approximations are computed.
287
+
288
+
289
+ ACCURACY:
290
+
291
+ Relative error:
292
+ arithmetic domain # trials peak rms
293
+ IEEE 0,26.6417 30000 5.7e-14 1.5e-14
294
+
295
+ Cephes Math Library Release 2.8: June, 2000
296
+ Copyright 1984, 1987, 1988, 1992, 2000 by Stephen L. Moshier
297
+ *************************************************************************/
298
+ double errorfunctionc(const double x, const xparams _xparams = alglib::xdefault);
299
+
300
+
301
+ /*************************************************************************
302
+ Same as normalcdf(), obsolete name.
303
+ *************************************************************************/
304
+ double normaldistribution(const double x, const xparams _xparams = alglib::xdefault);
305
+
306
+
307
+ /*************************************************************************
308
+ Normal distribution PDF
309
+
310
+ Returns Gaussian probability density function:
311
+
312
+ 1
313
+ f(x) = --------- * exp(-x^2/2)
314
+ sqrt(2pi)
315
+
316
+ Cephes Math Library Release 2.8: June, 2000
317
+ Copyright 1984, 1987, 1988, 1992, 2000 by Stephen L. Moshier
318
+ *************************************************************************/
319
+ double normalpdf(const double x, const xparams _xparams = alglib::xdefault);
320
+
321
+
322
+ /*************************************************************************
323
+ Normal distribution CDF
324
+
325
+ Returns the area under the Gaussian probability density
326
+ function, integrated from minus infinity to x:
327
+
328
+ x
329
+ -
330
+ 1 | | 2
331
+ ndtr(x) = --------- | exp( - t /2 ) dt
332
+ sqrt(2pi) | |
333
+ -
334
+ -inf.
335
+
336
+ = ( 1 + erf(z) ) / 2
337
+ = erfc(z) / 2
338
+
339
+ where z = x/sqrt(2). Computation is via the functions
340
+ erf and erfc.
341
+
342
+
343
+ ACCURACY:
344
+
345
+ Relative error:
346
+ arithmetic domain # trials peak rms
347
+ IEEE -13,0 30000 3.4e-14 6.7e-15
348
+
349
+ Cephes Math Library Release 2.8: June, 2000
350
+ Copyright 1984, 1987, 1988, 1992, 2000 by Stephen L. Moshier
351
+ *************************************************************************/
352
+ double normalcdf(const double x, const xparams _xparams = alglib::xdefault);
353
+
354
+
355
+ /*************************************************************************
356
+ Inverse of the error function
357
+
358
+ Cephes Math Library Release 2.8: June, 2000
359
+ Copyright 1984, 1987, 1988, 1992, 2000 by Stephen L. Moshier
360
+ *************************************************************************/
361
+ double inverf(const double e, const xparams _xparams = alglib::xdefault);
362
+
363
+
364
+ /*************************************************************************
365
+ Same as invnormalcdf(), deprecated name
366
+ *************************************************************************/
367
+ double invnormaldistribution(const double y0, const xparams _xparams = alglib::xdefault);
368
+
369
+
370
+ /*************************************************************************
371
+ Inverse of Normal CDF
372
+
373
+ Returns the argument, x, for which the area under the
374
+ Gaussian probability density function (integrated from
375
+ minus infinity to x) is equal to y.
376
+
377
+
378
+ For small arguments 0 < y < exp(-2), the program computes
379
+ z = sqrt( -2.0 * log(y) ); then the approximation is
380
+ x = z - log(z)/z - (1/z) P(1/z) / Q(1/z).
381
+ There are two rational functions P/Q, one for 0 < y < exp(-32)
382
+ and the other for y up to exp(-2). For larger arguments,
383
+ w = y - 0.5, and x/sqrt(2pi) = w + w**3 R(w**2)/S(w**2)).
384
+
385
+ ACCURACY:
386
+
387
+ Relative error:
388
+ arithmetic domain # trials peak rms
389
+ IEEE 0.125, 1 20000 7.2e-16 1.3e-16
390
+ IEEE 3e-308, 0.135 50000 4.6e-16 9.8e-17
391
+
392
+ Cephes Math Library Release 2.8: June, 2000
393
+ Copyright 1984, 1987, 1988, 1992, 2000 by Stephen L. Moshier
394
+ *************************************************************************/
395
+ double invnormalcdf(const double y0, const xparams _xparams = alglib::xdefault);
396
+
397
+
398
+ /*************************************************************************
399
+ Bivariate normal PDF
400
+
401
+ Returns probability density function of the bivariate Gaussian with
402
+ correlation parameter equal to Rho:
403
+
404
+ 1 ( x^2 - 2*rho*x*y + y^2 )
405
+ f(x,y,rho) = ----------------- * exp( - ----------------------- )
406
+ 2pi*sqrt(1-rho^2) ( 2*(1-rho^2) )
407
+
408
+
409
+ with -1<rho<+1 and arbitrary x, y.
410
+
411
+ This function won't fail as long as Rho is in (-1,+1) range.
412
+
413
+ -- ALGLIB --
414
+ Copyright 15.11.2019 by Bochkanov Sergey
415
+ *************************************************************************/
416
+ double bivariatenormalpdf(const double x, const double y, const double rho, const xparams _xparams = alglib::xdefault);
417
+
418
+
419
+ /*************************************************************************
420
+ Bivariate normal CDF
421
+
422
+ Returns the area under the bivariate Gaussian PDF with correlation
423
+ parameter equal to Rho, integrated from minus infinity to (x,y):
424
+
425
+
426
+ x y
427
+ - -
428
+ 1 | | | |
429
+ bvn(x,y,rho) = ------------------- | | f(u,v,rho)*du*dv
430
+ 2pi*sqrt(1-rho^2) | | | |
431
+ - -
432
+ -INF -INF
433
+
434
+
435
+ where
436
+
437
+ ( u^2 - 2*rho*u*v + v^2 )
438
+ f(u,v,rho) = exp( - ----------------------- )
439
+ ( 2*(1-rho^2) )
440
+
441
+
442
+ with -1<rho<+1 and arbitrary x, y.
443
+
444
+ This subroutine uses high-precision approximation scheme proposed by
445
+ Alan Genz in "Numerical Computation of Rectangular Bivariate and
446
+ Trivariate Normal and t probabilities", which computes CDF with
447
+ absolute error roughly equal to 1e-14.
448
+
449
+ This function won't fail as long as Rho is in (-1,+1) range.
450
+
451
+ -- ALGLIB --
452
+ Copyright 15.11.2019 by Bochkanov Sergey
453
+ *************************************************************************/
454
+ double bivariatenormalcdf(const double x, const double y, const double rho, const xparams _xparams = alglib::xdefault);
455
+ #endif
456
+
457
+ #if defined(AE_COMPILE_IBETAF) || !defined(AE_PARTIAL_BUILD)
458
+ /*************************************************************************
459
+ Incomplete beta integral
460
+
461
+ Returns incomplete beta integral of the arguments, evaluated
462
+ from zero to x. The function is defined as
463
+
464
+ x
465
+ - -
466
+ | (a+b) | | a-1 b-1
467
+ ----------- | t (1-t) dt.
468
+ - - | |
469
+ | (a) | (b) -
470
+ 0
471
+
472
+ The domain of definition is 0 <= x <= 1. In this
473
+ implementation a and b are restricted to positive values.
474
+ The integral from x to 1 may be obtained by the symmetry
475
+ relation
476
+
477
+ 1 - incbet( a, b, x ) = incbet( b, a, 1-x ).
478
+
479
+ The integral is evaluated by a continued fraction expansion
480
+ or, when b*x is small, by a power series.
481
+
482
+ ACCURACY:
483
+
484
+ Tested at uniformly distributed random points (a,b,x) with a and b
485
+ in "domain" and x between 0 and 1.
486
+ Relative error
487
+ arithmetic domain # trials peak rms
488
+ IEEE 0,5 10000 6.9e-15 4.5e-16
489
+ IEEE 0,85 250000 2.2e-13 1.7e-14
490
+ IEEE 0,1000 30000 5.3e-12 6.3e-13
491
+ IEEE 0,10000 250000 9.3e-11 7.1e-12
492
+ IEEE 0,100000 10000 8.7e-10 4.8e-11
493
+ Outputs smaller than the IEEE gradual underflow threshold
494
+ were excluded from these statistics.
495
+
496
+ Cephes Math Library, Release 2.8: June, 2000
497
+ Copyright 1984, 1995, 2000 by Stephen L. Moshier
498
+ *************************************************************************/
499
+ double incompletebeta(const double a, const double b, const double x, const xparams _xparams = alglib::xdefault);
500
+
501
+
502
+ /*************************************************************************
503
+ Inverse of imcomplete beta integral
504
+
505
+ Given y, the function finds x such that
506
+
507
+ incbet( a, b, x ) = y .
508
+
509
+ The routine performs interval halving or Newton iterations to find the
510
+ root of incbet(a,b,x) - y = 0.
511
+
512
+
513
+ ACCURACY:
514
+
515
+ Relative error:
516
+ x a,b
517
+ arithmetic domain domain # trials peak rms
518
+ IEEE 0,1 .5,10000 50000 5.8e-12 1.3e-13
519
+ IEEE 0,1 .25,100 100000 1.8e-13 3.9e-15
520
+ IEEE 0,1 0,5 50000 1.1e-12 5.5e-15
521
+ With a and b constrained to half-integer or integer values:
522
+ IEEE 0,1 .5,10000 50000 5.8e-12 1.1e-13
523
+ IEEE 0,1 .5,100 100000 1.7e-14 7.9e-16
524
+ With a = .5, b constrained to half-integer or integer values:
525
+ IEEE 0,1 .5,10000 10000 8.3e-11 1.0e-11
526
+
527
+ Cephes Math Library Release 2.8: June, 2000
528
+ Copyright 1984, 1996, 2000 by Stephen L. Moshier
529
+ *************************************************************************/
530
+ double invincompletebeta(const double a, const double b, const double y, const xparams _xparams = alglib::xdefault);
531
+ #endif
532
+
533
+ #if defined(AE_COMPILE_STUDENTTDISTR) || !defined(AE_PARTIAL_BUILD)
534
+ /*************************************************************************
535
+ Student's t distribution
536
+
537
+ Computes the integral from minus infinity to t of the Student
538
+ t distribution with integer k > 0 degrees of freedom:
539
+
540
+ t
541
+ -
542
+ | |
543
+ - | 2 -(k+1)/2
544
+ | ( (k+1)/2 ) | ( x )
545
+ ---------------------- | ( 1 + --- ) dx
546
+ - | ( k )
547
+ sqrt( k pi ) | ( k/2 ) |
548
+ | |
549
+ -
550
+ -inf.
551
+
552
+ Relation to incomplete beta integral:
553
+
554
+ 1 - stdtr(k,t) = 0.5 * incbet( k/2, 1/2, z )
555
+ where
556
+ z = k/(k + t**2).
557
+
558
+ For t < -2, this is the method of computation. For higher t,
559
+ a direct method is derived from integration by parts.
560
+ Since the function is symmetric about t=0, the area under the
561
+ right tail of the density is found by calling the function
562
+ with -t instead of t.
563
+
564
+ ACCURACY:
565
+
566
+ Tested at random 1 <= k <= 25. The "domain" refers to t.
567
+ Relative error:
568
+ arithmetic domain # trials peak rms
569
+ IEEE -100,-2 50000 5.9e-15 1.4e-15
570
+ IEEE -2,100 500000 2.7e-15 4.9e-17
571
+
572
+ Cephes Math Library Release 2.8: June, 2000
573
+ Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
574
+ *************************************************************************/
575
+ double studenttdistribution(const ae_int_t k, const double t, const xparams _xparams = alglib::xdefault);
576
+
577
+
578
+ /*************************************************************************
579
+ Functional inverse of Student's t distribution
580
+
581
+ Given probability p, finds the argument t such that stdtr(k,t)
582
+ is equal to p.
583
+
584
+ ACCURACY:
585
+
586
+ Tested at random 1 <= k <= 100. The "domain" refers to p:
587
+ Relative error:
588
+ arithmetic domain # trials peak rms
589
+ IEEE .001,.999 25000 5.7e-15 8.0e-16
590
+ IEEE 10^-6,.001 25000 2.0e-12 2.9e-14
591
+
592
+ Cephes Math Library Release 2.8: June, 2000
593
+ Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
594
+ *************************************************************************/
595
+ double invstudenttdistribution(const ae_int_t k, const double p, const xparams _xparams = alglib::xdefault);
596
+ #endif
597
+
598
+ #if defined(AE_COMPILE_FDISTR) || !defined(AE_PARTIAL_BUILD)
599
+ /*************************************************************************
600
+ F distribution
601
+
602
+ Returns the area from zero to x under the F density
603
+ function (also known as Snedcor's density or the
604
+ variance ratio density). This is the density
605
+ of x = (u1/df1)/(u2/df2), where u1 and u2 are random
606
+ variables having Chi square distributions with df1
607
+ and df2 degrees of freedom, respectively.
608
+ The incomplete beta integral is used, according to the
609
+ formula
610
+
611
+ P(x) = incbet( df1/2, df2/2, (df1*x/(df2 + df1*x) ).
612
+
613
+
614
+ The arguments a and b are greater than zero, and x is
615
+ nonnegative.
616
+
617
+ ACCURACY:
618
+
619
+ Tested at random points (a,b,x).
620
+
621
+ x a,b Relative error:
622
+ arithmetic domain domain # trials peak rms
623
+ IEEE 0,1 0,100 100000 9.8e-15 1.7e-15
624
+ IEEE 1,5 0,100 100000 6.5e-15 3.5e-16
625
+ IEEE 0,1 1,10000 100000 2.2e-11 3.3e-12
626
+ IEEE 1,5 1,10000 100000 1.1e-11 1.7e-13
627
+
628
+ Cephes Math Library Release 2.8: June, 2000
629
+ Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
630
+ *************************************************************************/
631
+ double fdistribution(const ae_int_t a, const ae_int_t b, const double x, const xparams _xparams = alglib::xdefault);
632
+
633
+
634
+ /*************************************************************************
635
+ Complemented F distribution
636
+
637
+ Returns the area from x to infinity under the F density
638
+ function (also known as Snedcor's density or the
639
+ variance ratio density).
640
+
641
+
642
+ inf.
643
+ -
644
+ 1 | | a-1 b-1
645
+ 1-P(x) = ------ | t (1-t) dt
646
+ B(a,b) | |
647
+ -
648
+ x
649
+
650
+
651
+ The incomplete beta integral is used, according to the
652
+ formula
653
+
654
+ P(x) = incbet( df2/2, df1/2, (df2/(df2 + df1*x) ).
655
+
656
+
657
+ ACCURACY:
658
+
659
+ Tested at random points (a,b,x) in the indicated intervals.
660
+ x a,b Relative error:
661
+ arithmetic domain domain # trials peak rms
662
+ IEEE 0,1 1,100 100000 3.7e-14 5.9e-16
663
+ IEEE 1,5 1,100 100000 8.0e-15 1.6e-15
664
+ IEEE 0,1 1,10000 100000 1.8e-11 3.5e-13
665
+ IEEE 1,5 1,10000 100000 2.0e-11 3.0e-12
666
+
667
+ Cephes Math Library Release 2.8: June, 2000
668
+ Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
669
+ *************************************************************************/
670
+ double fcdistribution(const ae_int_t a, const ae_int_t b, const double x, const xparams _xparams = alglib::xdefault);
671
+
672
+
673
+ /*************************************************************************
674
+ Inverse of complemented F distribution
675
+
676
+ Finds the F density argument x such that the integral
677
+ from x to infinity of the F density is equal to the
678
+ given probability p.
679
+
680
+ This is accomplished using the inverse beta integral
681
+ function and the relations
682
+
683
+ z = incbi( df2/2, df1/2, p )
684
+ x = df2 (1-z) / (df1 z).
685
+
686
+ Note: the following relations hold for the inverse of
687
+ the uncomplemented F distribution:
688
+
689
+ z = incbi( df1/2, df2/2, p )
690
+ x = df2 z / (df1 (1-z)).
691
+
692
+ ACCURACY:
693
+
694
+ Tested at random points (a,b,p).
695
+
696
+ a,b Relative error:
697
+ arithmetic domain # trials peak rms
698
+ For p between .001 and 1:
699
+ IEEE 1,100 100000 8.3e-15 4.7e-16
700
+ IEEE 1,10000 100000 2.1e-11 1.4e-13
701
+ For p between 10^-6 and 10^-3:
702
+ IEEE 1,100 50000 1.3e-12 8.4e-15
703
+ IEEE 1,10000 50000 3.0e-12 4.8e-14
704
+
705
+ Cephes Math Library Release 2.8: June, 2000
706
+ Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
707
+ *************************************************************************/
708
+ double invfdistribution(const ae_int_t a, const ae_int_t b, const double y, const xparams _xparams = alglib::xdefault);
709
+ #endif
710
+
711
+ #if defined(AE_COMPILE_IGAMMAF) || !defined(AE_PARTIAL_BUILD)
712
+ /*************************************************************************
713
+ Incomplete gamma integral
714
+
715
+ The function is defined by
716
+
717
+ x
718
+ -
719
+ 1 | | -t a-1
720
+ igam(a,x) = ----- | e t dt.
721
+ - | |
722
+ | (a) -
723
+ 0
724
+
725
+
726
+ In this implementation both arguments must be positive.
727
+ The integral is evaluated by either a power series or
728
+ continued fraction expansion, depending on the relative
729
+ values of a and x.
730
+
731
+ ACCURACY:
732
+
733
+ Relative error:
734
+ arithmetic domain # trials peak rms
735
+ IEEE 0,30 200000 3.6e-14 2.9e-15
736
+ IEEE 0,100 300000 9.9e-14 1.5e-14
737
+
738
+ Cephes Math Library Release 2.8: June, 2000
739
+ Copyright 1985, 1987, 2000 by Stephen L. Moshier
740
+ *************************************************************************/
741
+ double incompletegamma(const double a, const double x, const xparams _xparams = alglib::xdefault);
742
+
743
+
744
+ /*************************************************************************
745
+ Complemented incomplete gamma integral
746
+
747
+ The function is defined by
748
+
749
+
750
+ igamc(a,x) = 1 - igam(a,x)
751
+
752
+ inf.
753
+ -
754
+ 1 | | -t a-1
755
+ = ----- | e t dt.
756
+ - | |
757
+ | (a) -
758
+ x
759
+
760
+
761
+ In this implementation both arguments must be positive.
762
+ The integral is evaluated by either a power series or
763
+ continued fraction expansion, depending on the relative
764
+ values of a and x.
765
+
766
+ ACCURACY:
767
+
768
+ Tested at random a, x.
769
+ a x Relative error:
770
+ arithmetic domain domain # trials peak rms
771
+ IEEE 0.5,100 0,100 200000 1.9e-14 1.7e-15
772
+ IEEE 0.01,0.5 0,100 200000 1.4e-13 1.6e-15
773
+
774
+ Cephes Math Library Release 2.8: June, 2000
775
+ Copyright 1985, 1987, 2000 by Stephen L. Moshier
776
+ *************************************************************************/
777
+ double incompletegammac(const double a, const double x, const xparams _xparams = alglib::xdefault);
778
+
779
+
780
+ /*************************************************************************
781
+ Inverse of complemented imcomplete gamma integral
782
+
783
+ Given p, the function finds x such that
784
+
785
+ igamc( a, x ) = p.
786
+
787
+ Starting with the approximate value
788
+
789
+ 3
790
+ x = a t
791
+
792
+ where
793
+
794
+ t = 1 - d - ndtri(p) sqrt(d)
795
+
796
+ and
797
+
798
+ d = 1/9a,
799
+
800
+ the routine performs up to 10 Newton iterations to find the
801
+ root of igamc(a,x) - p = 0.
802
+
803
+ ACCURACY:
804
+
805
+ Tested at random a, p in the intervals indicated.
806
+
807
+ a p Relative error:
808
+ arithmetic domain domain # trials peak rms
809
+ IEEE 0.5,100 0,0.5 100000 1.0e-14 1.7e-15
810
+ IEEE 0.01,0.5 0,0.5 100000 9.0e-14 3.4e-15
811
+ IEEE 0.5,10000 0,0.5 20000 2.3e-13 3.8e-14
812
+
813
+ Cephes Math Library Release 2.8: June, 2000
814
+ Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
815
+ *************************************************************************/
816
+ double invincompletegammac(const double a, const double y0, const xparams _xparams = alglib::xdefault);
817
+ #endif
818
+
819
+ #if defined(AE_COMPILE_CHISQUAREDISTR) || !defined(AE_PARTIAL_BUILD)
820
+ /*************************************************************************
821
+ Chi-square distribution
822
+
823
+ Returns the area under the left hand tail (from 0 to x)
824
+ of the Chi square probability density function with
825
+ v degrees of freedom.
826
+
827
+
828
+ x
829
+ -
830
+ 1 | | v/2-1 -t/2
831
+ P( x | v ) = ----------- | t e dt
832
+ v/2 - | |
833
+ 2 | (v/2) -
834
+ 0
835
+
836
+ where x is the Chi-square variable.
837
+
838
+ The incomplete gamma integral is used, according to the
839
+ formula
840
+
841
+ y = chdtr( v, x ) = igam( v/2.0, x/2.0 ).
842
+
843
+ The arguments must both be positive.
844
+
845
+ ACCURACY:
846
+
847
+ See incomplete gamma function
848
+
849
+
850
+ Cephes Math Library Release 2.8: June, 2000
851
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
852
+ *************************************************************************/
853
+ double chisquaredistribution(const double v, const double x, const xparams _xparams = alglib::xdefault);
854
+
855
+
856
+ /*************************************************************************
857
+ Complemented Chi-square distribution
858
+
859
+ Returns the area under the right hand tail (from x to
860
+ infinity) of the Chi square probability density function
861
+ with v degrees of freedom:
862
+
863
+ inf.
864
+ -
865
+ 1 | | v/2-1 -t/2
866
+ P( x | v ) = ----------- | t e dt
867
+ v/2 - | |
868
+ 2 | (v/2) -
869
+ x
870
+
871
+ where x is the Chi-square variable.
872
+
873
+ The incomplete gamma integral is used, according to the
874
+ formula
875
+
876
+ y = chdtr( v, x ) = igamc( v/2.0, x/2.0 ).
877
+
878
+ The arguments must both be positive.
879
+
880
+ ACCURACY:
881
+
882
+ See incomplete gamma function
883
+
884
+ Cephes Math Library Release 2.8: June, 2000
885
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
886
+ *************************************************************************/
887
+ double chisquarecdistribution(const double v, const double x, const xparams _xparams = alglib::xdefault);
888
+
889
+
890
+ /*************************************************************************
891
+ Inverse of complemented Chi-square distribution
892
+
893
+ Finds the Chi-square argument x such that the integral
894
+ from x to infinity of the Chi-square density is equal
895
+ to the given cumulative probability y.
896
+
897
+ This is accomplished using the inverse gamma integral
898
+ function and the relation
899
+
900
+ x/2 = igami( df/2, y );
901
+
902
+ ACCURACY:
903
+
904
+ See inverse incomplete gamma function
905
+
906
+
907
+ Cephes Math Library Release 2.8: June, 2000
908
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
909
+ *************************************************************************/
910
+ double invchisquaredistribution(const double v, const double y, const xparams _xparams = alglib::xdefault);
911
+ #endif
912
+
913
+ #if defined(AE_COMPILE_BINOMIALDISTR) || !defined(AE_PARTIAL_BUILD)
914
+ /*************************************************************************
915
+ Binomial distribution
916
+
917
+ Returns the sum of the terms 0 through k of the Binomial
918
+ probability density:
919
+
920
+ k
921
+ -- ( n ) j n-j
922
+ > ( ) p (1-p)
923
+ -- ( j )
924
+ j=0
925
+
926
+ The terms are not summed directly; instead the incomplete
927
+ beta integral is employed, according to the formula
928
+
929
+ y = bdtr( k, n, p ) = incbet( n-k, k+1, 1-p ).
930
+
931
+ The arguments must be positive, with p ranging from 0 to 1.
932
+
933
+ ACCURACY:
934
+
935
+ Tested at random points (a,b,p), with p between 0 and 1.
936
+
937
+ a,b Relative error:
938
+ arithmetic domain # trials peak rms
939
+ For p between 0.001 and 1:
940
+ IEEE 0,100 100000 4.3e-15 2.6e-16
941
+
942
+ Cephes Math Library Release 2.8: June, 2000
943
+ Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
944
+ *************************************************************************/
945
+ double binomialdistribution(const ae_int_t k, const ae_int_t n, const double p, const xparams _xparams = alglib::xdefault);
946
+
947
+
948
+ /*************************************************************************
949
+ Complemented binomial distribution
950
+
951
+ Returns the sum of the terms k+1 through n of the Binomial
952
+ probability density:
953
+
954
+ n
955
+ -- ( n ) j n-j
956
+ > ( ) p (1-p)
957
+ -- ( j )
958
+ j=k+1
959
+
960
+ The terms are not summed directly; instead the incomplete
961
+ beta integral is employed, according to the formula
962
+
963
+ y = bdtrc( k, n, p ) = incbet( k+1, n-k, p ).
964
+
965
+ The arguments must be positive, with p ranging from 0 to 1.
966
+
967
+ ACCURACY:
968
+
969
+ Tested at random points (a,b,p).
970
+
971
+ a,b Relative error:
972
+ arithmetic domain # trials peak rms
973
+ For p between 0.001 and 1:
974
+ IEEE 0,100 100000 6.7e-15 8.2e-16
975
+ For p between 0 and .001:
976
+ IEEE 0,100 100000 1.5e-13 2.7e-15
977
+
978
+ Cephes Math Library Release 2.8: June, 2000
979
+ Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
980
+ *************************************************************************/
981
+ double binomialcdistribution(const ae_int_t k, const ae_int_t n, const double p, const xparams _xparams = alglib::xdefault);
982
+
983
+
984
+ /*************************************************************************
985
+ Inverse binomial distribution
986
+
987
+ Finds the event probability p such that the sum of the
988
+ terms 0 through k of the Binomial probability density
989
+ is equal to the given cumulative probability y.
990
+
991
+ This is accomplished using the inverse beta integral
992
+ function and the relation
993
+
994
+ 1 - p = incbi( n-k, k+1, y ).
995
+
996
+ ACCURACY:
997
+
998
+ Tested at random points (a,b,p).
999
+
1000
+ a,b Relative error:
1001
+ arithmetic domain # trials peak rms
1002
+ For p between 0.001 and 1:
1003
+ IEEE 0,100 100000 2.3e-14 6.4e-16
1004
+ IEEE 0,10000 100000 6.6e-12 1.2e-13
1005
+ For p between 10^-6 and 0.001:
1006
+ IEEE 0,100 100000 2.0e-12 1.3e-14
1007
+ IEEE 0,10000 100000 1.5e-12 3.2e-14
1008
+
1009
+ Cephes Math Library Release 2.8: June, 2000
1010
+ Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
1011
+ *************************************************************************/
1012
+ double invbinomialdistribution(const ae_int_t k, const ae_int_t n, const double y, const xparams _xparams = alglib::xdefault);
1013
+ #endif
1014
+
1015
+ #if defined(AE_COMPILE_EXPINTEGRALS) || !defined(AE_PARTIAL_BUILD)
1016
+ /*************************************************************************
1017
+ Exponential integral Ei(x)
1018
+
1019
+ x
1020
+ - t
1021
+ | | e
1022
+ Ei(x) = -|- --- dt .
1023
+ | | t
1024
+ -
1025
+ -inf
1026
+
1027
+ Not defined for x <= 0.
1028
+ See also expn.c.
1029
+
1030
+
1031
+
1032
+ ACCURACY:
1033
+
1034
+ Relative error:
1035
+ arithmetic domain # trials peak rms
1036
+ IEEE 0,100 50000 8.6e-16 1.3e-16
1037
+
1038
+ Cephes Math Library Release 2.8: May, 1999
1039
+ Copyright 1999 by Stephen L. Moshier
1040
+ *************************************************************************/
1041
+ double exponentialintegralei(const double x, const xparams _xparams = alglib::xdefault);
1042
+
1043
+
1044
+ /*************************************************************************
1045
+ Exponential integral En(x)
1046
+
1047
+ Evaluates the exponential integral
1048
+
1049
+ inf.
1050
+ -
1051
+ | | -xt
1052
+ | e
1053
+ E (x) = | ---- dt.
1054
+ n | n
1055
+ | | t
1056
+ -
1057
+ 1
1058
+
1059
+
1060
+ Both n and x must be nonnegative.
1061
+
1062
+ The routine employs either a power series, a continued
1063
+ fraction, or an asymptotic formula depending on the
1064
+ relative values of n and x.
1065
+
1066
+ ACCURACY:
1067
+
1068
+ Relative error:
1069
+ arithmetic domain # trials peak rms
1070
+ IEEE 0, 30 10000 1.7e-15 3.6e-16
1071
+
1072
+ Cephes Math Library Release 2.8: June, 2000
1073
+ Copyright 1985, 2000 by Stephen L. Moshier
1074
+ *************************************************************************/
1075
+ double exponentialintegralen(const double x, const ae_int_t n, const xparams _xparams = alglib::xdefault);
1076
+ #endif
1077
+
1078
+ #if defined(AE_COMPILE_JACOBIANELLIPTIC) || !defined(AE_PARTIAL_BUILD)
1079
+ /*************************************************************************
1080
+ Jacobian Elliptic Functions
1081
+
1082
+ Evaluates the Jacobian elliptic functions sn(u|m), cn(u|m),
1083
+ and dn(u|m) of parameter m between 0 and 1, and real
1084
+ argument u.
1085
+
1086
+ These functions are periodic, with quarter-period on the
1087
+ real axis equal to the complete elliptic integral
1088
+ ellpk(1.0-m).
1089
+
1090
+ Relation to incomplete elliptic integral:
1091
+ If u = ellik(phi,m), then sn(u|m) = sin(phi),
1092
+ and cn(u|m) = cos(phi). Phi is called the amplitude of u.
1093
+
1094
+ Computation is by means of the arithmetic-geometric mean
1095
+ algorithm, except when m is within 1e-9 of 0 or 1. In the
1096
+ latter case with m close to 1, the approximation applies
1097
+ only for phi < pi/2.
1098
+
1099
+ ACCURACY:
1100
+
1101
+ Tested at random points with u between 0 and 10, m between
1102
+ 0 and 1.
1103
+
1104
+ Absolute error (* = relative error):
1105
+ arithmetic function # trials peak rms
1106
+ IEEE phi 10000 9.2e-16* 1.4e-16*
1107
+ IEEE sn 50000 4.1e-15 4.6e-16
1108
+ IEEE cn 40000 3.6e-15 4.4e-16
1109
+ IEEE dn 10000 1.3e-12 1.8e-14
1110
+
1111
+ Peak error observed in consistency check using addition
1112
+ theorem for sn(u+v) was 4e-16 (absolute). Also tested by
1113
+ the above relation to the incomplete elliptic integral.
1114
+ Accuracy deteriorates when u is large.
1115
+
1116
+ Cephes Math Library Release 2.8: June, 2000
1117
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
1118
+ *************************************************************************/
1119
+ void jacobianellipticfunctions(const double u, const double m, double &sn, double &cn, double &dn, double &ph, const xparams _xparams = alglib::xdefault);
1120
+ #endif
1121
+
1122
+ #if defined(AE_COMPILE_TRIGINTEGRALS) || !defined(AE_PARTIAL_BUILD)
1123
+ /*************************************************************************
1124
+ Sine and cosine integrals
1125
+
1126
+ Evaluates the integrals
1127
+
1128
+ x
1129
+ -
1130
+ | cos t - 1
1131
+ Ci(x) = eul + ln x + | --------- dt,
1132
+ | t
1133
+ -
1134
+ 0
1135
+ x
1136
+ -
1137
+ | sin t
1138
+ Si(x) = | ----- dt
1139
+ | t
1140
+ -
1141
+ 0
1142
+
1143
+ where eul = 0.57721566490153286061 is Euler's constant.
1144
+ The integrals are approximated by rational functions.
1145
+ For x > 8 auxiliary functions f(x) and g(x) are employed
1146
+ such that
1147
+
1148
+ Ci(x) = f(x) sin(x) - g(x) cos(x)
1149
+ Si(x) = pi/2 - f(x) cos(x) - g(x) sin(x)
1150
+
1151
+
1152
+ ACCURACY:
1153
+ Test interval = [0,50].
1154
+ Absolute error, except relative when > 1:
1155
+ arithmetic function # trials peak rms
1156
+ IEEE Si 30000 4.4e-16 7.3e-17
1157
+ IEEE Ci 30000 6.9e-16 5.1e-17
1158
+
1159
+ Cephes Math Library Release 2.1: January, 1989
1160
+ Copyright 1984, 1987, 1989 by Stephen L. Moshier
1161
+ *************************************************************************/
1162
+ void sinecosineintegrals(const double x, double &si, double &ci, const xparams _xparams = alglib::xdefault);
1163
+
1164
+
1165
+ /*************************************************************************
1166
+ Hyperbolic sine and cosine integrals
1167
+
1168
+ Approximates the integrals
1169
+
1170
+ x
1171
+ -
1172
+ | | cosh t - 1
1173
+ Chi(x) = eul + ln x + | ----------- dt,
1174
+ | | t
1175
+ -
1176
+ 0
1177
+
1178
+ x
1179
+ -
1180
+ | | sinh t
1181
+ Shi(x) = | ------ dt
1182
+ | | t
1183
+ -
1184
+ 0
1185
+
1186
+ where eul = 0.57721566490153286061 is Euler's constant.
1187
+ The integrals are evaluated by power series for x < 8
1188
+ and by Chebyshev expansions for x between 8 and 88.
1189
+ For large x, both functions approach exp(x)/2x.
1190
+ Arguments greater than 88 in magnitude return MAXNUM.
1191
+
1192
+
1193
+ ACCURACY:
1194
+
1195
+ Test interval 0 to 88.
1196
+ Relative error:
1197
+ arithmetic function # trials peak rms
1198
+ IEEE Shi 30000 6.9e-16 1.6e-16
1199
+ Absolute error, except relative when |Chi| > 1:
1200
+ IEEE Chi 30000 8.4e-16 1.4e-16
1201
+
1202
+ Cephes Math Library Release 2.8: June, 2000
1203
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
1204
+ *************************************************************************/
1205
+ void hyperbolicsinecosineintegrals(const double x, double &shi, double &chi, const xparams _xparams = alglib::xdefault);
1206
+ #endif
1207
+
1208
+ #if defined(AE_COMPILE_CHEBYSHEV) || !defined(AE_PARTIAL_BUILD)
1209
+ /*************************************************************************
1210
+ Calculation of the value of the Chebyshev polynomials of the
1211
+ first and second kinds.
1212
+
1213
+ Parameters:
1214
+ r - polynomial kind, either 1 or 2.
1215
+ n - degree, n>=0
1216
+ x - argument, -1 <= x <= 1
1217
+
1218
+ Result:
1219
+ the value of the Chebyshev polynomial at x
1220
+ *************************************************************************/
1221
+ double chebyshevcalculate(const ae_int_t r, const ae_int_t n, const double x, const xparams _xparams = alglib::xdefault);
1222
+
1223
+
1224
+ /*************************************************************************
1225
+ Summation of Chebyshev polynomials using Clenshaw's recurrence formula.
1226
+
1227
+ This routine calculates
1228
+ c[0]*T0(x) + c[1]*T1(x) + ... + c[N]*TN(x)
1229
+ or
1230
+ c[0]*U0(x) + c[1]*U1(x) + ... + c[N]*UN(x)
1231
+ depending on the R.
1232
+
1233
+ Parameters:
1234
+ r - polynomial kind, either 1 or 2.
1235
+ n - degree, n>=0
1236
+ x - argument
1237
+
1238
+ Result:
1239
+ the value of the Chebyshev polynomial at x
1240
+ *************************************************************************/
1241
+ double chebyshevsum(const real_1d_array &c, const ae_int_t r, const ae_int_t n, const double x, const xparams _xparams = alglib::xdefault);
1242
+
1243
+
1244
+ /*************************************************************************
1245
+ Representation of Tn as C[0] + C[1]*X + ... + C[N]*X^N
1246
+
1247
+ Input parameters:
1248
+ N - polynomial degree, n>=0
1249
+
1250
+ Output parameters:
1251
+ C - coefficients
1252
+ *************************************************************************/
1253
+ void chebyshevcoefficients(const ae_int_t n, real_1d_array &c, const xparams _xparams = alglib::xdefault);
1254
+
1255
+
1256
+ /*************************************************************************
1257
+ Conversion of a series of Chebyshev polynomials to a power series.
1258
+
1259
+ Represents A[0]*T0(x) + A[1]*T1(x) + ... + A[N]*Tn(x) as
1260
+ B[0] + B[1]*X + ... + B[N]*X^N.
1261
+
1262
+ Input parameters:
1263
+ A - Chebyshev series coefficients
1264
+ N - degree, N>=0
1265
+
1266
+ Output parameters
1267
+ B - power series coefficients
1268
+ *************************************************************************/
1269
+ void fromchebyshev(const real_1d_array &a, const ae_int_t n, real_1d_array &b, const xparams _xparams = alglib::xdefault);
1270
+ #endif
1271
+
1272
+ #if defined(AE_COMPILE_POISSONDISTR) || !defined(AE_PARTIAL_BUILD)
1273
+ /*************************************************************************
1274
+ Poisson distribution
1275
+
1276
+ Returns the sum of the first k+1 terms of the Poisson
1277
+ distribution:
1278
+
1279
+ k j
1280
+ -- -m m
1281
+ > e --
1282
+ -- j!
1283
+ j=0
1284
+
1285
+ The terms are not summed directly; instead the incomplete
1286
+ gamma integral is employed, according to the relation
1287
+
1288
+ y = pdtr( k, m ) = igamc( k+1, m ).
1289
+
1290
+ The arguments must both be positive.
1291
+ ACCURACY:
1292
+
1293
+ See incomplete gamma function
1294
+
1295
+ Cephes Math Library Release 2.8: June, 2000
1296
+ Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
1297
+ *************************************************************************/
1298
+ double poissondistribution(const ae_int_t k, const double m, const xparams _xparams = alglib::xdefault);
1299
+
1300
+
1301
+ /*************************************************************************
1302
+ Complemented Poisson distribution
1303
+
1304
+ Returns the sum of the terms k+1 to infinity of the Poisson
1305
+ distribution:
1306
+
1307
+ inf. j
1308
+ -- -m m
1309
+ > e --
1310
+ -- j!
1311
+ j=k+1
1312
+
1313
+ The terms are not summed directly; instead the incomplete
1314
+ gamma integral is employed, according to the formula
1315
+
1316
+ y = pdtrc( k, m ) = igam( k+1, m ).
1317
+
1318
+ The arguments must both be positive.
1319
+
1320
+ ACCURACY:
1321
+
1322
+ See incomplete gamma function
1323
+
1324
+ Cephes Math Library Release 2.8: June, 2000
1325
+ Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
1326
+ *************************************************************************/
1327
+ double poissoncdistribution(const ae_int_t k, const double m, const xparams _xparams = alglib::xdefault);
1328
+
1329
+
1330
+ /*************************************************************************
1331
+ Inverse Poisson distribution
1332
+
1333
+ Finds the Poisson variable x such that the integral
1334
+ from 0 to x of the Poisson density is equal to the
1335
+ given probability y.
1336
+
1337
+ This is accomplished using the inverse gamma integral
1338
+ function and the relation
1339
+
1340
+ m = igami( k+1, y ).
1341
+
1342
+ ACCURACY:
1343
+
1344
+ See inverse incomplete gamma function
1345
+
1346
+ Cephes Math Library Release 2.8: June, 2000
1347
+ Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
1348
+ *************************************************************************/
1349
+ double invpoissondistribution(const ae_int_t k, const double y, const xparams _xparams = alglib::xdefault);
1350
+ #endif
1351
+
1352
+ #if defined(AE_COMPILE_BETAF) || !defined(AE_PARTIAL_BUILD)
1353
+ /*************************************************************************
1354
+ Beta function
1355
+
1356
+
1357
+ - -
1358
+ | (a) | (b)
1359
+ beta( a, b ) = -----------.
1360
+ -
1361
+ | (a+b)
1362
+
1363
+ For large arguments the logarithm of the function is
1364
+ evaluated using lgam(), then exponentiated.
1365
+
1366
+ ACCURACY:
1367
+
1368
+ Relative error:
1369
+ arithmetic domain # trials peak rms
1370
+ IEEE 0,30 30000 8.1e-14 1.1e-14
1371
+
1372
+ Cephes Math Library Release 2.0: April, 1987
1373
+ Copyright 1984, 1987 by Stephen L. Moshier
1374
+ *************************************************************************/
1375
+ double beta(const double a, const double b, const xparams _xparams = alglib::xdefault);
1376
+ #endif
1377
+
1378
+ #if defined(AE_COMPILE_FRESNEL) || !defined(AE_PARTIAL_BUILD)
1379
+ /*************************************************************************
1380
+ Fresnel integral
1381
+
1382
+ Evaluates the Fresnel integrals
1383
+
1384
+ x
1385
+ -
1386
+ | |
1387
+ C(x) = | cos(pi/2 t**2) dt,
1388
+ | |
1389
+ -
1390
+ 0
1391
+
1392
+ x
1393
+ -
1394
+ | |
1395
+ S(x) = | sin(pi/2 t**2) dt.
1396
+ | |
1397
+ -
1398
+ 0
1399
+
1400
+
1401
+ The integrals are evaluated by a power series for x < 1.
1402
+ For x >= 1 auxiliary functions f(x) and g(x) are employed
1403
+ such that
1404
+
1405
+ C(x) = 0.5 + f(x) sin( pi/2 x**2 ) - g(x) cos( pi/2 x**2 )
1406
+ S(x) = 0.5 - f(x) cos( pi/2 x**2 ) - g(x) sin( pi/2 x**2 )
1407
+
1408
+
1409
+
1410
+ ACCURACY:
1411
+
1412
+ Relative error.
1413
+
1414
+ Arithmetic function domain # trials peak rms
1415
+ IEEE S(x) 0, 10 10000 2.0e-15 3.2e-16
1416
+ IEEE C(x) 0, 10 10000 1.8e-15 3.3e-16
1417
+
1418
+ Cephes Math Library Release 2.8: June, 2000
1419
+ Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier
1420
+ *************************************************************************/
1421
+ void fresnelintegral(const double x, double &c, double &s, const xparams _xparams = alglib::xdefault);
1422
+ #endif
1423
+
1424
+ #if defined(AE_COMPILE_PSIF) || !defined(AE_PARTIAL_BUILD)
1425
+ /*************************************************************************
1426
+ Psi (digamma) function
1427
+
1428
+ d -
1429
+ psi(x) = -- ln | (x)
1430
+ dx
1431
+
1432
+ is the logarithmic derivative of the gamma function.
1433
+ For integer x,
1434
+ n-1
1435
+ -
1436
+ psi(n) = -EUL + > 1/k.
1437
+ -
1438
+ k=1
1439
+
1440
+ This formula is used for 0 < n <= 10. If x is negative, it
1441
+ is transformed to a positive argument by the reflection
1442
+ formula psi(1-x) = psi(x) + pi cot(pi x).
1443
+ For general positive x, the argument is made greater than 10
1444
+ using the recurrence psi(x+1) = psi(x) + 1/x.
1445
+ Then the following asymptotic expansion is applied:
1446
+
1447
+ inf. B
1448
+ - 2k
1449
+ psi(x) = log(x) - 1/2x - > -------
1450
+ - 2k
1451
+ k=1 2k x
1452
+
1453
+ where the B2k are Bernoulli numbers.
1454
+
1455
+ ACCURACY:
1456
+ Relative error (except absolute when |psi| < 1):
1457
+ arithmetic domain # trials peak rms
1458
+ IEEE 0,30 30000 1.3e-15 1.4e-16
1459
+ IEEE -30,0 40000 1.5e-15 2.2e-16
1460
+
1461
+ Cephes Math Library Release 2.8: June, 2000
1462
+ Copyright 1984, 1987, 1992, 2000 by Stephen L. Moshier
1463
+ *************************************************************************/
1464
+ double psi(const double x, const xparams _xparams = alglib::xdefault);
1465
+ #endif
1466
+
1467
+ #if defined(AE_COMPILE_AIRYF) || !defined(AE_PARTIAL_BUILD)
1468
+ /*************************************************************************
1469
+ Airy function
1470
+
1471
+ Solution of the differential equation
1472
+
1473
+ y"(x) = xy.
1474
+
1475
+ The function returns the two independent solutions Ai, Bi
1476
+ and their first derivatives Ai'(x), Bi'(x).
1477
+
1478
+ Evaluation is by power series summation for small x,
1479
+ by rational minimax approximations for large x.
1480
+
1481
+
1482
+
1483
+ ACCURACY:
1484
+ Error criterion is absolute when function <= 1, relative
1485
+ when function > 1, except * denotes relative error criterion.
1486
+ For large negative x, the absolute error increases as x^1.5.
1487
+ For large positive x, the relative error increases as x^1.5.
1488
+
1489
+ Arithmetic domain function # trials peak rms
1490
+ IEEE -10, 0 Ai 10000 1.6e-15 2.7e-16
1491
+ IEEE 0, 10 Ai 10000 2.3e-14* 1.8e-15*
1492
+ IEEE -10, 0 Ai' 10000 4.6e-15 7.6e-16
1493
+ IEEE 0, 10 Ai' 10000 1.8e-14* 1.5e-15*
1494
+ IEEE -10, 10 Bi 30000 4.2e-15 5.3e-16
1495
+ IEEE -10, 10 Bi' 30000 4.9e-15 7.3e-16
1496
+
1497
+ Cephes Math Library Release 2.8: June, 2000
1498
+ Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier
1499
+ *************************************************************************/
1500
+ void airy(const double x, double &ai, double &aip, double &bi, double &bip, const xparams _xparams = alglib::xdefault);
1501
+ #endif
1502
+
1503
+ #if defined(AE_COMPILE_DAWSON) || !defined(AE_PARTIAL_BUILD)
1504
+ /*************************************************************************
1505
+ Dawson's Integral
1506
+
1507
+ Approximates the integral
1508
+
1509
+ x
1510
+ -
1511
+ 2 | | 2
1512
+ dawsn(x) = exp( -x ) | exp( t ) dt
1513
+ | |
1514
+ -
1515
+ 0
1516
+
1517
+ Three different rational approximations are employed, for
1518
+ the intervals 0 to 3.25; 3.25 to 6.25; and 6.25 up.
1519
+
1520
+ ACCURACY:
1521
+
1522
+ Relative error:
1523
+ arithmetic domain # trials peak rms
1524
+ IEEE 0,10 10000 6.9e-16 1.0e-16
1525
+
1526
+ Cephes Math Library Release 2.8: June, 2000
1527
+ Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier
1528
+ *************************************************************************/
1529
+ double dawsonintegral(const double x, const xparams _xparams = alglib::xdefault);
1530
+ #endif
1531
+
1532
+ #if defined(AE_COMPILE_HERMITE) || !defined(AE_PARTIAL_BUILD)
1533
+ /*************************************************************************
1534
+ Calculation of the value of the Hermite polynomial.
1535
+
1536
+ Parameters:
1537
+ n - degree, n>=0
1538
+ x - argument
1539
+
1540
+ Result:
1541
+ the value of the Hermite polynomial Hn at x
1542
+ *************************************************************************/
1543
+ double hermitecalculate(const ae_int_t n, const double x, const xparams _xparams = alglib::xdefault);
1544
+
1545
+
1546
+ /*************************************************************************
1547
+ Summation of Hermite polynomials using Clenshaw's recurrence formula.
1548
+
1549
+ This routine calculates
1550
+ c[0]*H0(x) + c[1]*H1(x) + ... + c[N]*HN(x)
1551
+
1552
+ Parameters:
1553
+ n - degree, n>=0
1554
+ x - argument
1555
+
1556
+ Result:
1557
+ the value of the Hermite polynomial at x
1558
+ *************************************************************************/
1559
+ double hermitesum(const real_1d_array &c, const ae_int_t n, const double x, const xparams _xparams = alglib::xdefault);
1560
+
1561
+
1562
+ /*************************************************************************
1563
+ Representation of Hn as C[0] + C[1]*X + ... + C[N]*X^N
1564
+
1565
+ Input parameters:
1566
+ N - polynomial degree, n>=0
1567
+
1568
+ Output parameters:
1569
+ C - coefficients
1570
+ *************************************************************************/
1571
+ void hermitecoefficients(const ae_int_t n, real_1d_array &c, const xparams _xparams = alglib::xdefault);
1572
+ #endif
1573
+
1574
+ #if defined(AE_COMPILE_LEGENDRE) || !defined(AE_PARTIAL_BUILD)
1575
+ /*************************************************************************
1576
+ Calculation of the value of the Legendre polynomial Pn.
1577
+
1578
+ Parameters:
1579
+ n - degree, n>=0
1580
+ x - argument
1581
+
1582
+ Result:
1583
+ the value of the Legendre polynomial Pn at x
1584
+ *************************************************************************/
1585
+ double legendrecalculate(const ae_int_t n, const double x, const xparams _xparams = alglib::xdefault);
1586
+
1587
+
1588
+ /*************************************************************************
1589
+ Summation of Legendre polynomials using Clenshaw's recurrence formula.
1590
+
1591
+ This routine calculates
1592
+ c[0]*P0(x) + c[1]*P1(x) + ... + c[N]*PN(x)
1593
+
1594
+ Parameters:
1595
+ n - degree, n>=0
1596
+ x - argument
1597
+
1598
+ Result:
1599
+ the value of the Legendre polynomial at x
1600
+ *************************************************************************/
1601
+ double legendresum(const real_1d_array &c, const ae_int_t n, const double x, const xparams _xparams = alglib::xdefault);
1602
+
1603
+
1604
+ /*************************************************************************
1605
+ Representation of Pn as C[0] + C[1]*X + ... + C[N]*X^N
1606
+
1607
+ Input parameters:
1608
+ N - polynomial degree, n>=0
1609
+
1610
+ Output parameters:
1611
+ C - coefficients
1612
+ *************************************************************************/
1613
+ void legendrecoefficients(const ae_int_t n, real_1d_array &c, const xparams _xparams = alglib::xdefault);
1614
+ #endif
1615
+
1616
+ #if defined(AE_COMPILE_BESSEL) || !defined(AE_PARTIAL_BUILD)
1617
+ /*************************************************************************
1618
+ Bessel function of order zero
1619
+
1620
+ Returns Bessel function of order zero of the argument.
1621
+
1622
+ The domain is divided into the intervals [0, 5] and
1623
+ (5, infinity). In the first interval the following rational
1624
+ approximation is used:
1625
+
1626
+
1627
+ 2 2
1628
+ (w - r ) (w - r ) P (w) / Q (w)
1629
+ 1 2 3 8
1630
+
1631
+ 2
1632
+ where w = x and the two r's are zeros of the function.
1633
+
1634
+ In the second interval, the Hankel asymptotic expansion
1635
+ is employed with two rational functions of degree 6/6
1636
+ and 7/7.
1637
+
1638
+ ACCURACY:
1639
+
1640
+ Absolute error:
1641
+ arithmetic domain # trials peak rms
1642
+ IEEE 0, 30 60000 4.2e-16 1.1e-16
1643
+
1644
+ Cephes Math Library Release 2.8: June, 2000
1645
+ Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier
1646
+ *************************************************************************/
1647
+ double besselj0(const double x, const xparams _xparams = alglib::xdefault);
1648
+
1649
+
1650
+ /*************************************************************************
1651
+ Bessel function of order one
1652
+
1653
+ Returns Bessel function of order one of the argument.
1654
+
1655
+ The domain is divided into the intervals [0, 8] and
1656
+ (8, infinity). In the first interval a 24 term Chebyshev
1657
+ expansion is used. In the second, the asymptotic
1658
+ trigonometric representation is employed using two
1659
+ rational functions of degree 5/5.
1660
+
1661
+ ACCURACY:
1662
+
1663
+ Absolute error:
1664
+ arithmetic domain # trials peak rms
1665
+ IEEE 0, 30 30000 2.6e-16 1.1e-16
1666
+
1667
+ Cephes Math Library Release 2.8: June, 2000
1668
+ Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier
1669
+ *************************************************************************/
1670
+ double besselj1(const double x, const xparams _xparams = alglib::xdefault);
1671
+
1672
+
1673
+ /*************************************************************************
1674
+ Bessel function of integer order
1675
+
1676
+ Returns Bessel function of order n, where n is a
1677
+ (possibly negative) integer.
1678
+
1679
+ The ratio of jn(x) to j0(x) is computed by backward
1680
+ recurrence. First the ratio jn/jn-1 is found by a
1681
+ continued fraction expansion. Then the recurrence
1682
+ relating successive orders is applied until j0 or j1 is
1683
+ reached.
1684
+
1685
+ If n = 0 or 1 the routine for j0 or j1 is called
1686
+ directly.
1687
+
1688
+ ACCURACY:
1689
+
1690
+ Absolute error:
1691
+ arithmetic range # trials peak rms
1692
+ IEEE 0, 30 5000 4.4e-16 7.9e-17
1693
+
1694
+
1695
+ Not suitable for large n or x. Use jv() (fractional order) instead.
1696
+
1697
+ Cephes Math Library Release 2.8: June, 2000
1698
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
1699
+ *************************************************************************/
1700
+ double besseljn(const ae_int_t n, const double x, const xparams _xparams = alglib::xdefault);
1701
+
1702
+
1703
+ /*************************************************************************
1704
+ Bessel function of the second kind, order zero
1705
+
1706
+ Returns Bessel function of the second kind, of order
1707
+ zero, of the argument.
1708
+
1709
+ The domain is divided into the intervals [0, 5] and
1710
+ (5, infinity). In the first interval a rational approximation
1711
+ R(x) is employed to compute
1712
+ y0(x) = R(x) + 2 * log(x) * j0(x) / PI.
1713
+ Thus a call to j0() is required.
1714
+
1715
+ In the second interval, the Hankel asymptotic expansion
1716
+ is employed with two rational functions of degree 6/6
1717
+ and 7/7.
1718
+
1719
+
1720
+
1721
+ ACCURACY:
1722
+
1723
+ Absolute error, when y0(x) < 1; else relative error:
1724
+
1725
+ arithmetic domain # trials peak rms
1726
+ IEEE 0, 30 30000 1.3e-15 1.6e-16
1727
+
1728
+ Cephes Math Library Release 2.8: June, 2000
1729
+ Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier
1730
+ *************************************************************************/
1731
+ double bessely0(const double x, const xparams _xparams = alglib::xdefault);
1732
+
1733
+
1734
+ /*************************************************************************
1735
+ Bessel function of second kind of order one
1736
+
1737
+ Returns Bessel function of the second kind of order one
1738
+ of the argument.
1739
+
1740
+ The domain is divided into the intervals [0, 8] and
1741
+ (8, infinity). In the first interval a 25 term Chebyshev
1742
+ expansion is used, and a call to j1() is required.
1743
+ In the second, the asymptotic trigonometric representation
1744
+ is employed using two rational functions of degree 5/5.
1745
+
1746
+ ACCURACY:
1747
+
1748
+ Absolute error:
1749
+ arithmetic domain # trials peak rms
1750
+ IEEE 0, 30 30000 1.0e-15 1.3e-16
1751
+
1752
+ Cephes Math Library Release 2.8: June, 2000
1753
+ Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier
1754
+ *************************************************************************/
1755
+ double bessely1(const double x, const xparams _xparams = alglib::xdefault);
1756
+
1757
+
1758
+ /*************************************************************************
1759
+ Bessel function of second kind of integer order
1760
+
1761
+ Returns Bessel function of order n, where n is a
1762
+ (possibly negative) integer.
1763
+
1764
+ The function is evaluated by forward recurrence on
1765
+ n, starting with values computed by the routines
1766
+ y0() and y1().
1767
+
1768
+ If n = 0 or 1 the routine for y0 or y1 is called
1769
+ directly.
1770
+
1771
+ ACCURACY:
1772
+ Absolute error, except relative
1773
+ when y > 1:
1774
+ arithmetic domain # trials peak rms
1775
+ IEEE 0, 30 30000 3.4e-15 4.3e-16
1776
+
1777
+ Cephes Math Library Release 2.8: June, 2000
1778
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
1779
+ *************************************************************************/
1780
+ double besselyn(const ae_int_t n, const double x, const xparams _xparams = alglib::xdefault);
1781
+
1782
+
1783
+ /*************************************************************************
1784
+ Modified Bessel function of order zero
1785
+
1786
+ Returns modified Bessel function of order zero of the
1787
+ argument.
1788
+
1789
+ The function is defined as i0(x) = j0( ix ).
1790
+
1791
+ The range is partitioned into the two intervals [0,8] and
1792
+ (8, infinity). Chebyshev polynomial expansions are employed
1793
+ in each interval.
1794
+
1795
+ ACCURACY:
1796
+
1797
+ Relative error:
1798
+ arithmetic domain # trials peak rms
1799
+ IEEE 0,30 30000 5.8e-16 1.4e-16
1800
+
1801
+ Cephes Math Library Release 2.8: June, 2000
1802
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
1803
+ *************************************************************************/
1804
+ double besseli0(const double x, const xparams _xparams = alglib::xdefault);
1805
+
1806
+
1807
+ /*************************************************************************
1808
+ Modified Bessel function of order one
1809
+
1810
+ Returns modified Bessel function of order one of the
1811
+ argument.
1812
+
1813
+ The function is defined as i1(x) = -i j1( ix ).
1814
+
1815
+ The range is partitioned into the two intervals [0,8] and
1816
+ (8, infinity). Chebyshev polynomial expansions are employed
1817
+ in each interval.
1818
+
1819
+ ACCURACY:
1820
+
1821
+ Relative error:
1822
+ arithmetic domain # trials peak rms
1823
+ IEEE 0, 30 30000 1.9e-15 2.1e-16
1824
+
1825
+ Cephes Math Library Release 2.8: June, 2000
1826
+ Copyright 1985, 1987, 2000 by Stephen L. Moshier
1827
+ *************************************************************************/
1828
+ double besseli1(const double x, const xparams _xparams = alglib::xdefault);
1829
+
1830
+
1831
+ /*************************************************************************
1832
+ Modified Bessel function, second kind, order zero
1833
+
1834
+ Returns modified Bessel function of the second kind
1835
+ of order zero of the argument.
1836
+
1837
+ The range is partitioned into the two intervals [0,8] and
1838
+ (8, infinity). Chebyshev polynomial expansions are employed
1839
+ in each interval.
1840
+
1841
+ ACCURACY:
1842
+
1843
+ Tested at 2000 random points between 0 and 8. Peak absolute
1844
+ error (relative when K0 > 1) was 1.46e-14; rms, 4.26e-15.
1845
+ Relative error:
1846
+ arithmetic domain # trials peak rms
1847
+ IEEE 0, 30 30000 1.2e-15 1.6e-16
1848
+
1849
+ Cephes Math Library Release 2.8: June, 2000
1850
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
1851
+ *************************************************************************/
1852
+ double besselk0(const double x, const xparams _xparams = alglib::xdefault);
1853
+
1854
+
1855
+ /*************************************************************************
1856
+ Modified Bessel function, second kind, order one
1857
+
1858
+ Computes the modified Bessel function of the second kind
1859
+ of order one of the argument.
1860
+
1861
+ The range is partitioned into the two intervals [0,2] and
1862
+ (2, infinity). Chebyshev polynomial expansions are employed
1863
+ in each interval.
1864
+
1865
+ ACCURACY:
1866
+
1867
+ Relative error:
1868
+ arithmetic domain # trials peak rms
1869
+ IEEE 0, 30 30000 1.2e-15 1.6e-16
1870
+
1871
+ Cephes Math Library Release 2.8: June, 2000
1872
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
1873
+ *************************************************************************/
1874
+ double besselk1(const double x, const xparams _xparams = alglib::xdefault);
1875
+
1876
+
1877
+ /*************************************************************************
1878
+ Modified Bessel function, second kind, integer order
1879
+
1880
+ Returns modified Bessel function of the second kind
1881
+ of order n of the argument.
1882
+
1883
+ The range is partitioned into the two intervals [0,9.55] and
1884
+ (9.55, infinity). An ascending power series is used in the
1885
+ low range, and an asymptotic expansion in the high range.
1886
+
1887
+ ACCURACY:
1888
+
1889
+ Relative error:
1890
+ arithmetic domain # trials peak rms
1891
+ IEEE 0,30 90000 1.8e-8 3.0e-10
1892
+
1893
+ Error is high only near the crossover point x = 9.55
1894
+ between the two expansions used.
1895
+
1896
+ Cephes Math Library Release 2.8: June, 2000
1897
+ Copyright 1984, 1987, 1988, 2000 by Stephen L. Moshier
1898
+ *************************************************************************/
1899
+ double besselkn(const ae_int_t nn, const double x, const xparams _xparams = alglib::xdefault);
1900
+ #endif
1901
+
1902
+ #if defined(AE_COMPILE_LAGUERRE) || !defined(AE_PARTIAL_BUILD)
1903
+ /*************************************************************************
1904
+ Calculation of the value of the Laguerre polynomial.
1905
+
1906
+ Parameters:
1907
+ n - degree, n>=0
1908
+ x - argument
1909
+
1910
+ Result:
1911
+ the value of the Laguerre polynomial Ln at x
1912
+ *************************************************************************/
1913
+ double laguerrecalculate(const ae_int_t n, const double x, const xparams _xparams = alglib::xdefault);
1914
+
1915
+
1916
+ /*************************************************************************
1917
+ Summation of Laguerre polynomials using Clenshaw's recurrence formula.
1918
+
1919
+ This routine calculates c[0]*L0(x) + c[1]*L1(x) + ... + c[N]*LN(x)
1920
+
1921
+ Parameters:
1922
+ n - degree, n>=0
1923
+ x - argument
1924
+
1925
+ Result:
1926
+ the value of the Laguerre polynomial at x
1927
+ *************************************************************************/
1928
+ double laguerresum(const real_1d_array &c, const ae_int_t n, const double x, const xparams _xparams = alglib::xdefault);
1929
+
1930
+
1931
+ /*************************************************************************
1932
+ Representation of Ln as C[0] + C[1]*X + ... + C[N]*X^N
1933
+
1934
+ Input parameters:
1935
+ N - polynomial degree, n>=0
1936
+
1937
+ Output parameters:
1938
+ C - coefficients
1939
+ *************************************************************************/
1940
+ void laguerrecoefficients(const ae_int_t n, real_1d_array &c, const xparams _xparams = alglib::xdefault);
1941
+ #endif
1942
+
1943
+ #if defined(AE_COMPILE_ELLIPTIC) || !defined(AE_PARTIAL_BUILD)
1944
+ /*************************************************************************
1945
+ Complete elliptic integral of the first kind
1946
+
1947
+ Approximates the integral
1948
+
1949
+
1950
+
1951
+ pi/2
1952
+ -
1953
+ | |
1954
+ | dt
1955
+ K(m) = | ------------------
1956
+ | 2
1957
+ | | sqrt( 1 - m sin t )
1958
+ -
1959
+ 0
1960
+
1961
+ using the approximation
1962
+
1963
+ P(x) - log x Q(x).
1964
+
1965
+ ACCURACY:
1966
+
1967
+ Relative error:
1968
+ arithmetic domain # trials peak rms
1969
+ IEEE 0,1 30000 2.5e-16 6.8e-17
1970
+
1971
+ Cephes Math Library, Release 2.8: June, 2000
1972
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
1973
+ *************************************************************************/
1974
+ double ellipticintegralk(const double m, const xparams _xparams = alglib::xdefault);
1975
+
1976
+
1977
+ /*************************************************************************
1978
+ Complete elliptic integral of the first kind
1979
+
1980
+ Approximates the integral
1981
+
1982
+
1983
+
1984
+ pi/2
1985
+ -
1986
+ | |
1987
+ | dt
1988
+ K(m) = | ------------------
1989
+ | 2
1990
+ | | sqrt( 1 - m sin t )
1991
+ -
1992
+ 0
1993
+
1994
+ where m = 1 - m1, using the approximation
1995
+
1996
+ P(x) - log x Q(x).
1997
+
1998
+ The argument m1 is used rather than m so that the logarithmic
1999
+ singularity at m = 1 will be shifted to the origin; this
2000
+ preserves maximum accuracy.
2001
+
2002
+ K(0) = pi/2.
2003
+
2004
+ ACCURACY:
2005
+
2006
+ Relative error:
2007
+ arithmetic domain # trials peak rms
2008
+ IEEE 0,1 30000 2.5e-16 6.8e-17
2009
+
2010
+ Cephes Math Library, Release 2.8: June, 2000
2011
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
2012
+ *************************************************************************/
2013
+ double ellipticintegralkhighprecision(const double m1, const xparams _xparams = alglib::xdefault);
2014
+
2015
+
2016
+ /*************************************************************************
2017
+ Incomplete elliptic integral of the first kind F(phi|m)
2018
+
2019
+ Approximates the integral
2020
+
2021
+
2022
+
2023
+ phi
2024
+ -
2025
+ | |
2026
+ | dt
2027
+ F(phi_\m) = | ------------------
2028
+ | 2
2029
+ | | sqrt( 1 - m sin t )
2030
+ -
2031
+ 0
2032
+
2033
+ of amplitude phi and modulus m, using the arithmetic -
2034
+ geometric mean algorithm.
2035
+
2036
+
2037
+
2038
+
2039
+ ACCURACY:
2040
+
2041
+ Tested at random points with m in [0, 1] and phi as indicated.
2042
+
2043
+ Relative error:
2044
+ arithmetic domain # trials peak rms
2045
+ IEEE -10,10 200000 7.4e-16 1.0e-16
2046
+
2047
+ Cephes Math Library Release 2.8: June, 2000
2048
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
2049
+ *************************************************************************/
2050
+ double incompleteellipticintegralk(const double phi, const double m, const xparams _xparams = alglib::xdefault);
2051
+
2052
+
2053
+ /*************************************************************************
2054
+ Complete elliptic integral of the second kind
2055
+
2056
+ Approximates the integral
2057
+
2058
+
2059
+ pi/2
2060
+ -
2061
+ | | 2
2062
+ E(m) = | sqrt( 1 - m sin t ) dt
2063
+ | |
2064
+ -
2065
+ 0
2066
+
2067
+ using the approximation
2068
+
2069
+ P(x) - x log x Q(x).
2070
+
2071
+ ACCURACY:
2072
+
2073
+ Relative error:
2074
+ arithmetic domain # trials peak rms
2075
+ IEEE 0, 1 10000 2.1e-16 7.3e-17
2076
+
2077
+ Cephes Math Library, Release 2.8: June, 2000
2078
+ Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier
2079
+ *************************************************************************/
2080
+ double ellipticintegrale(const double m, const xparams _xparams = alglib::xdefault);
2081
+
2082
+
2083
+ /*************************************************************************
2084
+ Incomplete elliptic integral of the second kind
2085
+
2086
+ Approximates the integral
2087
+
2088
+
2089
+ phi
2090
+ -
2091
+ | |
2092
+ | 2
2093
+ E(phi_\m) = | sqrt( 1 - m sin t ) dt
2094
+ |
2095
+ | |
2096
+ -
2097
+ 0
2098
+
2099
+ of amplitude phi and modulus m, using the arithmetic -
2100
+ geometric mean algorithm.
2101
+
2102
+ ACCURACY:
2103
+
2104
+ Tested at random arguments with phi in [-10, 10] and m in
2105
+ [0, 1].
2106
+ Relative error:
2107
+ arithmetic domain # trials peak rms
2108
+ IEEE -10,10 150000 3.3e-15 1.4e-16
2109
+
2110
+ Cephes Math Library Release 2.8: June, 2000
2111
+ Copyright 1984, 1987, 1993, 2000 by Stephen L. Moshier
2112
+ *************************************************************************/
2113
+ double incompleteellipticintegrale(const double phi, const double m, const xparams _xparams = alglib::xdefault);
2114
+ #endif
2115
+ }
2116
+
2117
+ /////////////////////////////////////////////////////////////////////////
2118
+ //
2119
+ // THIS SECTION CONTAINS COMPUTATIONAL CORE DECLARATIONS (FUNCTIONS)
2120
+ //
2121
+ /////////////////////////////////////////////////////////////////////////
2122
+ namespace alglib_impl
2123
+ {
2124
+ #if defined(AE_COMPILE_GAMMAFUNC) || !defined(AE_PARTIAL_BUILD)
2125
+ double gammafunction(double x, ae_state *_state);
2126
+ double lngamma(double x, double* sgngam, ae_state *_state);
2127
+ #endif
2128
+ #if defined(AE_COMPILE_NORMALDISTR) || !defined(AE_PARTIAL_BUILD)
2129
+ double errorfunction(double x, ae_state *_state);
2130
+ double errorfunctionc(double x, ae_state *_state);
2131
+ double normaldistribution(double x, ae_state *_state);
2132
+ double normalpdf(double x, ae_state *_state);
2133
+ double normalcdf(double x, ae_state *_state);
2134
+ double inverf(double e, ae_state *_state);
2135
+ double invnormaldistribution(double y0, ae_state *_state);
2136
+ double invnormalcdf(double y0, ae_state *_state);
2137
+ double bivariatenormalpdf(double x,
2138
+ double y,
2139
+ double rho,
2140
+ ae_state *_state);
2141
+ double bivariatenormalcdf(double x,
2142
+ double y,
2143
+ double rho,
2144
+ ae_state *_state);
2145
+ #endif
2146
+ #if defined(AE_COMPILE_IBETAF) || !defined(AE_PARTIAL_BUILD)
2147
+ double incompletebeta(double a, double b, double x, ae_state *_state);
2148
+ double invincompletebeta(double a, double b, double y, ae_state *_state);
2149
+ #endif
2150
+ #if defined(AE_COMPILE_STUDENTTDISTR) || !defined(AE_PARTIAL_BUILD)
2151
+ double studenttdistribution(ae_int_t k, double t, ae_state *_state);
2152
+ double invstudenttdistribution(ae_int_t k, double p, ae_state *_state);
2153
+ #endif
2154
+ #if defined(AE_COMPILE_FDISTR) || !defined(AE_PARTIAL_BUILD)
2155
+ double fdistribution(ae_int_t a, ae_int_t b, double x, ae_state *_state);
2156
+ double fcdistribution(ae_int_t a, ae_int_t b, double x, ae_state *_state);
2157
+ double invfdistribution(ae_int_t a,
2158
+ ae_int_t b,
2159
+ double y,
2160
+ ae_state *_state);
2161
+ #endif
2162
+ #if defined(AE_COMPILE_IGAMMAF) || !defined(AE_PARTIAL_BUILD)
2163
+ double incompletegamma(double a, double x, ae_state *_state);
2164
+ double incompletegammac(double a, double x, ae_state *_state);
2165
+ double invincompletegammac(double a, double y0, ae_state *_state);
2166
+ #endif
2167
+ #if defined(AE_COMPILE_CHISQUAREDISTR) || !defined(AE_PARTIAL_BUILD)
2168
+ double chisquaredistribution(double v, double x, ae_state *_state);
2169
+ double chisquarecdistribution(double v, double x, ae_state *_state);
2170
+ double invchisquaredistribution(double v, double y, ae_state *_state);
2171
+ #endif
2172
+ #if defined(AE_COMPILE_BINOMIALDISTR) || !defined(AE_PARTIAL_BUILD)
2173
+ double binomialdistribution(ae_int_t k,
2174
+ ae_int_t n,
2175
+ double p,
2176
+ ae_state *_state);
2177
+ double binomialcdistribution(ae_int_t k,
2178
+ ae_int_t n,
2179
+ double p,
2180
+ ae_state *_state);
2181
+ double invbinomialdistribution(ae_int_t k,
2182
+ ae_int_t n,
2183
+ double y,
2184
+ ae_state *_state);
2185
+ #endif
2186
+ #if defined(AE_COMPILE_EXPINTEGRALS) || !defined(AE_PARTIAL_BUILD)
2187
+ double exponentialintegralei(double x, ae_state *_state);
2188
+ double exponentialintegralen(double x, ae_int_t n, ae_state *_state);
2189
+ #endif
2190
+ #if defined(AE_COMPILE_JACOBIANELLIPTIC) || !defined(AE_PARTIAL_BUILD)
2191
+ void jacobianellipticfunctions(double u,
2192
+ double m,
2193
+ double* sn,
2194
+ double* cn,
2195
+ double* dn,
2196
+ double* ph,
2197
+ ae_state *_state);
2198
+ #endif
2199
+ #if defined(AE_COMPILE_TRIGINTEGRALS) || !defined(AE_PARTIAL_BUILD)
2200
+ void sinecosineintegrals(double x,
2201
+ double* si,
2202
+ double* ci,
2203
+ ae_state *_state);
2204
+ void hyperbolicsinecosineintegrals(double x,
2205
+ double* shi,
2206
+ double* chi,
2207
+ ae_state *_state);
2208
+ #endif
2209
+ #if defined(AE_COMPILE_CHEBYSHEV) || !defined(AE_PARTIAL_BUILD)
2210
+ double chebyshevcalculate(ae_int_t r,
2211
+ ae_int_t n,
2212
+ double x,
2213
+ ae_state *_state);
2214
+ double chebyshevsum(/* Real */ const ae_vector* c,
2215
+ ae_int_t r,
2216
+ ae_int_t n,
2217
+ double x,
2218
+ ae_state *_state);
2219
+ void chebyshevcoefficients(ae_int_t n,
2220
+ /* Real */ ae_vector* c,
2221
+ ae_state *_state);
2222
+ void fromchebyshev(/* Real */ const ae_vector* a,
2223
+ ae_int_t n,
2224
+ /* Real */ ae_vector* b,
2225
+ ae_state *_state);
2226
+ #endif
2227
+ #if defined(AE_COMPILE_POISSONDISTR) || !defined(AE_PARTIAL_BUILD)
2228
+ double poissondistribution(ae_int_t k, double m, ae_state *_state);
2229
+ double poissoncdistribution(ae_int_t k, double m, ae_state *_state);
2230
+ double invpoissondistribution(ae_int_t k, double y, ae_state *_state);
2231
+ #endif
2232
+ #if defined(AE_COMPILE_BETAF) || !defined(AE_PARTIAL_BUILD)
2233
+ double beta(double a, double b, ae_state *_state);
2234
+ #endif
2235
+ #if defined(AE_COMPILE_FRESNEL) || !defined(AE_PARTIAL_BUILD)
2236
+ void fresnelintegral(double x, double* c, double* s, ae_state *_state);
2237
+ #endif
2238
+ #if defined(AE_COMPILE_PSIF) || !defined(AE_PARTIAL_BUILD)
2239
+ double psi(double x, ae_state *_state);
2240
+ #endif
2241
+ #if defined(AE_COMPILE_AIRYF) || !defined(AE_PARTIAL_BUILD)
2242
+ void airy(double x,
2243
+ double* ai,
2244
+ double* aip,
2245
+ double* bi,
2246
+ double* bip,
2247
+ ae_state *_state);
2248
+ #endif
2249
+ #if defined(AE_COMPILE_DAWSON) || !defined(AE_PARTIAL_BUILD)
2250
+ double dawsonintegral(double x, ae_state *_state);
2251
+ #endif
2252
+ #if defined(AE_COMPILE_HERMITE) || !defined(AE_PARTIAL_BUILD)
2253
+ double hermitecalculate(ae_int_t n, double x, ae_state *_state);
2254
+ double hermitesum(/* Real */ const ae_vector* c,
2255
+ ae_int_t n,
2256
+ double x,
2257
+ ae_state *_state);
2258
+ void hermitecoefficients(ae_int_t n,
2259
+ /* Real */ ae_vector* c,
2260
+ ae_state *_state);
2261
+ #endif
2262
+ #if defined(AE_COMPILE_LEGENDRE) || !defined(AE_PARTIAL_BUILD)
2263
+ double legendrecalculate(ae_int_t n, double x, ae_state *_state);
2264
+ double legendresum(/* Real */ const ae_vector* c,
2265
+ ae_int_t n,
2266
+ double x,
2267
+ ae_state *_state);
2268
+ void legendrecoefficients(ae_int_t n,
2269
+ /* Real */ ae_vector* c,
2270
+ ae_state *_state);
2271
+ #endif
2272
+ #if defined(AE_COMPILE_BESSEL) || !defined(AE_PARTIAL_BUILD)
2273
+ double besselj0(double x, ae_state *_state);
2274
+ double besselj1(double x, ae_state *_state);
2275
+ double besseljn(ae_int_t n, double x, ae_state *_state);
2276
+ double bessely0(double x, ae_state *_state);
2277
+ double bessely1(double x, ae_state *_state);
2278
+ double besselyn(ae_int_t n, double x, ae_state *_state);
2279
+ double besseli0(double x, ae_state *_state);
2280
+ double besseli1(double x, ae_state *_state);
2281
+ double besselk0(double x, ae_state *_state);
2282
+ double besselk1(double x, ae_state *_state);
2283
+ double besselkn(ae_int_t nn, double x, ae_state *_state);
2284
+ #endif
2285
+ #if defined(AE_COMPILE_LAGUERRE) || !defined(AE_PARTIAL_BUILD)
2286
+ double laguerrecalculate(ae_int_t n, double x, ae_state *_state);
2287
+ double laguerresum(/* Real */ const ae_vector* c,
2288
+ ae_int_t n,
2289
+ double x,
2290
+ ae_state *_state);
2291
+ void laguerrecoefficients(ae_int_t n,
2292
+ /* Real */ ae_vector* c,
2293
+ ae_state *_state);
2294
+ #endif
2295
+ #if defined(AE_COMPILE_ELLIPTIC) || !defined(AE_PARTIAL_BUILD)
2296
+ double ellipticintegralk(double m, ae_state *_state);
2297
+ double ellipticintegralkhighprecision(double m1, ae_state *_state);
2298
+ double incompleteellipticintegralk(double phi, double m, ae_state *_state);
2299
+ double ellipticintegrale(double m, ae_state *_state);
2300
+ double incompleteellipticintegrale(double phi, double m, ae_state *_state);
2301
+ #endif
2302
+
2303
+ }
2304
+ #endif
2305
+