7 inline double polevl(
double x,
const double coef[],
int N);
8 inline double p1evl(
double x,
const double coef[],
int N);
9 inline double chbevl(
double,
const double[],
int);
97 valarray<double> x(n);
98 valarray<double> y(n);
100 for(
long i=0; i < n; i++ )
115 for(
long i=0; i < n; i++ )
120 double rn = (double)n;
125 for(
long i=0; i < n; i++ )
133 if(
pow2(sxx) == 0.0 )
146 for(
long i=0; i < n; i++ )
147 sum1 +=
pow2(x[i]*(y[i] - b*x[i]));
150 sigb = sum1/
pow2(sxx);
153 for(
long i=0; i < n; i++ )
154 siga +=
pow2((y[i] - b*x[i])*(1.0 - rn*xavg*x[i]/sxx));
158 siga = sqrt(siga)/rn;
161 for(
long i=0; i < n; i++ )
183 1.00000000000000000000e+00,
184 1.00000000000000000000e+00,
185 2.00000000000000000000e+00,
186 6.00000000000000000000e+00,
187 2.40000000000000000000e+01,
188 1.20000000000000000000e+02,
189 7.20000000000000000000e+02,
190 5.04000000000000000000e+03,
191 4.03200000000000000000e+04,
192 3.62880000000000000000e+05,
193 3.62880000000000000000e+06,
194 3.99168000000000000000e+07,
195 4.79001600000000000000e+08,
196 6.22702080000000000000e+09,
197 8.71782912000000000000e+10,
198 1.30767436800000000000e+12,
199 2.09227898880000000000e+13,
200 3.55687428096000000000e+14,
201 6.40237370572800000000e+15,
202 1.21645100408832000000e+17,
203 2.43290200817664000000e+18,
204 5.10909421717094400000e+19,
205 1.12400072777760768000e+21,
206 2.58520167388849766400e+22,
207 6.20448401733239439360e+23,
208 1.55112100433309859840e+25,
209 4.03291461126605635592e+26,
210 1.08888694504183521614e+28,
211 3.04888344611713860511e+29,
212 8.84176199373970195470e+30,
213 2.65252859812191058647e+32,
214 8.22283865417792281807e+33,
215 2.63130836933693530178e+35,
216 8.68331761881188649615e+36,
217 2.95232799039604140861e+38,
218 1.03331479663861449300e+40,
219 3.71993326789901217463e+41,
220 1.37637530912263450457e+43,
221 5.23022617466601111726e+44,
222 2.03978820811974433568e+46,
223 8.15915283247897734264e+47,
224 3.34525266131638071044e+49,
225 1.40500611775287989839e+51,
226 6.04152630633738356321e+52,
227 2.65827157478844876773e+54,
228 1.19622220865480194551e+56,
229 5.50262215981208894940e+57,
230 2.58623241511168180614e+59,
231 1.24139155925360726691e+61,
232 6.08281864034267560801e+62,
233 3.04140932017133780398e+64,
234 1.55111875328738227999e+66,
235 8.06581751709438785585e+67,
236 4.27488328406002556374e+69,
237 2.30843697339241380441e+71,
238 1.26964033536582759243e+73,
239 7.10998587804863451749e+74,
240 4.05269195048772167487e+76,
241 2.35056133128287857145e+78,
242 1.38683118545689835713e+80,
243 8.32098711274139014271e+81,
244 5.07580213877224798711e+83,
245 3.14699732603879375200e+85,
246 1.98260831540444006372e+87,
247 1.26886932185884164078e+89,
248 8.24765059208247066512e+90,
249 5.44344939077443063905e+92,
250 3.64711109181886852801e+94,
251 2.48003554243683059915e+96,
252 1.71122452428141311337e+98,
253 1.19785716699698917933e+100,
254 8.50478588567862317347e+101,
255 6.12344583768860868500e+103,
256 4.47011546151268434004e+105,
257 3.30788544151938641157e+107,
258 2.48091408113953980872e+109,
259 1.88549470166605025458e+111,
260 1.45183092028285869606e+113,
261 1.13242811782062978295e+115,
262 8.94618213078297528506e+116,
263 7.15694570462638022794e+118,
264 5.79712602074736798470e+120,
265 4.75364333701284174746e+122,
266 3.94552396972065865030e+124,
267 3.31424013456535326627e+126,
268 2.81710411438055027626e+128,
269 2.42270953836727323750e+130,
270 2.10775729837952771662e+132,
271 1.85482642257398439069e+134,
272 1.65079551609084610774e+136,
273 1.48571596448176149700e+138,
274 1.35200152767840296226e+140,
275 1.24384140546413072522e+142,
276 1.15677250708164157442e+144,
277 1.08736615665674307994e+146,
278 1.03299784882390592592e+148,
279 9.91677934870949688836e+149,
280 9.61927596824821198159e+151,
281 9.42689044888324774164e+153,
282 9.33262154439441526381e+155,
283 9.33262154439441526388e+157,
284 9.42594775983835941673e+159,
285 9.61446671503512660515e+161,
286 9.90290071648618040340e+163,
287 1.02990167451456276198e+166,
288 1.08139675824029090008e+168,
289 1.14628056373470835406e+170,
290 1.22652020319613793888e+172,
291 1.32464181945182897396e+174,
292 1.44385958320249358163e+176,
293 1.58824554152274293982e+178,
294 1.76295255109024466316e+180,
295 1.97450685722107402277e+182,
296 2.23119274865981364576e+184,
297 2.54355973347218755612e+186,
298 2.92509369349301568964e+188,
299 3.39310868445189820004e+190,
300 3.96993716080872089396e+192,
301 4.68452584975429065488e+194,
302 5.57458576120760587943e+196,
303 6.68950291344912705515e+198,
304 8.09429852527344373681e+200,
305 9.87504420083360135884e+202,
306 1.21463043670253296712e+205,
307 1.50614174151114087918e+207,
308 1.88267717688892609901e+209,
309 2.37217324288004688470e+211,
310 3.01266001845765954361e+213,
311 3.85620482362580421582e+215,
312 4.97450422247728743840e+217,
313 6.46685548922047366972e+219,
314 8.47158069087882050755e+221,
315 1.11824865119600430699e+224,
316 1.48727070609068572828e+226,
317 1.99294274616151887582e+228,
318 2.69047270731805048244e+230,
319 3.65904288195254865604e+232,
320 5.01288874827499165889e+234,
321 6.91778647261948848943e+236,
322 9.61572319694108900019e+238,
323 1.34620124757175246000e+241,
324 1.89814375907617096864e+243,
325 2.69536413788816277557e+245,
326 3.85437071718007276916e+247,
327 5.55029383273930478744e+249,
328 8.04792605747199194159e+251,
329 1.17499720439091082343e+254,
330 1.72724589045463891049e+256,
331 2.55632391787286558753e+258,
332 3.80892263763056972532e+260,
333 5.71338395644585458806e+262,
334 8.62720977423324042775e+264,
335 1.31133588568345254503e+267,
336 2.00634390509568239384e+269,
337 3.08976961384735088657e+271,
338 4.78914290146339387432e+273,
339 7.47106292628289444390e+275,
340 1.17295687942641442768e+278,
341 1.85327186949373479574e+280,
342 2.94670227249503832518e+282,
343 4.71472363599206132029e+284,
344 7.59070505394721872577e+286,
345 1.22969421873944943358e+289,
346 2.00440157654530257674e+291,
347 3.28721858553429622598e+293,
348 5.42391066613158877297e+295,
349 9.00369170577843736335e+297,
350 1.50361651486499903974e+300,
351 2.52607574497319838672e+302,
352 4.26906800900470527345e+304,
353 7.25741561530799896496e+306
362 fprintf(
ioQQQ,
"factorial: domain error\n" );
378 p_lf.push_back( 0. );
379 p_lf.push_back( 0. );
386 if( n <
p_lf.size() )
392 for(
unsigned long i=(
unsigned long)
p_lf.size(); i <= n; i++ )
393 p_lf.push_back(
p_lf[i-1] + log10(
static_cast<double>(i)) );
413 fprintf(
ioQQQ,
"lfactorial: domain error\n" );
434 double xr, xi, wr, wi, ur, ui, vr, vi, yr, yi, t;
450 ur = wr + 6.00009857740312429;
451 vr = ur * (wr + 4.99999857982434025) - wi * wi;
452 vi = wi * (wr + 4.99999857982434025) + ur * wi;
453 yr = ur * 13.2280130755055088 + vr * 66.2756400966213521 +
454 0.293729529320536228;
455 yi = wi * 13.2280130755055088 + vi * 66.2756400966213521;
456 ur = vr * (wr + 4.00000003016801681) - vi * wi;
457 ui = vi * (wr + 4.00000003016801681) + vr * wi;
458 vr = ur * (wr + 2.99999999944915534) - ui * wi;
459 vi = ui * (wr + 2.99999999944915534) + ur * wi;
460 yr += ur * 91.1395751189899762 + vr * 47.3821439163096063;
461 yi += ui * 91.1395751189899762 + vi * 47.3821439163096063;
462 ur = vr * (wr + 2.00000000000603851) - vi * wi;
463 ui = vi * (wr + 2.00000000000603851) + vr * wi;
464 vr = ur * (wr + 0.999999999999975753) - ui * wi;
465 vi = ui * (wr + 0.999999999999975753) + ur * wi;
466 yr += ur * 10.5400280458730808 + vr;
467 yi += ui * 10.5400280458730808 + vi;
468 ur = vr * wr - vi * wi;
469 ui = vi * wr + vr * wi;
470 t = ur * ur + ui * ui;
471 vr = yr * ur + yi * ui + t * 0.0327673720261526849;
472 vi = yi * ur - yr * ui;
473 yr = wr + 7.31790632447016203;
474 ur = log(yr * yr + wi * wi) * 0.5 - 1;
476 yr = exp(ur * (wr - 0.5) - ui * wi - 3.48064577727581257) / t;
477 yi = ui * (wr - 0.5) + ur * wi;
480 yr = ur * vr - ui * vi;
481 yi = ui * vr + ur * vi;
484 wr = xr * 3.14159265358979324;
485 wi = exp(xi * 3.14159265358979324);
487 ur = (vi + wi) * sin(wr);
488 ui = (vi - wi) * cos(wr);
489 vr = ur * yr + ui * yi;
490 vi = ui * yr - ur * yi;
491 ur = 6.2831853071795862 / (vr * vr + vi * vi);
495 return complex<double>( yr, yi );
617 7.96936729297347051624e-4,
618 8.28352392107440799803e-2,
619 1.23953371646414299388e0,
620 5.44725003058768775090e0,
621 8.74716500199817011941e0,
622 5.30324038235394892183e0,
623 9.99999999999999997821e-1,
627 9.24408810558863637013e-4,
628 8.56288474354474431428e-2,
629 1.25352743901058953537e0,
630 5.47097740330417105182e0,
631 8.76190883237069594232e0,
632 5.30605288235394617618e0,
633 1.00000000000000000218e0,
637 -1.13663838898469149931e-2,
638 -1.28252718670509318512e0,
639 -1.95539544257735972385e1,
640 -9.32060152123768231369e1,
641 -1.77681167980488050595e2,
642 -1.47077505154951170175e2,
643 -5.14105326766599330220e1,
644 -6.05014350600728481186e0,
649 6.43178256118178023184e1,
650 8.56430025976980587198e2,
651 3.88240183605401609683e3,
652 7.24046774195652478189e3,
653 5.93072701187316984827e3,
654 2.06209331660327847417e3,
655 2.42005740240291393179e2,
659 1.55924367855235737965e4,
660 -1.46639295903971606143e7,
661 5.43526477051876500413e9,
662 -9.82136065717911466409e11,
663 8.75906394395366999549e13,
664 -3.46628303384729719441e15,
665 4.42733268572569800351e16,
666 -1.84950800436986690637e16,
671 1.04128353664259848412e3,
672 6.26107330137134956842e5,
673 2.68919633393814121987e8,
674 8.64002487103935000337e10,
675 2.02979612750105546709e13,
676 3.17157752842975028269e15,
677 2.50596256172653059228e17,
681 static const double DR1 = 5.78318596294678452118e0;
683 static const double DR2 = 3.04712623436620863991e1;
686 -4.79443220978201773821e9,
687 1.95617491946556577543e12,
688 -2.49248344360967716204e14,
689 9.70862251047306323952e15,
694 4.99563147152651017219e2,
695 1.73785401676374683123e5,
696 4.84409658339962045305e7,
697 1.11855537045356834862e10,
698 2.11277520115489217587e12,
699 3.10518229857422583814e14,
700 3.18121955943204943306e16,
701 1.71086294081043136091e18,
710 double w, z, p, q, xn;
723 p = (z -
DR1) * (z -
DR2);
733 p = p * cos(xn) - w * q * sin(xn);
734 return p *
SQ2OPI / sqrt(x);
748 double w, z, p, q, xn;
756 fprintf(
ioQQQ,
"bessel_y0: domain error\n" );
770 p = p * sin(xn) + w * q * cos(xn);
771 return p *
SQ2OPI / sqrt(x);
853 -8.99971225705559398224e8,
854 4.52228297998194034323e11,
855 -7.27494245221818276015e13,
856 3.68295732863852883286e15,
861 6.20836478118054335476e2,
862 2.56987256757748830383e5,
863 8.35146791431949253037e7,
864 2.21511595479792499675e10,
865 4.74914122079991414898e12,
866 7.84369607876235854894e14,
867 8.95222336184627338078e16,
868 5.32278620332680085395e18,
872 7.62125616208173112003e-4,
873 7.31397056940917570436e-2,
874 1.12719608129684925192e0,
875 5.11207951146807644818e0,
876 8.42404590141772420927e0,
877 5.21451598682361504063e0,
878 1.00000000000000000254e0,
882 5.71323128072548699714e-4,
883 6.88455908754495404082e-2,
884 1.10514232634061696926e0,
885 5.07386386128601488557e0,
886 8.39985554327604159757e0,
887 5.20982848682361821619e0,
888 9.99999999999999997461e-1,
892 5.10862594750176621635e-2,
893 4.98213872951233449420e0,
894 7.58238284132545283818e1,
895 3.66779609360150777800e2,
896 7.10856304998926107277e2,
897 5.97489612400613639965e2,
898 2.11688757100572135698e2,
899 2.52070205858023719784e1,
904 7.42373277035675149943e1,
905 1.05644886038262816351e3,
906 4.98641058337653607651e3,
907 9.56231892404756170795e3,
908 7.99704160447350683650e3,
909 2.82619278517639096600e3,
910 3.36093607810698293419e2,
914 1.26320474790178026440e9,
915 -6.47355876379160291031e11,
916 1.14509511541823727583e14,
917 -8.12770255501325109621e15,
918 2.02439475713594898196e17,
919 -7.78877196265950026825e17,
924 5.94301592346128195359E2,
925 2.35564092943068577943E5,
926 7.34811944459721705660E7,
927 1.87601316108706159478E10,
928 3.88231277496238566008E12,
929 6.20557727146953693363E14,
930 6.87141087355300489866E16,
931 3.97270608116560655612E18,
934 static const double Z1 = 1.46819706421238932572E1;
935 static const double Z2 = 4.92184563216946036703E1;
941 double w, z, p, q, xn;
953 w = w * x * (z -
Z1) * (z -
Z2);
962 p = p * cos(xn) - w * q * sin(xn);
963 return p *
SQ2OPI / sqrt(x);
968 double w, z, p, q, xn;
976 fprintf(
ioQQQ,
"bessel_y1: domain error\n" );
990 p = p * sin(xn) + w * q * cos(xn);
991 return p *
SQ2OPI / sqrt(x);
1044 double pkm2, pkm1, pk, xk, r, ans;
1067 if( x < DBL_EPSILON )
1081 if( n == 2 && x > 0.1 )
1096 ans = pk - (xk/ans);
1109 pkm2 = (pkm1 * r - pk * x) / x;
1116 if( fabs(pk) > fabs(pkm1) )
1179 double an, anm1, anm2, r;
1207 fprintf(
ioQQQ,
"bessel_yn: domain error\n" );
1218 an = r * anm1 / x - anm2;
1313 1.37446543561352307156e-16,
1314 4.25981614279661018399e-14,
1315 1.03496952576338420167e-11,
1316 1.90451637722020886025e-9,
1317 2.53479107902614945675e-7,
1318 2.28621210311945178607e-5,
1319 1.26461541144692592338e-3,
1320 3.59799365153615016266e-2,
1321 3.44289899924628486886e-1,
1322 -5.35327393233902768720e-1
1332 5.30043377268626276149e-18,
1333 -1.64758043015242134646e-17,
1334 5.21039150503902756861e-17,
1335 -1.67823109680541210385e-16,
1336 5.51205597852431940784e-16,
1337 -1.84859337734377901440e-15,
1338 6.34007647740507060557e-15,
1339 -2.22751332699166985548e-14,
1340 8.03289077536357521100e-14,
1341 -2.98009692317273043925e-13,
1342 1.14034058820847496303e-12,
1343 -4.51459788337394416547e-12,
1344 1.85594911495471785253e-11,
1345 -7.95748924447710747776e-11,
1346 3.57739728140030116597e-10,
1347 -1.69753450938905987466e-9,
1348 8.57403401741422608519e-9,
1349 -4.66048989768794782956e-8,
1350 2.76681363944501510342e-7,
1351 -1.83175552271911948767e-6,
1352 1.39498137188764993662e-5,
1353 -1.28495495816278026384e-4,
1354 1.56988388573005337491e-3,
1355 -3.14481013119645005427e-2,
1356 2.44030308206595545468e0
1367 fprintf(
ioQQQ,
"bessel_k0: domain error\n" );
1378 y = exp(-x) *
chbevl( z,
k0_B, 25 ) / sqrt(x);
1390 fprintf(
ioQQQ,
"bessel_k0_scaled: domain error\n" );
1400 return chbevl( 8.0/x - 2.0,
k0_B, 25 ) / sqrt(x);
1487 -7.02386347938628759343e-18,
1488 -2.42744985051936593393e-15,
1489 -6.66690169419932900609e-13,
1490 -1.41148839263352776110e-10,
1491 -2.21338763073472585583e-8,
1492 -2.43340614156596823496e-6,
1493 -1.73028895751305206302e-4,
1494 -6.97572385963986435018e-3,
1495 -1.22611180822657148235e-1,
1496 -3.53155960776544875667e-1,
1497 1.52530022733894777053e0
1508 -5.75674448366501715755e-18,
1509 1.79405087314755922667e-17,
1510 -5.68946255844285935196e-17,
1511 1.83809354436663880070e-16,
1512 -6.05704724837331885336e-16,
1513 2.03870316562433424052e-15,
1514 -7.01983709041831346144e-15,
1515 2.47715442448130437068e-14,
1516 -8.97670518232499435011e-14,
1517 3.34841966607842919884e-13,
1518 -1.28917396095102890680e-12,
1519 5.13963967348173025100e-12,
1520 -2.12996783842756842877e-11,
1521 9.21831518760500529508e-11,
1522 -4.19035475934189648750e-10,
1523 2.01504975519703286596e-9,
1524 -1.03457624656780970260e-8,
1525 5.74108412545004946722e-8,
1526 -3.50196060308781257119e-7,
1527 2.40648494783721712015e-6,
1528 -1.93619797416608296024e-5,
1529 1.95215518471351631108e-4,
1530 -2.85781685962277938680e-3,
1531 1.03923736576817238437e-1,
1532 2.72062619048444266945e0
1544 fprintf(
ioQQQ,
"bessel_k1: domain error\n" );
1554 return exp(-x) *
chbevl( 8.0/x - 2.0,
k1_B, 25 ) / sqrt(x);
1565 fprintf(
ioQQQ,
"bessel_k1_scaled: domain error\n" );
1575 return chbevl( 8.0/x - 2.0,
k1_B, 25 ) / sqrt(x);
1659 -4.41534164647933937950e-18,
1660 3.33079451882223809783e-17,
1661 -2.43127984654795469359e-16,
1662 1.71539128555513303061e-15,
1663 -1.16853328779934516808e-14,
1664 7.67618549860493561688e-14,
1665 -4.85644678311192946090e-13,
1666 2.95505266312963983461e-12,
1667 -1.72682629144155570723e-11,
1668 9.67580903537323691224e-11,
1669 -5.18979560163526290666e-10,
1670 2.65982372468238665035e-9,
1671 -1.30002500998624804212e-8,
1672 6.04699502254191894932e-8,
1673 -2.67079385394061173391e-7,
1674 1.11738753912010371815e-6,
1675 -4.41673835845875056359e-6,
1676 1.64484480707288970893e-5,
1677 -5.75419501008210370398e-5,
1678 1.88502885095841655729e-4,
1679 -5.76375574538582365885e-4,
1680 1.63947561694133579842e-3,
1681 -4.32430999505057594430e-3,
1682 1.05464603945949983183e-2,
1683 -2.37374148058994688156e-2,
1684 4.93052842396707084878e-2,
1685 -9.49010970480476444210e-2,
1686 1.71620901522208775349e-1,
1687 -3.04682672343198398683e-1,
1688 6.76795274409476084995e-1
1699 -7.23318048787475395456e-18,
1700 -4.83050448594418207126e-18,
1701 4.46562142029675999901e-17,
1702 3.46122286769746109310e-17,
1703 -2.82762398051658348494e-16,
1704 -3.42548561967721913462e-16,
1705 1.77256013305652638360e-15,
1706 3.81168066935262242075e-15,
1707 -9.55484669882830764870e-15,
1708 -4.15056934728722208663e-14,
1709 1.54008621752140982691e-14,
1710 3.85277838274214270114e-13,
1711 7.18012445138366623367e-13,
1712 -1.79417853150680611778e-12,
1713 -1.32158118404477131188e-11,
1714 -3.14991652796324136454e-11,
1715 1.18891471078464383424e-11,
1716 4.94060238822496958910e-10,
1717 3.39623202570838634515e-9,
1718 2.26666899049817806459e-8,
1719 2.04891858946906374183e-7,
1720 2.89137052083475648297e-6,
1721 6.88975834691682398426e-5,
1722 3.36911647825569408990e-3,
1723 8.04490411014108831608e-1
1740 return exp(x) *
chbevl( 32.0/x - 2.0,
i0_B, 25 ) / sqrt(x);
1757 return chbevl( 32.0/x - 2.0,
i0_B, 25 ) / sqrt(x);
1842 2.77791411276104639959e-18,
1843 -2.11142121435816608115e-17,
1844 1.55363195773620046921e-16,
1845 -1.10559694773538630805e-15,
1846 7.60068429473540693410e-15,
1847 -5.04218550472791168711e-14,
1848 3.22379336594557470981e-13,
1849 -1.98397439776494371520e-12,
1850 1.17361862988909016308e-11,
1851 -6.66348972350202774223e-11,
1852 3.62559028155211703701e-10,
1853 -1.88724975172282928790e-9,
1854 9.38153738649577178388e-9,
1855 -4.44505912879632808065e-8,
1856 2.00329475355213526229e-7,
1857 -8.56872026469545474066e-7,
1858 3.47025130813767847674e-6,
1859 -1.32731636560394358279e-5,
1860 4.78156510755005422638e-5,
1861 -1.61760815825896745588e-4,
1862 5.12285956168575772895e-4,
1863 -1.51357245063125314899e-3,
1864 4.15642294431288815669e-3,
1865 -1.05640848946261981558e-2,
1866 2.47264490306265168283e-2,
1867 -5.29459812080949914269e-2,
1868 1.02643658689847095384e-1,
1869 -1.76416518357834055153e-1,
1870 2.52587186443633654823e-1
1881 7.51729631084210481353e-18,
1882 4.41434832307170791151e-18,
1883 -4.65030536848935832153e-17,
1884 -3.20952592199342395980e-17,
1885 2.96262899764595013876e-16,
1886 3.30820231092092828324e-16,
1887 -1.88035477551078244854e-15,
1888 -3.81440307243700780478e-15,
1889 1.04202769841288027642e-14,
1890 4.27244001671195135429e-14,
1891 -2.10154184277266431302e-14,
1892 -4.08355111109219731823e-13,
1893 -7.19855177624590851209e-13,
1894 2.03562854414708950722e-12,
1895 1.41258074366137813316e-11,
1896 3.25260358301548823856e-11,
1897 -1.89749581235054123450e-11,
1898 -5.58974346219658380687e-10,
1899 -3.83538038596423702205e-9,
1900 -2.63146884688951950684e-8,
1901 -2.51223623787020892529e-7,
1902 -3.88256480887769039346e-6,
1903 -1.10588938762623716291e-4,
1904 -9.76109749136146840777e-3,
1905 7.78576235018280120474e-1
1922 z = exp(z) *
chbevl( 32.0/z - 2.0,
i1_B, 25 ) / sqrt(z);
1943 z =
chbevl( 32.0/z - 2.0,
i1_B, 25 ) / sqrt(z);
2011 1.37982864606273237150e-4,
2012 2.28025724005875567385e-3,
2013 7.97404013220415179367e-3,
2014 9.85821379021226008714e-3,
2015 6.87489687449949877925e-3,
2016 6.18901033637687613229e-3,
2017 8.79078273952743772254e-3,
2018 1.49380448916805252718e-2,
2019 3.08851465246711995998e-2,
2020 9.65735902811690126535e-2,
2021 1.38629436111989062502e0
2026 2.94078955048598507511e-5,
2027 9.14184723865917226571e-4,
2028 5.94058303753167793257e-3,
2029 1.54850516649762399335e-2,
2030 2.39089602715924892727e-2,
2031 3.01204715227604046988e-2,
2032 3.73774314173823228969e-2,
2033 4.88280347570998239232e-2,
2034 7.03124996963957469739e-2,
2035 1.24999999999870820058e-1,
2036 4.99999999999999999821e-1
2039 static const double C1 = 1.3862943611198906188e0;
2045 if( x < 0.0 || x > 1.0 )
2047 fprintf(
ioQQQ,
"ellpk: domain error\n" );
2051 if( x > DBL_EPSILON )
2059 fprintf(
ioQQQ,
"ellpk: domain error\n" );
2064 return C1 - 0.5 * log(x);
2118 static const double BIG = 1.44115188075855872E+17;
2123 double ans, r, t, yk, xk;
2124 double pk, pkm1, pkm2, qk, qkm1, qkm2;
2130 if( n < 0 || x < 0. )
2132 fprintf(
ioQQQ,
"expn: domain error\n" );
2145 fprintf(
ioQQQ,
"expn: domain error\n" );
2150 return 1.0/((double)n-1.0);
2163 yk = 1.0 / (xk * xk);
2165 ans = yk * t * (6.0 * x * x - 8.0 * t * x + t * t);
2166 ans = yk * (ans + t * (t - 2.0 * x));
2167 ans = yk * (ans + t);
2168 ans = (ans + 1.0) * exp( -x ) / xk;
2175 psi = -
EULER - log(x);
2176 for( i=1; i < n; i++ )
2201 while( t > DBL_EPSILON );
2221 xk =
static_cast<double>(n + (k-1)/2);
2226 xk =
static_cast<double>(k/2);
2228 pk = pkm1 * yk + pkm2 * xk;
2229 qk = qkm1 * yk + qkm2 * xk;
2233 t = fabs( (ans - r)/r );
2242 if( fabs(pk) >
BIG )
2250 while( t > DBL_EPSILON );
2355 2.46196981473530512524e-10,
2356 5.64189564831068821977e-1,
2357 7.46321056442269912687e0,
2358 4.86371970985681366614e1,
2359 1.96520832956077098242e2,
2360 5.26445194995477358631e2,
2361 9.34528527171957607540e2,
2362 1.02755188689515710272e3,
2363 5.57535335369399327526e2
2367 1.32281951154744992508e1,
2368 8.67072140885989742329e1,
2369 3.54937778887819891062e2,
2370 9.75708501743205489753e2,
2371 1.82390916687909736289e3,
2372 2.24633760818710981792e3,
2373 1.65666309194161350182e3,
2374 5.57535340817727675546e2
2377 5.64189583547755073984e-1,
2378 1.27536670759978104416e0,
2379 5.01905042251180477414e0,
2380 6.16021097993053585195e0,
2381 7.40974269950448939160e0,
2382 2.97886665372100240670e0
2386 2.26052863220117276590e0,
2387 9.39603524938001434673e0,
2388 1.20489539808096656605e1,
2389 1.70814450747565897222e1,
2390 9.60896809063285878198e0,
2391 3.36907645100081516050e0
2402 const bool lgUSE_EXPXSQ =
true;
2404 double erfc(
double a)
2413 return 1.0 -
erf(a);
2418 return ( a < 0.0 ) ? 2.0 : 0.0;
2442 return ( a < 0. ) ? 2.0 : 0.0;
2476 static double erf_T[] = {
2477 9.60497373987051638749e0,
2478 9.00260197203842689217e1,
2479 2.23200534594684319226e3,
2480 7.00332514112805075473e3,
2481 5.55923013010394962768e4
2483 static double erf_U[] = {
2485 3.35617141647503099647e1,
2486 5.21357949780152679795e2,
2487 4.59432382970980127987e3,
2488 2.26290000613890934246e4,
2489 4.92673942608635921086e4
2492 double erf(
double x)
2499 return 1.0 -
erfc(x);
2501 y = x *
polevl( z, erf_T, 4 ) /
p1evl( z, erf_U, 5 );
2548 const double exp_M = 128.0;
2549 const double exp_MINV = .0078125;
2564 m = exp_MINV * floor(exp_M * x + 0.5);
2569 u1 = 2 * m * f + f * f;
2581 u = exp(u) * exp(u1);
2638 inline double polevl(
double x,
const double coef[],
int N)
2642 const double *p = coef;
2648 ans = ans * x + *p++;
2660 inline double p1evl(
double x,
const double coef[],
int N)
2663 const double *p = coef;
2670 ans = ans * x + *p++;
2734 inline double chbevl(
double x,
const double array[],
int n)
2737 const double *p = array;
2814 static const int N = 624;
2815 static const int M = 397;
2817 static const unsigned long UMASK = 0x80000000UL;
2818 static const unsigned long LMASK = 0x7fffffffUL;
2819 inline unsigned long MIXBITS(
unsigned long u,
unsigned long v)
2823 inline unsigned long TWIST(
unsigned long u,
unsigned long v)
2837 state[0]= s & 0xffffffffUL;
2838 for (j=1; j<
N; j++) {
2844 state[j] &= 0xffffffffUL;
2858 k = (
N>key_length ?
N : key_length);
2862 state[i] &= 0xffffffffUL;
2865 if (j>=key_length) j=0;
2867 for (k=
N-1; k; k--) {
2870 state[i] &= 0xffffffffUL;
2875 state[0] = 0x80000000UL;
2881 unsigned long *p=
state;
2891 for (j=
N-
M+1; --j; p++)
2892 *p = p[
M] ^
TWIST(p[0], p[1]);
2895 *p = p[
M-
N] ^
TWIST(p[0], p[1]);
2910 y ^= (y << 7) & 0x9d2c5680UL;
2911 y ^= (y << 15) & 0xefc60000UL;
2927 y ^= (y << 7) & 0x9d2c5680UL;
2928 y ^= (y << 15) & 0xefc60000UL;
2931 return (
long)(y>>1);
2944 y ^= (y << 7) & 0x9d2c5680UL;
2945 y ^= (y << 15) & 0xefc60000UL;
2948 return (
double)y * (1.0/4294967295.0);
2962 y ^= (y << 7) & 0x9d2c5680UL;
2963 y ^= (y << 15) & 0xefc60000UL;
2966 return (
double)y * (1.0/4294967296.0);
2980 y ^= (y << 7) & 0x9d2c5680UL;
2981 y ^= (y << 15) & 0xefc60000UL;
2984 return ((
double)y + 0.5) * (1.0/4294967296.0);
2992 return (a*67108864.0+b)*(1.0/9007199254740992.0);
3007 0.000000000000000000e+0,
3008 9.933599239785286114e-2,
3009 1.947510333680280496e-1,
3010 2.826316650213119286e-1,
3011 3.599434819348881042e-1,
3012 4.244363835020222959e-1,
3013 4.747632036629779306e-1,
3014 5.105040575592317787e-1,
3015 5.321017070563654290e-1,
3016 5.407243187262986750e-1,
3017 5.380794985696822201e-1,
3018 5.262066799705525356e-1,
3019 5.072734964077396141e-1,
3020 4.833975173848241360e-1,
3021 4.565072375268972572e-1,
3022 4.282490710853986254e-1,
3023 3.999398943230814126e-1,
3024 3.725593489740788250e-1,
3025 3.467727691148722451e-1,
3026 3.229743193228178382e-1,
3027 3.013403889237919660e-1,
3028 2.818849389255277938e-1,
3029 2.645107599508319576e-1,
3030 2.490529568377666955e-1,
3031 2.353130556638425762e-1,
3032 2.230837221674354811e-1,
3033 2.121651242424990041e-1,
3034 2.023745109105139857e-1,
3035 1.935507238593667923e-1,
3036 1.855552345354997718e-1,
3037 1.782710306105582873e-1,
3038 1.716003557161446928e-1,
3039 1.654619998786752031e-1,
3040 1.597885804744950500e-1,
3041 1.545240577369634525e-1,
3042 1.496215930807564847e-1,
3043 1.450417730540888593e-1,
3044 1.407511741154154125e-1,
3045 1.367212216746364963e-1,
3046 1.329272910810892667e-1,
3047 1.293480012360051155e-1,
3048 1.259646584343461329e-1,
3049 1.227608160065229225e-1,
3050 1.197219228088390280e-1,
3051 1.168350399532972540e-1,
3052 1.140886102268249801e-1,
3053 1.114722685321253072e-1,
3054 1.089766845891902214e-1,
3055 1.065934312832810744e-1,
3056 1.043148736220704706e-1,
3057 1.021340744242768354e-1,
3058 1.000447137201476355e-1,
3059 9.804101948507806734e-2,
3060 9.611770781195023073e-2,
3061 9.426993099823683440e-2,
3062 9.249323231075475996e-2,
3063 9.078350641561113352e-2,
3064 8.913696463869524546e-2,
3065 8.755010436413927499e-2,
3066 8.601968199264808016e-2,
3067 8.454268897454385223e-2,
3068 8.311633050835148859e-2,
3069 8.173800655824702378e-2,
3070 8.040529489538834118e-2,
3071 7.911593591113373223e-2,
3072 7.786781898606987138e-2,
3073 7.665897022891428948e-2,
3074 7.548754142476270211e-2,
3075 7.435180005364808165e-2,
3076 7.325012025863538754e-2,
3077 7.218097465823629202e-2,
3078 7.114292691123472774e-2,
3079 7.013462495342931107e-2,
3080 6.915479483562112754e-2,
3081 6.820223510065167384e-2,
3082 6.727581164463061598e-2,
3083 6.637445301385693290e-2,
3084 6.549714609447248675e-2,
3085 6.464293215671364666e-2,
3086 6.381090321984490301e-2,
3087 6.300019870755338791e-2,
3088 6.221000236682679049e-2,
3089 6.143953942619040819e-2,
3090 6.068807397169402555e-2,
3091 5.995490652126037542e-2,
3092 5.923937177997213955e-2,
3093 5.854083656061641403e-2,
3094 5.785869785535237086e-2,
3095 5.719238104574369009e-2,
3096 5.654133823962313062e-2,
3097 5.590504672435046070e-2,
3098 5.528300752700259690e-2,
3099 5.467474407290986634e-2,
3100 5.407980093473671650e-2,
3101 5.349774266500934015e-2,
3102 5.292815270562564644e-2,
3103 5.237063236845275277e-2,
3104 5.182479988163068060e-2,
3105 5.129028949666435102e-2,
3106 5.076675065180469937e-2,
3107 5.025384718759852810e-2
3143 double p = x10 - double(ind);
3146 else if(
order == 3 )
3149 double p = x10 - double(ind+1);
3216 return a*vm2/
realnum(
SQRTPI)*(((105.f/8.f*vm2 + 15.f/4.f)*vm2 + 3.f/2.f)*vm2 + 1.f);
3226 int order = ( a > 0.003f || v > 1.5f ) ? 3 : 1;
3240 return emv2*(1.f-
pow2(a)*(2.f*v2-1.f)) +
3270 static const double c[6] = { 1.0117281, -.75197147, .012557727, .010022008, -2.4206814e-4, 5.0084806e-7 };
3271 static const double s[6] = { 1.393237, .23115241, -.15535147, .0062183662, 9.1908299e-5, -6.2752596e-7 };
3272 static const double t[6] = { .31424038, .94778839, 1.5976826, 2.2795071, 3.020637, 3.8897249 };
3274 static const double R0 = 146.7, R1 = 14.67;
3279 double a0, d0, e0, d2,
e2, h0, e4,
h2, h4, h6, p0,
3280 p2, p4, p6, p8, z0, z2, z4, z6, z8, mf[6], pf[6],
3281 mq[6], yf, pq[6], xm[6], ym[6], xp[6], xq, yq, yp[6];
3283 double abx, ypy0, xlim0, xlim1, xlim2, xlim3, xlim4, ypy0q, yrrtpi;
3285 rg1 = rg2 = rg3 =
true;
3287 z0 = z2 = z4 = z6 = z8 = 0.;
3288 p0 = p2 = p4 = p6 = p8 = 0.;
3289 h0 =
h2 = h4 = h6 = 0.;
3290 a0 = d0 = d2 = e0 =
e2 = e4 = 0.;
3293 yrrtpi = y * .56418958;
3297 xlim3 = y * 3.097 - .45;
3299 xlim4 = y * 18.1 + 1.65;
3306 for (i = 0; i < n; ++i)
3312 k[i] =
realnum(yrrtpi / (xq + yq));
3314 else if (abx > xlim1)
3324 d = .56418958 / (d0 + xq * (d2 + xq));
3327 else if (abx > xlim2)
3332 h0 = yq * (yq * (yq * (yq + 6.) + 10.5) + 4.5) + .5625;
3333 h2 = yq * (yq * (yq * 4. + 6.) + 9.) - 4.5;
3334 h4 = 10.5 - yq * (6. - yq * 6.);
3336 e0 = yq * (yq * (yq + 5.5) + 8.25) + 1.875;
3337 e2 = yq * (yq * 3. + 1.) + 5.25;
3340 d = .56418958 / (h0 + xq * (
h2 + xq * (h4 + xq * (h6 + xq))));
3341 k[i] =
realnum(d * y * (e0 + xq * (
e2 + xq * (e4 + xq))));
3343 else if (abx < xlim3)
3349 z0 = y * (y * (y * (y * (y * (y * (y * (y * (y * (y + 13.3988) +
3350 88.26741) + 369.1989) + 1074.409) + 2256.981) + 3447.629) +
3351 3764.966) + 2802.87) + 1280.829) + 272.1014;
3352 z2 = y * (y * (y * (y * (y * (y * (y * (y * 5. + 53.59518) +
3353 266.2987) + 793.4273) + 1549.675) + 2037.31) + 1758.336) +
3354 902.3066) + 211.678;
3355 z4 = y * (y * (y * (y * (y * (y * 10. + 80.39278) + 269.2916) +
3356 479.2576) + 497.3014) + 308.1852) + 78.86585;
3357 z6 = y * (y * (y * (y * 10. + 53.59518) + 92.75679) + 55.02933) +
3359 z8 = y * (y * 5. + 13.3988) + 1.49646;
3360 p0 = y * (y * (y * (y * (y * (y * (y * (y * (y * .3183291 +
3361 4.264678) + 27.93941) + 115.3772) + 328.2151) + 662.8097) +
3362 946.897) + 919.4955) + 549.3954) + 153.5168;
3363 p2 = y * (y * (y * (y * (y * (y * (y * 1.2733163 + 12.79458) +
3364 56.81652) + 139.4665) + 189.773) + 124.5975) - 1.322256) -
3366 p4 = y * (y * (y * (y * (y * 1.9099744 + 12.79568) + 29.81482) +
3367 24.01655) + 10.46332) + 2.584042;
3368 p6 = y * (y * (y * 1.273316 + 4.266322) + .9377051) - .07272979;
3369 p8 = y * .3183291 + 5.480304e-4;
3371 d = 1.7724538 / (z0 + xq * (z2 + xq * (z4 + xq * (z6 + xq * (z8 + xq)))));
3372 k[i] =
realnum(d * (p0 + xq * (p2 + xq * (p4 + xq * (p6 + xq * p8)))));
3377 ypy0q = ypy0 * ypy0;
3379 for (j = 0; j <= 5; ++j)
3383 mf[j] = 1. / (mq[j] + ypy0q);
3385 ym[j] = mf[j] * ypy0;
3388 pf[j] = 1. / (pq[j] + ypy0q);
3390 yp[j] = pf[j] * ypy0;
3394 for (j = 0; j <= 5; ++j)
3396 ki = ki + c[j] * (ym[j] + yp[j]) - s[j] * (xm[j] - xp[j]);
3402 for (j = 0; j <= 5; ++j)
3404 ki = ki + (c[j] * (mq[j] * mf[j] - ym[j] * 1.5) + s[j] * yf * xm[j]) / (mq[j] + 2.25) +
3405 (c[j] * (pq[j] * pf[j] - yp[j] * 1.5) - s[j] * yf * xp[j]) / (pq[j] + 2.25);
3407 ki = y * ki + exp(-xq);
3434 while( ioFile.get(c) )
3451 string line, content;
3452 while( getline( ioFile, line ) )
3453 if( line[0] !=
'#' )
3467 state[0] = 0x67452301L;
3468 state[1] = 0xefcdab89L;
3469 state[2] = 0x98badcfeL;
3470 state[3] = 0x10325476L;
3475 uint32 bytes = str.length()%64;
3476 uint32 padlen = ( bytes >= 56 ) ? 64 + 56 - bytes : 56 - bytes;
3478 for( uint32 i=1; i < padlen; ++i )
3481 ASSERT( lstr.length()%64 == 56 );
3486 unsigned char chr[64];
3489 for( i=0; i < lstr.length()/64; ++i )
3491 for( uint32 j=0; j < 64; ++j )
3494 u.chr[j] = lstr[i*64+j];
3499 u.chr[j4+3-jr] = lstr[i*64+j];
3504 for( uint32 j=0; j < 56; ++j )
3507 u.chr[j] = lstr[i*64+j];
3512 u.chr[j4+3-jr] = lstr[i*64+j];
3516 u.in[14] = (str.length()<<3)&0xffffffff;
3517 u.in[15] = (str.length()>>29)&0xffffffff;
3522 for( uint32 i=0; i < 4; ++i )
3523 hash << hex << setfill(
'0') << setw(8) <<
MD5swap(
state[i]);
3534 unsigned char byte[4];
3538 uo.byte[0] = ui.byte[3];
3539 uo.byte[1] = ui.byte[2];
3540 uo.byte[2] = ui.byte[1];
3541 uo.byte[3] = ui.byte[0];
3621 return uint32((x<<y) | (x>>(32-y)));
3628 #define F1(x, y, z) (z ^ (x & (y ^ z)))
3629 #define F2(x, y, z) F1(z, x, y)
3630 #define F3(x, y, z) (x ^ y ^ z)
3631 #define F4(x, y, z) (y ^ (x | ~z))
3633 #define MD5STEP(f, w, x, y, z, data, s) \
3634 w = rotlFixed(w + f(x, y, z) + data, s) + x
3643 MD5STEP(
F1, a, b, c, d, in[0] + 0xd76aa478, 7);
3644 MD5STEP(
F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
3645 MD5STEP(
F1, c, d, a, b, in[2] + 0x242070db, 17);
3646 MD5STEP(
F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
3647 MD5STEP(
F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
3648 MD5STEP(
F1, d, a, b, c, in[5] + 0x4787c62a, 12);
3649 MD5STEP(
F1, c, d, a, b, in[6] + 0xa8304613, 17);
3650 MD5STEP(
F1, b, c, d, a, in[7] + 0xfd469501, 22);
3651 MD5STEP(
F1, a, b, c, d, in[8] + 0x698098d8, 7);
3652 MD5STEP(
F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
3653 MD5STEP(
F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
3654 MD5STEP(
F1, b, c, d, a, in[11] + 0x895cd7be, 22);
3655 MD5STEP(
F1, a, b, c, d, in[12] + 0x6b901122, 7);
3656 MD5STEP(
F1, d, a, b, c, in[13] + 0xfd987193, 12);
3657 MD5STEP(
F1, c, d, a, b, in[14] + 0xa679438e, 17);
3658 MD5STEP(
F1, b, c, d, a, in[15] + 0x49b40821, 22);
3660 MD5STEP(
F2, a, b, c, d, in[1] + 0xf61e2562, 5);
3661 MD5STEP(
F2, d, a, b, c, in[6] + 0xc040b340, 9);
3662 MD5STEP(
F2, c, d, a, b, in[11] + 0x265e5a51, 14);
3663 MD5STEP(
F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
3664 MD5STEP(
F2, a, b, c, d, in[5] + 0xd62f105d, 5);
3665 MD5STEP(
F2, d, a, b, c, in[10] + 0x02441453, 9);
3666 MD5STEP(
F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
3667 MD5STEP(
F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
3668 MD5STEP(
F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
3669 MD5STEP(
F2, d, a, b, c, in[14] + 0xc33707d6, 9);
3670 MD5STEP(
F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
3671 MD5STEP(
F2, b, c, d, a, in[8] + 0x455a14ed, 20);
3672 MD5STEP(
F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
3673 MD5STEP(
F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
3674 MD5STEP(
F2, c, d, a, b, in[7] + 0x676f02d9, 14);
3675 MD5STEP(
F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
3677 MD5STEP(
F3, a, b, c, d, in[5] + 0xfffa3942, 4);
3678 MD5STEP(
F3, d, a, b, c, in[8] + 0x8771f681, 11);
3679 MD5STEP(
F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
3680 MD5STEP(
F3, b, c, d, a, in[14] + 0xfde5380c, 23);
3681 MD5STEP(
F3, a, b, c, d, in[1] + 0xa4beea44, 4);
3682 MD5STEP(
F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
3683 MD5STEP(
F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
3684 MD5STEP(
F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
3685 MD5STEP(
F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
3686 MD5STEP(
F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
3687 MD5STEP(
F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
3688 MD5STEP(
F3, b, c, d, a, in[6] + 0x04881d05, 23);
3689 MD5STEP(
F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
3690 MD5STEP(
F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
3691 MD5STEP(
F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
3692 MD5STEP(
F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
3694 MD5STEP(
F4, a, b, c, d, in[0] + 0xf4292244, 6);
3695 MD5STEP(
F4, d, a, b, c, in[7] + 0x432aff97, 10);
3696 MD5STEP(
F4, c, d, a, b, in[14] + 0xab9423a7, 15);
3697 MD5STEP(
F4, b, c, d, a, in[5] + 0xfc93a039, 21);
3698 MD5STEP(
F4, a, b, c, d, in[12] + 0x655b59c3, 6);
3699 MD5STEP(
F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
3700 MD5STEP(
F4, c, d, a, b, in[10] + 0xffeff47d, 15);
3701 MD5STEP(
F4, b, c, d, a, in[1] + 0x85845dd1, 21);
3702 MD5STEP(
F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
3703 MD5STEP(
F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
3704 MD5STEP(
F4, c, d, a, b, in[6] + 0xa3014314, 15);
3705 MD5STEP(
F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
3706 MD5STEP(
F4, a, b, c, d, in[4] + 0xf7537e82, 6);
3707 MD5STEP(
F4, d, a, b, c, in[11] + 0xbd3af235, 10);
3708 MD5STEP(
F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
3709 MD5STEP(
F4, b, c, d, a, in[9] + 0xeb86d391, 21);