117{
118 static const G4int nat1 = 15;
119 static const G4int nat2 = nat1+nat1;
120 static const G4int npi = 25;
121 static const G4int npil = npi-1;
122 static const G4int npk = 17;
123 static const G4int npkl = npk-1;
124 static const G4int npj = 20;
125 static const G4int npjl = npj-1;
132 static const G4double PI = 3.14159265358979324;
133 static const G4double CE = 0.57721566490153286;
136 static const G4double PI3 = PIH+PI4;
138 static const G4double RPI2 = RPIH/4;
139
140 static const G4double CI0[npi]={+1.00829205458740032E0,
141 +.00845122624920943E0,+.00012700630777567E0,+.00007247591099959E0,
142 +.00000513587726878E0,+.00000056816965808E0,+.00000008513091223E0,
143 +.00000001238425364E0,+.00000000029801672E0,-.00000000078956698E0,
144 -.00000000033127128E0,-.00000000004497339E0,+.00000000001799790E0,
145 +.00000000000965748E0,+.00000000000038604E0,-.00000000000104039E0,
146 -.00000000000023950E0,+.00000000000009554E0,+.00000000000004443E0,
147 -.00000000000000859E0,-.00000000000000709E0,+.00000000000000087E0,
148 +.00000000000000112E0,-.00000000000000012E0,-.00000000000000018E0};
149
150 static const G4double CI1[npi]={+.975800602326285926E0,
151 -.024467442963276385E0,-.000277205360763829E0,-.000009732146728020E0,
152 -.000000629724238640E0,-.000000065961142154E0,-.000000009613872919E0,
153 -.000000001401140901E0,-.000000000047563167E0,+.000000000081530681E0,
154 +.000000000035408148E0,+.000000000005102564E0,-.000000000001804409E0,
155 -.000000000001023594E0,-.000000000000052678E0,+.000000000000107094E0,
156 +.000000000000026120E0,-.000000000000009561E0,-.000000000000004713E0,
157 +.000000000000000829E0,+.000000000000000743E0,-.000000000000000080E0,
158 -.000000000000000117E0,+.000000000000000011E0,+.000000000000000019E0};
159
160 static const G4double CK0[npk]={+.988408174230825800E0,-.011310504646928281E0,
161 +.000269532612762724E0,-.000011106685196665E0,+.000000632575108500E0,
162 -.000000045047337641E0,+.000000003792996456E0,-.000000000364547179E0,
163 +.000000000039043756E0,-.000000000004579936E0,+.000000000000580811E0,
164 -.000000000000078832E0,+.000000000000011360E0,-.000000000000001727E0,
165 +.000000000000000275E0,-.000000000000000046E0,+.000000000000000008E0};
166
167 static const G4double CK1[npk]={+1.035950858772358331E0,+.035465291243331114E0,
168 -.000468475028166889E0,+.000016185063810053E0,-.000000845172048124E0,
169 +.000000057132218103E0,-.000000004645554607E0,+.000000000435417339E0,
170 -.000000000045757297E0,+.000000000005288133E0,-.000000000000662613E0,
171 +.000000000000089048E0,-.000000000000012726E0,+.000000000000001921E0,
172 -.000000000000000305E0,+.000000000000000050E0,-.000000000000000009E0};
173
174 static const G4double CA[npk]={+.157727971474890120E0,-.008723442352852221E0,
175 +.265178613203336810E0,-.370094993872649779E0,+.158067102332097261E0,
176 -.034893769411408885E0,+.004819180069467605E0,-.000460626166206275E0,
177 +.000032460328821005E0,-.000001761946907762E0,+.000000076081635924E0,
178 -.000000002679253531E0,+.000000000078486963E0,-.000000000001943835E0,
179 +.000000000000041253E0,-.000000000000000759E0,+.000000000000000012E0};
180
181 static const G4double CB[npk]={-.021505111449657551E0,-.275118133043518791E0,
182 +.198605634702554156E0,+.234252746109021802E0,-.165635981713650413E0,
183 +.044621379540669282E0,-.006932286291523188E0,+.000719117403752303E0,
184 -.000053925079722939E0,+.000003076493288108E0,-.000000138457181230E0,
185 +.000000005051054369E0,-.000000000152582850E0,+.000000000003882867E0,
186 -.000000000000084429E0,+.000000000000001587E0,-.000000000000000026E0};
187
189 G4complex(+.998988089858965153E0,-.012331520578544144E0),
190 G4complex(-.001338428549971856E0,-.012249496281259475E0),
191 G4complex(-.000318789878061893E0,+.000096494184993423E0),
192 G4complex(+.000008511232210657E0,+.000013655570490357E0),
193 G4complex(+.000000691542349139E0,-.000000851806644426E0),
194 G4complex(-.000000090770101537E0,-.000000027244053414E0),
195 G4complex(+.000000001454928079E0,+.000000009646421338E0),
196 G4complex(+.000000000926762487E0,-.000000000683347518E0),
197 G4complex(-.000000000139166198E0,-.000000000060627380E0),
198 G4complex(+.000000000003237975E0,+.000000000021695716E0),
199 G4complex(+.000000000002535357E0,-.000000000002304899E0),
200 G4complex(-.000000000000559090E0,-.000000000000122554E0),
201 G4complex(+.000000000000041919E0,+.000000000000092314E0),
202 G4complex(+.000000000000008733E0,-.000000000000016778E0),
203 G4complex(-.000000000000003619E0,+.000000000000000754E0),
204 G4complex(+.000000000000000594E0,+.000000000000000462E0),
205 G4complex(-.000000000000000010E0,-.000000000000000159E0),
206 G4complex(-.000000000000000024E0,+.000000000000000025E0),
207 G4complex(+.000000000000000008E0,+.000000000000000000E0),
208 G4complex(-.000000000000000001E0,-.000000000000000001E0)};
209
210 static const G4double CD[npk]={+0.648358770605264921E0,-1.191801160541216873E0,
211 +1.287994098857677620E0,-0.661443934134543253E0,+0.177709117239728283E0,
212 -0.029175524806154208E0,+0.003240270182683857E0,-0.000260444389348581E0,
213 +0.000015887019239932E0,-0.000000761758780540E0,+0.000000029497070073E0,
214 -0.000000000942421298E0,+0.000000000025281237E0,-0.000000000000577740E0,
215 +0.000000000000011386E0,-0.000000000000000196E0,+0.000000000000000003E0};
216
217 static const G4double EE[npk]={-.040172946544414076E0,-.444447147630558063E0,
218 -.022719244428417736E0,+.206644541017490520E0,-.086671697056948524E0,
219 +.017636703003163134E0,-.002235619294485095E0,+.000197062302701541E0,
220 -.000012885853299241E0,+.000000652847952359E0,-.000000026450737175E0,
221 +.000000000878030117E0,-.000000000024343279E0,+.000000000000572612E0,
222 -.000000000000011578E0,+.000000000000000203E0,-.000000000000000003E0};
223
225 G4complex(+1.001702234853820996E0,+.037261715000537654E0),
226 G4complex(+.002255572846561180E0,+.037145322479807690E0),
227 G4complex(+.000543216487508013E0,-.000137263238201907E0),
228 G4complex(-.000011179461895408E0,-.000019851294687597E0),
229 G4complex(-.000000946901382392E0,+.000001070014057386E0),
230 G4complex(+.000000111032677121E0,+.000000038305261714E0),
231 G4complex(-.000000001294398927E0,-.000000011628723277E0),
232 G4complex(-.000000001114905944E0,+.000000000759733092E0),
233 G4complex(+.000000000157637232E0,+.000000000075476075E0),
234 G4complex(-.000000000002830457E0,-.000000000024752781E0),
235 G4complex(-.000000000002932169E0,+.000000000002493893E0),
236 G4complex(+.000000000000617809E0,+.000000000000156198E0),
237 G4complex(-.000000000000043162E0,-.000000000000103385E0),
238 G4complex(-.000000000000010133E0,+.000000000000018129E0),
239 G4complex(+.000000000000003973E0,-.000000000000000709E0),
240 G4complex(-.000000000000000632E0,-.000000000000000520E0),
241 G4complex(+.000000000000000006E0,+.000000000000000172E0),
242 G4complex(+.000000000000000027E0,-.000000000000000026E0),
243 G4complex(-.000000000000000008E0,-.000000000000000000E0),
244 G4complex(+.000000000000000001E0,+.000000000000000001E0)};
245
247 if (ij)
248 {
249 if (ik)
250 {
253 if (V < 8.)
254 {
265 G4double A2=1.+Y*(4.+(DY+Y)/(XLD*XL))/(W1*V3);
268 G4double B2=1.-Y*(1.-Y/(XLD+XLD))/W1;
272 for (
G4int N=3; N<=30; N++)
273 {
276 W1=W1+2;
284 V3=V3+1;
293 C=A/B;
294 if (std::abs(C0-C) < EPS*std::abs(C)) break;
295 A0=A1; A1=A2; A2=A; B0=B1; B1=B2; B2=B;
296 }
297 H=C;
298 if (nu==1) H*=HF*X;
299 if (ex) H*=std::exp(-V);
300 }
301 else
302 {
307 for (
G4int I=npil; I>=0; I--)
308 {
309 if (!nu) CJ=CI0[I];
310 else CJ=CI1[I];
312 B2=B1;
313 B1=B0;
314 }
315 H=std::sqrt(RPI2/V)*(B1-P*B2);
316 if (nu && X < 0.) H=-H;
317 if (!ex) H*=std::exp(V);
318 }
319 }
320 else
321 {
322#ifdef debug
323 G4cout<<
"G4BesIKJY: ------------>> K is called, X="<<X<<
",n="<<nu<<
",E="<<ex<<
G4endl;
324#endif
326 if (X < 0.)
327 {
328 G4cout<<
"G4BesIKJY::NegativeArg in K-BessFun X="<<X<<
", n="<<nu<<
",E="<<ex<<
G4endl;
329 return H;
330 }
331 else if (X < 1.)
332 {
333#ifdef debug
334 G4cout<<
"G4BesIKJY: -->> [ X < 1 ] is called, X="<<X<<
",n="<<nu<<
",E="<<ex<<
G4endl;
335#endif
344 for (
G4int N=1; N<=nat1; N++)
345 {
347 P/=FN;
348 Q/=FN;
349 F=(F+P+Q)/FN;
350 C*=D/FN;
353 BK=BK+R;
354 BK1=BK1+G;
355 if (BK1*R+std::abs(G)*BK < EPS*BK*BK1) break;
356 }
357 if (nu==1) H=BK1/B;
358 else H=BK;
359 if (ex) H*=std::exp(X);
360 }
361 else if (X < 5.)
362 {
363#ifdef debug
364 G4cout<<
"G4BesIKJY: -->> [ X < 5 ] is called, X="<<X<<
",n="<<nu<<
",E="<<ex<<
G4endl;
365#endif
367 if (nu==1) NUS=1;
377 G4double A2=(C+C0*(XN+23.)+XN*(XN+62.)+129.)/(A*B);
381 C=0.;
382 for (
G4int N=3; N<=nat2; N++)
383 {
384 C0=C;
397 A=(F1*A2+F2*A1+F3*A0)*RAN;
398 B=(F1*B2+F2*B1+F3*B0)*RAN;
399 C=A/B;
400 if (std::abs(C0-C) < EPS*std::abs(C)) break;
401 A0=A1; A1=A2; A2=A; B0=B1; B1=B2; B2=B;
402 }
403 H=C/std::sqrt(RPIH*X);
404 if (!ex) H*=std::exp(-X);
405 }
406 else
407 {
408#ifdef debug
409 G4cout<<
"G4BesIKJY: ->> [ X >= 5 ] is called, X="<<X<<
",n="<<nu<<
",E="<<ex<<
G4endl;
410#endif
415#ifdef debug
416 G4cout<<
"G4BesIKJY: ->> [ X >= 5 ] is called, X="<<X<<
",n="<<nu<<
",E="<<ex<<
G4endl;
417#endif
418 for (
G4int I=npkl; I>=0; I--)
419 {
420 if (!nu) CK=CK0[I];
421 else CK=CK1[I];
423 B2=B1;
424 B1=B0;
425 }
426 H=std::sqrt(PIH/X)*(B1-P*B2);
427 if (!ex) H*=std::exp(-X);
428 }
429 }
430 }
431 else
432 {
433 if (!ik && X < 0.)
434 {
435 G4cout<<
"G4BesIKJY::NegativeArgument in Y BesselFunction X="<<X<<
", nu="<<nu<<
G4endl;
436 return H;
437 }
439 if (!nu)
440 {
441 if (V < 8.)
442 {
448 {
450 B2=B1;
451 B1=B0;
452 }
453 H=B1-P*B2;
454 if (!ik)
455 {
456 B1=0.;
457 B2=0.;
458 for (
G4int JT=npkl; JT>=0; JT--)
459 {
461 B2=B1;
462 B1=B0;
463 }
464 H=RPIH*(CE+std::log(HF*X))*H+B1-P*B2;
465 }
466 }
467 else
468 {
474 {
476 CB2=CB1;
477 CB1=CB0;
478 }
479 CB1=std::sqrt(RPIH/V)*std::exp(CI*(V-PI4))*(CB1-P*CB2);
480 if (ik) H=real(CB1);
481 else H=real(-CI*CB1);
482 }
483 }
484 else
485 {
486 if (V < 8.)
487 {
495 {
497 B2=B1;
498 B1=B0;
499 }
500 H=Y*(B1-P*B2);
501 if (!ik)
502 {
503 B1=0.;
504 B2=0.;
505 for (
G4int JT=npkl; JT>=0; JT--)
506 {
508 B2=B1;
509 B1=B0;
510 }
511 H=RPIH*((CE+std::log(HF*X))*H-1./X)+Y*(B1-B2);
512 }
513 }
514 else
515 {
521 {
523 CB2=CB1;
524 CB1=CB0;
525 }
526 CB1=std::sqrt(RPIH/V)*std::exp(CI*(V-PI3))*(CB1-P*CB2);
527 if (ik) H=real(CB1);
528 else H=real(-CI*CB1);
529 }
530 if (X < 0.) H=-H;
531 }
532 }
533 return H;
534}
std::complex< G4double > G4complex
G4DLLIMPORT std::ostream G4cout