14 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
24 #include<boost/bind.hpp>
27 namespace sistripvvi {
29 namespace VVIObjDetails {
30 void sincosint(
double x,
double & sint,
double & cint);
35 inline double f1(
double x,
double const * h_) {
return h_[0]+h_[1]*
std::log(h_[2]*x)-h_[3]*
x;}
38 int dzero(
double a,
double b,
double& x0,
39 double& rv,
double eps,
int mxf,
F func);
54 const double xp[9] = { 9.29,2.47,.89,.36,.15,.07,.03,.02,0.0 };
55 const double xq[7] = { .012,.03,.08,.26,.87,3.83,11.0 };
57 double q, u,
x,
c1, c2, c3, c4, d1, h4, h5, h6,
q2, x1, d, ll, ul, xf1, xf2, rv;
62 if(kappa < 0.01) kappa = 0.01;
63 if(kappa > 10.) kappa = 10.;
64 if(beta2 < 0.) beta2 = 0.;
65 if(beta2 > 1.) beta2 = 1.;
67 h_[4] = 1. - beta2*0.42278433999999998 + 7.6/kappa;
70 h4 = -7.6/kappa - (beta2 * .57721566 + 1);
77 for (lp = 0; lp < 9; ++lp) {
78 if (kappa >= xp[lp])
break;
81 for (lq = 0; lq < 7; ++lq) {
82 if (kappa <= xq[lq])
break;
91 h_[0] = kappa * (beta2 * .57721566 + 2.) + 9.9166128600000008;
92 if (kappa >= .07) {h_[0] += 6.90775527;}
93 h_[1] = beta2 * kappa;
95 h_[3] = omega_ * 1.5707963250000001;
99 d =
exp(kappa * (beta2 * (.57721566 - h5) + 1.)) * .31830988654751274;
102 a_[n - 1] = omega_ * .31830988654751274;
106 for (k = 1; k <
n; ++
k) {
114 xf1 = kappa * (beta2 * c1 - c4) - x * c2;
115 xf2 = x * c1 + kappa * (c3 + beta2 * c2) + t0_ * x;
117 d1 = q * d * omega_ *
exp(xf1);
118 a_[l - 1] = d1 *
cos(xf2);
119 b_[l - 1] = -d1 *
sin(xf2);
121 d1 = q * d *
exp(xf1)/
k;
122 a_[l - 1] = d1 *
sin(xf2);
123 b_[l - 1] = d1 *
cos(xf2);
124 a_[n - 1] += q2 *
a_[l - 1];
143 double f, u,
y, a0, a1;
145 double b1, b0, b2, cof;
151 }
else if (x <=
t1_) {
153 u =
omega_ * y - 3.141592653589793;
158 for (k = 2; k <= n1; ++
k) {
161 a0 =
a_[k - 1] + cof * a1 - a2;
165 for (k = 2; k <=
n; ++
k) {
168 b0 =
b_[k - 1] + cof * b1 - b2;
170 f = (a0 - a2) * .5 + b0 *
sin(u);
174 if (
mode_ != 0) {f = 1.;}
196 namespace VVIObjDetails {
200 const double zero = 0.;
201 const double one = 1.;
202 const double two = 2.;
203 const double eight = 8.;
204 const double ce = .57721566490153;
205 const double c__[14] = { 1.9405491464836,.9413409132865,
206 -.579845034293,.3091572011159,-.0916101792208,.0164437407515,
207 -.0019713091952,1.692538851e-4,-1.09393296e-5,5.522386e-7,
208 -2.23995e-8,7.465e-10,-2.08e-11,5
e-13 };
209 const double p[23] = { .96074783975204,-.0371138962124,
210 .00194143988899,-1.7165988425e-4,2.112637753e-5,-3.27163257e-6,
211 6.0069212e-7,-1.2586794e-7,2.932563e-8,-7.45696e-9,2.04105e-9,
212 -5.9502e-10,1.8323e-10,-5.921e-11,1.997e-11,-7
e-12,2.54e-12,
213 -9.5e-13,3.7e-13,-1.4e-13,6
e-14,-2
e-14,1e-14 };
214 const double q[20] = { .98604065696238,-.0134717382083,
215 4.5329284117e-4,-3.067288652e-5,3.13199198e-6,-4.2110196e-7,
216 6.907245e-8,-1.318321e-8,2.83697e-9,-6.7329e-10,1.734e-10,
217 -4.787e-11,1.403e-11,-4.33e-12,1.4e-12,-4.7e-13,1.7e-13,-6
e-14,
226 double r__,
y, b0, b1, b2,
pp, qq, alfa;
233 if (fabs(x) <= eight) {
237 h__ = two * (d__1 * d__1) - one;
241 for (i__ = 13; i__ >= 0; --i__) {
242 b0 = c__[i__] - alfa * b1 - b2;
246 b1 = ce +
log((fabs(x))) - b0 + h__ * b2;
252 h__ = two * (d__1 * d__1) - one;
256 for (i__ = 22; i__ >= 0; --i__) {
257 b0 = p[i__] - alfa * b1 - b2;
264 for (i__ = 19; i__ >= 0; --i__) {
265 b0 = q[i__] - alfa * b1 - b2;
270 b1 = r__ * (qq *
sin(x) - r__ * pp *
cos(x));
278 const double zero = 0.;
279 const double one = 1.;
280 const double two = 2.;
281 const double eight = 8.;
282 const double pih = 1.5707963267949;
283 const double s[14] = { 1.9522209759531,-.6884042321257,
284 .4551855132256,-.1804571236838,.0410422133759,-.0059586169556,
285 6.001427414e-4,-4.44708329e-5,2.5300782e-6,-1.141308e-7,4.1858e-9,
286 -1.273e-10,3.3e-12,-1
e-13 };
287 const double p[23] = { .96074783975204,-.0371138962124,
288 .00194143988899,-1.7165988425e-4,2.112637753e-5,-3.27163257e-6,
289 6.0069212e-7,-1.2586794e-7,2.932563e-8,-7.45696e-9,2.04105e-9,
290 -5.9502e-10,1.8323e-10,-5.921e-11,1.997e-11,-7
e-12,2.54e-12,
291 -9.5e-13,3.7e-13,-1.4e-13,6
e-14,-2
e-14,1e-14 };
292 const double q[20] = { .98604065696238,-.0134717382083,
293 4.5329284117e-4,-3.067288652e-5,3.13199198e-6,-4.2110196e-7,
294 6.907245e-8,-1.318321e-8,2.83697e-9,-6.7329e-10,1.734e-10,
295 -4.787e-11,1.403e-11,-4.33e-12,1.4e-12,-4.7e-13,1.7e-13,-6
e-14,
304 double r__,
y, b0, b1, b2,
pp, qq, alfa;
306 if (fabs(x) <= eight) {
309 h__ = two * (d__1 * d__1) - one;
313 for (i__ = 13; i__ >= 0; --i__) {
314 b0 = s[i__] - alfa * b1 - b2;
323 h__ = two * (d__1 * d__1) - one;
327 for (i__ = 22; i__ >= 0; --i__) {
328 b0 = p[i__] - alfa * b1 - b2;
335 for (i__ = 19; i__ >= 0; --i__) {
336 b0 = q[i__] - alfa * b1 - b2;
342 if(x < 0.) d__1 = -d__1;
343 b1 = d__1 - r__ * (r__ * pp *
sin(x) + qq *
cos(x));
352 const double zero = 0.;
353 const double one = 1.;
354 const double two = 2.;
355 const double eight = 8.;
356 const double ce = .57721566490153;
357 const double pih = 1.5707963267949;
358 const double s__[14] = { 1.9522209759531,-.6884042321257,
359 .4551855132256,-.1804571236838,.0410422133759,-.0059586169556,
360 6.001427414e-4,-4.44708329e-5,2.5300782e-6,-1.141308e-7,4.1858e-9,
361 -1.273e-10,3.3e-12,-1
e-13 };
363 const double c__[14] = { 1.9405491464836,.9413409132865,
364 -.579845034293,.3091572011159,-.0916101792208,.0164437407515,
365 -.0019713091952,1.692538851e-4,-1.09393296e-5,5.522386e-7,
366 -2.23995e-8,7.465e-10,-2.08e-11,5
e-13 };
368 const double p[23] = { .96074783975204,-.0371138962124,
369 .00194143988899,-1.7165988425e-4,2.112637753e-5,-3.27163257e-6,
370 6.0069212e-7,-1.2586794e-7,2.932563e-8,-7.45696e-9,2.04105e-9,
371 -5.9502e-10,1.8323e-10,-5.921e-11,1.997e-11,-7
e-12,2.54e-12,
372 -9.5e-13,3.7e-13,-1.4e-13,6
e-14,-2
e-14,1e-14 };
373 const double q[20] = { .98604065696238,-.0134717382083,
374 4.5329284117e-4,-3.067288652e-5,3.13199198e-6,-4.2110196e-7,
375 6.907245e-8,-1.318321e-8,2.83697e-9,-6.7329e-10,1.734e-10,
376 -4.787e-11,1.403e-11,-4.33e-12,1.4e-12,-4.7e-13,1.7e-13,-6
e-14,
385 double r__,
y, b0, b1, b2,
pp, qq, alfa;
391 if (fabs(x) <= eight) {
395 h__ = two * (d__1 * d__1) - one;
402 for (i__ = 13; i__ >= 0; --i__) {
403 b0 = c__[i__] - alfa * b1 - b2;
407 cint = ce +
log((fabs(x))) - b0 + h__ * b2;
412 for (i__ = 13; i__ >= 0; --i__) {
413 b0 = s__[i__] - alfa * b1 - b2;
417 sint = y * (b0 - b2);
424 h__ = two * (d__1 * d__1) - one;
428 for (i__ = 22; i__ >= 0; --i__) {
429 b0 = p[i__] - alfa * b1 - b2;
436 for (i__ = 19; i__ >= 0; --i__) {
437 b0 = q[i__] - alfa * b1 - b2;
443 cint = r__ * (qq *
sin(x) - r__ * pp *
cos(x));
446 if(x < 0.) d__1 = -d__1;
447 sint = d__1 - r__ * (r__ * pp *
sin(x) + qq *
cos(x));
456 const double zero = 0.;
457 const double q2[7] = { .10340013040487,3.319092135933,
458 20.449478501379,41.280784189142,32.426421069514,10.041164382905,
460 const double p3[6] = { -2.3909964453136,-147.98219500504,
461 -254.3763397689,-119.55761038372,-19.630408535939,-.9999999999036
463 const double q3[6] = { 177.60070940351,530.68509610812,
464 462.23027156148,156.81843364539,21.630408494238,1. };
465 const double p4[8] = { -8.6693733995107,-549.14226552109,
466 -4210.0161535707,-249301.39345865,-119623.66934925,
467 -22174462.775885,3892804.213112,-391546073.8091 };
468 const double q4[8] = { 34.171875,-1607.0892658722,35730.029805851,
469 -483547.43616216,4285596.2461175,-24903337.574054,89192576.757561,
471 const double a1[8] = { -2.1808638152072,-21.901023385488,
472 9.3081638566217,25.076281129356,-33.184253199722,60.121799083008,
473 -43.253113287813,1.0044310922808 };
474 const double b1[8] = { 0.,3.9370770185272,300.89264837292,
475 -6.2504116167188,1003.6743951673,14.325673812194,2736.2411988933,
477 const double a2[8] = { -3.4833465360285,-18.65454548834,
478 -8.2856199414064,-32.34673303054,17.960168876925,1.7565631546961,
479 -1.9502232128966,.99999429607471 };
480 const double b2[8] = { 0.,69.500065588743,57.283719383732,
481 25.777638423844,760.76114800773,28.951672792514,-3.4394226689987,
483 const double a3[6] = { -27.780928934438,-10.10479081576,
484 -9.1483008216736,-5.0223317461851,-3.0000077799358,
486 const double one = 1.;
487 const double b3[6] = { 0.,122.39993926823,2.7276100778779,
488 -7.1897518395045,-2.9990118065262,1.999999942826 };
489 const double two = 2.;
490 const double three = 3.;
491 const double x0 = .37250741078137;
492 const double xl[6] = { -24.,-12.,-6.,0.,1.,4. };
493 const double p1[5] = { 4.293125234321,39.894153870321,
494 292.52518866921,425.69682638592,-434.98143832952 };
495 const double q1[5] = { 1.,18.899288395003,150.95038744251,
496 568.05252718987,753.58564359843 };
497 const double p2[7] = { .43096783946939,6.9052252278444,
498 23.019255939133,24.378408879132,9.0416155694633,.99997957705159,
502 double v,
y, ap, bp, aq,
dp, bq, dq;
506 for (
int i__ = 2; i__ <= 5; ++i__) {
508 ap = a3[i__ - 1] - x + b3[i__ - 1] / ap;
510 y =
exp(-x) / x * (one - (a3[5] + b3[5] / ap) / x);
511 }
else if (x <= xl[1]) {
513 for (
int i__ = 2; i__ <= 7; ++i__) {
514 ap = a2[i__ - 1] - x + b2[i__ - 1] / ap;
516 y =
exp(-x) / x * (a2[7] + b2[7] / ap);
517 }
else if (x <= xl[2]) {
519 for (
int i__ = 2; i__ <= 7; ++i__) {
520 ap = a1[i__ - 1] - x + b1[i__ - 1] / ap;
522 y =
exp(-x) / x * (a1[7] + b1[7] / ap);
523 }
else if (x < xl[3]) {
524 v = -two * (x / three + one);
527 for (
int i__ = 2; i__ <= 8; ++i__) {
530 dp = p4[i__ - 1] - ap + v * bp;
534 for (
int i__ = 2; i__ <= 8; ++i__) {
537 dq = q4[i__ - 1] - aq + v * bq;
539 y = -
log(-x / x0) + (x + x0) * (dp - ap) / (dq - aq);
540 }
else if (x == xl[3]) {
542 }
else if (x < xl[4]) {
545 for (
int i__ = 2; i__ <= 5; ++i__) {
546 ap = p1[i__ - 1] + x * ap;
547 aq = q1[i__ - 1] + x * aq;
549 y = -
log(x) + ap / aq;
550 }
else if (x <= xl[5]) {
554 for (
int i__ = 2; i__ <= 7; ++i__) {
555 ap = p2[i__ - 1] + y * ap;
556 aq = q2[i__ - 1] + y * aq;
558 y =
exp(-x) * ap / aq;
563 for (
int i__ = 2; i__ <= 6; ++i__) {
564 ap = p3[i__ - 1] + y * ap;
565 aq = q3[i__ - 1] + y * aq;
567 y =
exp(-x) * y * (one + y * ap / aq);
575 double& rv,
double eps,
int mxf,
F func) {
577 double d__1, d__2, d__3, d__4;
580 double f1,
f2,
f3, u1, u2, x1, x2, u3, u4, x3, ca, cb, cc,
fa,
fb, ee,
ff;
582 double xa, xb, fx, xx, su4;
597 ee = eps * (fabs(x0) + 1);
611 rv = (d__1 = xb - xa, fabs(d__1)) * -.5;
627 if (u2 == 0. || u4 == 0.) {
goto L1;}
633 cb = (x1 + x2) * u2 - (x2 + x0) * u1;
634 cc = (x1 - x0) * f1 - x1 * (ca * x1 + cb);
636 if (cb == 0.) {
goto L1;}
640 u4 = u3 * u3 - cc / ca;
641 if (u4 < 0.) {
goto L1;}
643 if (x0 + u3 < 0.
f) {su4 = -su4;}
646 if (x0 < xa || x0 > xb) {
goto L1;}
648 d__3 = (d__1 = x0 - x3, fabs(d__1)), d__4 = (d__2 = x0 - x2, fabs(d__2));
650 ee = eps * (fabs(x0) + 1);
688 rv = (d__1 = xb - xa, fabs(d__1)) * -.5;
double expint(double x)
Private version of the sine integral.
double sinint(double x)
Private version of the cosine integral.
void sincosint(double x, double &sint, double &cint)
Sin< T >::type sin(const T &t)
const int mode_
returns the limits on the non-zero (mode=0) or normalized region (mode=1)
int dzero(double a, double b, double &x0, double &rv, double eps, int mxf, F func)
double fcn(double x) const
const T & max(const T &a, const T &b)
void limits(double &xl, double &xu) const
density (mode=0) or distribution (mode=1) function
double cosint(double x)
Private version of the cosine and sine integral.
Cos< T >::type cos(const T &t)
double f1(double x, double const *h_)
Private version of the exponential integral.
Abs< T >::type abs(const T &t)
double f2(double x, double const *h_)
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
VVIObj(double kappa=0.01, double beta2=1., int mode=0)
Constructor.