123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- #include "slatec-internal.hpp"
- static integer const c__15 = 15;
- static integer const c__5 = 5;
- static integer const c__1 = 1;
- static integer const c__2 = 2;
- static integer const c__6 = 6;
- int dbesy_(double const *x, double const *fnu, integer const *n, double *y)
- {
-
- static integer nulim[2] = { 70,100 };
-
- integer i__1;
-
- integer i__, j;
- double s, w[2], s1, s2 = 0.;
- integer nb;
- double cn;
- integer nd;
- double fn;
- integer nn;
- double tm = 0., wk[7], w2n, ran;
- integer nud;
- double dnu, azn, trx = 0., xxn, elim;
- integer iflw;
- double xlim, flgjy;
-
- --y;
-
- nn = -i1mach_(15);
- elim = (nn * d1mach_(5) - 3.) * 2.303;
- xlim = d1mach_(1) * 1e3;
- if (*fnu < 0.) {
- goto L140;
- }
- if (*x <= 0.) {
- goto L150;
- }
- if (*x < xlim) {
- goto L170;
- }
- if (*n < 1) {
- goto L160;
- }
- nd = *n;
- nud = (integer) (*fnu);
- dnu = *fnu - nud;
- nn = min(2,nd);
- fn = *fnu + *n - 1;
- if (fn < 2.) {
- goto L100;
- }
- xxn = *x / fn;
- w2n = 1. - xxn * xxn;
- if (w2n <= 0.) {
- goto L10;
- }
- ran = sqrt(w2n);
- azn = log((ran + 1.) / xxn) - ran;
- cn = fn * azn;
- if (cn > elim) {
- goto L170;
- }
- L10:
- if (nud < nulim[nn - 1]) {
- goto L20;
- }
- flgjy = -1.;
- dasyjy_(dyairy_, x, fnu, &flgjy, &nn, &y[1], wk, &iflw);
- if (iflw != 0) {
- goto L170;
- }
- if (nn == 1) {
- return 0;
- }
- trx = 2. / *x;
- tm = (*fnu + *fnu + 2.) / *x;
- goto L80;
- L20:
- if (dnu != 0.) {
- goto L30;
- }
- s1 = dbesy0_(x);
- if (nud == 0 && nd == 1) {
- goto L70;
- }
- s2 = dbesy1_(x);
- goto L40;
- L30:
- nb = 2;
- if (nud == 0 && nd == 1) {
- nb = 1;
- }
- dbsynu_(x, &dnu, &nb, w);
- s1 = w[0];
- if (nb == 1) {
- goto L70;
- }
- s2 = w[1];
- L40:
- trx = 2. / *x;
- tm = (dnu + dnu + 2.) / *x;
- if (nd == 1) {
- --nud;
- }
- if (nud > 0) {
- goto L50;
- }
- if (nd > 1) {
- goto L70;
- }
- s1 = s2;
- goto L70;
- L50:
- i__1 = nud;
- for (i__ = 1; i__ <= i__1; ++i__) {
- s = s2;
- s2 = tm * s2 - s1;
- s1 = s;
- tm += trx;
- }
- if (nd == 1) {
- s1 = s2;
- }
- L70:
- y[1] = s1;
- if (nd == 1) {
- return 0;
- }
- y[2] = s2;
- L80:
- if (nd == 2) {
- return 0;
- }
- i__1 = nd;
- for (i__ = 3; i__ <= i__1; ++i__) {
- y[i__] = tm * y[i__ - 1] - y[i__ - 2];
- tm += trx;
- }
- return 0;
- L100:
- if (fn <= 1.) {
- goto L110;
- }
- if (-fn * (log(*x) - .693) > elim) {
- goto L170;
- }
- L110:
- if (dnu == 0.) {
- goto L120;
- }
- dbsynu_(x, fnu, &nd, &y[1]);
- return 0;
- L120:
- j = nud;
- if (j == 1) {
- goto L130;
- }
- ++j;
- y[j] = dbesy0_(x);
- if (nd == 1) {
- return 0;
- }
- ++j;
- L130:
- y[j] = dbesy1_(x);
- if (nd == 1) {
- return 0;
- }
- trx = 2. / *x;
- tm = trx;
- goto L80;
- L140:
- xermsg_("SLATEC", "DBESY", "ORDER, FNU, LESS THAN ZERO", &c__2, &c__1, (
- ftnlen)6, (ftnlen)5, (ftnlen)26);
- return 0;
- L150:
- xermsg_("SLATEC", "DBESY", "X LESS THAN OR EQUAL TO ZERO", &c__2, &c__1, (
- ftnlen)6, (ftnlen)5, (ftnlen)28);
- return 0;
- L160:
- xermsg_("SLATEC", "DBESY", "N LESS THAN ONE", &c__2, &c__1, (ftnlen)6, (
- ftnlen)5, (ftnlen)15);
- return 0;
- L170:
- xermsg_("SLATEC", "DBESY", "OVERFLOW, FNU OR N TOO LARGE OR X TOO SMALL",
- &c__6, &c__1, (ftnlen)6, (ftnlen)5, (ftnlen)43);
- return 0;
- }
|