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