28 #if defined(USE_DDOUBLE)
29 # define doublereal dd_real
44 typedef long long longint;
45 typedef unsigned long long ulongint;
46 #define qbit_clear(a,b) ((a) & ~((ulongint)1 << (b)))
47 #define qbit_set(a,b) ((a) | ((ulongint)1 << (b)))
186 #define abs(x) ((x) >= 0 ? (x) : -(x))
187 #define dabs(x) (doublereal)abs(x)
188 #define min(a,b) ((a) <= (b) ? (a) : (b))
189 #define max(a,b) ((a) >= (b) ? (a) : (b))
190 #define dmin(a,b) (doublereal)min(a,b)
191 #define dmax(a,b) (doublereal)max(a,b)
192 #define bit_test(a,b) ((a) >> (b) & 1)
193 #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
194 #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
198 #define F2C_proc_par_types 1
200 typedef int (*U_fp)(...);
210 typedef int (*
S_fp)(...);
212 typedef int (*U_fp)();
232 #ifndef Skip_f2c_Undefs
253 double cmvbvu_(
const double *sh,
const double *sk,
267 double cumbvn(
const double&
x,
const double& y,
const double& rho)
289 double cumbvn(
const double& xl,
const double& yl,
290 const double& xu,
const double& yu,
const double& rho)
294 double my=
cumbvn(xl,yl,rho);
307 double cmvbvu_(
const double *sh,
const double *sk,
const double *r__)
319 } equiv_21 = { {.1713244923791705, .3607615730481384,
320 .4679139345726904}, {0, 0, 0, 0, 0, 0, 0},
321 {.04717533638651177, .1069393259953183,
322 .1600783285433464, .2031674267230659, .2334925365383547,
323 .2491470458134029}, {0, 0, 0, 0}, {.01761400713915212,
324 .04060142980038694, .06267204833410906, .08327674157670475,
325 .1019301198172404, .1181945319615184, .1316886384491766,
326 .1420961093183821, .1491729864726037, .1527533871307259}};
328 #define w ((doublereal *)&equiv_21)
336 } equiv_22 = { {-.9324695142031522, -.6612093864662647,
337 -.238619186083197}, {0, 0, 0, 0, 0, 0, 0}, {-.9815606342467191,
339 -.769902674194305, -.5873179542866171, -.3678314989981802,
340 -.1252334085114692}, {0, 0, 0, 0}, {-.9931285991850949,
341 -.9639719272779138, -.9122344282513259, -.8391169718222188,
342 -.7463319064601508, -.636053680726515, -.5108670019508271,
343 -.3737060887154196, -.2277858511416451, -.07652652113349733}};
345 #define x ((doublereal *)&equiv_22)
350 double ret_val, d__1, d__2,d__3,d__4;
357 static double a, b, c__, d__, h__;
361 extern double cmvphi_(
double *);
366 static double bs,rs,xs;
367 static double hs, hk, sn, asr, bvn;
395 if (
abs(*r__) < (
float).3) {
398 }
else if (
abs(*r__) < (
float).75) {
409 if (
abs(*r__) < (
float).925) {
410 hs = (h__ * h__ + k * k) / 2;
413 for (i__ = 1; i__ <= i__1; ++i__) {
414 sn =
sin(asr * (
x[i__ + ng * 10 - 11] + 1) / 2);
415 bvn +=
w[i__ + ng * 10 - 11] *
exp((sn * hk - hs) / (1 - sn * sn));
416 sn =
sin(asr * (-
x[i__ + ng * 10 - 11] + 1) / 2);
417 bvn +=
w[i__ + ng * 10 - 11] *
exp((sn * hk - hs) / (1 - sn * sn));
421 bvn = bvn * asr / 12.566370614359172 +
cmvphi_(&d__1) *
cmvphi_(&d__2);
427 if (
abs(*r__) < 1.) {
428 as = (1 - *r__) * (*r__ + 1);
434 d__ = (12 - hk) / 16;
435 bvn = a *
exp(-(bs / as + hk) / 2) * (1 - c__ * (bs - as) * (1 -
436 d__ * bs / 5) / 3 + c__ * d__ * as * as / 5);
441 * b * (1 - c__ * bs * (1 - d__ * bs / 5) / 3);
445 for (i__ = 1; i__ <= i__1; ++i__) {
447 d__1 = a * (
x[i__ + ng * 10 - 11] + 1);
450 bvn += a *
w[i__ + ng * 10 - 11] * (
exp(-bs / (xs * 2) - hk /
451 (rs + 1)) / rs -
exp(-(bs / xs + hk) / 2) * (c__ * xs
452 * (d__ * xs + 1) + 1));
454 d__1 = -
x[i__ + ng * 10 - 11] + 1;
455 xs = as * (d__1 * d__1) / 4;
457 bvn += a *
w[i__ + ng * 10 - 11] *
exp(-(bs / xs + hk) / 2) *
458 (
exp(-hk * (1 - rs) / ((rs + 1) * 2)) / rs - (c__ *
459 xs * (d__ * xs + 1) + 1));
461 bvn = -bvn / 6.283185307179586;
472 bvn = -bvn +
max(d__1,d__2);
492 #if !defined(USE_DDOUBLE)
522 expntl =
exp(-(d__1 * d__1) / 2);
526 if (zabs < 7.071067811865475) {
527 p = expntl * ((((((zabs * .03526249659989109 + .7003830644436881)
528 * zabs + 6.37396220353165) * zabs + 33.912866078383) *
529 zabs + 112.0792914978709) * zabs + 221.2135961699311) *
530 zabs + 220.2068679123761) / (((((((zabs *
531 .08838834764831844 + 1.755667163182642) * zabs +
532 16.06417757920695) * zabs + 86.78073220294608) * zabs +
533 296.5642487796737) * zabs + 637.3336333788311) * zabs +
534 793.8265125199484) * zabs + 440.4137358247522);
539 p = expntl / (zabs + 1 / (zabs + 2 / (zabs + 3 / (zabs + 4 / (
540 zabs + .65))))) / 2.506628274631001;
double cmvbvu_(const double *sh, const double *sk, const double *r__)
d3_array sin(const d3_array &arr3)
Returns d3_array results with computed sin from elements in arr3.
unsigned long int uinteger
d3_array sqrt(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
void RETURN_ARRAYS_INCREMENT()
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
d3_array exp(const d3_array &arr3)
Returns d3_array results with computed exp from elements in arr3.
static _THREAD gradient_structure * _instance
double cumbvn(const double &x, const double &y, const double &rho)
Cumulative bivariate normal distribution.
void RETURN_ARRAYS_DECREMENT()
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
double cmvphi_(double *z__)
dvector asin(const dvector &vec)
Returns dvector with principal value of the arc sine of vec, expressed in radians.