00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00014
00015 #include "RecoLocalTracker/SiPixelRecHits/interface/VVIObj.h"
00016 #else
00017 #include "VVIObj.h"
00018 #endif
00019
00020
00021 #include <cmath>
00022 #include <algorithm>
00023 #include<boost/bind.hpp>
00024
00025
00026 namespace VVIObjDetails {
00027 void sincosint(double x, double & sint, double & cint);
00028 double cosint(double x);
00029 double sinint(double x);
00030 double expint(double x);
00031
00032 inline double f1(double x, double const * h_) { return h_[0]+h_[1]*std::log(h_[2]*x)-h_[3]*x;}
00033 inline double f2(double x, double const * h_) { return h_[4]-x+h_[5]*(std::log(std::abs(x))+expint(x))-h_[6]*std::exp(-x);}
00034 template<typename F>
00035 int dzero(double a, double b, double& x0,
00036 double& rv, double eps, int mxf, F func);
00037 }
00038
00039
00040
00041
00047
00048
00049 VVIObj::VVIObj(double kappa, double beta2, double mode) : mode_(mode) {
00050
00051 const double xp[9] = { 9.29,2.47,.89,.36,.15,.07,.03,.02,0.0 };
00052 const double xq[7] = { .012,.03,.08,.26,.87,3.83,11.0 };
00053 double h_[7];
00054 double q, u, x, c1, c2, c3, c4, d1, h4, h5, h6, q2, x1, d, ll, ul, xf1, xf2, rv;
00055 int lp, lq, k, l, n;
00056
00057
00058
00059 if(kappa < 0.01) kappa = 0.01;
00060 if(kappa > 10.) kappa = 10.;
00061 if(beta2 < 0.) beta2 = 0.;
00062 if(beta2 > 1.) beta2 = 1.;
00063
00064 h_[4] = 1. - beta2*0.42278433999999998 + 7.6/kappa;
00065 h_[5] = beta2;
00066 h_[6] = 1. - beta2;
00067 h4 = -7.6/kappa - (beta2 * .57721566 + 1);
00068 h5 = log(kappa);
00069 h6 = 1./kappa;
00070 t0_ = (h4 - h_[4]*h5 - (h_[4] + beta2)*(log(h_[4]) + VVIObjDetails::expint(h_[4])) + exp(-h_[4]))/h_[4];
00071
00072
00073
00074 for (lp = 0; lp < 9; ++lp) {
00075 if (kappa >= xp[lp]) break;
00076 }
00077 ll = -lp - 1.5;
00078 for (lq = 0; lq < 7; ++lq) {
00079 if (kappa <= xq[lq]) break;
00080 }
00081 ul = lq - 6.5;
00082
00083 VVIObjDetails::dzero(ll, ul, u, rv, 1.e-5, 1000, boost::bind(&VVIObjDetails::f2, _1,h_));
00084 q = 1./u;
00085 t1_ = h4 * q - h5 - (beta2 * q + 1) * (log((fabs(u))) + VVIObjDetails::expint(u)) + exp(-u) * q;
00086 t_ = t1_ - t0_;
00087 omega_ = 6.2831853000000004/t_;
00088 h_[0] = kappa * (beta2 * .57721566 + 2.) + 9.9166128600000008;
00089 if (kappa >= .07) {h_[0] += 6.90775527;}
00090 h_[1] = beta2 * kappa;
00091 h_[2] = h6 * omega_;
00092 h_[3] = omega_ * 1.5707963250000001;
00093
00094 VVIObjDetails::dzero(5., 155., x0_, rv, 1.e-5, 1000, boost::bind(&VVIObjDetails::f1, _1,h_));
00095 n = x0_ + 1.;
00096 d = exp(kappa * (beta2 * (.57721566 - h5) + 1.)) * .31830988654751274;
00097 a_[n - 1] = 0.;
00098 if (mode_ == 0) {
00099 a_[n - 1] = omega_ * .31830988654751274;
00100 }
00101 q = -1.;
00102 q2 = 2.;
00103 for (k = 1; k < n; ++k) {
00104 l = n - k;
00105 x = omega_ * k;
00106 x1 = h6 * x;
00107 VVIObjDetails::sincosint(x1,c2,c1);
00108 c1 = log(x) - c1;
00109 c3 = sin(x1);
00110 c4 = cos(x1);
00111 xf1 = kappa * (beta2 * c1 - c4) - x * c2;
00112 xf2 = x * c1 + kappa * (c3 + beta2 * c2) + t0_ * x;
00113 if (mode_ == 0) {
00114 d1 = q * d * omega_ * exp(xf1);
00115 a_[l - 1] = d1 * cos(xf2);
00116 b_[l - 1] = -d1 * sin(xf2);
00117 } else {
00118 d1 = q * d * exp(xf1)/k;
00119 a_[l - 1] = d1 * sin(xf2);
00120 b_[l - 1] = d1 * cos(xf2);
00121 a_[n - 1] += q2 * a_[l - 1];
00122 }
00123 q = -q;
00124 q2 = -q2;
00125 }
00126
00127 }
00128
00129
00133
00134
00135
00136 double VVIObj::fcn(double x) const {
00137
00138
00139
00140 double f, u, y, a0, a1;
00141 double a2 = 0.;
00142 double b1, b0, b2, cof;
00143 int k, n, n1;
00144
00145 n = x0_;
00146 if (x < t0_) {
00147 f = 0.;
00148 } else if (x <= t1_) {
00149 y = x - t0_;
00150 u = omega_ * y - 3.141592653589793;
00151 cof = cos(u) * 2.;
00152 a1 = 0.;
00153 a0 = a_[0];
00154 n1=n+1;
00155 for (k = 2; k <= n1; ++k) {
00156 a2 = a1;
00157 a1 = a0;
00158 a0 = a_[k - 1] + cof * a1 - a2;
00159 }
00160 b1 = 0.;
00161 b0 = b_[0];
00162 for (k = 2; k <= n; ++k) {
00163 b2 = b1;
00164 b1 = b0;
00165 b0 = b_[k - 1] + cof * b1 - b2;
00166 }
00167 f = (a0 - a2) * .5 + b0 * sin(u);
00168 if (mode_ != 0) {f += y / t_;}
00169 } else {
00170 f = 0.;
00171 if (mode_ != 0) {f = 1.;}
00172 }
00173 return f;
00174 }
00175
00176
00177
00178
00182
00183
00184
00185 void VVIObj::limits(double& xl, double& xu) const {
00186
00187 xl = t0_;
00188 xu = t1_;
00189 return;
00190 }
00191
00192
00193 namespace VVIObjDetails {
00194 double cosint(double x) {
00195
00196
00197 const double zero = 0.;
00198 const double one = 1.;
00199 const double two = 2.;
00200 const double eight = 8.;
00201 const double ce = .57721566490153;
00202 const double c__[14] = { 1.9405491464836,.9413409132865,
00203 -.579845034293,.3091572011159,-.0916101792208,.0164437407515,
00204 -.0019713091952,1.692538851e-4,-1.09393296e-5,5.522386e-7,
00205 -2.23995e-8,7.465e-10,-2.08e-11,5e-13 };
00206 const double p[23] = { .96074783975204,-.0371138962124,
00207 .00194143988899,-1.7165988425e-4,2.112637753e-5,-3.27163257e-6,
00208 6.0069212e-7,-1.2586794e-7,2.932563e-8,-7.45696e-9,2.04105e-9,
00209 -5.9502e-10,1.8323e-10,-5.921e-11,1.997e-11,-7e-12,2.54e-12,
00210 -9.5e-13,3.7e-13,-1.4e-13,6e-14,-2e-14,1e-14 };
00211 const double q[20] = { .98604065696238,-.0134717382083,
00212 4.5329284117e-4,-3.067288652e-5,3.13199198e-6,-4.2110196e-7,
00213 6.907245e-8,-1.318321e-8,2.83697e-9,-6.7329e-10,1.734e-10,
00214 -4.787e-11,1.403e-11,-4.33e-12,1.4e-12,-4.7e-13,1.7e-13,-6e-14,
00215 2e-14,-1e-14 };
00216
00217
00218 double d__1;
00219
00220
00221 double h__;
00222 int i__;
00223 double r__, y, b0, b1, b2, pp, qq, alfa;
00224
00225
00226
00227 if (x == zero) {
00228 return zero;
00229 }
00230 if (fabs(x) <= eight) {
00231 y = x / eight;
00232
00233 d__1 = y;
00234 h__ = two * (d__1 * d__1) - one;
00235 alfa = -two * h__;
00236 b1 = zero;
00237 b2 = zero;
00238 for (i__ = 13; i__ >= 0; --i__) {
00239 b0 = c__[i__] - alfa * b1 - b2;
00240 b2 = b1;
00241 b1 = b0;
00242 }
00243 b1 = ce + log((fabs(x))) - b0 + h__ * b2;
00244 } else {
00245 r__ = one / x;
00246 y = eight * r__;
00247
00248 d__1 = y;
00249 h__ = two * (d__1 * d__1) - one;
00250 alfa = -two * h__;
00251 b1 = zero;
00252 b2 = zero;
00253 for (i__ = 22; i__ >= 0; --i__) {
00254 b0 = p[i__] - alfa * b1 - b2;
00255 b2 = b1;
00256 b1 = b0;
00257 }
00258 pp = b0 - h__ * b2;
00259 b1 = zero;
00260 b2 = zero;
00261 for (i__ = 19; i__ >= 0; --i__) {
00262 b0 = q[i__] - alfa * b1 - b2;
00263 b2 = b1;
00264 b1 = b0;
00265 }
00266 qq = b0 - h__ * b2;
00267 b1 = r__ * (qq * sin(x) - r__ * pp * cos(x));
00268 }
00269 return b1;
00270 }
00271
00272 double sinint(double x) {
00273
00274
00275 const double zero = 0.;
00276 const double one = 1.;
00277 const double two = 2.;
00278 const double eight = 8.;
00279 const double pih = 1.5707963267949;
00280 const double s[14] = { 1.9522209759531,-.6884042321257,
00281 .4551855132256,-.1804571236838,.0410422133759,-.0059586169556,
00282 6.001427414e-4,-4.44708329e-5,2.5300782e-6,-1.141308e-7,4.1858e-9,
00283 -1.273e-10,3.3e-12,-1e-13 };
00284 const double p[23] = { .96074783975204,-.0371138962124,
00285 .00194143988899,-1.7165988425e-4,2.112637753e-5,-3.27163257e-6,
00286 6.0069212e-7,-1.2586794e-7,2.932563e-8,-7.45696e-9,2.04105e-9,
00287 -5.9502e-10,1.8323e-10,-5.921e-11,1.997e-11,-7e-12,2.54e-12,
00288 -9.5e-13,3.7e-13,-1.4e-13,6e-14,-2e-14,1e-14 };
00289 const double q[20] = { .98604065696238,-.0134717382083,
00290 4.5329284117e-4,-3.067288652e-5,3.13199198e-6,-4.2110196e-7,
00291 6.907245e-8,-1.318321e-8,2.83697e-9,-6.7329e-10,1.734e-10,
00292 -4.787e-11,1.403e-11,-4.33e-12,1.4e-12,-4.7e-13,1.7e-13,-6e-14,
00293 2e-14,-1e-14 };
00294
00295
00296 double d__1;
00297
00298
00299 double h__;
00300 int i__;
00301 double r__, y, b0, b1, b2, pp, qq, alfa;
00302
00303 if (fabs(x) <= eight) {
00304 y = x / eight;
00305 d__1 = y;
00306 h__ = two * (d__1 * d__1) - one;
00307 alfa = -two * h__;
00308 b1 = zero;
00309 b2 = zero;
00310 for (i__ = 13; i__ >= 0; --i__) {
00311 b0 = s[i__] - alfa * b1 - b2;
00312 b2 = b1;
00313 b1 = b0;
00314 }
00315 b1 = y * (b0 - b2);
00316 } else {
00317 r__ = one / x;
00318 y = eight * r__;
00319 d__1 = y;
00320 h__ = two * (d__1 * d__1) - one;
00321 alfa = -two * h__;
00322 b1 = zero;
00323 b2 = zero;
00324 for (i__ = 22; i__ >= 0; --i__) {
00325 b0 = p[i__] - alfa * b1 - b2;
00326 b2 = b1;
00327 b1 = b0;
00328 }
00329 pp = b0 - h__ * b2;
00330 b1 = zero;
00331 b2 = zero;
00332 for (i__ = 19; i__ >= 0; --i__) {
00333 b0 = q[i__] - alfa * b1 - b2;
00334 b2 = b1;
00335 b1 = b0;
00336 }
00337 qq = b0 - h__ * b2;
00338 d__1 = fabs(pih);
00339 if(x < 0.) d__1 = -d__1;
00340 b1 = d__1 - r__ * (r__ * pp * sin(x) + qq * cos(x));
00341 }
00342
00343 return b1;
00344 }
00345
00346 void sincosint(double x, double & sint, double & cint) {
00347
00348
00349 const double zero = 0.;
00350 const double one = 1.;
00351 const double two = 2.;
00352 const double eight = 8.;
00353 const double ce = .57721566490153;
00354 const double pih = 1.5707963267949;
00355 const double s__[14] = { 1.9522209759531,-.6884042321257,
00356 .4551855132256,-.1804571236838,.0410422133759,-.0059586169556,
00357 6.001427414e-4,-4.44708329e-5,2.5300782e-6,-1.141308e-7,4.1858e-9,
00358 -1.273e-10,3.3e-12,-1e-13 };
00359
00360 const double c__[14] = { 1.9405491464836,.9413409132865,
00361 -.579845034293,.3091572011159,-.0916101792208,.0164437407515,
00362 -.0019713091952,1.692538851e-4,-1.09393296e-5,5.522386e-7,
00363 -2.23995e-8,7.465e-10,-2.08e-11,5e-13 };
00364
00365 const double p[23] = { .96074783975204,-.0371138962124,
00366 .00194143988899,-1.7165988425e-4,2.112637753e-5,-3.27163257e-6,
00367 6.0069212e-7,-1.2586794e-7,2.932563e-8,-7.45696e-9,2.04105e-9,
00368 -5.9502e-10,1.8323e-10,-5.921e-11,1.997e-11,-7e-12,2.54e-12,
00369 -9.5e-13,3.7e-13,-1.4e-13,6e-14,-2e-14,1e-14 };
00370 const double q[20] = { .98604065696238,-.0134717382083,
00371 4.5329284117e-4,-3.067288652e-5,3.13199198e-6,-4.2110196e-7,
00372 6.907245e-8,-1.318321e-8,2.83697e-9,-6.7329e-10,1.734e-10,
00373 -4.787e-11,1.403e-11,-4.33e-12,1.4e-12,-4.7e-13,1.7e-13,-6e-14,
00374 2e-14,-1e-14 };
00375
00376
00377 double d__1;
00378
00379
00380 double h__;
00381 int i__;
00382 double r__, y, b0, b1, b2, pp, qq, alfa;
00383
00384 sint=0;
00385 cint=0;
00386
00387
00388 if (fabs(x) <= eight) {
00389 y = x / eight;
00390
00391 d__1 = y;
00392 h__ = two * (d__1 * d__1) - one;
00393 alfa = -two * h__;
00394
00395
00396 if (x!=0) {
00397 b1 = zero;
00398 b2 = zero;
00399 for (i__ = 13; i__ >= 0; --i__) {
00400 b0 = c__[i__] - alfa * b1 - b2;
00401 b2 = b1;
00402 b1 = b0;
00403 }
00404 cint = ce + log((fabs(x))) - b0 + h__ * b2;
00405 }
00406
00407 b1 = zero;
00408 b2 = zero;
00409 for (i__ = 13; i__ >= 0; --i__) {
00410 b0 = s__[i__] - alfa * b1 - b2;
00411 b2 = b1;
00412 b1 = b0;
00413 }
00414 sint = y * (b0 - b2);
00415
00416 } else {
00417 r__ = one / x;
00418 y = eight * r__;
00419
00420 d__1 = y;
00421 h__ = two * (d__1 * d__1) - one;
00422 alfa = -two * h__;
00423 b1 = zero;
00424 b2 = zero;
00425 for (i__ = 22; i__ >= 0; --i__) {
00426 b0 = p[i__] - alfa * b1 - b2;
00427 b2 = b1;
00428 b1 = b0;
00429 }
00430 pp = b0 - h__ * b2;
00431 b1 = zero;
00432 b2 = zero;
00433 for (i__ = 19; i__ >= 0; --i__) {
00434 b0 = q[i__] - alfa * b1 - b2;
00435 b2 = b1;
00436 b1 = b0;
00437 }
00438 qq = b0 - h__ * b2;
00439
00440 cint = r__ * (qq * sin(x) - r__ * pp * cos(x));
00441
00442 d__1 = pih;
00443 if(x < 0.) d__1 = -d__1;
00444 sint = d__1 - r__ * (r__ * pp * sin(x) + qq * cos(x));
00445 }
00446 }
00447
00448
00449 double expint(double x) {
00450
00451
00452
00453 const double zero = 0.;
00454 const double q2[7] = { .10340013040487,3.319092135933,
00455 20.449478501379,41.280784189142,32.426421069514,10.041164382905,
00456 1. };
00457 const double p3[6] = { -2.3909964453136,-147.98219500504,
00458 -254.3763397689,-119.55761038372,-19.630408535939,-.9999999999036
00459 };
00460 const double q3[6] = { 177.60070940351,530.68509610812,
00461 462.23027156148,156.81843364539,21.630408494238,1. };
00462 const double p4[8] = { -8.6693733995107,-549.14226552109,
00463 -4210.0161535707,-249301.39345865,-119623.66934925,
00464 -22174462.775885,3892804.213112,-391546073.8091 };
00465 const double q4[8] = { 34.171875,-1607.0892658722,35730.029805851,
00466 -483547.43616216,4285596.2461175,-24903337.574054,89192576.757561,
00467 -165254299.72521 };
00468 const double a1[8] = { -2.1808638152072,-21.901023385488,
00469 9.3081638566217,25.076281129356,-33.184253199722,60.121799083008,
00470 -43.253113287813,1.0044310922808 };
00471 const double b1[8] = { 0.,3.9370770185272,300.89264837292,
00472 -6.2504116167188,1003.6743951673,14.325673812194,2736.2411988933,
00473 .52746885196291 };
00474 const double a2[8] = { -3.4833465360285,-18.65454548834,
00475 -8.2856199414064,-32.34673303054,17.960168876925,1.7565631546961,
00476 -1.9502232128966,.99999429607471 };
00477 const double b2[8] = { 0.,69.500065588743,57.283719383732,
00478 25.777638423844,760.76114800773,28.951672792514,-3.4394226689987,
00479 1.0008386740264 };
00480 const double a3[6] = { -27.780928934438,-10.10479081576,
00481 -9.1483008216736,-5.0223317461851,-3.0000077799358,
00482 1.0000000000704 };
00483 const double one = 1.;
00484 const double b3[6] = { 0.,122.39993926823,2.7276100778779,
00485 -7.1897518395045,-2.9990118065262,1.999999942826 };
00486 const double two = 2.;
00487 const double three = 3.;
00488 const double x0 = .37250741078137;
00489 const double xl[6] = { -24.,-12.,-6.,0.,1.,4. };
00490 const double p1[5] = { 4.293125234321,39.894153870321,
00491 292.52518866921,425.69682638592,-434.98143832952 };
00492 const double q1[5] = { 1.,18.899288395003,150.95038744251,
00493 568.05252718987,753.58564359843 };
00494 const double p2[7] = { .43096783946939,6.9052252278444,
00495 23.019255939133,24.378408879132,9.0416155694633,.99997957705159,
00496 4.656271079751e-7 };
00497
00498
00499 double v, y, ap, bp, aq, dp, bq, dq;
00500
00501 if (x <= xl[0]) {
00502 ap = a3[0] - x;
00503 for ( int i__ = 2; i__ <= 5; ++i__) {
00504
00505 ap = a3[i__ - 1] - x + b3[i__ - 1] / ap;
00506 }
00507 y = exp(-x) / x * (one - (a3[5] + b3[5] / ap) / x);
00508 } else if (x <= xl[1]) {
00509 ap = a2[0] - x;
00510 for ( int i__ = 2; i__ <= 7; ++i__) {
00511 ap = a2[i__ - 1] - x + b2[i__ - 1] / ap;
00512 }
00513 y = exp(-x) / x * (a2[7] + b2[7] / ap);
00514 } else if (x <= xl[2]) {
00515 ap = a1[0] - x;
00516 for ( int i__ = 2; i__ <= 7; ++i__) {
00517 ap = a1[i__ - 1] - x + b1[i__ - 1] / ap;
00518 }
00519 y = exp(-x) / x * (a1[7] + b1[7] / ap);
00520 } else if (x < xl[3]) {
00521 v = -two * (x / three + one);
00522 bp = zero;
00523 dp = p4[0];
00524 for ( int i__ = 2; i__ <= 8; ++i__) {
00525 ap = bp;
00526 bp = dp;
00527 dp = p4[i__ - 1] - ap + v * bp;
00528 }
00529 bq = zero;
00530 dq = q4[0];
00531 for ( int i__ = 2; i__ <= 8; ++i__) {
00532 aq = bq;
00533 bq = dq;
00534 dq = q4[i__ - 1] - aq + v * bq;
00535 }
00536 y = -log(-x / x0) + (x + x0) * (dp - ap) / (dq - aq);
00537 } else if (x == xl[3]) {
00538 return zero;
00539 } else if (x < xl[4]) {
00540 ap = p1[0];
00541 aq = q1[0];
00542 for ( int i__ = 2; i__ <= 5; ++i__) {
00543 ap = p1[i__ - 1] + x * ap;
00544 aq = q1[i__ - 1] + x * aq;
00545 }
00546 y = -log(x) + ap / aq;
00547 } else if (x <= xl[5]) {
00548 y = one / x;
00549 ap = p2[0];
00550 aq = q2[0];
00551 for ( int i__ = 2; i__ <= 7; ++i__) {
00552 ap = p2[i__ - 1] + y * ap;
00553 aq = q2[i__ - 1] + y * aq;
00554 }
00555 y = exp(-x) * ap / aq;
00556 } else {
00557 y = one / x;
00558 ap = p3[0];
00559 aq = q3[0];
00560 for ( int i__ = 2; i__ <= 6; ++i__) {
00561 ap = p3[i__ - 1] + y * ap;
00562 aq = q3[i__ - 1] + y * aq;
00563 }
00564 y = exp(-x) * y * (one + y * ap / aq);
00565 }
00566 return y;
00567 }
00568
00569
00570 template<typename F>
00571 int dzero(double a, double b, double& x0,
00572 double& rv, double eps, int mxf, F func) {
00573
00574 double d__1, d__2, d__3, d__4;
00575
00576
00577 double f1, f2, f3, u1, u2, x1, x2, u3, u4, x3, ca, cb, cc, fa, fb, ee, ff;
00578 int mc;
00579 double xa, xb, fx, xx, su4;
00580
00581 xa = std::min(a,b);
00582 xb = std::max(a,b);
00583 fa = func(xa);
00584 fb = func(xb);
00585 if (fa * fb > 0.) {
00586 rv = (xb - xa) * -2;
00587 x0 = 0.;
00588 return 1;
00589 }
00590 mc = 0;
00591 L1:
00592 x0 = (xa + xb) * .5;
00593 rv = x0 - xa;
00594 ee = eps * (fabs(x0) + 1);
00595 if (rv <= ee) {
00596 rv = ee;
00597 ff = func(x0);
00598 return 0;
00599 }
00600 f1 = fa;
00601 x1 = xa;
00602 f2 = fb;
00603 x2 = xb;
00604 L2:
00605 fx = func(x0);
00606 ++mc;
00607 if (mc > mxf) {
00608 rv = (d__1 = xb - xa, fabs(d__1)) * -.5;
00609 x0 = 0.;
00610 return 0;
00611 }
00612 if (fx * fa > 0.) {
00613 xa = x0;
00614 fa = fx;
00615 } else {
00616 xb = x0;
00617 fb = fx;
00618 }
00619 L3:
00620 u1 = f1 - f2;
00621 u2 = x1 - x2;
00622 u3 = f2 - fx;
00623 u4 = x2 - x0;
00624 if (u2 == 0. || u4 == 0.) {goto L1;}
00625 f3 = fx;
00626 x3 = x0;
00627 u1 /= u2;
00628 u2 = u3 / u4;
00629 ca = u1 - u2;
00630 cb = (x1 + x2) * u2 - (x2 + x0) * u1;
00631 cc = (x1 - x0) * f1 - x1 * (ca * x1 + cb);
00632 if (ca == 0.) {
00633 if (cb == 0.) {goto L1;}
00634 x0 = -cc / cb;
00635 } else {
00636 u3 = cb / (ca * 2);
00637 u4 = u3 * u3 - cc / ca;
00638 if (u4 < 0.) {goto L1;}
00639 su4 = fabs(u4);
00640 if (x0 + u3 < 0.f) {su4 = -su4;}
00641 x0 = -u3 + su4;
00642 }
00643 if (x0 < xa || x0 > xb) {goto L1;}
00644
00645 d__3 = (d__1 = x0 - x3, fabs(d__1)), d__4 = (d__2 = x0 - x2, fabs(d__2));
00646 rv = std::min(d__3,d__4);
00647 ee = eps * (fabs(x0) + 1);
00648 if (rv > ee) {
00649 f1 = f2;
00650 x1 = x2;
00651 f2 = f3;
00652 x2 = x3;
00653 goto L2;
00654 }
00655 fx = func(x0);
00656 if (fx == 0.) {
00657 rv = ee;
00658 ff = func(x0);
00659 return 0;
00660 }
00661 if (fx * fa < 0.) {
00662 xx = x0 - ee;
00663 if (xx <= xa) {
00664 rv = ee;
00665 ff = func(x0);
00666 return 0;
00667 }
00668 ff = func(xx);
00669 fb = ff;
00670 xb = xx;
00671 } else {
00672 xx = x0 + ee;
00673 if (xx >= xb) {
00674 rv = ee;
00675 ff = func(x0);
00676 return 0;
00677 }
00678 ff = func(xx);
00679 fa = ff;
00680 xa = xx;
00681 }
00682 if (fx * ff > 0.) {
00683 mc += 2;
00684 if (mc > mxf) {
00685 rv = (d__1 = xb - xa, fabs(d__1)) * -.5;
00686 x0 = 0.;
00687 return 0;
00688 }
00689 f1 = f3;
00690 x1 = x3;
00691 f2 = fx;
00692 x2 = x0;
00693 x0 = xx;
00694 fx = ff;
00695 goto L3;
00696 }
00697
00698 rv = ee;
00699 ff = func(x0);
00700 return 0;
00701 }
00702
00703 }