tmp
/
pip-install-ghxuqwgs
/numpy_78e94bf2b6094bf9a1f3d92042f9bf46
/numpy
/linalg
/lapack_lite
/f2c_lite.c
| extern void s_wsfe(cilist *f) {;} | |
| extern void e_wsfe(void) {;} | |
| extern void do_fio(integer *c, char *s, ftnlen l) {;} | |
| /* You'll want this if you redo the *_lite.c files with the -C option | |
| * to f2c for checking array subscripts. (It's not suggested you do that | |
| * for production use, of course.) */ | |
| extern int | |
| s_rnge(char *var, int index, char *routine, int lineno) | |
| { | |
| fprintf(stderr, "array index out-of-bounds for %s[%d] in routine %s:%d\n", | |
| var, index, routine, lineno); | |
| fflush(stderr); | |
| abort(); | |
| } | |
| extern float sqrtf(); | |
| double f__cabsf(real, imag) float real, imag; | |
| double f__cabsf(float real, float imag) | |
| { | |
| float temp; | |
| if(real < 0.0f) | |
| real = -real; | |
| if(imag < 0.0f) | |
| imag = -imag; | |
| if(imag > real){ | |
| temp = real; | |
| real = imag; | |
| imag = temp; | |
| } | |
| if((imag+real) == real) | |
| return((float)real); | |
| temp = imag/real; | |
| temp = real*sqrtf(1.0 + temp*temp); /*overflow!!*/ | |
| return(temp); | |
| } | |
| extern double sqrt(); | |
| double f__cabs(real, imag) double real, imag; | |
| double f__cabs(double real, double imag) | |
| { | |
| double temp; | |
| if(real < 0) | |
| real = -real; | |
| if(imag < 0) | |
| imag = -imag; | |
| if(imag > real){ | |
| temp = real; | |
| real = imag; | |
| imag = temp; | |
| } | |
| if((imag+real) == real) | |
| return((double)real); | |
| temp = imag/real; | |
| temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/ | |
| return(temp); | |
| } | |
| VOID | |
| r_cnjg(r, z) complex *r, *z; | |
| r_cnjg(complex *r, complex *z) | |
| { | |
| r->r = z->r; | |
| r->i = - z->i; | |
| } | |
| VOID | |
| d_cnjg(r, z) doublecomplex *r, *z; | |
| d_cnjg(doublecomplex *r, doublecomplex *z) | |
| { | |
| r->r = z->r; | |
| r->i = - z->i; | |
| } | |
| float r_imag(z) complex *z; | |
| float r_imag(complex *z) | |
| { | |
| return(z->i); | |
| } | |
| double d_imag(z) doublecomplex *z; | |
| double d_imag(doublecomplex *z) | |
| { | |
| return(z->i); | |
| } | |
| float logf(); | |
| float r_lg10(x) real *x; | |
| float r_lg10(real *x) | |
| { | |
| return( log10e * logf(*x) ); | |
| } | |
| double log(); | |
| double d_lg10(x) doublereal *x; | |
| double d_lg10(doublereal *x) | |
| { | |
| return( log10e * log(*x) ); | |
| } | |
| double r_sign(a,b) real *a, *b; | |
| double r_sign(real *a, real *b) | |
| { | |
| float x; | |
| x = (*a >= 0.0f ? *a : - *a); | |
| return( *b >= 0.0f ? x : -x); | |
| } | |
| double d_sign(a,b) doublereal *a, *b; | |
| double d_sign(doublereal *a, doublereal *b) | |
| { | |
| double x; | |
| x = (*a >= 0 ? *a : - *a); | |
| return( *b >= 0 ? x : -x); | |
| } | |
| double floor(); | |
| integer i_dnnt(x) doublereal *x; | |
| integer i_dnnt(doublereal *x) | |
| { | |
| return( (*x)>=0 ? | |
| floor(*x + .5) : -floor(.5 - *x) ); | |
| } | |
| double pow(); | |
| double pow_dd(ap, bp) doublereal *ap, *bp; | |
| double pow_dd(doublereal *ap, doublereal *bp) | |
| { | |
| return(pow(*ap, *bp) ); | |
| } | |
| double pow_ri(ap, bp) real *ap; integer *bp; | |
| double pow_ri(real *ap, integer *bp) | |
| { | |
| float pow, x; | |
| integer n; | |
| unsigned long u; | |
| pow = 1; | |
| x = *ap; | |
| n = *bp; | |
| if(n != 0) | |
| { | |
| if(n < 0) | |
| { | |
| n = -n; | |
| x = 1.0f/x; | |
| } | |
| for(u = n; ; ) | |
| { | |
| if(u & 01) | |
| pow *= x; | |
| if(u >>= 1) | |
| x *= x; | |
| else | |
| break; | |
| } | |
| } | |
| return(pow); | |
| } | |
| double pow_di(ap, bp) doublereal *ap; integer *bp; | |
| double pow_di(doublereal *ap, integer *bp) | |
| { | |
| double pow, x; | |
| integer n; | |
| unsigned long u; | |
| pow = 1; | |
| x = *ap; | |
| n = *bp; | |
| if(n != 0) | |
| { | |
| if(n < 0) | |
| { | |
| n = -n; | |
| x = 1/x; | |
| } | |
| for(u = n; ; ) | |
| { | |
| if(u & 01) | |
| pow *= x; | |
| if(u >>= 1) | |
| x *= x; | |
| else | |
| break; | |
| } | |
| } | |
| return(pow); | |
| } | |
| /* Unless compiled with -DNO_OVERWRITE, this variant of s_cat allows the | |
| * target of a concatenation to appear on its right-hand side (contrary | |
| * to the Fortran 77 Standard, but in accordance with Fortran 90). | |
| */ | |
| extern char *F77_aloc(); | |
| extern void free(); | |
| extern void exit_(); | |
| extern char *F77_aloc(ftnlen, char*); | |
| VOID | |
| s_cat(lp, rpp, rnp, np, ll) char *lp, *rpp[]; ftnlen rnp[], *np, ll; | |
| s_cat(char *lp, char *rpp[], ftnlen rnp[], ftnlen *np, ftnlen ll) | |
| { | |
| ftnlen i, nc; | |
| char *rp; | |
| ftnlen n = *np; | |
| ftnlen L, m; | |
| char *lp0, *lp1; | |
| lp0 = 0; | |
| lp1 = lp; | |
| L = ll; | |
| i = 0; | |
| while(i < n) { | |
| rp = rpp[i]; | |
| m = rnp[i++]; | |
| if (rp >= lp1 || rp + m <= lp) { | |
| if ((L -= m) <= 0) { | |
| n = i; | |
| break; | |
| } | |
| lp1 += m; | |
| continue; | |
| } | |
| lp0 = lp; | |
| lp = lp1 = F77_aloc(L = ll, "s_cat"); | |
| break; | |
| } | |
| lp1 = lp; | |
| for(i = 0 ; i < n ; ++i) { | |
| nc = ll; | |
| if(rnp[i] < nc) | |
| nc = rnp[i]; | |
| ll -= nc; | |
| rp = rpp[i]; | |
| while(--nc >= 0) | |
| *lp++ = *rp++; | |
| } | |
| while(--ll >= 0) | |
| *lp++ = ' '; | |
| if (lp0) { | |
| memmove(lp0, lp1, L); | |
| free(lp1); | |
| } | |
| } | |
| /* compare two strings */ | |
| integer s_cmp(a0, b0, la, lb) char *a0, *b0; ftnlen la, lb; | |
| integer s_cmp(char *a0, char *b0, ftnlen la, ftnlen lb) | |
| { | |
| register unsigned char *a, *aend, *b, *bend; | |
| a = (unsigned char *)a0; | |
| b = (unsigned char *)b0; | |
| aend = a + la; | |
| bend = b + lb; | |
| if(la <= lb) | |
| { | |
| while(a < aend) | |
| if(*a != *b) | |
| return( *a - *b ); | |
| else | |
| { ++a; ++b; } | |
| while(b < bend) | |
| if(*b != ' ') | |
| return( ' ' - *b ); | |
| else ++b; | |
| } | |
| else | |
| { | |
| while(b < bend) | |
| if(*a == *b) | |
| { ++a; ++b; } | |
| else | |
| return( *a - *b ); | |
| while(a < aend) | |
| if(*a != ' ') | |
| return(*a - ' '); | |
| else ++a; | |
| } | |
| return(0); | |
| } | |
| /* Unless compiled with -DNO_OVERWRITE, this variant of s_copy allows the | |
| * target of an assignment to appear on its right-hand side (contrary | |
| * to the Fortran 77 Standard, but in accordance with Fortran 90), | |
| * as in a(2:5) = a(4:7) . | |
| */ | |
| /* assign strings: a = b */ | |
| VOID s_copy(a, b, la, lb) register char *a, *b; ftnlen la, lb; | |
| void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb) | |
| { | |
| register char *aend, *bend; | |
| aend = a + la; | |
| if(la <= lb) | |
| if (a <= b || a >= b + la) | |
| while(a < aend) | |
| *a++ = *b++; | |
| else | |
| for(b += la; a < aend; ) | |
| *--aend = *--b; | |
| else { | |
| bend = b + lb; | |
| if (a <= b || a >= bend) | |
| while(b < bend) | |
| *a++ = *b++; | |
| else { | |
| a += lb; | |
| while(b < bend) | |
| *--a = *--bend; | |
| a += lb; | |
| } | |
| while(a < aend) | |
| *a++ = ' '; | |
| } | |
| } | |
| double f__cabsf(); | |
| double c_abs(z) complex *z; | |
| double f__cabsf(float, float); | |
| double c_abs(complex *z) | |
| { | |
| return( f__cabsf( z->r, z->i ) ); | |
| } | |
| double f__cabs(); | |
| double z_abs(z) doublecomplex *z; | |
| double f__cabs(double, double); | |
| double z_abs(doublecomplex *z) | |
| { | |
| return( f__cabs( z->r, z->i ) ); | |
| } | |
| extern void sig_die(); | |
| VOID c_div(c, a, b) complex *a, *b, *c; | |
| extern void sig_die(char*, int); | |
| void c_div(complex *c, complex *a, complex *b) | |
| { | |
| float ratio, den; | |
| float abr, abi; | |
| if( (abr = b->r) < 0.f) | |
| abr = - abr; | |
| if( (abi = b->i) < 0.f) | |
| abi = - abi; | |
| if( abr <= abi ) | |
| { | |
| /*Let IEEE Infinties handle this ;( */ | |
| /*if(abi == 0) | |
| sig_die("complex division by zero", 1);*/ | |
| ratio = b->r / b->i ; | |
| den = b->i * (1 + ratio*ratio); | |
| c->r = (a->r*ratio + a->i) / den; | |
| c->i = (a->i*ratio - a->r) / den; | |
| } | |
| else | |
| { | |
| ratio = b->i / b->r ; | |
| den = b->r * (1.f + ratio*ratio); | |
| c->r = (a->r + a->i*ratio) / den; | |
| c->i = (a->i - a->r*ratio) / den; | |
| } | |
| } | |
| extern void sig_die(); | |
| VOID z_div(c, a, b) doublecomplex *a, *b, *c; | |
| extern void sig_die(char*, int); | |
| void z_div(doublecomplex *c, doublecomplex *a, doublecomplex *b) | |
| { | |
| double ratio, den; | |
| double abr, abi; | |
| if( (abr = b->r) < 0.) | |
| abr = - abr; | |
| if( (abi = b->i) < 0.) | |
| abi = - abi; | |
| if( abr <= abi ) | |
| { | |
| /*Let IEEE Infinties handle this ;( */ | |
| /*if(abi == 0) | |
| sig_die("complex division by zero", 1);*/ | |
| ratio = b->r / b->i ; | |
| den = b->i * (1 + ratio*ratio); | |
| c->r = (a->r*ratio + a->i) / den; | |
| c->i = (a->i*ratio - a->r) / den; | |
| } | |
| else | |
| { | |
| ratio = b->i / b->r ; | |
| den = b->r * (1 + ratio*ratio); | |
| c->r = (a->r + a->i*ratio) / den; | |
| c->i = (a->i - a->r*ratio) / den; | |
| } | |
| } | |
| float sqrtf(), f__cabsf(); | |
| VOID c_sqrt(r, z) complex *r, *z; | |
| extern double f__cabsf(float, float); | |
| void c_sqrt(complex *r, complex *z) | |
| { | |
| float mag; | |
| if( (mag = f__cabsf(z->r, z->i)) == 0.f) | |
| r->r = r->i = 0.f; | |
| else if(z->r > 0.0f) | |
| { | |
| r->r = sqrtf(0.5f * (mag + z->r) ); | |
| r->i = z->i / r->r / 2.0f; | |
| } | |
| else | |
| { | |
| r->i = sqrtf(0.5f * (mag - z->r) ); | |
| if(z->i < 0.0f) | |
| r->i = - r->i; | |
| r->r = z->i / r->i / 2.0f; | |
| } | |
| } | |
| double sqrt(), f__cabs(); | |
| VOID z_sqrt(r, z) doublecomplex *r, *z; | |
| extern double f__cabs(double, double); | |
| void z_sqrt(doublecomplex *r, doublecomplex *z) | |
| { | |
| double mag; | |
| if( (mag = f__cabs(z->r, z->i)) == 0.) | |
| r->r = r->i = 0.; | |
| else if(z->r > 0) | |
| { | |
| r->r = sqrt(0.5 * (mag + z->r) ); | |
| r->i = z->i / r->r / 2; | |
| } | |
| else | |
| { | |
| r->i = sqrt(0.5 * (mag - z->r) ); | |
| if(z->i < 0) | |
| r->i = - r->i; | |
| r->r = z->i / r->i / 2; | |
| } | |
| } | |
| extern "C" { | |
| integer pow_ii(ap, bp) integer *ap, *bp; | |
| integer pow_ii(integer *ap, integer *bp) | |
| { | |
| integer pow, x, n; | |
| unsigned long u; | |
| x = *ap; | |
| n = *bp; | |
| if (n <= 0) { | |
| if (n == 0 || x == 1) | |
| return 1; | |
| if (x != -1) | |
| return x == 0 ? 1/x : 0; | |
| n = -n; | |
| } | |
| u = n; | |
| for(pow = 1; ; ) | |
| { | |
| if(u & 01) | |
| pow *= x; | |
| if(u >>= 1) | |
| x *= x; | |
| else | |
| break; | |
| } | |
| return(pow); | |
| } | |
| } | |
| extern void f_exit(); | |
| VOID s_stop(s, n) char *s; ftnlen n; | |
| extern "C" { | |
| extern "C" { | |
| void f_exit(void); | |
| int s_stop(char *s, ftnlen n) | |
| { | |
| int i; | |
| if(n > 0) | |
| { | |
| fprintf(stderr, "STOP "); | |
| for(i = 0; i<n ; ++i) | |
| putc(*s++, stderr); | |
| fprintf(stderr, " statement executed\n"); | |
| } | |
| f_exit(); | |
| exit(0); | |
| /* We cannot avoid (useless) compiler diagnostics here: */ | |
| /* some compilers complain if there is no return statement, */ | |
| /* and others complain that this one cannot be reached. */ | |
| return 0; /* NOT REACHED */ | |
| } | |
| } | |
| } | |