31 long double f,
g, x2,
s;
38 s = 0.5L - cosl(x2) * f - sinl(x2) *
g;
39 return (
x < 0.0L) ? -
s :
s;
45 long double f,
g, x2,
c;
52 c = 0.5L + sinl(x2) * f - cosl(x2) *
g;
53 return (
x < 0.0L) ? -
c :
c;
56 long double mrpt::math::lfresnel_sin_integral(
long double x)
MRPT_NO_THROWS 58 long double sqrt_2_o_pi = 7.978845608028653558798921198687637369517e-1L;
62 long double mrpt::math::lfresnel_cos_integral(
long double x)
MRPT_NO_THROWS 64 long double sqrt_2_o_pi = 7.978845608028653558798921198687637369517e-1L;
70 return static_cast<double>(lfresnel_sin_integral(static_cast<long double>(
x)));
75 return static_cast<double>(lfresnel_cos_integral(static_cast<long double>(
x)));
144 s = 0.5L - cosl(x2) * f - sinl(x2) *
g;
145 return (
x < 0.0L) ? -
s :
s;
174 long double x2 =
x *
x;
175 long double x3 =
x * x2;
176 long double x4 = -x2 * x2;
177 long double xn = 1.0L;
178 long double Sn = 1.0L;
179 long double Sm1 = 0.0L;
182 long double sqrt_2_o_pi = 7.978845608028653558798921198687637369517e-1L;
185 if (
x == 0.0L)
return 0.0L;
187 while (fabsl(Sn - Sm1) > LDBL_EPSILON * fabsl(Sm1)) {
194 term /= (
long double)(
y +
y +
y +
y + 3);
197 return x3 * sqrt_2_o_pi * Sn;
207 static long double const sqrt_2pi = 2.506628274631000502415765284811045253006L;
273 if (
x == 0.0L)
return 0.5L;
308 static long double const c[] = {
309 +2.560134650043040830997e-1L, -1.993005146464943284549e-1L,
310 +4.025503636721387266117e-2L, -4.459600454502960250729e-3L,
311 +6.447097305145147224459e-5L, +7.544218493763717599380e-5L,
312 -1.580422720690700333493e-5L, +1.755845848573471891519e-6L,
313 -9.289769688468301734718e-8L, -5.624033192624251079833e-9L,
314 +1.854740406702369495830e-9L, -2.174644768724492443378e-10L,
315 +1.392899828133395918767e-11L, -6.989216003725983789869e-14L,
316 -9.959396121060010838331e-14L, +1.312085140393647257714e-14L,
317 -9.240470383522792593305e-16L, +2.472168944148817385152e-17L,
318 +2.834615576069400293894e-18L, -4.650983461314449088349e-19L,
319 +3.544083040732391556797e-20L
322 static const int degree =
sizeof(
c) /
sizeof(
long double) - 1;
323 static const long double midpoint = 0.5L;
324 static const long double scale = 0.5L;
355 static long double const c[] = {
356 +3.470341566046115476477e-2L, -3.855580521778624043304e-2L,
357 +1.420604309383996764083e-2L, -4.037349972538938202143e-3L,
358 +9.292478174580997778194e-4L, -1.742730601244797978044e-4L,
359 +2.563352976720387343201e-5L, -2.498437524746606551732e-6L,
360 -1.334367201897140224779e-8L, +7.436854728157752667212e-8L,
361 -2.059620371321272169176e-8L, +3.753674773239250330547e-9L,
362 -5.052913010605479996432e-10L, +4.580877371233042345794e-11L,
363 -7.664740716178066564952e-13L, -7.200170736686941995387e-13L,
364 +1.812701686438975518372e-13L, -2.799876487275995466163e-14L,
365 +3.048940815174731772007e-15L, -1.936754063718089166725e-16L,
366 -7.653673328908379651914e-18L, +4.534308864750374603371e-18L,
367 -8.011054486030591219007e-19L, +9.374587915222218230337e-20L,
368 -7.144943099280650363024e-21L, +1.105276695821552769144e-22L,
369 +6.989334213887669628647e-23L
372 static const int degree =
sizeof(
c) /
sizeof(
long double) - 1;
373 static const long double midpoint = 2.0L;
404 static long double const c[] = {
405 +3.684922395955255848372e-3L, -2.624595437764014386717e-3L,
406 +6.329162500611499391493e-4L, -1.258275676151483358569e-4L,
407 +2.207375763252044217165e-5L, -3.521929664607266176132e-6L,
408 +5.186211398012883705616e-7L, -7.095056569102400546407e-8L,
409 +9.030550018646936241849e-9L, -1.066057806832232908641e-9L,
410 +1.157128073917012957550e-10L, -1.133877461819345992066e-11L,
411 +9.633572308791154852278e-13L, -6.336675771012312827721e-14L,
412 +1.634407356931822107368e-15L, +3.944542177576016972249e-16L,
413 -9.577486627424256130607e-17L, +1.428772744117447206807e-17L,
414 -1.715342656474756703926e-18L, +1.753564314320837957805e-19L,
415 -1.526125102356904908532e-20L, +1.070275366865736879194e-21L,
416 -4.783978662888842165071e-23L
419 static const int degree =
sizeof(
c) /
sizeof(
long double) - 1;
420 static const long double midpoint = 4.0L;
451 static long double const c[] = {
452 +1.000801217561417083840e-3L, -4.915205279689293180607e-4L,
453 +8.133163567827942356534e-5L, -1.120758739236976144656e-5L,
454 +1.384441872281356422699e-6L, -1.586485067224130537823e-7L,
455 +1.717840749804993618997e-8L, -1.776373217323590289701e-9L,
456 +1.765399783094380160549e-10L, -1.692470022450343343158e-11L,
457 +1.568238301528778401489e-12L, -1.405356860742769958771e-13L,
458 +1.217377701691787512346e-14L, -1.017697418261094517680e-15L,
459 +8.186068056719295045596e-17L, -6.305153620995673221364e-18L,
460 +4.614110100197028845266e-19L, -3.165914620159266813849e-20L,
461 +1.986716456911232767045e-21L, -1.078418278174434671506e-22L,
462 +4.255983404468350776788e-24L
465 static const int degree =
sizeof(
c) /
sizeof(
long double) - 1;
466 static const long double midpoint = 6.0L;
497 #define NUM_ASYMPTOTIC_TERMS 35 500 long double x2 =
x *
x;
501 long double x4 = -4.0L * x2 * x2;
502 long double xn = 1.0L;
504 long double g = 0.0L;
506 long double epsilon = LDBL_EPSILON / 4.0L;
513 factorial *= ((
long double)j * (
long double)(j - 2));
517 if (fabsl(term[i]) >= fabsl(term[i - 1])) {
521 if (fabsl(term[i]) <= epsilon)
break;
523 for (; i >= 0; i--)
g += term[i];
526 return g / (x2 + x2);
595 if (
x == 0.0L)
return 0.5L;
673 c = 0.5L + sinl(x2) * f - cosl(x2) *
g;
674 return (
x < 0.0L) ? -
c :
c;
704 long double x2 =
x *
x;
706 long double x4 = -x2 * x2;
707 long double xn = 1.0L;
708 long double Sn = 1.0L;
709 long double Sm1 = 0.0L;
712 long double sqrt_2_o_pi = 7.978845608028653558798921198687637369517e-1L;
715 if (
x == 0.0L)
return 0.0L;
716 while (fabsl(Sn - Sm1) > LDBL_EPSILON * fabsl(Sm1)) {
723 term /= (
long double)(
y +
y +
y +
y + 1);
726 return x * sqrt_2_o_pi * Sn;
773 long double yp2 = 0.0L;
774 long double yp1 = 0.0L;
775 long double y = 0.0L;
776 long double two_x =
x +
x;
781 if (degree < 0)
return 0.0L;
785 for (k = degree; k >= 1; k--, yp2 = yp1, yp1 =
y)
786 y = two_x * yp1 - yp2 +
a[k];
790 return x * yp1 - yp2 +
a[0];
820 static long double const c[] = {
821 +4.200987560240514577713e-1L, -9.358785913634965235904e-2L,
822 -7.642539415723373644927e-3L, +4.958117751796130135544e-3L,
823 -9.750236036106120253456e-4L, +1.075201474958704192865e-4L,
824 -4.415344769301324238886e-6L, -7.861633919783064216022e-7L,
825 +1.919240966215861471754e-7L, -2.175775608982741065385e-8L,
826 +1.296559541430849437217e-9L, +2.207205095025162212169e-11L,
827 -1.479219615873704298874e-11L, +1.821350127295808288614e-12L,
828 -1.228919312990171362342e-13L, +2.227139250593818235212e-15L,
829 +5.734729405928016301596e-16L, -8.284965573075354177016e-17L,
830 +6.067422701530157308321e-18L, -1.994908519477689596319e-19L,
831 -1.173365630675305693390e-20L
834 static const int degree =
sizeof(
c) /
sizeof(
long double) - 1;
835 static const long double midpoint = 0.5L;
836 static const long double scale = 0.5L;
867 static long double const c[] = {
868 +2.098677278318224971989e-1L, -9.314234883154103266195e-2L,
869 +1.739905936938124979297e-2L, -2.454274824644285136137e-3L,
870 +1.589872606981337312438e-4L, +4.203943842506079780413e-5L,
871 -2.018022256093216535093e-5L, +5.125709636776428285284e-6L,
872 -9.601813551752718650057e-7L, +1.373989484857155846826e-7L,
873 -1.348105546577211255591e-8L, +2.745868700337953872632e-10L,
874 +2.401655517097260106976e-10L, -6.678059547527685587692e-11L,
875 +1.140562171732840809159e-11L, -1.401526517205212219089e-12L,
876 +1.105498827380224475667e-13L, +2.040731455126809208066e-16L,
877 -1.946040679213045143184e-15L, +4.151821375667161733612e-16L,
878 -5.642257647205149369594e-17L, +5.266176626521504829010e-18L,
879 -2.299025577897146333791e-19L, -2.952226367506641078731e-20L,
880 +8.760405943193778149078e-21L
883 static const int degree =
sizeof(
c) /
sizeof(
long double) - 1;
884 static const long double midpoint = 2.0L;
916 static long double const c[] = {
917 +1.025703371090289562388e-1L, -2.569833023232301400495e-2L,
918 +3.160592981728234288078e-3L, -3.776110718882714758799e-4L,
919 +4.325593433537248833341e-5L, -4.668447489229591855730e-6L,
920 +4.619254757356785108280e-7L, -3.970436510433553795244e-8L,
921 +2.535664754977344448598e-9L, -2.108170964644819803367e-11L,
922 -2.959172018518707683013e-11L, +6.727219944906606516055e-12L,
923 -1.062829587519902899001e-12L, +1.402071724705287701110e-13L,
924 -1.619154679722651005075e-14L, +1.651319588396970446858e-15L,
925 -1.461704569438083772889e-16L, +1.053521559559583268504e-17L,
926 -4.760946403462515858756e-19L, -1.803784084922403924313e-20L,
927 +7.873130866418738207547e-21L
930 static const int degree =
sizeof(
c) /
sizeof(
long double) - 1;
931 static const long double midpoint = 4.0L;
962 static long double const c[] = {
963 +6.738667333400589274018e-2L, -1.128146832637904868638e-2L,
964 +9.408843234170404670278e-4L, -7.800074103496165011747e-5L,
965 +6.409101169623350885527e-6L, -5.201350558247239981834e-7L,
966 +4.151668914650221476906e-8L, -3.242202015335530552721e-9L,
967 +2.460339340900396789789e-10L, -1.796823324763304661865e-11L,
968 +1.244108496436438952425e-12L, -7.950417122987063540635e-14L,
969 +4.419142625999150971878e-15L, -1.759082736751040110146e-16L,
970 -1.307443936270786700760e-18L, +1.362484141039320395814e-18L,
971 -2.055236564763877250559e-19L, +2.329142055084791308691e-20L,
972 -2.282438671525884861970e-21L
975 static const int degree =
sizeof(
c) /
sizeof(
long double) - 1;
976 static const long double midpoint = 6.0L;
1007 #define NUM_ASYMPTOTIC_TERMS 35 1010 long double x2 =
x *
x;
1011 long double x4 = -4.0L * x2 * x2;
1012 long double xn = 1.0L;
1014 long double f = 0.0L;
1016 long double epsilon = LDBL_EPSILON / 4.0L;
1023 factorial *= ((
long double)j * (
long double)(j - 2));
1027 if (fabsl(term[i]) >= fabsl(term[i - 1])) {
1031 if (fabsl(term[i]) <= epsilon)
break;
1034 for (; i >= 0; i--) f += term[i];
static long double sin_Chebyshev_Expansion_0_1(long double x)
long double lfresnel_sin_alt(long double x)
static long double cos_Chebyshev_Expansion_1_3(long double x)
static long double xFresnel_Auxiliary_Sine_Integral(long double x)
static long double sin_Chebyshev_Expansion_5_7(long double x)
GLenum GLenum GLenum GLenum GLenum scale
#define MRPT_NO_THROWS
C++11 noexcept: Used after member declarations.
long double xFresnel_Sine_Integral(long double x)
static long double sin_Asymptotic_Series(long double x)
long double lfresnel_cos_alt(long double x)
double BASE_IMPEXP factorial(unsigned int n)
Computes the factorial of an integer number and returns it as a double value (internally it uses loga...
double BASE_IMPEXP fresnel_cos_integral(double x) MRPT_NO_THROWS
Evaluates the integral from 0 to x of sqrt(2/pi) cos(t^2) dt.
static long double cos_Asymptotic_Series(long double x)
static long double cos_Chebyshev_Expansion_3_5(long double x)
static long double cos_Chebyshev_Expansion_5_7(long double x)
double Fresnel_Auxiliary_Sine_Integral(double x)
double Fresnel_Sine_Integral(double x)
long double xFresnel_Cosine_Integral(long double x)
static long double Power_Series_S(long double x)
double BASE_IMPEXP fresnel_sin_integral(double x) MRPT_NO_THROWS
Evaluates the integral from 0 to x of sqrt(2/pi) sin(t^2) dt.
#define NUM_ASYMPTOTIC_TERMS
static long double cos_Chebyshev_Expansion_0_1(long double x)
static long double xFresnel_Auxiliary_Cosine_Integral(long double x)
static long double const sqrt_2pi
static long double sin_Chebyshev_Expansion_1_3(long double x)
static long double sin_Chebyshev_Expansion_3_5(long double x)
static long double xChebyshev_Tn_Series(long double x, const long double a[], int degree)
GLubyte GLubyte GLubyte a
double Fresnel_Cosine_Integral(double x)
static long double Power_Series_C(long double x)
double Fresnel_Auxiliary_Cosine_Integral(double x)