48 :
sr(0.), si(0.),
u(0.),
v(0.),
49 a(0.),
b(0.),
c(0.),
d(0.),
50 a1(0.), a3(0.), a7(0.),
51 e(0.),
f(0.),
g(0.),
h(0.),
52 szr(0.), szi(0.), lzr(0.), lzi(0.),
67 G4int cnt=0, nz=0, i=0, j=0, jj=0, l=0, nm1=0, zerok=0;
74 static const G4double cosr = std::cos(rot),
81 if (!(op[0] != 0.0)) {
return -1; }
85 while (!(op[
n] != 0.0))
92 if (
n < 1) {
return -1; }
96 std::vector<G4double> temp(degr+1) ;
97 std::vector<G4double>
pt(degr+1) ;
100 qp.assign(degr+1,0) ;
102 qk.assign(degr+1,0) ;
103 svk.assign(degr+1,0) ;
114 zeror[degr-1] = -
p[1]/
p[0];
122 &zeror[degr-1],&zeroi[degr-1]);
134 if (
x > max) { max =
x; }
146 if ( ((
sc <= 1.0) && (max >= 10.0))
148 || ((
infin/
sc >= max) && (max >= 10)) )
157 {
p[i] = factor*
p[i]; }
165 pt[i] = (std::fabs(
p[i]));
178 if (xm <
x) {
x = xm; }
188 {
ff =
ff*xm + pt[i]; }
189 if (
ff <= 0.0) {
break; }
196 while (std::fabs(
dx/
x) > 0.005)
220 zerok = (
k[n-1] == 0);
232 k[j] = t*
k[j-1]+
p[j];
235 zerok = (std::fabs(
k[n-1]) <= std::fabs(
bb)*
eta*10.0);
245 zerok = (!(
k[n-1] != 0.0));
256 for (cnt = 0;cnt < 20;cnt++)
263 xxx = cosr*xo - sinr*yo;
264 yo = sinr*xo + cosr*yo;
316 G4double svu=0.0, svv=0.0, ui=0.0, vi=0.0, xs=0.0;
318 ss=0.0, vv=0.0, ts=1.0, tv=1.0;
321 G4int type=0, i=0, j=0, iflag=0, vpass=0, spass=0, vtry=0, stry=0;
341 if (
k[
n-1] != 0.0) { ss = -
p[
n]/
k[
n-1]; }
344 if (j == 0 || type == 3)
355 if (vv != 0.0) { tv = std::fabs((vv-ovv)/vv); }
356 if (ss != 0.0) { ts = std::fabs((ss-oss)/ss); }
360 if (tv < otv) { tvv = tv*otv; }
362 if (ts < ots) { tss = ts*ots; }
365 vpass = (tvv < betav);
366 spass = (tss < betas);
367 if (!(spass || vpass))
391 if ((spass && (!vpass)) || (tss < tvv))
394 if (*nz > 0) {
return; }
401 if (iflag == 0) {
goto _restore_variables; }
410 _quadratic_iteration:
415 if (*nz > 0) {
return; }
426 if (stry || !spass) {
break; }
432 if (*nz > 0) {
return; }
439 if (iflag == 0) {
break; }
463 if (vpass && !vtry) {
goto _quadratic_iteration; }
491 G4int type=0, i=1, j=0, tried=0;
508 if (std::fabs(std::fabs(
szr)-std::fabs(
lzr)) > 0.01 * std::fabs(
lzr))
514 mp = std::fabs(
a-
szr*
b) + std::fabs(
szi*b);
518 zm = std::sqrt(std::fabs(
v));
519 ee = 2.0*std::fabs(
qp[0]);
523 ee = ee*zm + std::fabs(
qp[i]);
525 ee = ee*zm + std::fabs(
a+
t);
526 ee *= (5.0 *
mre + 4.0*
are);
527 ee = ee - (5.0*
mre+2.0*
are)*(std::fabs(
a+
t)+std::fabs(b)*zm)
528 + 2.0*
are*std::fabs(
t);
542 if (j > 20) {
return; }
545 if (!(relstp > 0.01 || mp < omp || tried))
550 if (relstp <
eta) { relstp =
eta; }
551 relstp = std::sqrt(relstp);
575 if (!(vi != 0.0)) {
return; }
576 relstp = std::fabs((vi-
v)/vi);
621 ee = ee*mx + std::fabs(
qp[i]);
638 if (j > 10) {
return; }
641 if (!(std::fabs(t) > 0.001*std::fabs(xs-t) || mp < omp))
663 if (std::fabs(kv) <= std::fabs(
k[n-1])*10.0*
eta)
677 k[i] = t*
qk[i-1] +
qp[i];
686 if (std::fabs(kv) > std::fabs(
k[n-1]*10.0*
eta)) { t = -pv/kv; }
702 if (std::fabs(
c) <= std::fabs(
k[
n-1]*100.0*
eta))
704 if (std::fabs(
d) <= std::fabs(
k[
n-2]*100.0*
eta))
711 if (std::fabs(
d) < std::fabs(
c))
751 if (*type == 1) { temp =
b; }
752 if (std::fabs(
a1) <= std::fabs(temp)*
eta*10.0)
760 k[i] =
a3*
qk[i-2] -
a7*qp[i-1];
773 k[i] =
a3*
qk[i-2] -
a7*qp[i-1] + qp[i];
783 G4double a4=0.0, a5=0.0, b1=0.0, b2=0.0,
784 c1=0.0,
c2=0.0, c3=0.0, c4=0.0, temp=0.0;
808 b2 = -(
k[
n-2]+b1*
p[
n-1])/
p[
n];
813 temp = a5 + b1*a4 - c4;
820 *uu =
u - (
u*(c3+
c2)+
v*(b1*a1+b2*a7))/temp;
821 *vv =
v*(1.0+c4/temp);
827 std::vector<G4double> &
pp, std::vector<G4double> &qq,
836 *aa = pp[1] - (*bb)*(*uu);
840 cc = pp[i] - (*aa)*(*uu) - (*bb)*(*vv);
883 if (std::fabs(bb) < std::fabs(cc))
889 ee = bb*(bb/std::fabs(cc)) - ee;
890 dd = std::sqrt(std::fabs(ee))*std::sqrt(std::fabs(cc));
894 ee = 1.0 - (aa/
bb)*(cc/bb);
895 dd = std::sqrt(std::fabs(ee))*std::fabs(bb);
901 *ssi = std::fabs(dd/aa);
911 { *ssr = (cc/ *lr)/aa; }