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.),
64 G4double t=0.0, aa=0.0, bb=0.0, cc=0.0, factor=1.0;
66 G4double xm=0.0, ff=0.0, df=0.0, dx=0.0;
67 G4int cnt=0, nz=0, i=0, j=0, jj=0, l=0, nm1=0, zerok=0;
80 if (!(op[0] != 0.0)) {
return -1; }
84 while (!(op[
n] != 0.0))
91 if (
n < 1) {
return -1; }
95 std::vector<G4double> temp(degr+1) ;
96 std::vector<G4double> pt(degr+1) ;
101 qk.assign(degr+1,0) ;
102 svk.assign(degr+1,0) ;
113 zeror[degr-1] = -
p[1]/
p[0];
121 &zeror[degr-1],&zeroi[degr-1]);
133 if (x > max) { max = x; }
134 if (x != 0.0 && x <
min) {
min = x; }
145 if ( ((sc <= 1.0) && (max >= 10.0))
146 || ((sc > 1.0) && (
infin/sc >= max))
147 || ((
infin/sc >= max) && (max >= 10)) )
151 l = (
G4int)(std::log(sc)/std::log(
base) + 0.5);
152 factor = std::pow(
base*1.0,l);
156 {
p[i] = factor*
p[i]; }
164 pt[i] = (std::fabs(
p[i]));
170 x = std::exp((std::log(-pt[
n])-std::log(pt[0])) / (
G4double)n);
177 if (xm < x) { x = xm; }
187 { ff = ff*xm + pt[i]; }
188 if (ff <= 0.0) {
break; }
195 while (std::fabs(dx/x) > 0.005)
219 zerok = (
k[n-1] == 0);
231 k[j] = t*
k[j-1]+
p[j];
234 zerok = (std::fabs(
k[n-1]) <= std::fabs(bb)*
eta*10.0);
244 zerok = (!(
k[n-1] != 0.0));
255 for (cnt = 0;cnt < 20;cnt++)
262 xxx = cosr*xx - sinr*yy;
263 yy = sinr*xx + cosr*yy;
315 G4double svu=0.0, svv=0.0, ui=0.0, vi=0.0, xs=0.0;
317 ss=0.0, vv=0.0, ts=1.0, tv=1.0;
320 G4int type=0, i=0, j=0, iflag=0, vpass=0, spass=0, vtry=0, stry=0;
340 if (
k[
n-1] != 0.0) { ss = -
p[
n]/
k[
n-1]; }
343 if (j == 0 || type == 3)
354 if (vv != 0.0) { tv = std::fabs((vv-ovv)/vv); }
355 if (ss != 0.0) { ts = std::fabs((ss-oss)/ss); }
359 if (tv < otv) { tvv = tv*otv; }
361 if (ts < ots) { tss = ts*ots; }
364 vpass = (tvv < betav);
365 spass = (tss < betas);
366 if (!(spass || vpass))
390 if ((spass && (!vpass)) || (tss < tvv))
393 if (*nz > 0) {
return; }
400 if (iflag == 0) {
goto _restore_variables; }
409 _quadratic_iteration:
414 if (*nz > 0) {
return; }
425 if (stry || !spass) {
break; }
431 if (*nz > 0) {
return; }
438 if (iflag == 0) {
break; }
462 if (vpass && !vtry) {
goto _quadratic_iteration; }
489 G4double mp=0.0, ee=0.0, t=0.0, zm=0.0;
490 G4int type=0, i=1, j=0, tried=0;
507 if (std::fabs(std::fabs(
szr)-std::fabs(
lzr)) > 0.01 * std::fabs(
lzr))
513 mp = std::fabs(
a-
szr*
b) + std::fabs(
szi*b);
517 zm = std::sqrt(std::fabs(
v));
518 ee = 2.0*std::fabs(
qp[0]);
522 ee = ee*zm + std::fabs(
qp[i]);
524 ee = ee*zm + std::fabs(
a+t);
525 ee *= (5.0 *
mre + 4.0*
are);
526 ee = ee - (5.0*
mre+2.0*
are)*(std::fabs(
a+t)+std::fabs(b)*zm)
527 + 2.0*
are*std::fabs(t);
541 if (j > 20) {
return; }
544 if (!(relstp > 0.01 || mp < omp || tried))
549 if (relstp <
eta) { relstp =
eta; }
550 relstp = std::sqrt(relstp);
574 if (!(vi != 0.0)) {
return; }
575 relstp = std::fabs((vi-
v)/vi);
620 ee = ee*mx + std::fabs(
qp[i]);
637 if (j > 10) {
return; }
640 if (!(std::fabs(t) > 0.001*std::fabs(xs-t) || mp < omp))
662 if (std::fabs(kv) <= std::fabs(
k[n-1])*10.0*
eta)
676 k[i] = t*
qk[i-1] +
qp[i];
685 if (std::fabs(kv) > std::fabs(
k[n-1]*10.0*
eta)) { t = -pv/kv; }
701 if (std::fabs(
c) <= std::fabs(
k[
n-1]*100.0*
eta))
703 if (std::fabs(
d) <= std::fabs(
k[
n-2]*100.0*
eta))
710 if (std::fabs(
d) < std::fabs(
c))
750 if (*type == 1) { temp =
b; }
751 if (std::fabs(
a1) <= std::fabs(temp)*
eta*10.0)
759 k[i] =
a3*
qk[i-2] -
a7*qp[i-1];
772 k[i] =
a3*
qk[i-2] -
a7*qp[i-1] + qp[i];
783 c1=0.0,
c2=0.0,
c3=0.0,
c4=0.0, temp=0.0;
819 *uu =
u - (
u*(c3+
c2)+
v*(
b1*a1+
b2*a7))/temp;
820 *vv =
v*(1.0+c4/temp);
826 std::vector<G4double> &
pp, std::vector<G4double> &qq,
835 *aa = pp[1] - (*bb)*(*uu);
839 cc = pp[i] - (*aa)*(*uu) - (*bb)*(*vv);
882 if (std::fabs(bb) < std::fabs(cc))
888 ee = bb*(bb/std::fabs(cc)) - ee;
889 dd = std::sqrt(std::fabs(ee))*std::sqrt(std::fabs(cc));
893 ee = 1.0 - (aa/bb)*(cc/bb);
894 dd = std::sqrt(std::fabs(ee))*std::fabs(bb);
900 *ssi = std::fabs(dd/aa);
910 { *ssr = (cc/ *lr)/aa; }
static const G4double are
void ComputeFixedShiftPolynomial(G4int l2, G4int *nz)
static c2_factory< G4double > c2
std::vector< G4double > svk
std::vector< G4double > qk
static const G4double mre
void ComputeScalarFactors(G4int *type)
std::vector< G4double > p
static const G4double smalno
std::vector< G4double > qp
void ComputeNewEstimate(G4int type, G4double *uu, G4double *vv)
static const G4double eta
std::vector< G4double > k
static const G4double infin
void ComputeNextPolynomial(G4int *type)
void RealPolynomialIteration(G4double *sss, G4int *nz, G4int *iflag)
static const G4double base
static const char sss[MAX_N_PAR+2]
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void QuadraticSyntheticDivision(G4int n, G4double *u, G4double *v, std::vector< G4double > &p, std::vector< G4double > &q, G4double *a, G4double *b)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
void QuadraticPolynomialIteration(G4double *uu, G4double *vv, G4int *nz)
G4int FindRoots(G4double *op, G4int degree, G4double *zeror, G4double *zeroi)
void Quadratic(G4double a, G4double b1, G4double c, G4double *sr, G4double *si, G4double *lr, G4double *li)