1- /* f2c.h -- Standard Fortran to C header file */
2-
3- /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
4-
5- - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
6-
7- #ifndef F2C_INCLUDE
8- #define F2C_INCLUDE
9-
101#include <math.h>
112#include <stdlib.h>
123#include <string.h>
1910#undef I
2011#endif
2112
22- typedef int integer ;
13+ #if defined(_WIN64 )
14+ typedef long long BLASLONG ;
15+ typedef unsigned long long BLASULONG ;
16+ #else
17+ typedef long BLASLONG ;
18+ typedef unsigned long BLASULONG ;
19+ #endif
20+
21+ #ifdef LAPACK_ILP64
22+ typedef BLASLONG blasint ;
23+ #if defined(_WIN64 )
24+ #define blasabs (x ) llabs(x)
25+ #else
26+ #define blasabs (x ) labs(x)
27+ #endif
28+ #else
29+ typedef int blasint ;
30+ #define blasabs (x ) abs(x)
31+ #endif
32+
33+ typedef blasint integer ;
34+
2335typedef unsigned int uinteger ;
2436typedef char * address ;
2537typedef short int shortint ;
2638typedef float real ;
2739typedef double doublereal ;
2840typedef struct { real r , i ; } complex ;
2941typedef struct { doublereal r , i ; } doublecomplex ;
42+ #ifdef _MSC_VER
43+ static inline _Fcomplex Cf (complex * z ) {_Fcomplex zz = {z -> r , z -> i }; return zz ;}
44+ static inline _Dcomplex Cd (doublecomplex * z ) {_Dcomplex zz = {z -> r , z -> i };return zz ;}
45+ static inline _Fcomplex * _pCf (complex * z ) {return (_Fcomplex * )z ;}
46+ static inline _Dcomplex * _pCd (doublecomplex * z ) {return (_Dcomplex * )z ;}
47+ #else
3048static inline _Complex float Cf (complex * z ) {return z -> r + z -> i * _Complex_I ;}
3149static inline _Complex double Cd (doublecomplex * z ) {return z -> r + z -> i * _Complex_I ;}
3250static inline _Complex float * _pCf (complex * z ) {return (_Complex float * )z ;}
3351static inline _Complex double * _pCd (doublecomplex * z ) {return (_Complex double * )z ;}
52+ #endif
3453#define pCf (z ) (*_pCf(z))
3554#define pCd (z ) (*_pCd(z))
3655typedef int logical ;
@@ -170,8 +189,13 @@ typedef struct Namelist Namelist;
170189#define abort_ () { sig_die("Fortran abort routine called", 1); }
171190#define c_abs (z ) (cabsf(Cf(z)))
172191#define c_cos (R ,Z ) { pCf(R)=ccos(Cf(Z)); }
192+ #ifdef _MSC_VER
193+ #define c_div (c , a , b ) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
194+ #define z_div (c , a , b ) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
195+ #else
173196#define c_div (c , a , b ) {pCf(c) = Cf(a)/Cf(b);}
174197#define z_div (c , a , b ) {pCd(c) = Cd(a)/Cd(b);}
198+ #endif
175199#define c_exp (R , Z ) {pCf(R) = cexpf(Cf(Z));}
176200#define c_log (R , Z ) {pCf(R) = clogf(Cf(Z));}
177201#define c_sin (R , Z ) {pCf(R) = csinf(Cf(Z));}
@@ -183,13 +207,13 @@ typedef struct Namelist Namelist;
183207#define d_atan (x ) (atan(*(x)))
184208#define d_atn2 (x , y ) (atan2(*(x),*(y)))
185209#define d_cnjg (R , Z ) { pCd(R) = conj(Cd(Z)); }
186- #define r_cnjg (R , Z ) { pCf(R) = conj (Cf(Z)); }
210+ #define r_cnjg (R , Z ) { pCf(R) = conjf (Cf(Z)); }
187211#define d_cos (x ) (cos(*(x)))
188212#define d_cosh (x ) (cosh(*(x)))
189213#define d_dim (__a , __b ) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
190214#define d_exp (x ) (exp(*(x)))
191215#define d_imag (z ) (cimag(Cd(z)))
192- #define r_imag (z ) (cimag (Cf(z)))
216+ #define r_imag (z ) (cimagf (Cf(z)))
193217#define d_int (__x ) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
194218#define r_int (__x ) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
195219#define d_lg10 (x ) ( 0.43429448190325182765 * log(*(x)) )
@@ -228,11 +252,11 @@ static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
228252#define z_exp (R , Z ) {pCd(R) = cexp(Cd(Z));}
229253#define z_sqrt (R , Z ) {pCd(R) = csqrt(Cd(Z));}
230254#define myexit_ () break;
231- #define mycycle_ () continue;
232- #define myceiling_ (w ) ceil(w)
233- #define myhuge_ (w ) HUGE_VAL
255+ #define mycycle () continue;
256+ #define myceiling (w ) { ceil(w)}
257+ #define myhuge (w ) { HUGE_VAL}
234258//#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
235- #define mymaxloc_ (w ,s ,e ,n ) dmaxloc_(w,*(s),*(e),n)
259+ #define mymaxloc (w ,s ,e ,n ) { dmaxloc_(w,*(s),*(e),n)}
236260
237261/* procedure parameter types for -A and -C++ */
238262
@@ -267,6 +291,21 @@ static double dpow_ui(double x, integer n) {
267291 }
268292 return pow ;
269293}
294+ #ifdef _MSC_VER
295+ static _Fcomplex cpow_ui (complex x , integer n ) {
296+ complex pow = {1.0 ,0.0 }; unsigned long int u ;
297+ if (n != 0 ) {
298+ if (n < 0 ) n = - n , x .r = 1 /x .r , x .i = 1 /x .i ;
299+ for (u = n ; ; ) {
300+ if (u & 01 ) pow .r *= x .r , pow .i *= x .i ;
301+ if (u >>= 1 ) x .r *= x .r , x .i *= x .i ;
302+ else break ;
303+ }
304+ }
305+ _Fcomplex p = {pow .r , pow .i };
306+ return p ;
307+ }
308+ #else
270309static _Complex float cpow_ui (_Complex float x , integer n ) {
271310 _Complex float pow = 1.0 ; unsigned long int u ;
272311 if (n != 0 ) {
@@ -279,6 +318,22 @@ static _Complex float cpow_ui(_Complex float x, integer n) {
279318 }
280319 return pow ;
281320}
321+ #endif
322+ #ifdef _MSC_VER
323+ static _Dcomplex zpow_ui (_Dcomplex x , integer n ) {
324+ _Dcomplex pow = {1.0 ,0.0 }; unsigned long int u ;
325+ if (n != 0 ) {
326+ if (n < 0 ) n = - n , x ._Val [0 ] = 1 /x ._Val [0 ], x ._Val [1 ] = 1 /x ._Val [1 ];
327+ for (u = n ; ; ) {
328+ if (u & 01 ) pow ._Val [0 ] *= x ._Val [0 ], pow ._Val [1 ] *= x ._Val [1 ];
329+ if (u >>= 1 ) x ._Val [0 ] *= x ._Val [0 ], x ._Val [1 ] *= x ._Val [1 ];
330+ else break ;
331+ }
332+ }
333+ _Dcomplex p = {pow ._Val [0 ], pow ._Val [1 ]};
334+ return p ;
335+ }
336+ #else
282337static _Complex double zpow_ui (_Complex double x , integer n ) {
283338 _Complex double pow = 1.0 ; unsigned long int u ;
284339 if (n != 0 ) {
@@ -291,6 +346,7 @@ static _Complex double zpow_ui(_Complex double x, integer n) {
291346 }
292347 return pow ;
293348}
349+ #endif
294350static integer pow_ii (integer x , integer n ) {
295351 integer pow ; unsigned long int u ;
296352 if (n <= 0 ) {
@@ -324,6 +380,22 @@ static integer smaxloc_(float *w, integer s, integer e, integer *n)
324380}
325381static inline void cdotc_ (complex * z , integer * n_ , complex * x , integer * incx_ , complex * y , integer * incy_ ) {
326382 integer n = * n_ , incx = * incx_ , incy = * incy_ , i ;
383+ #ifdef _MSC_VER
384+ _Fcomplex zdotc = {0.0 , 0.0 };
385+ if (incx == 1 && incy == 1 ) {
386+ for (i = 0 ;i < n ;i ++ ) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
387+ zdotc ._Val [0 ] += conjf (Cf (& x [i ]))._Val [0 ] * Cf (& y [i ])._Val [0 ];
388+ zdotc ._Val [1 ] += conjf (Cf (& x [i ]))._Val [1 ] * Cf (& y [i ])._Val [1 ];
389+ }
390+ } else {
391+ for (i = 0 ;i < n ;i ++ ) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
392+ zdotc ._Val [0 ] += conjf (Cf (& x [i * incx ]))._Val [0 ] * Cf (& y [i * incy ])._Val [0 ];
393+ zdotc ._Val [1 ] += conjf (Cf (& x [i * incx ]))._Val [1 ] * Cf (& y [i * incy ])._Val [1 ];
394+ }
395+ }
396+ pCf (z ) = zdotc ;
397+ }
398+ #else
327399 _Complex float zdotc = 0.0 ;
328400 if (incx == 1 && incy == 1 ) {
329401 for (i = 0 ;i < n ;i ++ ) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
@@ -336,8 +408,25 @@ static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, c
336408 }
337409 pCf (z ) = zdotc ;
338410}
411+ #endif
339412static inline void zdotc_ (doublecomplex * z , integer * n_ , doublecomplex * x , integer * incx_ , doublecomplex * y , integer * incy_ ) {
340413 integer n = * n_ , incx = * incx_ , incy = * incy_ , i ;
414+ #ifdef _MSC_VER
415+ _Dcomplex zdotc = {0.0 , 0.0 };
416+ if (incx == 1 && incy == 1 ) {
417+ for (i = 0 ;i < n ;i ++ ) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
418+ zdotc ._Val [0 ] += conj (Cd (& x [i ]))._Val [0 ] * Cd (& y [i ])._Val [0 ];
419+ zdotc ._Val [1 ] += conj (Cd (& x [i ]))._Val [1 ] * Cd (& y [i ])._Val [1 ];
420+ }
421+ } else {
422+ for (i = 0 ;i < n ;i ++ ) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
423+ zdotc ._Val [0 ] += conj (Cd (& x [i * incx ]))._Val [0 ] * Cd (& y [i * incy ])._Val [0 ];
424+ zdotc ._Val [1 ] += conj (Cd (& x [i * incx ]))._Val [1 ] * Cd (& y [i * incy ])._Val [1 ];
425+ }
426+ }
427+ pCd (z ) = zdotc ;
428+ }
429+ #else
341430 _Complex double zdotc = 0.0 ;
342431 if (incx == 1 && incy == 1 ) {
343432 for (i = 0 ;i < n ;i ++ ) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
@@ -349,9 +438,26 @@ static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integ
349438 }
350439 }
351440 pCd (z ) = zdotc ;
352- }
441+ }
442+ #endif
353443static inline void cdotu_ (complex * z , integer * n_ , complex * x , integer * incx_ , complex * y , integer * incy_ ) {
354444 integer n = * n_ , incx = * incx_ , incy = * incy_ , i ;
445+ #ifdef _MSC_VER
446+ _Fcomplex zdotc = {0.0 , 0.0 };
447+ if (incx == 1 && incy == 1 ) {
448+ for (i = 0 ;i < n ;i ++ ) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
449+ zdotc ._Val [0 ] += Cf (& x [i ])._Val [0 ] * Cf (& y [i ])._Val [0 ];
450+ zdotc ._Val [1 ] += Cf (& x [i ])._Val [1 ] * Cf (& y [i ])._Val [1 ];
451+ }
452+ } else {
453+ for (i = 0 ;i < n ;i ++ ) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
454+ zdotc ._Val [0 ] += Cf (& x [i * incx ])._Val [0 ] * Cf (& y [i * incy ])._Val [0 ];
455+ zdotc ._Val [1 ] += Cf (& x [i * incx ])._Val [1 ] * Cf (& y [i * incy ])._Val [1 ];
456+ }
457+ }
458+ pCf (z ) = zdotc ;
459+ }
460+ #else
355461 _Complex float zdotc = 0.0 ;
356462 if (incx == 1 && incy == 1 ) {
357463 for (i = 0 ;i < n ;i ++ ) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
@@ -364,8 +470,25 @@ static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, c
364470 }
365471 pCf (z ) = zdotc ;
366472}
473+ #endif
367474static inline void zdotu_ (doublecomplex * z , integer * n_ , doublecomplex * x , integer * incx_ , doublecomplex * y , integer * incy_ ) {
368475 integer n = * n_ , incx = * incx_ , incy = * incy_ , i ;
476+ #ifdef _MSC_VER
477+ _Dcomplex zdotc = {0.0 , 0.0 };
478+ if (incx == 1 && incy == 1 ) {
479+ for (i = 0 ;i < n ;i ++ ) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
480+ zdotc ._Val [0 ] += Cd (& x [i ])._Val [0 ] * Cd (& y [i ])._Val [0 ];
481+ zdotc ._Val [1 ] += Cd (& x [i ])._Val [1 ] * Cd (& y [i ])._Val [1 ];
482+ }
483+ } else {
484+ for (i = 0 ;i < n ;i ++ ) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
485+ zdotc ._Val [0 ] += Cd (& x [i * incx ])._Val [0 ] * Cd (& y [i * incy ])._Val [0 ];
486+ zdotc ._Val [1 ] += Cd (& x [i * incx ])._Val [1 ] * Cd (& y [i * incy ])._Val [1 ];
487+ }
488+ }
489+ pCd (z ) = zdotc ;
490+ }
491+ #else
369492 _Complex double zdotc = 0.0 ;
370493 if (incx == 1 && incy == 1 ) {
371494 for (i = 0 ;i < n ;i ++ ) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
@@ -386,6 +509,7 @@ static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integ
386509
387510
388511
512+
389513/* Table of constant values */
390514
391515static integer c__1 = 1 ;
0 commit comments