| @@ -0,0 +1,717 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matr | |||
| ix-vector products. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLACN2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlacn2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlacn2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlacn2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLACN2( N, V, X, EST, KASE, ISAVE ) */ | |||
| /* INTEGER KASE, N */ | |||
| /* DOUBLE PRECISION EST */ | |||
| /* INTEGER ISAVE( 3 ) */ | |||
| /* COMPLEX*16 V( * ), X( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLACN2 estimates the 1-norm of a square, complex matrix A. */ | |||
| /* > Reverse communication is used for evaluating matrix-vector products. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix. N >= 1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX*16 array, dimension (N) */ | |||
| /* > On the final return, V = A*W, where EST = norm(V)/norm(W) */ | |||
| /* > (W is not returned). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension (N) */ | |||
| /* > On an intermediate return, X should be overwritten by */ | |||
| /* > A * X, if KASE=1, */ | |||
| /* > A**H * X, if KASE=2, */ | |||
| /* > where A**H is the conjugate transpose of A, and ZLACN2 must be */ | |||
| /* > re-called with all the other parameters unchanged. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] EST */ | |||
| /* > \verbatim */ | |||
| /* > EST is DOUBLE PRECISION */ | |||
| /* > On entry with KASE = 1 or 2 and ISAVE(1) = 3, EST should be */ | |||
| /* > unchanged from the previous call to ZLACN2. */ | |||
| /* > On exit, EST is an estimate (a lower bound) for norm(A). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] KASE */ | |||
| /* > \verbatim */ | |||
| /* > KASE is INTEGER */ | |||
| /* > On the initial call to ZLACN2, KASE should be 0. */ | |||
| /* > On an intermediate return, KASE will be 1 or 2, indicating */ | |||
| /* > whether X should be overwritten by A * X or A**H * X. */ | |||
| /* > On the final return from ZLACN2, KASE will again be 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] ISAVE */ | |||
| /* > \verbatim */ | |||
| /* > ISAVE is INTEGER array, dimension (3) */ | |||
| /* > ISAVE is used to save variables between calls to ZLACN2 */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > Originally named CONEST, dated March 16, 1988. */ | |||
| /* > */ | |||
| /* > Last modified: April, 1999 */ | |||
| /* > */ | |||
| /* > This is a thread safe version of ZLACON, which uses the array ISAVE */ | |||
| /* > in place of a SAVE statement, as follows: */ | |||
| /* > */ | |||
| /* > ZLACON ZLACN2 */ | |||
| /* > JUMP ISAVE(1) */ | |||
| /* > J ISAVE(2) */ | |||
| /* > ITER ISAVE(3) */ | |||
| /* > \endverbatim */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > Nick Higham, University of Manchester */ | |||
| /* > \par References: */ | |||
| /* ================ */ | |||
| /* > */ | |||
| /* > N.J. Higham, "FORTRAN codes for estimating the one-norm of */ | |||
| /* > a real or complex matrix, with applications to condition estimation", */ | |||
| /* > ACM Trans. Math. Soft., vol. 14, no. 4, pp. 381-396, December 1988. */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlacn2_(integer *n, doublecomplex *v, doublecomplex *x, | |||
| doublereal *est, integer *kase, integer *isave) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2, i__3; | |||
| doublereal d__1, d__2; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| doublereal temp; | |||
| integer i__; | |||
| doublereal absxi; | |||
| integer jlast; | |||
| extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *); | |||
| extern integer izmax1_(integer *, doublecomplex *, integer *); | |||
| extern doublereal dzsum1_(integer *, doublecomplex *, integer *), dlamch_( | |||
| char *); | |||
| doublereal safmin, altsgn, estold; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --isave; | |||
| --x; | |||
| --v; | |||
| /* Function Body */ | |||
| safmin = dlamch_("Safe minimum"); | |||
| if (*kase == 0) { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| d__1 = 1. / (doublereal) (*n); | |||
| z__1.r = d__1, z__1.i = 0.; | |||
| x[i__2].r = z__1.r, x[i__2].i = z__1.i; | |||
| /* L10: */ | |||
| } | |||
| *kase = 1; | |||
| isave[1] = 1; | |||
| return 0; | |||
| } | |||
| switch (isave[1]) { | |||
| case 1: goto L20; | |||
| case 2: goto L40; | |||
| case 3: goto L70; | |||
| case 4: goto L90; | |||
| case 5: goto L120; | |||
| } | |||
| /* ................ ENTRY (ISAVE( 1 ) = 1) */ | |||
| /* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY A*X. */ | |||
| L20: | |||
| if (*n == 1) { | |||
| v[1].r = x[1].r, v[1].i = x[1].i; | |||
| *est = z_abs(&v[1]); | |||
| /* ... QUIT */ | |||
| goto L130; | |||
| } | |||
| *est = dzsum1_(n, &x[1], &c__1); | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| absxi = z_abs(&x[i__]); | |||
| if (absxi > safmin) { | |||
| i__2 = i__; | |||
| i__3 = i__; | |||
| d__1 = x[i__3].r / absxi; | |||
| d__2 = d_imag(&x[i__]) / absxi; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| x[i__2].r = z__1.r, x[i__2].i = z__1.i; | |||
| } else { | |||
| i__2 = i__; | |||
| x[i__2].r = 1., x[i__2].i = 0.; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| *kase = 2; | |||
| isave[1] = 2; | |||
| return 0; | |||
| /* ................ ENTRY (ISAVE( 1 ) = 2) */ | |||
| /* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY CTRANS(A)*X. */ | |||
| L40: | |||
| isave[2] = izmax1_(n, &x[1], &c__1); | |||
| isave[3] = 2; | |||
| /* MAIN LOOP - ITERATIONS 2,3,...,ITMAX. */ | |||
| L50: | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| x[i__2].r = 0., x[i__2].i = 0.; | |||
| /* L60: */ | |||
| } | |||
| i__1 = isave[2]; | |||
| x[i__1].r = 1., x[i__1].i = 0.; | |||
| *kase = 1; | |||
| isave[1] = 3; | |||
| return 0; | |||
| /* ................ ENTRY (ISAVE( 1 ) = 3) */ | |||
| /* X HAS BEEN OVERWRITTEN BY A*X. */ | |||
| L70: | |||
| zcopy_(n, &x[1], &c__1, &v[1], &c__1); | |||
| estold = *est; | |||
| *est = dzsum1_(n, &v[1], &c__1); | |||
| /* TEST FOR CYCLING. */ | |||
| if (*est <= estold) { | |||
| goto L100; | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| absxi = z_abs(&x[i__]); | |||
| if (absxi > safmin) { | |||
| i__2 = i__; | |||
| i__3 = i__; | |||
| d__1 = x[i__3].r / absxi; | |||
| d__2 = d_imag(&x[i__]) / absxi; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| x[i__2].r = z__1.r, x[i__2].i = z__1.i; | |||
| } else { | |||
| i__2 = i__; | |||
| x[i__2].r = 1., x[i__2].i = 0.; | |||
| } | |||
| /* L80: */ | |||
| } | |||
| *kase = 2; | |||
| isave[1] = 4; | |||
| return 0; | |||
| /* ................ ENTRY (ISAVE( 1 ) = 4) */ | |||
| /* X HAS BEEN OVERWRITTEN BY CTRANS(A)*X. */ | |||
| L90: | |||
| jlast = isave[2]; | |||
| isave[2] = izmax1_(n, &x[1], &c__1); | |||
| if (z_abs(&x[jlast]) != z_abs(&x[isave[2]]) && isave[3] < 5) { | |||
| ++isave[3]; | |||
| goto L50; | |||
| } | |||
| /* ITERATION COMPLETE. FINAL STAGE. */ | |||
| L100: | |||
| altsgn = 1.; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| d__1 = altsgn * ((doublereal) (i__ - 1) / (doublereal) (*n - 1) + 1.); | |||
| z__1.r = d__1, z__1.i = 0.; | |||
| x[i__2].r = z__1.r, x[i__2].i = z__1.i; | |||
| altsgn = -altsgn; | |||
| /* L110: */ | |||
| } | |||
| *kase = 1; | |||
| isave[1] = 5; | |||
| return 0; | |||
| /* ................ ENTRY (ISAVE( 1 ) = 5) */ | |||
| /* X HAS BEEN OVERWRITTEN BY A*X. */ | |||
| L120: | |||
| temp = dzsum1_(n, &x[1], &c__1) / (doublereal) (*n * 3) * 2.; | |||
| if (temp > *est) { | |||
| zcopy_(n, &x[1], &c__1, &v[1], &c__1); | |||
| *est = temp; | |||
| } | |||
| L130: | |||
| *kase = 0; | |||
| return 0; | |||
| /* End of ZLACN2 */ | |||
| } /* zlacn2_ */ | |||
| @@ -0,0 +1,698 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLACON estimates the 1-norm of a square matrix, using reverse communication for evaluating matr | |||
| ix-vector products. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLACON + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlacon. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlacon. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlacon. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLACON( N, V, X, EST, KASE ) */ | |||
| /* INTEGER KASE, N */ | |||
| /* DOUBLE PRECISION EST */ | |||
| /* COMPLEX*16 V( N ), X( N ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLACON estimates the 1-norm of a square, complex matrix A. */ | |||
| /* > Reverse communication is used for evaluating matrix-vector products. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix. N >= 1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX*16 array, dimension (N) */ | |||
| /* > On the final return, V = A*W, where EST = norm(V)/norm(W) */ | |||
| /* > (W is not returned). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension (N) */ | |||
| /* > On an intermediate return, X should be overwritten by */ | |||
| /* > A * X, if KASE=1, */ | |||
| /* > A**H * X, if KASE=2, */ | |||
| /* > where A**H is the conjugate transpose of A, and ZLACON must be */ | |||
| /* > re-called with all the other parameters unchanged. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] EST */ | |||
| /* > \verbatim */ | |||
| /* > EST is DOUBLE PRECISION */ | |||
| /* > On entry with KASE = 1 or 2 and JUMP = 3, EST should be */ | |||
| /* > unchanged from the previous call to ZLACON. */ | |||
| /* > On exit, EST is an estimate (a lower bound) for norm(A). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] KASE */ | |||
| /* > \verbatim */ | |||
| /* > KASE is INTEGER */ | |||
| /* > On the initial call to ZLACON, KASE should be 0. */ | |||
| /* > On an intermediate return, KASE will be 1 or 2, indicating */ | |||
| /* > whether X should be overwritten by A * X or A**H * X. */ | |||
| /* > On the final return from ZLACON, KASE will again be 0. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > Originally named CONEST, dated March 16, 1988. \n */ | |||
| /* > Last modified: April, 1999 */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > Nick Higham, University of Manchester */ | |||
| /* > \par References: */ | |||
| /* ================ */ | |||
| /* > */ | |||
| /* > N.J. Higham, "FORTRAN codes for estimating the one-norm of */ | |||
| /* > a real or complex matrix, with applications to condition estimation", */ | |||
| /* > ACM Trans. Math. Soft., vol. 14, no. 4, pp. 381-396, December 1988. */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlacon_(integer *n, doublecomplex *v, doublecomplex *x, | |||
| doublereal *est, integer *kase) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2, i__3; | |||
| doublereal d__1, d__2; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| static integer iter; | |||
| static doublereal temp; | |||
| static integer jump, i__, j; | |||
| static doublereal absxi; | |||
| static integer jlast; | |||
| extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *); | |||
| extern integer izmax1_(integer *, doublecomplex *, integer *); | |||
| extern doublereal dzsum1_(integer *, doublecomplex *, integer *), dlamch_( | |||
| char *); | |||
| static doublereal safmin, altsgn, estold; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --x; | |||
| --v; | |||
| /* Function Body */ | |||
| safmin = dlamch_("Safe minimum"); | |||
| if (*kase == 0) { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| d__1 = 1. / (doublereal) (*n); | |||
| z__1.r = d__1, z__1.i = 0.; | |||
| x[i__2].r = z__1.r, x[i__2].i = z__1.i; | |||
| /* L10: */ | |||
| } | |||
| *kase = 1; | |||
| jump = 1; | |||
| return 0; | |||
| } | |||
| switch (jump) { | |||
| case 1: goto L20; | |||
| case 2: goto L40; | |||
| case 3: goto L70; | |||
| case 4: goto L90; | |||
| case 5: goto L120; | |||
| } | |||
| /* ................ ENTRY (JUMP = 1) */ | |||
| /* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY A*X. */ | |||
| L20: | |||
| if (*n == 1) { | |||
| v[1].r = x[1].r, v[1].i = x[1].i; | |||
| *est = z_abs(&v[1]); | |||
| /* ... QUIT */ | |||
| goto L130; | |||
| } | |||
| *est = dzsum1_(n, &x[1], &c__1); | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| absxi = z_abs(&x[i__]); | |||
| if (absxi > safmin) { | |||
| i__2 = i__; | |||
| i__3 = i__; | |||
| d__1 = x[i__3].r / absxi; | |||
| d__2 = d_imag(&x[i__]) / absxi; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| x[i__2].r = z__1.r, x[i__2].i = z__1.i; | |||
| } else { | |||
| i__2 = i__; | |||
| x[i__2].r = 1., x[i__2].i = 0.; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| *kase = 2; | |||
| jump = 2; | |||
| return 0; | |||
| /* ................ ENTRY (JUMP = 2) */ | |||
| /* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY CTRANS(A)*X. */ | |||
| L40: | |||
| j = izmax1_(n, &x[1], &c__1); | |||
| iter = 2; | |||
| /* MAIN LOOP - ITERATIONS 2,3,...,ITMAX. */ | |||
| L50: | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| x[i__2].r = 0., x[i__2].i = 0.; | |||
| /* L60: */ | |||
| } | |||
| i__1 = j; | |||
| x[i__1].r = 1., x[i__1].i = 0.; | |||
| *kase = 1; | |||
| jump = 3; | |||
| return 0; | |||
| /* ................ ENTRY (JUMP = 3) */ | |||
| /* X HAS BEEN OVERWRITTEN BY A*X. */ | |||
| L70: | |||
| zcopy_(n, &x[1], &c__1, &v[1], &c__1); | |||
| estold = *est; | |||
| *est = dzsum1_(n, &v[1], &c__1); | |||
| /* TEST FOR CYCLING. */ | |||
| if (*est <= estold) { | |||
| goto L100; | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| absxi = z_abs(&x[i__]); | |||
| if (absxi > safmin) { | |||
| i__2 = i__; | |||
| i__3 = i__; | |||
| d__1 = x[i__3].r / absxi; | |||
| d__2 = d_imag(&x[i__]) / absxi; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| x[i__2].r = z__1.r, x[i__2].i = z__1.i; | |||
| } else { | |||
| i__2 = i__; | |||
| x[i__2].r = 1., x[i__2].i = 0.; | |||
| } | |||
| /* L80: */ | |||
| } | |||
| *kase = 2; | |||
| jump = 4; | |||
| return 0; | |||
| /* ................ ENTRY (JUMP = 4) */ | |||
| /* X HAS BEEN OVERWRITTEN BY CTRANS(A)*X. */ | |||
| L90: | |||
| jlast = j; | |||
| j = izmax1_(n, &x[1], &c__1); | |||
| if (z_abs(&x[jlast]) != z_abs(&x[j]) && iter < 5) { | |||
| ++iter; | |||
| goto L50; | |||
| } | |||
| /* ITERATION COMPLETE. FINAL STAGE. */ | |||
| L100: | |||
| altsgn = 1.; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| d__1 = altsgn * ((doublereal) (i__ - 1) / (doublereal) (*n - 1) + 1.); | |||
| z__1.r = d__1, z__1.i = 0.; | |||
| x[i__2].r = z__1.r, x[i__2].i = z__1.i; | |||
| altsgn = -altsgn; | |||
| /* L110: */ | |||
| } | |||
| *kase = 1; | |||
| jump = 5; | |||
| return 0; | |||
| /* ................ ENTRY (JUMP = 5) */ | |||
| /* X HAS BEEN OVERWRITTEN BY A*X. */ | |||
| L120: | |||
| temp = dzsum1_(n, &x[1], &c__1) / (doublereal) (*n * 3) * 2.; | |||
| if (temp > *est) { | |||
| zcopy_(n, &x[1], &c__1, &v[1], &c__1); | |||
| *est = temp; | |||
| } | |||
| L130: | |||
| *kase = 0; | |||
| return 0; | |||
| /* End of ZLACON */ | |||
| } /* zlacon_ */ | |||
| @@ -0,0 +1,566 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLACP2 copies all or part of a real two-dimensional array to a complex array. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLACP2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlacp2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlacp2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlacp2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLACP2( UPLO, M, N, A, LDA, B, LDB ) */ | |||
| /* CHARACTER UPLO */ | |||
| /* INTEGER LDA, LDB, M, N */ | |||
| /* DOUBLE PRECISION A( LDA, * ) */ | |||
| /* COMPLEX*16 B( LDB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLACP2 copies all or part of a real two-dimensional matrix A to a */ | |||
| /* > complex matrix B. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies the part of the matrix A to be copied to B. */ | |||
| /* > = 'U': Upper triangular part */ | |||
| /* > = 'L': Lower triangular part */ | |||
| /* > Otherwise: All of the matrix A */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is DOUBLE PRECISION array, dimension (LDA,N) */ | |||
| /* > The m by n matrix A. If UPLO = 'U', only the upper trapezium */ | |||
| /* > is accessed; if UPLO = 'L', only the lower trapezium is */ | |||
| /* > accessed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX*16 array, dimension (LDB,N) */ | |||
| /* > On exit, B = A in the locations specified by UPLO. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlacp2_(char *uplo, integer *m, integer *n, doublereal * | |||
| a, integer *lda, doublecomplex *b, integer *ldb) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3, i__4; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| /* Function Body */ | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = f2cmin(j,*m); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| b[i__3].r = a[i__4], b[i__3].i = 0.; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else if (lsame_(uplo, "L")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = j; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| b[i__3].r = a[i__4], b[i__3].i = 0.; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| b[i__3].r = a[i__4], b[i__3].i = 0.; | |||
| /* L50: */ | |||
| } | |||
| /* L60: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLACP2 */ | |||
| } /* zlacp2_ */ | |||
| @@ -0,0 +1,565 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLACPY copies all or part of one two-dimensional array to another. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLACPY + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlacpy. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlacpy. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlacpy. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLACPY( UPLO, M, N, A, LDA, B, LDB ) */ | |||
| /* CHARACTER UPLO */ | |||
| /* INTEGER LDA, LDB, M, N */ | |||
| /* COMPLEX*16 A( LDA, * ), B( LDB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLACPY copies all or part of a two-dimensional matrix A to another */ | |||
| /* > matrix B. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies the part of the matrix A to be copied to B. */ | |||
| /* > = 'U': Upper triangular part */ | |||
| /* > = 'L': Lower triangular part */ | |||
| /* > Otherwise: All of the matrix A */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > The m by n matrix A. If UPLO = 'U', only the upper trapezium */ | |||
| /* > is accessed; if UPLO = 'L', only the lower trapezium is */ | |||
| /* > accessed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX*16 array, dimension (LDB,N) */ | |||
| /* > On exit, B = A in the locations specified by UPLO. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlacpy_(char *uplo, integer *m, integer *n, | |||
| doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3, i__4; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| /* Function Body */ | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = f2cmin(j,*m); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| b[i__3].r = a[i__4].r, b[i__3].i = a[i__4].i; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else if (lsame_(uplo, "L")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = j; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| b[i__3].r = a[i__4].r, b[i__3].i = a[i__4].i; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| b[i__3].r = a[i__4].r, b[i__3].i = a[i__4].i; | |||
| /* L50: */ | |||
| } | |||
| /* L60: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLACPY */ | |||
| } /* zlacpy_ */ | |||
| @@ -0,0 +1,609 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublereal c_b6 = 1.; | |||
| static doublereal c_b7 = 0.; | |||
| /* > \brief \b ZLACRM multiplies a complex matrix by a square real matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLACRM + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlacrm. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlacrm. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlacrm. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLACRM( M, N, A, LDA, B, LDB, C, LDC, RWORK ) */ | |||
| /* INTEGER LDA, LDB, LDC, M, N */ | |||
| /* DOUBLE PRECISION B( LDB, * ), RWORK( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ), C( LDC, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLACRM performs a very simple matrix-matrix multiplication: */ | |||
| /* > C := A * B, */ | |||
| /* > where A is M by N and complex; B is N by N and real; */ | |||
| /* > C is M by N and complex. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A and of the matrix C. */ | |||
| /* > M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns and rows of the matrix B and */ | |||
| /* > the number of columns of the matrix C. */ | |||
| /* > N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA, N) */ | |||
| /* > On entry, A contains the M by N matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >=f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] B */ | |||
| /* > \verbatim */ | |||
| /* > B is DOUBLE PRECISION array, dimension (LDB, N) */ | |||
| /* > On entry, B contains the N by N matrix B. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >=f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX*16 array, dimension (LDC, N) */ | |||
| /* > On exit, C contains the M by N matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the array C. LDC >=f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is DOUBLE PRECISION array, dimension (2*M*N) */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlacrm_(integer *m, integer *n, doublecomplex *a, | |||
| integer *lda, doublereal *b, integer *ldb, doublecomplex *c__, | |||
| integer *ldc, doublereal *rwork) | |||
| { | |||
| /* System generated locals */ | |||
| integer b_dim1, b_offset, a_dim1, a_offset, c_dim1, c_offset, i__1, i__2, | |||
| i__3, i__4, i__5; | |||
| doublereal d__1; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__, j, l; | |||
| extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *, | |||
| integer *, doublereal *, doublereal *, integer *, doublereal *, | |||
| integer *, doublereal *, doublereal *, integer *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible. */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| --rwork; | |||
| /* Function Body */ | |||
| if (*m == 0 || *n == 0) { | |||
| return 0; | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| rwork[(j - 1) * *m + i__] = a[i__3].r; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| l = *m * *n + 1; | |||
| dgemm_("N", "N", m, n, n, &c_b6, &rwork[1], m, &b[b_offset], ldb, &c_b7, & | |||
| rwork[l], m); | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * c_dim1; | |||
| i__4 = l + (j - 1) * *m + i__ - 1; | |||
| c__[i__3].r = rwork[i__4], c__[i__3].i = 0.; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| rwork[(j - 1) * *m + i__] = d_imag(&a[i__ + j * a_dim1]); | |||
| /* L50: */ | |||
| } | |||
| /* L60: */ | |||
| } | |||
| dgemm_("N", "N", m, n, n, &c_b6, &rwork[1], m, &b[b_offset], ldb, &c_b7, & | |||
| rwork[l], m); | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * c_dim1; | |||
| i__4 = i__ + j * c_dim1; | |||
| d__1 = c__[i__4].r; | |||
| i__5 = l + (j - 1) * *m + i__ - 1; | |||
| z__1.r = d__1, z__1.i = rwork[i__5]; | |||
| c__[i__3].r = z__1.r, c__[i__3].i = z__1.i; | |||
| /* L70: */ | |||
| } | |||
| /* L80: */ | |||
| } | |||
| return 0; | |||
| /* End of ZLACRM */ | |||
| } /* zlacrm_ */ | |||
| @@ -0,0 +1,593 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLACRT performs a linear transformation of a pair of complex vectors. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLACRT + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlacrt. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlacrt. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlacrt. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLACRT( N, CX, INCX, CY, INCY, C, S ) */ | |||
| /* INTEGER INCX, INCY, N */ | |||
| /* COMPLEX*16 C, S */ | |||
| /* COMPLEX*16 CX( * ), CY( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLACRT performs the operation */ | |||
| /* > */ | |||
| /* > ( c s )( x ) ==> ( x ) */ | |||
| /* > ( -s c )( y ) ( y ) */ | |||
| /* > */ | |||
| /* > where c and s are complex and the vectors x and y are complex. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of elements in the vectors CX and CY. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] CX */ | |||
| /* > \verbatim */ | |||
| /* > CX is COMPLEX*16 array, dimension (N) */ | |||
| /* > On input, the vector x. */ | |||
| /* > On output, CX is overwritten with c*x + s*y. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCX */ | |||
| /* > \verbatim */ | |||
| /* > INCX is INTEGER */ | |||
| /* > The increment between successive values of CX. INCX <> 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] CY */ | |||
| /* > \verbatim */ | |||
| /* > CY is COMPLEX*16 array, dimension (N) */ | |||
| /* > On input, the vector y. */ | |||
| /* > On output, CY is overwritten with -s*x + c*y. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCY */ | |||
| /* > \verbatim */ | |||
| /* > INCY is INTEGER */ | |||
| /* > The increment between successive values of CY. INCY <> 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX*16 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] S */ | |||
| /* > \verbatim */ | |||
| /* > S is COMPLEX*16 */ | |||
| /* > C and S define the matrix */ | |||
| /* > [ C S ]. */ | |||
| /* > [ -S C ] */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlacrt_(integer *n, doublecomplex *cx, integer *incx, | |||
| doublecomplex *cy, integer *incy, doublecomplex *c__, doublecomplex * | |||
| s) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2, i__3, i__4; | |||
| doublecomplex z__1, z__2, z__3; | |||
| /* Local variables */ | |||
| integer i__; | |||
| doublecomplex ctemp; | |||
| integer ix, iy; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --cy; | |||
| --cx; | |||
| /* Function Body */ | |||
| if (*n <= 0) { | |||
| return 0; | |||
| } | |||
| if (*incx == 1 && *incy == 1) { | |||
| goto L20; | |||
| } | |||
| /* Code for unequal increments or equal increments not equal to 1 */ | |||
| ix = 1; | |||
| iy = 1; | |||
| if (*incx < 0) { | |||
| ix = (-(*n) + 1) * *incx + 1; | |||
| } | |||
| if (*incy < 0) { | |||
| iy = (-(*n) + 1) * *incy + 1; | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = ix; | |||
| z__2.r = c__->r * cx[i__2].r - c__->i * cx[i__2].i, z__2.i = c__->r * | |||
| cx[i__2].i + c__->i * cx[i__2].r; | |||
| i__3 = iy; | |||
| z__3.r = s->r * cy[i__3].r - s->i * cy[i__3].i, z__3.i = s->r * cy[ | |||
| i__3].i + s->i * cy[i__3].r; | |||
| z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; | |||
| ctemp.r = z__1.r, ctemp.i = z__1.i; | |||
| i__2 = iy; | |||
| i__3 = iy; | |||
| z__2.r = c__->r * cy[i__3].r - c__->i * cy[i__3].i, z__2.i = c__->r * | |||
| cy[i__3].i + c__->i * cy[i__3].r; | |||
| i__4 = ix; | |||
| z__3.r = s->r * cx[i__4].r - s->i * cx[i__4].i, z__3.i = s->r * cx[ | |||
| i__4].i + s->i * cx[i__4].r; | |||
| z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i; | |||
| cy[i__2].r = z__1.r, cy[i__2].i = z__1.i; | |||
| i__2 = ix; | |||
| cx[i__2].r = ctemp.r, cx[i__2].i = ctemp.i; | |||
| ix += *incx; | |||
| iy += *incy; | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* Code for both increments equal to 1 */ | |||
| L20: | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| z__2.r = c__->r * cx[i__2].r - c__->i * cx[i__2].i, z__2.i = c__->r * | |||
| cx[i__2].i + c__->i * cx[i__2].r; | |||
| i__3 = i__; | |||
| z__3.r = s->r * cy[i__3].r - s->i * cy[i__3].i, z__3.i = s->r * cy[ | |||
| i__3].i + s->i * cy[i__3].r; | |||
| z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; | |||
| ctemp.r = z__1.r, ctemp.i = z__1.i; | |||
| i__2 = i__; | |||
| i__3 = i__; | |||
| z__2.r = c__->r * cy[i__3].r - c__->i * cy[i__3].i, z__2.i = c__->r * | |||
| cy[i__3].i + c__->i * cy[i__3].r; | |||
| i__4 = i__; | |||
| z__3.r = s->r * cx[i__4].r - s->i * cx[i__4].i, z__3.i = s->r * cx[ | |||
| i__4].i + s->i * cx[i__4].r; | |||
| z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i; | |||
| cy[i__2].r = z__1.r, cy[i__2].i = z__1.i; | |||
| i__2 = i__; | |||
| cx[i__2].r = ctemp.r, cx[i__2].i = ctemp.i; | |||
| /* L30: */ | |||
| } | |||
| return 0; | |||
| } /* zlacrt_ */ | |||
| @@ -0,0 +1,490 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLADIV performs complex division in real arithmetic, avoiding unnecessary overflow. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLADIV + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zladiv. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zladiv. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zladiv. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* COMPLEX*16 FUNCTION ZLADIV( X, Y ) */ | |||
| /* COMPLEX*16 X, Y */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLADIV := X / Y, where X and Y are complex. The computation of X / Y */ | |||
| /* > will not overflow on an intermediary step unless the results */ | |||
| /* > overflows. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] Y */ | |||
| /* > \verbatim */ | |||
| /* > Y is COMPLEX*16 */ | |||
| /* > The complex scalars X and Y. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Double Complex */ VOID zladiv_(doublecomplex * ret_val, doublecomplex *x, | |||
| doublecomplex *y) | |||
| { | |||
| /* System generated locals */ | |||
| doublereal d__1, d__2, d__3, d__4; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| doublereal zi; | |||
| extern /* Subroutine */ int dladiv_(doublereal *, doublereal *, | |||
| doublereal *, doublereal *, doublereal *, doublereal *); | |||
| doublereal zr; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| d__1 = x->r; | |||
| d__2 = d_imag(x); | |||
| d__3 = y->r; | |||
| d__4 = d_imag(y); | |||
| dladiv_(&d__1, &d__2, &d__3, &d__4, &zr, &zi); | |||
| z__1.r = zr, z__1.i = zi; | |||
| ret_val->r = z__1.r, ret_val->i = z__1.i; | |||
| return ; | |||
| /* End of ZLADIV */ | |||
| } /* zladiv_ */ | |||
| @@ -0,0 +1,804 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__9 = 9; | |||
| static integer c__0 = 0; | |||
| static integer c__2 = 2; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLAED0 used by sstedc. Computes all eigenvalues and corresponding eigenvectors of an unreduced | |||
| symmetric tridiagonal matrix using the divide and conquer method. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAED0 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaed0. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaed0. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaed0. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAED0( QSIZ, N, D, E, Q, LDQ, QSTORE, LDQS, RWORK, */ | |||
| /* IWORK, INFO ) */ | |||
| /* INTEGER INFO, LDQ, LDQS, N, QSIZ */ | |||
| /* INTEGER IWORK( * ) */ | |||
| /* DOUBLE PRECISION D( * ), E( * ), RWORK( * ) */ | |||
| /* COMPLEX*16 Q( LDQ, * ), QSTORE( LDQS, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > Using the divide and conquer method, ZLAED0 computes all eigenvalues */ | |||
| /* > of a symmetric tridiagonal matrix which is one diagonal block of */ | |||
| /* > those from reducing a dense or band Hermitian matrix and */ | |||
| /* > corresponding eigenvectors of the dense or band matrix. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] QSIZ */ | |||
| /* > \verbatim */ | |||
| /* > QSIZ is INTEGER */ | |||
| /* > The dimension of the unitary matrix used to reduce */ | |||
| /* > the full matrix to tridiagonal form. QSIZ >= N if ICOMPQ = 1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The dimension of the symmetric tridiagonal matrix. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] D */ | |||
| /* > \verbatim */ | |||
| /* > D is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > On entry, the diagonal elements of the tridiagonal matrix. */ | |||
| /* > On exit, the eigenvalues in ascending order. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] E */ | |||
| /* > \verbatim */ | |||
| /* > E is DOUBLE PRECISION array, dimension (N-1) */ | |||
| /* > On entry, the off-diagonal elements of the tridiagonal matrix. */ | |||
| /* > On exit, E has been destroyed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] Q */ | |||
| /* > \verbatim */ | |||
| /* > Q is COMPLEX*16 array, dimension (LDQ,N) */ | |||
| /* > On entry, Q must contain an QSIZ x N matrix whose columns */ | |||
| /* > unitarily orthonormal. It is a part of the unitary matrix */ | |||
| /* > that reduces the full dense Hermitian matrix to a */ | |||
| /* > (reducible) symmetric tridiagonal matrix. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDQ */ | |||
| /* > \verbatim */ | |||
| /* > LDQ is INTEGER */ | |||
| /* > The leading dimension of the array Q. LDQ >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] IWORK */ | |||
| /* > \verbatim */ | |||
| /* > IWORK is INTEGER array, */ | |||
| /* > the dimension of IWORK must be at least */ | |||
| /* > 6 + 6*N + 5*N*lg N */ | |||
| /* > ( lg( N ) = smallest integer k */ | |||
| /* > such that 2^k >= N ) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is DOUBLE PRECISION array, */ | |||
| /* > dimension (1 + 3*N + 2*N*lg N + 3*N**2) */ | |||
| /* > ( lg( N ) = smallest integer k */ | |||
| /* > such that 2^k >= N ) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] QSTORE */ | |||
| /* > \verbatim */ | |||
| /* > QSTORE is COMPLEX*16 array, dimension (LDQS, N) */ | |||
| /* > Used to store parts of */ | |||
| /* > the eigenvector matrix when the updating matrix multiplies */ | |||
| /* > take place. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDQS */ | |||
| /* > \verbatim */ | |||
| /* > LDQS is INTEGER */ | |||
| /* > The leading dimension of the array QSTORE. */ | |||
| /* > LDQS >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit. */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > > 0: The algorithm failed to compute an eigenvalue while */ | |||
| /* > working on the submatrix lying in rows and columns */ | |||
| /* > INFO/(N+1) through mod(INFO,N+1). */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaed0_(integer *qsiz, integer *n, doublereal *d__, | |||
| doublereal *e, doublecomplex *q, integer *ldq, doublecomplex *qstore, | |||
| integer *ldqs, doublereal *rwork, integer *iwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer q_dim1, q_offset, qstore_dim1, qstore_offset, i__1, i__2; | |||
| doublereal d__1; | |||
| /* Local variables */ | |||
| doublereal temp; | |||
| integer curr, i__, j, k, iperm; | |||
| extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, | |||
| doublereal *, integer *); | |||
| integer indxq, iwrem, iqptr, tlvls; | |||
| extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *), zlaed7_(integer *, integer *, | |||
| integer *, integer *, integer *, integer *, doublereal *, | |||
| doublecomplex *, integer *, doublereal *, integer *, doublereal *, | |||
| integer *, integer *, integer *, integer *, integer *, | |||
| doublereal *, doublecomplex *, doublereal *, integer *, integer *) | |||
| ; | |||
| integer ll, iq, igivcl; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| extern /* Subroutine */ int zlacrm_(integer *, integer *, doublecomplex *, | |||
| integer *, doublereal *, integer *, doublecomplex *, integer *, | |||
| doublereal *); | |||
| integer igivnm, submat, curprb, subpbs, igivpt; | |||
| extern /* Subroutine */ int dsteqr_(char *, integer *, doublereal *, | |||
| doublereal *, doublereal *, integer *, doublereal *, integer *); | |||
| integer curlvl, matsiz, iprmpt, smlsiz, lgn, msd2, smm1, spm1, spm2; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Warning: N could be as big as QSIZ! */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| --d__; | |||
| --e; | |||
| q_dim1 = *ldq; | |||
| q_offset = 1 + q_dim1 * 1; | |||
| q -= q_offset; | |||
| qstore_dim1 = *ldqs; | |||
| qstore_offset = 1 + qstore_dim1 * 1; | |||
| qstore -= qstore_offset; | |||
| --rwork; | |||
| --iwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| /* IF( ICOMPQ .LT. 0 .OR. ICOMPQ .GT. 2 ) THEN */ | |||
| /* INFO = -1 */ | |||
| /* ELSE IF( ( ICOMPQ .EQ. 1 ) .AND. ( QSIZ .LT. MAX( 0, N ) ) ) */ | |||
| /* $ THEN */ | |||
| if (*qsiz < f2cmax(0,*n)) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*ldq < f2cmax(1,*n)) { | |||
| *info = -6; | |||
| } else if (*ldqs < f2cmax(1,*n)) { | |||
| *info = -8; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("ZLAED0", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0) { | |||
| return 0; | |||
| } | |||
| smlsiz = ilaenv_(&c__9, "ZLAED0", " ", &c__0, &c__0, &c__0, &c__0, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| /* Determine the size and placement of the submatrices, and save in */ | |||
| /* the leading elements of IWORK. */ | |||
| iwork[1] = *n; | |||
| subpbs = 1; | |||
| tlvls = 0; | |||
| L10: | |||
| if (iwork[subpbs] > smlsiz) { | |||
| for (j = subpbs; j >= 1; --j) { | |||
| iwork[j * 2] = (iwork[j] + 1) / 2; | |||
| iwork[(j << 1) - 1] = iwork[j] / 2; | |||
| /* L20: */ | |||
| } | |||
| ++tlvls; | |||
| subpbs <<= 1; | |||
| goto L10; | |||
| } | |||
| i__1 = subpbs; | |||
| for (j = 2; j <= i__1; ++j) { | |||
| iwork[j] += iwork[j - 1]; | |||
| /* L30: */ | |||
| } | |||
| /* Divide the matrix into SUBPBS submatrices of size at most SMLSIZ+1 */ | |||
| /* using rank-1 modifications (cuts). */ | |||
| spm1 = subpbs - 1; | |||
| i__1 = spm1; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| submat = iwork[i__] + 1; | |||
| smm1 = submat - 1; | |||
| d__[smm1] -= (d__1 = e[smm1], abs(d__1)); | |||
| d__[submat] -= (d__1 = e[smm1], abs(d__1)); | |||
| /* L40: */ | |||
| } | |||
| indxq = (*n << 2) + 3; | |||
| /* Set up workspaces for eigenvalues only/accumulate new vectors */ | |||
| /* routine */ | |||
| temp = log((doublereal) (*n)) / log(2.); | |||
| lgn = (integer) temp; | |||
| if (pow_ii(&c__2, &lgn) < *n) { | |||
| ++lgn; | |||
| } | |||
| if (pow_ii(&c__2, &lgn) < *n) { | |||
| ++lgn; | |||
| } | |||
| iprmpt = indxq + *n + 1; | |||
| iperm = iprmpt + *n * lgn; | |||
| iqptr = iperm + *n * lgn; | |||
| igivpt = iqptr + *n + 2; | |||
| igivcl = igivpt + *n * lgn; | |||
| igivnm = 1; | |||
| iq = igivnm + (*n << 1) * lgn; | |||
| /* Computing 2nd power */ | |||
| i__1 = *n; | |||
| iwrem = iq + i__1 * i__1 + 1; | |||
| /* Initialize pointers */ | |||
| i__1 = subpbs; | |||
| for (i__ = 0; i__ <= i__1; ++i__) { | |||
| iwork[iprmpt + i__] = 1; | |||
| iwork[igivpt + i__] = 1; | |||
| /* L50: */ | |||
| } | |||
| iwork[iqptr] = 1; | |||
| /* Solve each submatrix eigenproblem at the bottom of the divide and */ | |||
| /* conquer tree. */ | |||
| curr = 0; | |||
| i__1 = spm1; | |||
| for (i__ = 0; i__ <= i__1; ++i__) { | |||
| if (i__ == 0) { | |||
| submat = 1; | |||
| matsiz = iwork[1]; | |||
| } else { | |||
| submat = iwork[i__] + 1; | |||
| matsiz = iwork[i__ + 1] - iwork[i__]; | |||
| } | |||
| ll = iq - 1 + iwork[iqptr + curr]; | |||
| dsteqr_("I", &matsiz, &d__[submat], &e[submat], &rwork[ll], &matsiz, & | |||
| rwork[1], info); | |||
| zlacrm_(qsiz, &matsiz, &q[submat * q_dim1 + 1], ldq, &rwork[ll], & | |||
| matsiz, &qstore[submat * qstore_dim1 + 1], ldqs, &rwork[iwrem] | |||
| ); | |||
| /* Computing 2nd power */ | |||
| i__2 = matsiz; | |||
| iwork[iqptr + curr + 1] = iwork[iqptr + curr] + i__2 * i__2; | |||
| ++curr; | |||
| if (*info > 0) { | |||
| *info = submat * (*n + 1) + submat + matsiz - 1; | |||
| return 0; | |||
| } | |||
| k = 1; | |||
| i__2 = iwork[i__ + 1]; | |||
| for (j = submat; j <= i__2; ++j) { | |||
| iwork[indxq + j] = k; | |||
| ++k; | |||
| /* L60: */ | |||
| } | |||
| /* L70: */ | |||
| } | |||
| /* Successively merge eigensystems of adjacent submatrices */ | |||
| /* into eigensystem for the corresponding larger matrix. */ | |||
| /* while ( SUBPBS > 1 ) */ | |||
| curlvl = 1; | |||
| L80: | |||
| if (subpbs > 1) { | |||
| spm2 = subpbs - 2; | |||
| i__1 = spm2; | |||
| for (i__ = 0; i__ <= i__1; i__ += 2) { | |||
| if (i__ == 0) { | |||
| submat = 1; | |||
| matsiz = iwork[2]; | |||
| msd2 = iwork[1]; | |||
| curprb = 0; | |||
| } else { | |||
| submat = iwork[i__] + 1; | |||
| matsiz = iwork[i__ + 2] - iwork[i__]; | |||
| msd2 = matsiz / 2; | |||
| ++curprb; | |||
| } | |||
| /* Merge lower order eigensystems (of size MSD2 and MATSIZ - MSD2) */ | |||
| /* into an eigensystem of size MATSIZ. ZLAED7 handles the case */ | |||
| /* when the eigenvectors of a full or band Hermitian matrix (which */ | |||
| /* was reduced to tridiagonal form) are desired. */ | |||
| /* I am free to use Q as a valuable working space until Loop 150. */ | |||
| zlaed7_(&matsiz, &msd2, qsiz, &tlvls, &curlvl, &curprb, &d__[ | |||
| submat], &qstore[submat * qstore_dim1 + 1], ldqs, &e[ | |||
| submat + msd2 - 1], &iwork[indxq + submat], &rwork[iq], & | |||
| iwork[iqptr], &iwork[iprmpt], &iwork[iperm], &iwork[ | |||
| igivpt], &iwork[igivcl], &rwork[igivnm], &q[submat * | |||
| q_dim1 + 1], &rwork[iwrem], &iwork[subpbs + 1], info); | |||
| if (*info > 0) { | |||
| *info = submat * (*n + 1) + submat + matsiz - 1; | |||
| return 0; | |||
| } | |||
| iwork[i__ / 2 + 1] = iwork[i__ + 2]; | |||
| /* L90: */ | |||
| } | |||
| subpbs /= 2; | |||
| ++curlvl; | |||
| goto L80; | |||
| } | |||
| /* end while */ | |||
| /* Re-merge the eigenvalues/vectors which were deflated at the final */ | |||
| /* merge step. */ | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| j = iwork[indxq + i__]; | |||
| rwork[i__] = d__[j]; | |||
| zcopy_(qsiz, &qstore[j * qstore_dim1 + 1], &c__1, &q[i__ * q_dim1 + 1] | |||
| , &c__1); | |||
| /* L100: */ | |||
| } | |||
| dcopy_(n, &rwork[1], &c__1, &d__[1], &c__1); | |||
| return 0; | |||
| /* End of ZLAED0 */ | |||
| } /* zlaed0_ */ | |||
| @@ -0,0 +1,808 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__2 = 2; | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| /* > \brief \b ZLAED7 used by sstedc. Computes the updated eigensystem of a diagonal matrix after modification | |||
| by a rank-one symmetric matrix. Used when the original matrix is dense. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAED7 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaed7. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaed7. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaed7. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAED7( N, CUTPNT, QSIZ, TLVLS, CURLVL, CURPBM, D, Q, */ | |||
| /* LDQ, RHO, INDXQ, QSTORE, QPTR, PRMPTR, PERM, */ | |||
| /* GIVPTR, GIVCOL, GIVNUM, WORK, RWORK, IWORK, */ | |||
| /* INFO ) */ | |||
| /* INTEGER CURLVL, CURPBM, CUTPNT, INFO, LDQ, N, QSIZ, */ | |||
| /* $ TLVLS */ | |||
| /* DOUBLE PRECISION RHO */ | |||
| /* INTEGER GIVCOL( 2, * ), GIVPTR( * ), INDXQ( * ), */ | |||
| /* $ IWORK( * ), PERM( * ), PRMPTR( * ), QPTR( * ) */ | |||
| /* DOUBLE PRECISION D( * ), GIVNUM( 2, * ), QSTORE( * ), RWORK( * ) */ | |||
| /* COMPLEX*16 Q( LDQ, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAED7 computes the updated eigensystem of a diagonal */ | |||
| /* > matrix after modification by a rank-one symmetric matrix. This */ | |||
| /* > routine is used only for the eigenproblem which requires all */ | |||
| /* > eigenvalues and optionally eigenvectors of a dense or banded */ | |||
| /* > Hermitian matrix that has been reduced to tridiagonal form. */ | |||
| /* > */ | |||
| /* > T = Q(in) ( D(in) + RHO * Z*Z**H ) Q**H(in) = Q(out) * D(out) * Q**H(out) */ | |||
| /* > */ | |||
| /* > where Z = Q**Hu, u is a vector of length N with ones in the */ | |||
| /* > CUTPNT and CUTPNT + 1 th elements and zeros elsewhere. */ | |||
| /* > */ | |||
| /* > The eigenvectors of the original matrix are stored in Q, and the */ | |||
| /* > eigenvalues are in D. The algorithm consists of three stages: */ | |||
| /* > */ | |||
| /* > The first stage consists of deflating the size of the problem */ | |||
| /* > when there are multiple eigenvalues or if there is a zero in */ | |||
| /* > the Z vector. For each such occurrence the dimension of the */ | |||
| /* > secular equation problem is reduced by one. This stage is */ | |||
| /* > performed by the routine DLAED2. */ | |||
| /* > */ | |||
| /* > The second stage consists of calculating the updated */ | |||
| /* > eigenvalues. This is done by finding the roots of the secular */ | |||
| /* > equation via the routine DLAED4 (as called by SLAED3). */ | |||
| /* > This routine also calculates the eigenvectors of the current */ | |||
| /* > problem. */ | |||
| /* > */ | |||
| /* > The final stage consists of computing the updated eigenvectors */ | |||
| /* > directly using the updated eigenvalues. The eigenvectors for */ | |||
| /* > the current problem are multiplied with the eigenvectors from */ | |||
| /* > the overall problem. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The dimension of the symmetric tridiagonal matrix. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] CUTPNT */ | |||
| /* > \verbatim */ | |||
| /* > CUTPNT is INTEGER */ | |||
| /* > Contains the location of the last eigenvalue in the leading */ | |||
| /* > sub-matrix. f2cmin(1,N) <= CUTPNT <= N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] QSIZ */ | |||
| /* > \verbatim */ | |||
| /* > QSIZ is INTEGER */ | |||
| /* > The dimension of the unitary matrix used to reduce */ | |||
| /* > the full matrix to tridiagonal form. QSIZ >= N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TLVLS */ | |||
| /* > \verbatim */ | |||
| /* > TLVLS is INTEGER */ | |||
| /* > The total number of merging levels in the overall divide and */ | |||
| /* > conquer tree. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] CURLVL */ | |||
| /* > \verbatim */ | |||
| /* > CURLVL is INTEGER */ | |||
| /* > The current level in the overall merge routine, */ | |||
| /* > 0 <= curlvl <= tlvls. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] CURPBM */ | |||
| /* > \verbatim */ | |||
| /* > CURPBM is INTEGER */ | |||
| /* > The current problem in the current level in the overall */ | |||
| /* > merge routine (counting from upper left to lower right). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] D */ | |||
| /* > \verbatim */ | |||
| /* > D is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > On entry, the eigenvalues of the rank-1-perturbed matrix. */ | |||
| /* > On exit, the eigenvalues of the repaired matrix. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] Q */ | |||
| /* > \verbatim */ | |||
| /* > Q is COMPLEX*16 array, dimension (LDQ,N) */ | |||
| /* > On entry, the eigenvectors of the rank-1-perturbed matrix. */ | |||
| /* > On exit, the eigenvectors of the repaired tridiagonal matrix. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDQ */ | |||
| /* > \verbatim */ | |||
| /* > LDQ is INTEGER */ | |||
| /* > The leading dimension of the array Q. LDQ >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] RHO */ | |||
| /* > \verbatim */ | |||
| /* > RHO is DOUBLE PRECISION */ | |||
| /* > Contains the subdiagonal element used to create the rank-1 */ | |||
| /* > modification. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INDXQ */ | |||
| /* > \verbatim */ | |||
| /* > INDXQ is INTEGER array, dimension (N) */ | |||
| /* > This contains the permutation which will reintegrate the */ | |||
| /* > subproblem just solved back into sorted order, */ | |||
| /* > ie. D( INDXQ( I = 1, N ) ) will be in ascending order. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] IWORK */ | |||
| /* > \verbatim */ | |||
| /* > IWORK is INTEGER array, dimension (4*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is DOUBLE PRECISION array, */ | |||
| /* > dimension (3*N+2*QSIZ*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX*16 array, dimension (QSIZ*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] QSTORE */ | |||
| /* > \verbatim */ | |||
| /* > QSTORE is DOUBLE PRECISION array, dimension (N**2+1) */ | |||
| /* > Stores eigenvectors of submatrices encountered during */ | |||
| /* > divide and conquer, packed together. QPTR points to */ | |||
| /* > beginning of the submatrices. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] QPTR */ | |||
| /* > \verbatim */ | |||
| /* > QPTR is INTEGER array, dimension (N+2) */ | |||
| /* > List of indices pointing to beginning of submatrices stored */ | |||
| /* > in QSTORE. The submatrices are numbered starting at the */ | |||
| /* > bottom left of the divide and conquer tree, from left to */ | |||
| /* > right and bottom to top. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] PRMPTR */ | |||
| /* > \verbatim */ | |||
| /* > PRMPTR is INTEGER array, dimension (N lg N) */ | |||
| /* > Contains a list of pointers which indicate where in PERM a */ | |||
| /* > level's permutation is stored. PRMPTR(i+1) - PRMPTR(i) */ | |||
| /* > indicates the size of the permutation and also the size of */ | |||
| /* > the full, non-deflated problem. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] PERM */ | |||
| /* > \verbatim */ | |||
| /* > PERM is INTEGER array, dimension (N lg N) */ | |||
| /* > Contains the permutations (from deflation and sorting) to be */ | |||
| /* > applied to each eigenblock. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] GIVPTR */ | |||
| /* > \verbatim */ | |||
| /* > GIVPTR is INTEGER array, dimension (N lg N) */ | |||
| /* > Contains a list of pointers which indicate where in GIVCOL a */ | |||
| /* > level's Givens rotations are stored. GIVPTR(i+1) - GIVPTR(i) */ | |||
| /* > indicates the number of Givens rotations. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] GIVCOL */ | |||
| /* > \verbatim */ | |||
| /* > GIVCOL is INTEGER array, dimension (2, N lg N) */ | |||
| /* > Each pair of numbers indicates a pair of columns to take place */ | |||
| /* > in a Givens rotation. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] GIVNUM */ | |||
| /* > \verbatim */ | |||
| /* > GIVNUM is DOUBLE PRECISION array, dimension (2, N lg N) */ | |||
| /* > Each number indicates the S value to be used in the */ | |||
| /* > corresponding Givens rotation. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit. */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > > 0: if INFO = 1, an eigenvalue did not converge */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complex16OTHERcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaed7_(integer *n, integer *cutpnt, integer *qsiz, | |||
| integer *tlvls, integer *curlvl, integer *curpbm, doublereal *d__, | |||
| doublecomplex *q, integer *ldq, doublereal *rho, integer *indxq, | |||
| doublereal *qstore, integer *qptr, integer *prmptr, integer *perm, | |||
| integer *givptr, integer *givcol, doublereal *givnum, doublecomplex * | |||
| work, doublereal *rwork, integer *iwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer q_dim1, q_offset, i__1, i__2; | |||
| /* Local variables */ | |||
| integer indx, curr, i__, k, indxc, indxp, n1, n2; | |||
| extern /* Subroutine */ int dlaed9_(integer *, integer *, integer *, | |||
| integer *, doublereal *, doublereal *, integer *, doublereal *, | |||
| doublereal *, doublereal *, doublereal *, integer *, integer *), | |||
| zlaed8_(integer *, integer *, integer *, doublecomplex *, integer | |||
| *, doublereal *, doublereal *, integer *, doublereal *, | |||
| doublereal *, doublecomplex *, integer *, doublereal *, integer *, | |||
| integer *, integer *, integer *, integer *, integer *, | |||
| doublereal *, integer *), dlaeda_(integer *, integer *, integer *, | |||
| integer *, integer *, integer *, integer *, integer *, | |||
| doublereal *, doublereal *, integer *, doublereal *, doublereal *, | |||
| integer *); | |||
| integer idlmda, iq, iw, iz; | |||
| extern /* Subroutine */ int dlamrg_(integer *, integer *, doublereal *, | |||
| integer *, integer *, integer *), xerbla_(char *, integer *, ftnlen), zlacrm_(integer *, integer *, doublecomplex *, integer *, | |||
| doublereal *, integer *, doublecomplex *, integer *, doublereal * | |||
| ); | |||
| integer coltyp, ptr; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| --d__; | |||
| q_dim1 = *ldq; | |||
| q_offset = 1 + q_dim1 * 1; | |||
| q -= q_offset; | |||
| --indxq; | |||
| --qstore; | |||
| --qptr; | |||
| --prmptr; | |||
| --perm; | |||
| --givptr; | |||
| givcol -= 3; | |||
| givnum -= 3; | |||
| --work; | |||
| --rwork; | |||
| --iwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| /* IF( ICOMPQ.LT.0 .OR. ICOMPQ.GT.1 ) THEN */ | |||
| /* INFO = -1 */ | |||
| /* ELSE IF( N.LT.0 ) THEN */ | |||
| if (*n < 0) { | |||
| *info = -1; | |||
| } else if (f2cmin(1,*n) > *cutpnt || *n < *cutpnt) { | |||
| *info = -2; | |||
| } else if (*qsiz < *n) { | |||
| *info = -3; | |||
| } else if (*ldq < f2cmax(1,*n)) { | |||
| *info = -9; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("ZLAED7", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0) { | |||
| return 0; | |||
| } | |||
| /* The following values are for bookkeeping purposes only. They are */ | |||
| /* integer pointers which indicate the portion of the workspace */ | |||
| /* used by a particular array in DLAED2 and SLAED3. */ | |||
| iz = 1; | |||
| idlmda = iz + *n; | |||
| iw = idlmda + *n; | |||
| iq = iw + *n; | |||
| indx = 1; | |||
| indxc = indx + *n; | |||
| coltyp = indxc + *n; | |||
| indxp = coltyp + *n; | |||
| /* Form the z-vector which consists of the last row of Q_1 and the */ | |||
| /* first row of Q_2. */ | |||
| ptr = pow_ii(&c__2, tlvls) + 1; | |||
| i__1 = *curlvl - 1; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = *tlvls - i__; | |||
| ptr += pow_ii(&c__2, &i__2); | |||
| /* L10: */ | |||
| } | |||
| curr = ptr + *curpbm; | |||
| dlaeda_(n, tlvls, curlvl, curpbm, &prmptr[1], &perm[1], &givptr[1], & | |||
| givcol[3], &givnum[3], &qstore[1], &qptr[1], &rwork[iz], &rwork[ | |||
| iz + *n], info); | |||
| /* When solving the final problem, we no longer need the stored data, */ | |||
| /* so we will overwrite the data from this level onto the previously */ | |||
| /* used storage space. */ | |||
| if (*curlvl == *tlvls) { | |||
| qptr[curr] = 1; | |||
| prmptr[curr] = 1; | |||
| givptr[curr] = 1; | |||
| } | |||
| /* Sort and Deflate eigenvalues. */ | |||
| zlaed8_(&k, n, qsiz, &q[q_offset], ldq, &d__[1], rho, cutpnt, &rwork[iz], | |||
| &rwork[idlmda], &work[1], qsiz, &rwork[iw], &iwork[indxp], &iwork[ | |||
| indx], &indxq[1], &perm[prmptr[curr]], &givptr[curr + 1], &givcol[ | |||
| (givptr[curr] << 1) + 1], &givnum[(givptr[curr] << 1) + 1], info); | |||
| prmptr[curr + 1] = prmptr[curr] + *n; | |||
| givptr[curr + 1] += givptr[curr]; | |||
| /* Solve Secular Equation. */ | |||
| if (k != 0) { | |||
| dlaed9_(&k, &c__1, &k, n, &d__[1], &rwork[iq], &k, rho, &rwork[idlmda] | |||
| , &rwork[iw], &qstore[qptr[curr]], &k, info); | |||
| zlacrm_(qsiz, &k, &work[1], qsiz, &qstore[qptr[curr]], &k, &q[ | |||
| q_offset], ldq, &rwork[iq]); | |||
| /* Computing 2nd power */ | |||
| i__1 = k; | |||
| qptr[curr + 1] = qptr[curr] + i__1 * i__1; | |||
| if (*info != 0) { | |||
| return 0; | |||
| } | |||
| /* Prepare the INDXQ sorting premutation. */ | |||
| n1 = k; | |||
| n2 = *n - k; | |||
| dlamrg_(&n1, &n2, &d__[1], &c__1, &c_n1, &indxq[1]); | |||
| } else { | |||
| qptr[curr + 1] = qptr[curr]; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| indxq[i__] = i__; | |||
| /* L20: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLAED7 */ | |||
| } /* zlaed7_ */ | |||
| @@ -0,0 +1,918 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublereal c_b3 = -1.; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLAED8 used by sstedc. Merges eigenvalues and deflates secular equation. Used when the original | |||
| matrix is dense. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAED8 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaed8. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaed8. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaed8. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAED8( K, N, QSIZ, Q, LDQ, D, RHO, CUTPNT, Z, DLAMDA, */ | |||
| /* Q2, LDQ2, W, INDXP, INDX, INDXQ, PERM, GIVPTR, */ | |||
| /* GIVCOL, GIVNUM, INFO ) */ | |||
| /* INTEGER CUTPNT, GIVPTR, INFO, K, LDQ, LDQ2, N, QSIZ */ | |||
| /* DOUBLE PRECISION RHO */ | |||
| /* INTEGER GIVCOL( 2, * ), INDX( * ), INDXP( * ), */ | |||
| /* $ INDXQ( * ), PERM( * ) */ | |||
| /* DOUBLE PRECISION D( * ), DLAMDA( * ), GIVNUM( 2, * ), W( * ), */ | |||
| /* $ Z( * ) */ | |||
| /* COMPLEX*16 Q( LDQ, * ), Q2( LDQ2, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAED8 merges the two sets of eigenvalues together into a single */ | |||
| /* > sorted set. Then it tries to deflate the size of the problem. */ | |||
| /* > There are two ways in which deflation can occur: when two or more */ | |||
| /* > eigenvalues are close together or if there is a tiny element in the */ | |||
| /* > Z vector. For each such occurrence the order of the related secular */ | |||
| /* > equation problem is reduced by one. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[out] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > Contains the number of non-deflated eigenvalues. */ | |||
| /* > This is the order of the related secular equation. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The dimension of the symmetric tridiagonal matrix. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] QSIZ */ | |||
| /* > \verbatim */ | |||
| /* > QSIZ is INTEGER */ | |||
| /* > The dimension of the unitary matrix used to reduce */ | |||
| /* > the dense or band matrix to tridiagonal form. */ | |||
| /* > QSIZ >= N if ICOMPQ = 1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] Q */ | |||
| /* > \verbatim */ | |||
| /* > Q is COMPLEX*16 array, dimension (LDQ,N) */ | |||
| /* > On entry, Q contains the eigenvectors of the partially solved */ | |||
| /* > system which has been previously updated in matrix */ | |||
| /* > multiplies with other partially solved eigensystems. */ | |||
| /* > On exit, Q contains the trailing (N-K) updated eigenvectors */ | |||
| /* > (those which were deflated) in its last N-K columns. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDQ */ | |||
| /* > \verbatim */ | |||
| /* > LDQ is INTEGER */ | |||
| /* > The leading dimension of the array Q. LDQ >= f2cmax( 1, N ). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] D */ | |||
| /* > \verbatim */ | |||
| /* > D is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > On entry, D contains the eigenvalues of the two submatrices to */ | |||
| /* > be combined. On exit, D contains the trailing (N-K) updated */ | |||
| /* > eigenvalues (those which were deflated) sorted into increasing */ | |||
| /* > order. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] RHO */ | |||
| /* > \verbatim */ | |||
| /* > RHO is DOUBLE PRECISION */ | |||
| /* > Contains the off diagonal element associated with the rank-1 */ | |||
| /* > cut which originally split the two submatrices which are now */ | |||
| /* > being recombined. RHO is modified during the computation to */ | |||
| /* > the value required by DLAED3. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] CUTPNT */ | |||
| /* > \verbatim */ | |||
| /* > CUTPNT is INTEGER */ | |||
| /* > Contains the location of the last eigenvalue in the leading */ | |||
| /* > sub-matrix. MIN(1,N) <= CUTPNT <= N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] Z */ | |||
| /* > \verbatim */ | |||
| /* > Z is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > On input this vector contains the updating vector (the last */ | |||
| /* > row of the first sub-eigenvector matrix and the first row of */ | |||
| /* > the second sub-eigenvector matrix). The contents of Z are */ | |||
| /* > destroyed during the updating process. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] DLAMDA */ | |||
| /* > \verbatim */ | |||
| /* > DLAMDA is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > Contains a copy of the first K eigenvalues which will be used */ | |||
| /* > by DLAED3 to form the secular equation. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] Q2 */ | |||
| /* > \verbatim */ | |||
| /* > Q2 is COMPLEX*16 array, dimension (LDQ2,N) */ | |||
| /* > If ICOMPQ = 0, Q2 is not referenced. Otherwise, */ | |||
| /* > Contains a copy of the first K eigenvectors which will be used */ | |||
| /* > by DLAED7 in a matrix multiply (DGEMM) to update the new */ | |||
| /* > eigenvectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDQ2 */ | |||
| /* > \verbatim */ | |||
| /* > LDQ2 is INTEGER */ | |||
| /* > The leading dimension of the array Q2. LDQ2 >= f2cmax( 1, N ). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] W */ | |||
| /* > \verbatim */ | |||
| /* > W is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > This will hold the first k values of the final */ | |||
| /* > deflation-altered z-vector and will be passed to DLAED3. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INDXP */ | |||
| /* > \verbatim */ | |||
| /* > INDXP is INTEGER array, dimension (N) */ | |||
| /* > This will contain the permutation used to place deflated */ | |||
| /* > values of D at the end of the array. On output INDXP(1:K) */ | |||
| /* > points to the nondeflated D-values and INDXP(K+1:N) */ | |||
| /* > points to the deflated eigenvalues. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INDX */ | |||
| /* > \verbatim */ | |||
| /* > INDX is INTEGER array, dimension (N) */ | |||
| /* > This will contain the permutation used to sort the contents of */ | |||
| /* > D into ascending order. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INDXQ */ | |||
| /* > \verbatim */ | |||
| /* > INDXQ is INTEGER array, dimension (N) */ | |||
| /* > This contains the permutation which separately sorts the two */ | |||
| /* > sub-problems in D into ascending order. Note that elements in */ | |||
| /* > the second half of this permutation must first have CUTPNT */ | |||
| /* > added to their values in order to be accurate. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] PERM */ | |||
| /* > \verbatim */ | |||
| /* > PERM is INTEGER array, dimension (N) */ | |||
| /* > Contains the permutations (from deflation and sorting) to be */ | |||
| /* > applied to each eigenblock. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] GIVPTR */ | |||
| /* > \verbatim */ | |||
| /* > GIVPTR is INTEGER */ | |||
| /* > Contains the number of Givens rotations which took place in */ | |||
| /* > this subproblem. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] GIVCOL */ | |||
| /* > \verbatim */ | |||
| /* > GIVCOL is INTEGER array, dimension (2, N) */ | |||
| /* > Each pair of numbers indicates a pair of columns to take place */ | |||
| /* > in a Givens rotation. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] GIVNUM */ | |||
| /* > \verbatim */ | |||
| /* > GIVNUM is DOUBLE PRECISION array, dimension (2, N) */ | |||
| /* > Each number indicates the S value to be used in the */ | |||
| /* > corresponding Givens rotation. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit. */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaed8_(integer *k, integer *n, integer *qsiz, | |||
| doublecomplex *q, integer *ldq, doublereal *d__, doublereal *rho, | |||
| integer *cutpnt, doublereal *z__, doublereal *dlamda, doublecomplex * | |||
| q2, integer *ldq2, doublereal *w, integer *indxp, integer *indx, | |||
| integer *indxq, integer *perm, integer *givptr, integer *givcol, | |||
| doublereal *givnum, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer q_dim1, q_offset, q2_dim1, q2_offset, i__1; | |||
| doublereal d__1; | |||
| /* Local variables */ | |||
| integer jlam, imax, jmax; | |||
| doublereal c__; | |||
| integer i__, j; | |||
| doublereal s, t; | |||
| extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, | |||
| integer *), dcopy_(integer *, doublereal *, integer *, doublereal | |||
| *, integer *); | |||
| integer k2, n1, n2; | |||
| extern /* Subroutine */ int zdrot_(integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublereal *, doublereal *), zcopy_( | |||
| integer *, doublecomplex *, integer *, doublecomplex *, integer *) | |||
| ; | |||
| extern doublereal dlapy2_(doublereal *, doublereal *), dlamch_(char *); | |||
| integer jp; | |||
| extern integer idamax_(integer *, doublereal *, integer *); | |||
| extern /* Subroutine */ int dlamrg_(integer *, integer *, doublereal *, | |||
| integer *, integer *, integer *), xerbla_(char *, integer *, ftnlen), zlacpy_(char *, integer *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, integer *); | |||
| integer n1p1; | |||
| doublereal eps, tau, tol; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| q_dim1 = *ldq; | |||
| q_offset = 1 + q_dim1 * 1; | |||
| q -= q_offset; | |||
| --d__; | |||
| --z__; | |||
| --dlamda; | |||
| q2_dim1 = *ldq2; | |||
| q2_offset = 1 + q2_dim1 * 1; | |||
| q2 -= q2_offset; | |||
| --w; | |||
| --indxp; | |||
| --indx; | |||
| --indxq; | |||
| --perm; | |||
| givcol -= 3; | |||
| givnum -= 3; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*qsiz < *n) { | |||
| *info = -3; | |||
| } else if (*ldq < f2cmax(1,*n)) { | |||
| *info = -5; | |||
| } else if (*cutpnt < f2cmin(1,*n) || *cutpnt > *n) { | |||
| *info = -8; | |||
| } else if (*ldq2 < f2cmax(1,*n)) { | |||
| *info = -12; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("ZLAED8", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Need to initialize GIVPTR to O here in case of quick exit */ | |||
| /* to prevent an unspecified code behavior (usually sigfault) */ | |||
| /* when IWORK array on entry to *stedc is not zeroed */ | |||
| /* (or at least some IWORK entries which used in *laed7 for GIVPTR). */ | |||
| *givptr = 0; | |||
| /* Quick return if possible */ | |||
| if (*n == 0) { | |||
| return 0; | |||
| } | |||
| n1 = *cutpnt; | |||
| n2 = *n - n1; | |||
| n1p1 = n1 + 1; | |||
| if (*rho < 0.) { | |||
| dscal_(&n2, &c_b3, &z__[n1p1], &c__1); | |||
| } | |||
| /* Normalize z so that norm(z) = 1 */ | |||
| t = 1. / sqrt(2.); | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| indx[j] = j; | |||
| /* L10: */ | |||
| } | |||
| dscal_(n, &t, &z__[1], &c__1); | |||
| *rho = (d__1 = *rho * 2., abs(d__1)); | |||
| /* Sort the eigenvalues into increasing order */ | |||
| i__1 = *n; | |||
| for (i__ = *cutpnt + 1; i__ <= i__1; ++i__) { | |||
| indxq[i__] += *cutpnt; | |||
| /* L20: */ | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| dlamda[i__] = d__[indxq[i__]]; | |||
| w[i__] = z__[indxq[i__]]; | |||
| /* L30: */ | |||
| } | |||
| i__ = 1; | |||
| j = *cutpnt + 1; | |||
| dlamrg_(&n1, &n2, &dlamda[1], &c__1, &c__1, &indx[1]); | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| d__[i__] = dlamda[indx[i__]]; | |||
| z__[i__] = w[indx[i__]]; | |||
| /* L40: */ | |||
| } | |||
| /* Calculate the allowable deflation tolerance */ | |||
| imax = idamax_(n, &z__[1], &c__1); | |||
| jmax = idamax_(n, &d__[1], &c__1); | |||
| eps = dlamch_("Epsilon"); | |||
| tol = eps * 8. * (d__1 = d__[jmax], abs(d__1)); | |||
| /* If the rank-1 modifier is small enough, no more needs to be done */ | |||
| /* -- except to reorganize Q so that its columns correspond with the */ | |||
| /* elements in D. */ | |||
| if (*rho * (d__1 = z__[imax], abs(d__1)) <= tol) { | |||
| *k = 0; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| perm[j] = indxq[indx[j]]; | |||
| zcopy_(qsiz, &q[perm[j] * q_dim1 + 1], &c__1, &q2[j * q2_dim1 + 1] | |||
| , &c__1); | |||
| /* L50: */ | |||
| } | |||
| zlacpy_("A", qsiz, n, &q2[q2_dim1 + 1], ldq2, &q[q_dim1 + 1], ldq); | |||
| return 0; | |||
| } | |||
| /* If there are multiple eigenvalues then the problem deflates. Here */ | |||
| /* the number of equal eigenvalues are found. As each equal */ | |||
| /* eigenvalue is found, an elementary reflector is computed to rotate */ | |||
| /* the corresponding eigensubspace so that the corresponding */ | |||
| /* components of Z are zero in this new basis. */ | |||
| *k = 0; | |||
| k2 = *n + 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (*rho * (d__1 = z__[j], abs(d__1)) <= tol) { | |||
| /* Deflate due to small z component. */ | |||
| --k2; | |||
| indxp[k2] = j; | |||
| if (j == *n) { | |||
| goto L100; | |||
| } | |||
| } else { | |||
| jlam = j; | |||
| goto L70; | |||
| } | |||
| /* L60: */ | |||
| } | |||
| L70: | |||
| ++j; | |||
| if (j > *n) { | |||
| goto L90; | |||
| } | |||
| if (*rho * (d__1 = z__[j], abs(d__1)) <= tol) { | |||
| /* Deflate due to small z component. */ | |||
| --k2; | |||
| indxp[k2] = j; | |||
| } else { | |||
| /* Check if eigenvalues are close enough to allow deflation. */ | |||
| s = z__[jlam]; | |||
| c__ = z__[j]; | |||
| /* Find sqrt(a**2+b**2) without overflow or */ | |||
| /* destructive underflow. */ | |||
| tau = dlapy2_(&c__, &s); | |||
| t = d__[j] - d__[jlam]; | |||
| c__ /= tau; | |||
| s = -s / tau; | |||
| if ((d__1 = t * c__ * s, abs(d__1)) <= tol) { | |||
| /* Deflation is possible. */ | |||
| z__[j] = tau; | |||
| z__[jlam] = 0.; | |||
| /* Record the appropriate Givens rotation */ | |||
| ++(*givptr); | |||
| givcol[(*givptr << 1) + 1] = indxq[indx[jlam]]; | |||
| givcol[(*givptr << 1) + 2] = indxq[indx[j]]; | |||
| givnum[(*givptr << 1) + 1] = c__; | |||
| givnum[(*givptr << 1) + 2] = s; | |||
| zdrot_(qsiz, &q[indxq[indx[jlam]] * q_dim1 + 1], &c__1, &q[indxq[ | |||
| indx[j]] * q_dim1 + 1], &c__1, &c__, &s); | |||
| t = d__[jlam] * c__ * c__ + d__[j] * s * s; | |||
| d__[j] = d__[jlam] * s * s + d__[j] * c__ * c__; | |||
| d__[jlam] = t; | |||
| --k2; | |||
| i__ = 1; | |||
| L80: | |||
| if (k2 + i__ <= *n) { | |||
| if (d__[jlam] < d__[indxp[k2 + i__]]) { | |||
| indxp[k2 + i__ - 1] = indxp[k2 + i__]; | |||
| indxp[k2 + i__] = jlam; | |||
| ++i__; | |||
| goto L80; | |||
| } else { | |||
| indxp[k2 + i__ - 1] = jlam; | |||
| } | |||
| } else { | |||
| indxp[k2 + i__ - 1] = jlam; | |||
| } | |||
| jlam = j; | |||
| } else { | |||
| ++(*k); | |||
| w[*k] = z__[jlam]; | |||
| dlamda[*k] = d__[jlam]; | |||
| indxp[*k] = jlam; | |||
| jlam = j; | |||
| } | |||
| } | |||
| goto L70; | |||
| L90: | |||
| /* Record the last eigenvalue. */ | |||
| ++(*k); | |||
| w[*k] = z__[jlam]; | |||
| dlamda[*k] = d__[jlam]; | |||
| indxp[*k] = jlam; | |||
| L100: | |||
| /* Sort the eigenvalues and corresponding eigenvectors into DLAMDA */ | |||
| /* and Q2 respectively. The eigenvalues/vectors which were not */ | |||
| /* deflated go into the first K slots of DLAMDA and Q2 respectively, */ | |||
| /* while those which were deflated go into the last N - K slots. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| jp = indxp[j]; | |||
| dlamda[j] = d__[jp]; | |||
| perm[j] = indxq[indx[jp]]; | |||
| zcopy_(qsiz, &q[perm[j] * q_dim1 + 1], &c__1, &q2[j * q2_dim1 + 1], & | |||
| c__1); | |||
| /* L110: */ | |||
| } | |||
| /* The deflated eigenvalues and their corresponding vectors go back */ | |||
| /* into the last N - K slots of D and Q respectively. */ | |||
| if (*k < *n) { | |||
| i__1 = *n - *k; | |||
| dcopy_(&i__1, &dlamda[*k + 1], &c__1, &d__[*k + 1], &c__1); | |||
| i__1 = *n - *k; | |||
| zlacpy_("A", qsiz, &i__1, &q2[(*k + 1) * q2_dim1 + 1], ldq2, &q[(*k + | |||
| 1) * q_dim1 + 1], ldq); | |||
| } | |||
| return 0; | |||
| /* End of ZLAED8 */ | |||
| } /* zlaed8_ */ | |||
| @@ -0,0 +1,842 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLAEIN computes a specified right or left eigenvector of an upper Hessenberg matrix by inverse | |||
| iteration. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAEIN + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaein. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaein. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaein. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAEIN( RIGHTV, NOINIT, N, H, LDH, W, V, B, LDB, RWORK, */ | |||
| /* EPS3, SMLNUM, INFO ) */ | |||
| /* LOGICAL NOINIT, RIGHTV */ | |||
| /* INTEGER INFO, LDB, LDH, N */ | |||
| /* DOUBLE PRECISION EPS3, SMLNUM */ | |||
| /* COMPLEX*16 W */ | |||
| /* DOUBLE PRECISION RWORK( * ) */ | |||
| /* COMPLEX*16 B( LDB, * ), H( LDH, * ), V( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAEIN uses inverse iteration to find a right or left eigenvector */ | |||
| /* > corresponding to the eigenvalue W of a complex upper Hessenberg */ | |||
| /* > matrix H. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] RIGHTV */ | |||
| /* > \verbatim */ | |||
| /* > RIGHTV is LOGICAL */ | |||
| /* > = .TRUE. : compute right eigenvector; */ | |||
| /* > = .FALSE.: compute left eigenvector. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NOINIT */ | |||
| /* > \verbatim */ | |||
| /* > NOINIT is LOGICAL */ | |||
| /* > = .TRUE. : no initial vector supplied in V */ | |||
| /* > = .FALSE.: initial vector supplied in V. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix H. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] H */ | |||
| /* > \verbatim */ | |||
| /* > H is COMPLEX*16 array, dimension (LDH,N) */ | |||
| /* > The upper Hessenberg matrix H. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDH */ | |||
| /* > \verbatim */ | |||
| /* > LDH is INTEGER */ | |||
| /* > The leading dimension of the array H. LDH >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] W */ | |||
| /* > \verbatim */ | |||
| /* > W is COMPLEX*16 */ | |||
| /* > The eigenvalue of H whose corresponding right or left */ | |||
| /* > eigenvector is to be computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX*16 array, dimension (N) */ | |||
| /* > On entry, if NOINIT = .FALSE., V must contain a starting */ | |||
| /* > vector for inverse iteration; otherwise V need not be set. */ | |||
| /* > On exit, V contains the computed eigenvector, normalized so */ | |||
| /* > that the component of largest magnitude has magnitude 1; here */ | |||
| /* > the magnitude of a complex number (x,y) is taken to be */ | |||
| /* > |x| + |y|. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX*16 array, dimension (LDB,N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] EPS3 */ | |||
| /* > \verbatim */ | |||
| /* > EPS3 is DOUBLE PRECISION */ | |||
| /* > A small machine-dependent value which is used to perturb */ | |||
| /* > close eigenvalues, and to replace zero pivots. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SMLNUM */ | |||
| /* > \verbatim */ | |||
| /* > SMLNUM is DOUBLE PRECISION */ | |||
| /* > A machine-dependent value close to the underflow threshold. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > = 1: inverse iteration did not converge; V is set to the */ | |||
| /* > last iterate. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaein_(logical *rightv, logical *noinit, integer *n, | |||
| doublecomplex *h__, integer *ldh, doublecomplex *w, doublecomplex *v, | |||
| doublecomplex *b, integer *ldb, doublereal *rwork, doublereal *eps3, | |||
| doublereal *smlnum, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer b_dim1, b_offset, h_dim1, h_offset, i__1, i__2, i__3, i__4, i__5; | |||
| doublereal d__1, d__2, d__3, d__4; | |||
| doublecomplex z__1, z__2; | |||
| /* Local variables */ | |||
| integer ierr; | |||
| doublecomplex temp; | |||
| integer i__, j; | |||
| doublereal scale; | |||
| doublecomplex x; | |||
| char trans[1]; | |||
| doublereal rtemp, rootn, vnorm; | |||
| extern doublereal dznrm2_(integer *, doublecomplex *, integer *); | |||
| doublecomplex ei, ej; | |||
| extern /* Subroutine */ int zdscal_(integer *, doublereal *, | |||
| doublecomplex *, integer *); | |||
| extern integer izamax_(integer *, doublecomplex *, integer *); | |||
| extern /* Double Complex */ VOID zladiv_(doublecomplex *, doublecomplex *, | |||
| doublecomplex *); | |||
| char normin[1]; | |||
| extern doublereal dzasum_(integer *, doublecomplex *, integer *); | |||
| doublereal nrmsml; | |||
| extern /* Subroutine */ int zlatrs_(char *, char *, char *, char *, | |||
| integer *, doublecomplex *, integer *, doublecomplex *, | |||
| doublereal *, doublereal *, integer *); | |||
| doublereal growto; | |||
| integer its; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| h_dim1 = *ldh; | |||
| h_offset = 1 + h_dim1 * 1; | |||
| h__ -= h_offset; | |||
| --v; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| --rwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| /* GROWTO is the threshold used in the acceptance test for an */ | |||
| /* eigenvector. */ | |||
| rootn = sqrt((doublereal) (*n)); | |||
| growto = .1 / rootn; | |||
| /* Computing MAX */ | |||
| d__1 = 1., d__2 = *eps3 * rootn; | |||
| nrmsml = f2cmax(d__1,d__2) * *smlnum; | |||
| /* Form B = H - W*I (except that the subdiagonal elements are not */ | |||
| /* stored). */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = j - 1; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| i__4 = i__ + j * h_dim1; | |||
| b[i__3].r = h__[i__4].r, b[i__3].i = h__[i__4].i; | |||
| /* L10: */ | |||
| } | |||
| i__2 = j + j * b_dim1; | |||
| i__3 = j + j * h_dim1; | |||
| z__1.r = h__[i__3].r - w->r, z__1.i = h__[i__3].i - w->i; | |||
| b[i__2].r = z__1.r, b[i__2].i = z__1.i; | |||
| /* L20: */ | |||
| } | |||
| if (*noinit) { | |||
| /* Initialize V. */ | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| v[i__2].r = *eps3, v[i__2].i = 0.; | |||
| /* L30: */ | |||
| } | |||
| } else { | |||
| /* Scale supplied initial vector. */ | |||
| vnorm = dznrm2_(n, &v[1], &c__1); | |||
| d__1 = *eps3 * rootn / f2cmax(vnorm,nrmsml); | |||
| zdscal_(n, &d__1, &v[1], &c__1); | |||
| } | |||
| if (*rightv) { | |||
| /* LU decomposition with partial pivoting of B, replacing zero */ | |||
| /* pivots by EPS3. */ | |||
| i__1 = *n - 1; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__ + 1 + i__ * h_dim1; | |||
| ei.r = h__[i__2].r, ei.i = h__[i__2].i; | |||
| i__2 = i__ + i__ * b_dim1; | |||
| if ((d__1 = b[i__2].r, abs(d__1)) + (d__2 = d_imag(&b[i__ + i__ * | |||
| b_dim1]), abs(d__2)) < (d__3 = ei.r, abs(d__3)) + (d__4 = | |||
| d_imag(&ei), abs(d__4))) { | |||
| /* Interchange rows and eliminate. */ | |||
| zladiv_(&z__1, &b[i__ + i__ * b_dim1], &ei); | |||
| x.r = z__1.r, x.i = z__1.i; | |||
| i__2 = i__ + i__ * b_dim1; | |||
| b[i__2].r = ei.r, b[i__2].i = ei.i; | |||
| i__2 = *n; | |||
| for (j = i__ + 1; j <= i__2; ++j) { | |||
| i__3 = i__ + 1 + j * b_dim1; | |||
| temp.r = b[i__3].r, temp.i = b[i__3].i; | |||
| i__3 = i__ + 1 + j * b_dim1; | |||
| i__4 = i__ + j * b_dim1; | |||
| z__2.r = x.r * temp.r - x.i * temp.i, z__2.i = x.r * | |||
| temp.i + x.i * temp.r; | |||
| z__1.r = b[i__4].r - z__2.r, z__1.i = b[i__4].i - z__2.i; | |||
| b[i__3].r = z__1.r, b[i__3].i = z__1.i; | |||
| i__3 = i__ + j * b_dim1; | |||
| b[i__3].r = temp.r, b[i__3].i = temp.i; | |||
| /* L40: */ | |||
| } | |||
| } else { | |||
| /* Eliminate without interchange. */ | |||
| i__2 = i__ + i__ * b_dim1; | |||
| if (b[i__2].r == 0. && b[i__2].i == 0.) { | |||
| i__3 = i__ + i__ * b_dim1; | |||
| b[i__3].r = *eps3, b[i__3].i = 0.; | |||
| } | |||
| zladiv_(&z__1, &ei, &b[i__ + i__ * b_dim1]); | |||
| x.r = z__1.r, x.i = z__1.i; | |||
| if (x.r != 0. || x.i != 0.) { | |||
| i__2 = *n; | |||
| for (j = i__ + 1; j <= i__2; ++j) { | |||
| i__3 = i__ + 1 + j * b_dim1; | |||
| i__4 = i__ + 1 + j * b_dim1; | |||
| i__5 = i__ + j * b_dim1; | |||
| z__2.r = x.r * b[i__5].r - x.i * b[i__5].i, z__2.i = | |||
| x.r * b[i__5].i + x.i * b[i__5].r; | |||
| z__1.r = b[i__4].r - z__2.r, z__1.i = b[i__4].i - | |||
| z__2.i; | |||
| b[i__3].r = z__1.r, b[i__3].i = z__1.i; | |||
| /* L50: */ | |||
| } | |||
| } | |||
| } | |||
| /* L60: */ | |||
| } | |||
| i__1 = *n + *n * b_dim1; | |||
| if (b[i__1].r == 0. && b[i__1].i == 0.) { | |||
| i__2 = *n + *n * b_dim1; | |||
| b[i__2].r = *eps3, b[i__2].i = 0.; | |||
| } | |||
| *(unsigned char *)trans = 'N'; | |||
| } else { | |||
| /* UL decomposition with partial pivoting of B, replacing zero */ | |||
| /* pivots by EPS3. */ | |||
| for (j = *n; j >= 2; --j) { | |||
| i__1 = j + (j - 1) * h_dim1; | |||
| ej.r = h__[i__1].r, ej.i = h__[i__1].i; | |||
| i__1 = j + j * b_dim1; | |||
| if ((d__1 = b[i__1].r, abs(d__1)) + (d__2 = d_imag(&b[j + j * | |||
| b_dim1]), abs(d__2)) < (d__3 = ej.r, abs(d__3)) + (d__4 = | |||
| d_imag(&ej), abs(d__4))) { | |||
| /* Interchange columns and eliminate. */ | |||
| zladiv_(&z__1, &b[j + j * b_dim1], &ej); | |||
| x.r = z__1.r, x.i = z__1.i; | |||
| i__1 = j + j * b_dim1; | |||
| b[i__1].r = ej.r, b[i__1].i = ej.i; | |||
| i__1 = j - 1; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__ + (j - 1) * b_dim1; | |||
| temp.r = b[i__2].r, temp.i = b[i__2].i; | |||
| i__2 = i__ + (j - 1) * b_dim1; | |||
| i__3 = i__ + j * b_dim1; | |||
| z__2.r = x.r * temp.r - x.i * temp.i, z__2.i = x.r * | |||
| temp.i + x.i * temp.r; | |||
| z__1.r = b[i__3].r - z__2.r, z__1.i = b[i__3].i - z__2.i; | |||
| b[i__2].r = z__1.r, b[i__2].i = z__1.i; | |||
| i__2 = i__ + j * b_dim1; | |||
| b[i__2].r = temp.r, b[i__2].i = temp.i; | |||
| /* L70: */ | |||
| } | |||
| } else { | |||
| /* Eliminate without interchange. */ | |||
| i__1 = j + j * b_dim1; | |||
| if (b[i__1].r == 0. && b[i__1].i == 0.) { | |||
| i__2 = j + j * b_dim1; | |||
| b[i__2].r = *eps3, b[i__2].i = 0.; | |||
| } | |||
| zladiv_(&z__1, &ej, &b[j + j * b_dim1]); | |||
| x.r = z__1.r, x.i = z__1.i; | |||
| if (x.r != 0. || x.i != 0.) { | |||
| i__1 = j - 1; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__ + (j - 1) * b_dim1; | |||
| i__3 = i__ + (j - 1) * b_dim1; | |||
| i__4 = i__ + j * b_dim1; | |||
| z__2.r = x.r * b[i__4].r - x.i * b[i__4].i, z__2.i = | |||
| x.r * b[i__4].i + x.i * b[i__4].r; | |||
| z__1.r = b[i__3].r - z__2.r, z__1.i = b[i__3].i - | |||
| z__2.i; | |||
| b[i__2].r = z__1.r, b[i__2].i = z__1.i; | |||
| /* L80: */ | |||
| } | |||
| } | |||
| } | |||
| /* L90: */ | |||
| } | |||
| i__1 = b_dim1 + 1; | |||
| if (b[i__1].r == 0. && b[i__1].i == 0.) { | |||
| i__2 = b_dim1 + 1; | |||
| b[i__2].r = *eps3, b[i__2].i = 0.; | |||
| } | |||
| *(unsigned char *)trans = 'C'; | |||
| } | |||
| *(unsigned char *)normin = 'N'; | |||
| i__1 = *n; | |||
| for (its = 1; its <= i__1; ++its) { | |||
| /* Solve U*x = scale*v for a right eigenvector */ | |||
| /* or U**H *x = scale*v for a left eigenvector, */ | |||
| /* overwriting x on v. */ | |||
| zlatrs_("Upper", trans, "Nonunit", normin, n, &b[b_offset], ldb, &v[1] | |||
| , &scale, &rwork[1], &ierr); | |||
| *(unsigned char *)normin = 'Y'; | |||
| /* Test for sufficient growth in the norm of v. */ | |||
| vnorm = dzasum_(n, &v[1], &c__1); | |||
| if (vnorm >= growto * scale) { | |||
| goto L120; | |||
| } | |||
| /* Choose new orthogonal starting vector and try again. */ | |||
| rtemp = *eps3 / (rootn + 1.); | |||
| v[1].r = *eps3, v[1].i = 0.; | |||
| i__2 = *n; | |||
| for (i__ = 2; i__ <= i__2; ++i__) { | |||
| i__3 = i__; | |||
| v[i__3].r = rtemp, v[i__3].i = 0.; | |||
| /* L100: */ | |||
| } | |||
| i__2 = *n - its + 1; | |||
| i__3 = *n - its + 1; | |||
| d__1 = *eps3 * rootn; | |||
| z__1.r = v[i__3].r - d__1, z__1.i = v[i__3].i; | |||
| v[i__2].r = z__1.r, v[i__2].i = z__1.i; | |||
| /* L110: */ | |||
| } | |||
| /* Failure to find eigenvector in N iterations. */ | |||
| *info = 1; | |||
| L120: | |||
| /* Normalize eigenvector. */ | |||
| i__ = izamax_(n, &v[1], &c__1); | |||
| i__1 = i__; | |||
| d__3 = 1. / ((d__1 = v[i__1].r, abs(d__1)) + (d__2 = d_imag(&v[i__]), abs( | |||
| d__2))); | |||
| zdscal_(n, &d__3, &v[1], &c__1); | |||
| return 0; | |||
| /* End of ZLAEIN */ | |||
| } /* zlaein_ */ | |||
| @@ -0,0 +1,637 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {1.,0.}; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b ZLAESY computes the eigenvalues and eigenvectors of a 2-by-2 complex symmetric matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAESY + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaesy. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaesy. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaesy. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAESY( A, B, C, RT1, RT2, EVSCAL, CS1, SN1 ) */ | |||
| /* COMPLEX*16 A, B, C, CS1, EVSCAL, RT1, RT2, SN1 */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAESY computes the eigendecomposition of a 2-by-2 symmetric matrix */ | |||
| /* > ( ( A, B );( B, C ) ) */ | |||
| /* > provided the norm of the matrix of eigenvectors is larger than */ | |||
| /* > some threshold value. */ | |||
| /* > */ | |||
| /* > RT1 is the eigenvalue of larger absolute value, and RT2 of */ | |||
| /* > smaller absolute value. If the eigenvectors are computed, then */ | |||
| /* > on return ( CS1, SN1 ) is the unit eigenvector for RT1, hence */ | |||
| /* > */ | |||
| /* > [ CS1 SN1 ] . [ A B ] . [ CS1 -SN1 ] = [ RT1 0 ] */ | |||
| /* > [ -SN1 CS1 ] [ B C ] [ SN1 CS1 ] [ 0 RT2 ] */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 */ | |||
| /* > The ( 1, 1 ) element of input matrix. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX*16 */ | |||
| /* > The ( 1, 2 ) element of input matrix. The ( 2, 1 ) element */ | |||
| /* > is also given by B, since the 2-by-2 matrix is symmetric. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX*16 */ | |||
| /* > The ( 2, 2 ) element of input matrix. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RT1 */ | |||
| /* > \verbatim */ | |||
| /* > RT1 is COMPLEX*16 */ | |||
| /* > The eigenvalue of larger modulus. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RT2 */ | |||
| /* > \verbatim */ | |||
| /* > RT2 is COMPLEX*16 */ | |||
| /* > The eigenvalue of smaller modulus. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] EVSCAL */ | |||
| /* > \verbatim */ | |||
| /* > EVSCAL is COMPLEX*16 */ | |||
| /* > The complex value by which the eigenvector matrix was scaled */ | |||
| /* > to make it orthonormal. If EVSCAL is zero, the eigenvectors */ | |||
| /* > were not computed. This means one of two things: the 2-by-2 */ | |||
| /* > matrix could not be diagonalized, or the norm of the matrix */ | |||
| /* > of eigenvectors before scaling was larger than the threshold */ | |||
| /* > value THRESH (set below). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] CS1 */ | |||
| /* > \verbatim */ | |||
| /* > CS1 is COMPLEX*16 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SN1 */ | |||
| /* > \verbatim */ | |||
| /* > SN1 is COMPLEX*16 */ | |||
| /* > If EVSCAL .NE. 0, ( CS1, SN1 ) is the unit right eigenvector */ | |||
| /* > for RT1. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16SYauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaesy_(doublecomplex *a, doublecomplex *b, | |||
| doublecomplex *c__, doublecomplex *rt1, doublecomplex *rt2, | |||
| doublecomplex *evscal, doublecomplex *cs1, doublecomplex *sn1) | |||
| { | |||
| /* System generated locals */ | |||
| doublereal d__1, d__2; | |||
| doublecomplex z__1, z__2, z__3, z__4, z__5, z__6, z__7; | |||
| /* Local variables */ | |||
| doublereal babs, tabs; | |||
| doublecomplex s, t; | |||
| doublereal z__, evnorm; | |||
| doublecomplex tmp; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Special case: The matrix is actually diagonal. */ | |||
| /* To avoid divide by zero later, we treat this case separately. */ | |||
| if (z_abs(b) == 0.) { | |||
| rt1->r = a->r, rt1->i = a->i; | |||
| rt2->r = c__->r, rt2->i = c__->i; | |||
| if (z_abs(rt1) < z_abs(rt2)) { | |||
| tmp.r = rt1->r, tmp.i = rt1->i; | |||
| rt1->r = rt2->r, rt1->i = rt2->i; | |||
| rt2->r = tmp.r, rt2->i = tmp.i; | |||
| cs1->r = 0., cs1->i = 0.; | |||
| sn1->r = 1., sn1->i = 0.; | |||
| } else { | |||
| cs1->r = 1., cs1->i = 0.; | |||
| sn1->r = 0., sn1->i = 0.; | |||
| } | |||
| } else { | |||
| /* Compute the eigenvalues and eigenvectors. */ | |||
| /* The characteristic equation is */ | |||
| /* lambda **2 - (A+C) lambda + (A*C - B*B) */ | |||
| /* and we solve it using the quadratic formula. */ | |||
| z__2.r = a->r + c__->r, z__2.i = a->i + c__->i; | |||
| z__1.r = z__2.r * .5, z__1.i = z__2.i * .5; | |||
| s.r = z__1.r, s.i = z__1.i; | |||
| z__2.r = a->r - c__->r, z__2.i = a->i - c__->i; | |||
| z__1.r = z__2.r * .5, z__1.i = z__2.i * .5; | |||
| t.r = z__1.r, t.i = z__1.i; | |||
| /* Take the square root carefully to avoid over/under flow. */ | |||
| babs = z_abs(b); | |||
| tabs = z_abs(&t); | |||
| z__ = f2cmax(babs,tabs); | |||
| if (z__ > 0.) { | |||
| z__5.r = t.r / z__, z__5.i = t.i / z__; | |||
| pow_zi(&z__4, &z__5, &c__2); | |||
| z__7.r = b->r / z__, z__7.i = b->i / z__; | |||
| pow_zi(&z__6, &z__7, &c__2); | |||
| z__3.r = z__4.r + z__6.r, z__3.i = z__4.i + z__6.i; | |||
| z_sqrt(&z__2, &z__3); | |||
| z__1.r = z__ * z__2.r, z__1.i = z__ * z__2.i; | |||
| t.r = z__1.r, t.i = z__1.i; | |||
| } | |||
| /* Compute the two eigenvalues. RT1 and RT2 are exchanged */ | |||
| /* if necessary so that RT1 will have the greater magnitude. */ | |||
| z__1.r = s.r + t.r, z__1.i = s.i + t.i; | |||
| rt1->r = z__1.r, rt1->i = z__1.i; | |||
| z__1.r = s.r - t.r, z__1.i = s.i - t.i; | |||
| rt2->r = z__1.r, rt2->i = z__1.i; | |||
| if (z_abs(rt1) < z_abs(rt2)) { | |||
| tmp.r = rt1->r, tmp.i = rt1->i; | |||
| rt1->r = rt2->r, rt1->i = rt2->i; | |||
| rt2->r = tmp.r, rt2->i = tmp.i; | |||
| } | |||
| /* Choose CS1 = 1 and SN1 to satisfy the first equation, then */ | |||
| /* scale the components of this eigenvector so that the matrix */ | |||
| /* of eigenvectors X satisfies X * X**T = I . (No scaling is */ | |||
| /* done if the norm of the eigenvalue matrix is less than THRESH.) */ | |||
| z__2.r = rt1->r - a->r, z__2.i = rt1->i - a->i; | |||
| z_div(&z__1, &z__2, b); | |||
| sn1->r = z__1.r, sn1->i = z__1.i; | |||
| tabs = z_abs(sn1); | |||
| if (tabs > 1.) { | |||
| /* Computing 2nd power */ | |||
| d__2 = 1. / tabs; | |||
| d__1 = d__2 * d__2; | |||
| z__5.r = sn1->r / tabs, z__5.i = sn1->i / tabs; | |||
| pow_zi(&z__4, &z__5, &c__2); | |||
| z__3.r = d__1 + z__4.r, z__3.i = z__4.i; | |||
| z_sqrt(&z__2, &z__3); | |||
| z__1.r = tabs * z__2.r, z__1.i = tabs * z__2.i; | |||
| t.r = z__1.r, t.i = z__1.i; | |||
| } else { | |||
| z__3.r = sn1->r * sn1->r - sn1->i * sn1->i, z__3.i = sn1->r * | |||
| sn1->i + sn1->i * sn1->r; | |||
| z__2.r = z__3.r + 1., z__2.i = z__3.i + 0.; | |||
| z_sqrt(&z__1, &z__2); | |||
| t.r = z__1.r, t.i = z__1.i; | |||
| } | |||
| evnorm = z_abs(&t); | |||
| if (evnorm >= .1) { | |||
| z_div(&z__1, &c_b1, &t); | |||
| evscal->r = z__1.r, evscal->i = z__1.i; | |||
| cs1->r = evscal->r, cs1->i = evscal->i; | |||
| z__1.r = sn1->r * evscal->r - sn1->i * evscal->i, z__1.i = sn1->r | |||
| * evscal->i + sn1->i * evscal->r; | |||
| sn1->r = z__1.r, sn1->i = z__1.i; | |||
| } else { | |||
| evscal->r = 0., evscal->i = 0.; | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLAESY */ | |||
| } /* zlaesy_ */ | |||
| @@ -0,0 +1,555 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAEV2 computes the eigenvalues and eigenvectors of a 2-by-2 symmetric/Hermitian matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAEV2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaev2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaev2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaev2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAEV2( A, B, C, RT1, RT2, CS1, SN1 ) */ | |||
| /* DOUBLE PRECISION CS1, RT1, RT2 */ | |||
| /* COMPLEX*16 A, B, C, SN1 */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAEV2 computes the eigendecomposition of a 2-by-2 Hermitian matrix */ | |||
| /* > [ A B ] */ | |||
| /* > [ CONJG(B) C ]. */ | |||
| /* > On return, RT1 is the eigenvalue of larger absolute value, RT2 is the */ | |||
| /* > eigenvalue of smaller absolute value, and (CS1,SN1) is the unit right */ | |||
| /* > eigenvector for RT1, giving the decomposition */ | |||
| /* > */ | |||
| /* > [ CS1 CONJG(SN1) ] [ A B ] [ CS1 -CONJG(SN1) ] = [ RT1 0 ] */ | |||
| /* > [-SN1 CS1 ] [ CONJG(B) C ] [ SN1 CS1 ] [ 0 RT2 ]. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 */ | |||
| /* > The (1,1) element of the 2-by-2 matrix. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX*16 */ | |||
| /* > The (1,2) element and the conjugate of the (2,1) element of */ | |||
| /* > the 2-by-2 matrix. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX*16 */ | |||
| /* > The (2,2) element of the 2-by-2 matrix. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RT1 */ | |||
| /* > \verbatim */ | |||
| /* > RT1 is DOUBLE PRECISION */ | |||
| /* > The eigenvalue of larger absolute value. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RT2 */ | |||
| /* > \verbatim */ | |||
| /* > RT2 is DOUBLE PRECISION */ | |||
| /* > The eigenvalue of smaller absolute value. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] CS1 */ | |||
| /* > \verbatim */ | |||
| /* > CS1 is DOUBLE PRECISION */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SN1 */ | |||
| /* > \verbatim */ | |||
| /* > SN1 is COMPLEX*16 */ | |||
| /* > The vector (CS1, SN1) is a unit right eigenvector for RT1. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > RT1 is accurate to a few ulps barring over/underflow. */ | |||
| /* > */ | |||
| /* > RT2 may be inaccurate if there is massive cancellation in the */ | |||
| /* > determinant A*C-B*B; higher precision or correctly rounded or */ | |||
| /* > correctly truncated arithmetic would be needed to compute RT2 */ | |||
| /* > accurately in all cases. */ | |||
| /* > */ | |||
| /* > CS1 and SN1 are accurate to a few ulps barring over/underflow. */ | |||
| /* > */ | |||
| /* > Overflow is possible only if RT1 is within a factor of 5 of overflow. */ | |||
| /* > Underflow is harmless if the input data is 0 or exceeds */ | |||
| /* > underflow_threshold / macheps. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaev2_(doublecomplex *a, doublecomplex *b, | |||
| doublecomplex *c__, doublereal *rt1, doublereal *rt2, doublereal *cs1, | |||
| doublecomplex *sn1) | |||
| { | |||
| /* System generated locals */ | |||
| doublereal d__1, d__2, d__3; | |||
| doublecomplex z__1, z__2; | |||
| /* Local variables */ | |||
| doublereal t; | |||
| doublecomplex w; | |||
| extern /* Subroutine */ int dlaev2_(doublereal *, doublereal *, | |||
| doublereal *, doublereal *, doublereal *, doublereal *, | |||
| doublereal *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| if (z_abs(b) == 0.) { | |||
| w.r = 1., w.i = 0.; | |||
| } else { | |||
| d_cnjg(&z__2, b); | |||
| d__1 = z_abs(b); | |||
| z__1.r = z__2.r / d__1, z__1.i = z__2.i / d__1; | |||
| w.r = z__1.r, w.i = z__1.i; | |||
| } | |||
| d__1 = a->r; | |||
| d__2 = z_abs(b); | |||
| d__3 = c__->r; | |||
| dlaev2_(&d__1, &d__2, &d__3, rt1, rt2, cs1, &t); | |||
| z__1.r = t * w.r, z__1.i = t * w.i; | |||
| sn1->r = z__1.r, sn1->i = z__1.i; | |||
| return 0; | |||
| /* End of ZLAEV2 */ | |||
| } /* zlaev2_ */ | |||
| @@ -0,0 +1,551 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAG2C converts a complex double precision matrix to a complex single precision matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAG2C + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlag2c. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlag2c. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlag2c. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAG2C( M, N, A, LDA, SA, LDSA, INFO ) */ | |||
| /* INTEGER INFO, LDA, LDSA, M, N */ | |||
| /* COMPLEX SA( LDSA, * ) */ | |||
| /* COMPLEX*16 A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAG2C converts a COMPLEX*16 matrix, SA, to a COMPLEX matrix, A. */ | |||
| /* > */ | |||
| /* > RMAX is the overflow for the SINGLE PRECISION arithmetic */ | |||
| /* > ZLAG2C checks that all the entries of A are between -RMAX and */ | |||
| /* > RMAX. If not the conversion is aborted and a flag is raised. */ | |||
| /* > */ | |||
| /* > This is an auxiliary routine so there is no argument checking. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of lines of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N coefficient matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SA */ | |||
| /* > \verbatim */ | |||
| /* > SA is COMPLEX array, dimension (LDSA,N) */ | |||
| /* > On exit, if INFO=0, the M-by-N coefficient matrix SA; if */ | |||
| /* > INFO>0, the content of SA is unspecified. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDSA */ | |||
| /* > \verbatim */ | |||
| /* > LDSA is INTEGER */ | |||
| /* > The leading dimension of the array SA. LDSA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit. */ | |||
| /* > = 1: an entry of the matrix A is greater than the SINGLE */ | |||
| /* > PRECISION overflow threshold, in this case, the content */ | |||
| /* > of SA in exit is unspecified. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlag2c_(integer *m, integer *n, doublecomplex *a, | |||
| integer *lda, complex *sa, integer *ldsa, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer sa_dim1, sa_offset, a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| /* Local variables */ | |||
| doublereal rmax; | |||
| integer i__, j; | |||
| extern real slamch_(char *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| sa_dim1 = *ldsa; | |||
| sa_offset = 1 + sa_dim1 * 1; | |||
| sa -= sa_offset; | |||
| /* Function Body */ | |||
| rmax = slamch_("O"); | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| if (a[i__3].r < -rmax || a[i__4].r > rmax || d_imag(&a[i__ + j * | |||
| a_dim1]) < -rmax || d_imag(&a[i__ + j * a_dim1]) > rmax) { | |||
| *info = 1; | |||
| goto L30; | |||
| } | |||
| i__3 = i__ + j * sa_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| sa[i__3].r = a[i__4].r, sa[i__3].i = a[i__4].i; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| *info = 0; | |||
| L30: | |||
| return 0; | |||
| /* End of ZLAG2C */ | |||
| } /* zlag2c_ */ | |||
| @@ -0,0 +1,916 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAGS2 */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAGS2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlags2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlags2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlags2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAGS2( UPPER, A1, A2, A3, B1, B2, B3, CSU, SNU, CSV, */ | |||
| /* SNV, CSQ, SNQ ) */ | |||
| /* LOGICAL UPPER */ | |||
| /* DOUBLE PRECISION A1, A3, B1, B3, CSQ, CSU, CSV */ | |||
| /* COMPLEX*16 A2, B2, SNQ, SNU, SNV */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAGS2 computes 2-by-2 unitary matrices U, V and Q, such */ | |||
| /* > that if ( UPPER ) then */ | |||
| /* > */ | |||
| /* > U**H *A*Q = U**H *( A1 A2 )*Q = ( x 0 ) */ | |||
| /* > ( 0 A3 ) ( x x ) */ | |||
| /* > and */ | |||
| /* > V**H*B*Q = V**H *( B1 B2 )*Q = ( x 0 ) */ | |||
| /* > ( 0 B3 ) ( x x ) */ | |||
| /* > */ | |||
| /* > or if ( .NOT.UPPER ) then */ | |||
| /* > */ | |||
| /* > U**H *A*Q = U**H *( A1 0 )*Q = ( x x ) */ | |||
| /* > ( A2 A3 ) ( 0 x ) */ | |||
| /* > and */ | |||
| /* > V**H *B*Q = V**H *( B1 0 )*Q = ( x x ) */ | |||
| /* > ( B2 B3 ) ( 0 x ) */ | |||
| /* > where */ | |||
| /* > */ | |||
| /* > U = ( CSU SNU ), V = ( CSV SNV ), */ | |||
| /* > ( -SNU**H CSU ) ( -SNV**H CSV ) */ | |||
| /* > */ | |||
| /* > Q = ( CSQ SNQ ) */ | |||
| /* > ( -SNQ**H CSQ ) */ | |||
| /* > */ | |||
| /* > The rows of the transformed A and B are parallel. Moreover, if the */ | |||
| /* > input 2-by-2 matrix A is not zero, then the transformed (1,1) entry */ | |||
| /* > of A is not zero. If the input matrices A and B are both not zero, */ | |||
| /* > then the transformed (2,2) element of B is not zero, except when the */ | |||
| /* > first rows of input A and B are parallel and the second rows are */ | |||
| /* > zero. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPPER */ | |||
| /* > \verbatim */ | |||
| /* > UPPER is LOGICAL */ | |||
| /* > = .TRUE.: the input matrices A and B are upper triangular. */ | |||
| /* > = .FALSE.: the input matrices A and B are lower triangular. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A1 */ | |||
| /* > \verbatim */ | |||
| /* > A1 is DOUBLE PRECISION */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A2 */ | |||
| /* > \verbatim */ | |||
| /* > A2 is COMPLEX*16 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A3 */ | |||
| /* > \verbatim */ | |||
| /* > A3 is DOUBLE PRECISION */ | |||
| /* > On entry, A1, A2 and A3 are elements of the input 2-by-2 */ | |||
| /* > upper (lower) triangular matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] B1 */ | |||
| /* > \verbatim */ | |||
| /* > B1 is DOUBLE PRECISION */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] B2 */ | |||
| /* > \verbatim */ | |||
| /* > B2 is COMPLEX*16 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] B3 */ | |||
| /* > \verbatim */ | |||
| /* > B3 is DOUBLE PRECISION */ | |||
| /* > On entry, B1, B2 and B3 are elements of the input 2-by-2 */ | |||
| /* > upper (lower) triangular matrix B. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] CSU */ | |||
| /* > \verbatim */ | |||
| /* > CSU is DOUBLE PRECISION */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SNU */ | |||
| /* > \verbatim */ | |||
| /* > SNU is COMPLEX*16 */ | |||
| /* > The desired unitary matrix U. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] CSV */ | |||
| /* > \verbatim */ | |||
| /* > CSV is DOUBLE PRECISION */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SNV */ | |||
| /* > \verbatim */ | |||
| /* > SNV is COMPLEX*16 */ | |||
| /* > The desired unitary matrix V. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] CSQ */ | |||
| /* > \verbatim */ | |||
| /* > CSQ is DOUBLE PRECISION */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SNQ */ | |||
| /* > \verbatim */ | |||
| /* > SNQ is COMPLEX*16 */ | |||
| /* > The desired unitary matrix Q. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlags2_(logical *upper, doublereal *a1, doublecomplex * | |||
| a2, doublereal *a3, doublereal *b1, doublecomplex *b2, doublereal *b3, | |||
| doublereal *csu, doublecomplex *snu, doublereal *csv, doublecomplex * | |||
| snv, doublereal *csq, doublecomplex *snq) | |||
| { | |||
| /* System generated locals */ | |||
| doublereal d__1, d__2, d__3, d__4, d__5, d__6, d__7, d__8; | |||
| doublecomplex z__1, z__2, z__3, z__4, z__5; | |||
| /* Local variables */ | |||
| doublereal aua11, aua12, aua21, aua22, avb12, avb11, avb21, avb22, ua11r, | |||
| ua22r, vb11r, vb22r, a; | |||
| doublecomplex b, c__; | |||
| doublereal d__; | |||
| doublecomplex r__, d1; | |||
| doublereal s1, s2; | |||
| extern /* Subroutine */ int dlasv2_(doublereal *, doublereal *, | |||
| doublereal *, doublereal *, doublereal *, doublereal *, | |||
| doublereal *, doublereal *, doublereal *); | |||
| doublereal fb, fc; | |||
| extern /* Subroutine */ int zlartg_(doublecomplex *, doublecomplex *, | |||
| doublereal *, doublecomplex *, doublecomplex *); | |||
| doublecomplex ua11, ua12, ua21, ua22, vb11, vb12, vb21, vb22; | |||
| doublereal csl, csr, snl, snr; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| if (*upper) { | |||
| /* Input matrices A and B are upper triangular matrices */ | |||
| /* Form matrix C = A*adj(B) = ( a b ) */ | |||
| /* ( 0 d ) */ | |||
| a = *a1 * *b3; | |||
| d__ = *a3 * *b1; | |||
| z__2.r = *b1 * a2->r, z__2.i = *b1 * a2->i; | |||
| z__3.r = *a1 * b2->r, z__3.i = *a1 * b2->i; | |||
| z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i; | |||
| b.r = z__1.r, b.i = z__1.i; | |||
| fb = z_abs(&b); | |||
| /* Transform complex 2-by-2 matrix C to real matrix by unitary */ | |||
| /* diagonal matrix diag(1,D1). */ | |||
| d1.r = 1., d1.i = 0.; | |||
| if (fb != 0.) { | |||
| z__1.r = b.r / fb, z__1.i = b.i / fb; | |||
| d1.r = z__1.r, d1.i = z__1.i; | |||
| } | |||
| /* The SVD of real 2 by 2 triangular C */ | |||
| /* ( CSL -SNL )*( A B )*( CSR SNR ) = ( R 0 ) */ | |||
| /* ( SNL CSL ) ( 0 D ) ( -SNR CSR ) ( 0 T ) */ | |||
| dlasv2_(&a, &fb, &d__, &s1, &s2, &snr, &csr, &snl, &csl); | |||
| if (abs(csl) >= abs(snl) || abs(csr) >= abs(snr)) { | |||
| /* Compute the (1,1) and (1,2) elements of U**H *A and V**H *B, */ | |||
| /* and (1,2) element of |U|**H *|A| and |V|**H *|B|. */ | |||
| ua11r = csl * *a1; | |||
| z__2.r = csl * a2->r, z__2.i = csl * a2->i; | |||
| z__4.r = snl * d1.r, z__4.i = snl * d1.i; | |||
| z__3.r = *a3 * z__4.r, z__3.i = *a3 * z__4.i; | |||
| z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; | |||
| ua12.r = z__1.r, ua12.i = z__1.i; | |||
| vb11r = csr * *b1; | |||
| z__2.r = csr * b2->r, z__2.i = csr * b2->i; | |||
| z__4.r = snr * d1.r, z__4.i = snr * d1.i; | |||
| z__3.r = *b3 * z__4.r, z__3.i = *b3 * z__4.i; | |||
| z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; | |||
| vb12.r = z__1.r, vb12.i = z__1.i; | |||
| aua12 = abs(csl) * ((d__1 = a2->r, abs(d__1)) + (d__2 = d_imag(a2) | |||
| , abs(d__2))) + abs(snl) * abs(*a3); | |||
| avb12 = abs(csr) * ((d__1 = b2->r, abs(d__1)) + (d__2 = d_imag(b2) | |||
| , abs(d__2))) + abs(snr) * abs(*b3); | |||
| /* zero (1,2) elements of U**H *A and V**H *B */ | |||
| if (abs(ua11r) + ((d__1 = ua12.r, abs(d__1)) + (d__2 = d_imag(& | |||
| ua12), abs(d__2))) == 0.) { | |||
| z__2.r = vb11r, z__2.i = 0.; | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| d_cnjg(&z__3, &vb12); | |||
| zlartg_(&z__1, &z__3, csq, snq, &r__); | |||
| } else if (abs(vb11r) + ((d__1 = vb12.r, abs(d__1)) + (d__2 = | |||
| d_imag(&vb12), abs(d__2))) == 0.) { | |||
| z__2.r = ua11r, z__2.i = 0.; | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| d_cnjg(&z__3, &ua12); | |||
| zlartg_(&z__1, &z__3, csq, snq, &r__); | |||
| } else if (aua12 / (abs(ua11r) + ((d__1 = ua12.r, abs(d__1)) + ( | |||
| d__2 = d_imag(&ua12), abs(d__2)))) <= avb12 / (abs(vb11r) | |||
| + ((d__3 = vb12.r, abs(d__3)) + (d__4 = d_imag(&vb12), | |||
| abs(d__4))))) { | |||
| z__2.r = ua11r, z__2.i = 0.; | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| d_cnjg(&z__3, &ua12); | |||
| zlartg_(&z__1, &z__3, csq, snq, &r__); | |||
| } else { | |||
| z__2.r = vb11r, z__2.i = 0.; | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| d_cnjg(&z__3, &vb12); | |||
| zlartg_(&z__1, &z__3, csq, snq, &r__); | |||
| } | |||
| *csu = csl; | |||
| z__2.r = -d1.r, z__2.i = -d1.i; | |||
| z__1.r = snl * z__2.r, z__1.i = snl * z__2.i; | |||
| snu->r = z__1.r, snu->i = z__1.i; | |||
| *csv = csr; | |||
| z__2.r = -d1.r, z__2.i = -d1.i; | |||
| z__1.r = snr * z__2.r, z__1.i = snr * z__2.i; | |||
| snv->r = z__1.r, snv->i = z__1.i; | |||
| } else { | |||
| /* Compute the (2,1) and (2,2) elements of U**H *A and V**H *B, */ | |||
| /* and (2,2) element of |U|**H *|A| and |V|**H *|B|. */ | |||
| d_cnjg(&z__4, &d1); | |||
| z__3.r = -z__4.r, z__3.i = -z__4.i; | |||
| z__2.r = snl * z__3.r, z__2.i = snl * z__3.i; | |||
| z__1.r = *a1 * z__2.r, z__1.i = *a1 * z__2.i; | |||
| ua21.r = z__1.r, ua21.i = z__1.i; | |||
| d_cnjg(&z__5, &d1); | |||
| z__4.r = -z__5.r, z__4.i = -z__5.i; | |||
| z__3.r = snl * z__4.r, z__3.i = snl * z__4.i; | |||
| z__2.r = z__3.r * a2->r - z__3.i * a2->i, z__2.i = z__3.r * a2->i | |||
| + z__3.i * a2->r; | |||
| d__1 = csl * *a3; | |||
| z__1.r = z__2.r + d__1, z__1.i = z__2.i; | |||
| ua22.r = z__1.r, ua22.i = z__1.i; | |||
| d_cnjg(&z__4, &d1); | |||
| z__3.r = -z__4.r, z__3.i = -z__4.i; | |||
| z__2.r = snr * z__3.r, z__2.i = snr * z__3.i; | |||
| z__1.r = *b1 * z__2.r, z__1.i = *b1 * z__2.i; | |||
| vb21.r = z__1.r, vb21.i = z__1.i; | |||
| d_cnjg(&z__5, &d1); | |||
| z__4.r = -z__5.r, z__4.i = -z__5.i; | |||
| z__3.r = snr * z__4.r, z__3.i = snr * z__4.i; | |||
| z__2.r = z__3.r * b2->r - z__3.i * b2->i, z__2.i = z__3.r * b2->i | |||
| + z__3.i * b2->r; | |||
| d__1 = csr * *b3; | |||
| z__1.r = z__2.r + d__1, z__1.i = z__2.i; | |||
| vb22.r = z__1.r, vb22.i = z__1.i; | |||
| aua22 = abs(snl) * ((d__1 = a2->r, abs(d__1)) + (d__2 = d_imag(a2) | |||
| , abs(d__2))) + abs(csl) * abs(*a3); | |||
| avb22 = abs(snr) * ((d__1 = b2->r, abs(d__1)) + (d__2 = d_imag(b2) | |||
| , abs(d__2))) + abs(csr) * abs(*b3); | |||
| /* zero (2,2) elements of U**H *A and V**H *B, and then swap. */ | |||
| if ((d__1 = ua21.r, abs(d__1)) + (d__2 = d_imag(&ua21), abs(d__2)) | |||
| + ((d__3 = ua22.r, abs(d__3)) + (d__4 = d_imag(&ua22), | |||
| abs(d__4))) == 0.) { | |||
| d_cnjg(&z__2, &vb21); | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| d_cnjg(&z__3, &vb22); | |||
| zlartg_(&z__1, &z__3, csq, snq, &r__); | |||
| } else if ((d__1 = vb21.r, abs(d__1)) + (d__2 = d_imag(&vb21), | |||
| abs(d__2)) + z_abs(&vb22) == 0.) { | |||
| d_cnjg(&z__2, &ua21); | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| d_cnjg(&z__3, &ua22); | |||
| zlartg_(&z__1, &z__3, csq, snq, &r__); | |||
| } else if (aua22 / ((d__1 = ua21.r, abs(d__1)) + (d__2 = d_imag(& | |||
| ua21), abs(d__2)) + ((d__3 = ua22.r, abs(d__3)) + (d__4 = | |||
| d_imag(&ua22), abs(d__4)))) <= avb22 / ((d__5 = vb21.r, | |||
| abs(d__5)) + (d__6 = d_imag(&vb21), abs(d__6)) + ((d__7 = | |||
| vb22.r, abs(d__7)) + (d__8 = d_imag(&vb22), abs(d__8))))) | |||
| { | |||
| d_cnjg(&z__2, &ua21); | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| d_cnjg(&z__3, &ua22); | |||
| zlartg_(&z__1, &z__3, csq, snq, &r__); | |||
| } else { | |||
| d_cnjg(&z__2, &vb21); | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| d_cnjg(&z__3, &vb22); | |||
| zlartg_(&z__1, &z__3, csq, snq, &r__); | |||
| } | |||
| *csu = snl; | |||
| z__1.r = csl * d1.r, z__1.i = csl * d1.i; | |||
| snu->r = z__1.r, snu->i = z__1.i; | |||
| *csv = snr; | |||
| z__1.r = csr * d1.r, z__1.i = csr * d1.i; | |||
| snv->r = z__1.r, snv->i = z__1.i; | |||
| } | |||
| } else { | |||
| /* Input matrices A and B are lower triangular matrices */ | |||
| /* Form matrix C = A*adj(B) = ( a 0 ) */ | |||
| /* ( c d ) */ | |||
| a = *a1 * *b3; | |||
| d__ = *a3 * *b1; | |||
| z__2.r = *b3 * a2->r, z__2.i = *b3 * a2->i; | |||
| z__3.r = *a3 * b2->r, z__3.i = *a3 * b2->i; | |||
| z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i; | |||
| c__.r = z__1.r, c__.i = z__1.i; | |||
| fc = z_abs(&c__); | |||
| /* Transform complex 2-by-2 matrix C to real matrix by unitary */ | |||
| /* diagonal matrix diag(d1,1). */ | |||
| d1.r = 1., d1.i = 0.; | |||
| if (fc != 0.) { | |||
| z__1.r = c__.r / fc, z__1.i = c__.i / fc; | |||
| d1.r = z__1.r, d1.i = z__1.i; | |||
| } | |||
| /* The SVD of real 2 by 2 triangular C */ | |||
| /* ( CSL -SNL )*( A 0 )*( CSR SNR ) = ( R 0 ) */ | |||
| /* ( SNL CSL ) ( C D ) ( -SNR CSR ) ( 0 T ) */ | |||
| dlasv2_(&a, &fc, &d__, &s1, &s2, &snr, &csr, &snl, &csl); | |||
| if (abs(csr) >= abs(snr) || abs(csl) >= abs(snl)) { | |||
| /* Compute the (2,1) and (2,2) elements of U**H *A and V**H *B, */ | |||
| /* and (2,1) element of |U|**H *|A| and |V|**H *|B|. */ | |||
| z__4.r = -d1.r, z__4.i = -d1.i; | |||
| z__3.r = snr * z__4.r, z__3.i = snr * z__4.i; | |||
| z__2.r = *a1 * z__3.r, z__2.i = *a1 * z__3.i; | |||
| z__5.r = csr * a2->r, z__5.i = csr * a2->i; | |||
| z__1.r = z__2.r + z__5.r, z__1.i = z__2.i + z__5.i; | |||
| ua21.r = z__1.r, ua21.i = z__1.i; | |||
| ua22r = csr * *a3; | |||
| z__4.r = -d1.r, z__4.i = -d1.i; | |||
| z__3.r = snl * z__4.r, z__3.i = snl * z__4.i; | |||
| z__2.r = *b1 * z__3.r, z__2.i = *b1 * z__3.i; | |||
| z__5.r = csl * b2->r, z__5.i = csl * b2->i; | |||
| z__1.r = z__2.r + z__5.r, z__1.i = z__2.i + z__5.i; | |||
| vb21.r = z__1.r, vb21.i = z__1.i; | |||
| vb22r = csl * *b3; | |||
| aua21 = abs(snr) * abs(*a1) + abs(csr) * ((d__1 = a2->r, abs(d__1) | |||
| ) + (d__2 = d_imag(a2), abs(d__2))); | |||
| avb21 = abs(snl) * abs(*b1) + abs(csl) * ((d__1 = b2->r, abs(d__1) | |||
| ) + (d__2 = d_imag(b2), abs(d__2))); | |||
| /* zero (2,1) elements of U**H *A and V**H *B. */ | |||
| if ((d__1 = ua21.r, abs(d__1)) + (d__2 = d_imag(&ua21), abs(d__2)) | |||
| + abs(ua22r) == 0.) { | |||
| z__1.r = vb22r, z__1.i = 0.; | |||
| zlartg_(&z__1, &vb21, csq, snq, &r__); | |||
| } else if ((d__1 = vb21.r, abs(d__1)) + (d__2 = d_imag(&vb21), | |||
| abs(d__2)) + abs(vb22r) == 0.) { | |||
| z__1.r = ua22r, z__1.i = 0.; | |||
| zlartg_(&z__1, &ua21, csq, snq, &r__); | |||
| } else if (aua21 / ((d__1 = ua21.r, abs(d__1)) + (d__2 = d_imag(& | |||
| ua21), abs(d__2)) + abs(ua22r)) <= avb21 / ((d__3 = | |||
| vb21.r, abs(d__3)) + (d__4 = d_imag(&vb21), abs(d__4)) + | |||
| abs(vb22r))) { | |||
| z__1.r = ua22r, z__1.i = 0.; | |||
| zlartg_(&z__1, &ua21, csq, snq, &r__); | |||
| } else { | |||
| z__1.r = vb22r, z__1.i = 0.; | |||
| zlartg_(&z__1, &vb21, csq, snq, &r__); | |||
| } | |||
| *csu = csr; | |||
| d_cnjg(&z__3, &d1); | |||
| z__2.r = -z__3.r, z__2.i = -z__3.i; | |||
| z__1.r = snr * z__2.r, z__1.i = snr * z__2.i; | |||
| snu->r = z__1.r, snu->i = z__1.i; | |||
| *csv = csl; | |||
| d_cnjg(&z__3, &d1); | |||
| z__2.r = -z__3.r, z__2.i = -z__3.i; | |||
| z__1.r = snl * z__2.r, z__1.i = snl * z__2.i; | |||
| snv->r = z__1.r, snv->i = z__1.i; | |||
| } else { | |||
| /* Compute the (1,1) and (1,2) elements of U**H *A and V**H *B, */ | |||
| /* and (1,1) element of |U|**H *|A| and |V|**H *|B|. */ | |||
| d__1 = csr * *a1; | |||
| d_cnjg(&z__4, &d1); | |||
| z__3.r = snr * z__4.r, z__3.i = snr * z__4.i; | |||
| z__2.r = z__3.r * a2->r - z__3.i * a2->i, z__2.i = z__3.r * a2->i | |||
| + z__3.i * a2->r; | |||
| z__1.r = d__1 + z__2.r, z__1.i = z__2.i; | |||
| ua11.r = z__1.r, ua11.i = z__1.i; | |||
| d_cnjg(&z__3, &d1); | |||
| z__2.r = snr * z__3.r, z__2.i = snr * z__3.i; | |||
| z__1.r = *a3 * z__2.r, z__1.i = *a3 * z__2.i; | |||
| ua12.r = z__1.r, ua12.i = z__1.i; | |||
| d__1 = csl * *b1; | |||
| d_cnjg(&z__4, &d1); | |||
| z__3.r = snl * z__4.r, z__3.i = snl * z__4.i; | |||
| z__2.r = z__3.r * b2->r - z__3.i * b2->i, z__2.i = z__3.r * b2->i | |||
| + z__3.i * b2->r; | |||
| z__1.r = d__1 + z__2.r, z__1.i = z__2.i; | |||
| vb11.r = z__1.r, vb11.i = z__1.i; | |||
| d_cnjg(&z__3, &d1); | |||
| z__2.r = snl * z__3.r, z__2.i = snl * z__3.i; | |||
| z__1.r = *b3 * z__2.r, z__1.i = *b3 * z__2.i; | |||
| vb12.r = z__1.r, vb12.i = z__1.i; | |||
| aua11 = abs(csr) * abs(*a1) + abs(snr) * ((d__1 = a2->r, abs(d__1) | |||
| ) + (d__2 = d_imag(a2), abs(d__2))); | |||
| avb11 = abs(csl) * abs(*b1) + abs(snl) * ((d__1 = b2->r, abs(d__1) | |||
| ) + (d__2 = d_imag(b2), abs(d__2))); | |||
| /* zero (1,1) elements of U**H *A and V**H *B, and then swap. */ | |||
| if ((d__1 = ua11.r, abs(d__1)) + (d__2 = d_imag(&ua11), abs(d__2)) | |||
| + ((d__3 = ua12.r, abs(d__3)) + (d__4 = d_imag(&ua12), | |||
| abs(d__4))) == 0.) { | |||
| zlartg_(&vb12, &vb11, csq, snq, &r__); | |||
| } else if ((d__1 = vb11.r, abs(d__1)) + (d__2 = d_imag(&vb11), | |||
| abs(d__2)) + ((d__3 = vb12.r, abs(d__3)) + (d__4 = d_imag( | |||
| &vb12), abs(d__4))) == 0.) { | |||
| zlartg_(&ua12, &ua11, csq, snq, &r__); | |||
| } else if (aua11 / ((d__1 = ua11.r, abs(d__1)) + (d__2 = d_imag(& | |||
| ua11), abs(d__2)) + ((d__3 = ua12.r, abs(d__3)) + (d__4 = | |||
| d_imag(&ua12), abs(d__4)))) <= avb11 / ((d__5 = vb11.r, | |||
| abs(d__5)) + (d__6 = d_imag(&vb11), abs(d__6)) + ((d__7 = | |||
| vb12.r, abs(d__7)) + (d__8 = d_imag(&vb12), abs(d__8))))) | |||
| { | |||
| zlartg_(&ua12, &ua11, csq, snq, &r__); | |||
| } else { | |||
| zlartg_(&vb12, &vb11, csq, snq, &r__); | |||
| } | |||
| *csu = snr; | |||
| d_cnjg(&z__2, &d1); | |||
| z__1.r = csr * z__2.r, z__1.i = csr * z__2.i; | |||
| snu->r = z__1.r, snu->i = z__1.i; | |||
| *csv = snl; | |||
| d_cnjg(&z__2, &d1); | |||
| z__1.r = csl * z__2.r, z__1.i = csl * z__2.i; | |||
| snv->r = z__1.r, snv->i = z__1.i; | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLAGS2 */ | |||
| } /* zlags2_ */ | |||
| @@ -0,0 +1,984 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {0.,0.}; | |||
| static doublecomplex c_b2 = {1.,0.}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLAHEF_AA */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAHEF_AA + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlahef_ | |||
| aa.f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlahef_ | |||
| aa.f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlahef_ | |||
| aa.f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAHEF_AA( UPLO, J1, M, NB, A, LDA, IPIV, */ | |||
| /* H, LDH, WORK ) */ | |||
| /* CHARACTER UPLO */ | |||
| /* INTEGER J1, M, NB, LDA, LDH */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ), H( LDH, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > DLAHEF_AA factorizes a panel of a complex hermitian matrix A using */ | |||
| /* > the Aasen's algorithm. The panel consists of a set of NB rows of A */ | |||
| /* > when UPLO is U, or a set of NB columns when UPLO is L. */ | |||
| /* > */ | |||
| /* > In order to factorize the panel, the Aasen's algorithm requires the */ | |||
| /* > last row, or column, of the previous panel. The first row, or column, */ | |||
| /* > of A is set to be the first row, or column, of an identity matrix, */ | |||
| /* > which is used to factorize the first panel. */ | |||
| /* > */ | |||
| /* > The resulting J-th row of U, or J-th column of L, is stored in the */ | |||
| /* > (J-1)-th row, or column, of A (without the unit diagonals), while */ | |||
| /* > the diagonal and subdiagonal of A are overwritten by those of T. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > = 'U': Upper triangle of A is stored; */ | |||
| /* > = 'L': Lower triangle of A is stored. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] J1 */ | |||
| /* > \verbatim */ | |||
| /* > J1 is INTEGER */ | |||
| /* > The location of the first row, or column, of the panel */ | |||
| /* > within the submatrix of A, passed to this routine, e.g., */ | |||
| /* > when called by ZHETRF_AA, for the first panel, J1 is 1, */ | |||
| /* > while for the remaining panels, J1 is 2. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The dimension of the submatrix. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The dimension of the panel to be facotorized. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,M) for */ | |||
| /* > the first panel, while dimension (LDA,M+1) for the */ | |||
| /* > remaining panels. */ | |||
| /* > */ | |||
| /* > On entry, A contains the last row, or column, of */ | |||
| /* > the previous panel, and the trailing submatrix of A */ | |||
| /* > to be factorized, except for the first panel, only */ | |||
| /* > the panel is passed. */ | |||
| /* > */ | |||
| /* > On exit, the leading panel is factorized. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (N) */ | |||
| /* > Details of the row and column interchanges, */ | |||
| /* > the row and column k were interchanged with the row and */ | |||
| /* > column IPIV(k). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] H */ | |||
| /* > \verbatim */ | |||
| /* > H is COMPLEX*16 workspace, dimension (LDH,NB). */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDH */ | |||
| /* > \verbatim */ | |||
| /* > LDH is INTEGER */ | |||
| /* > The leading dimension of the workspace H. LDH >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX*16 workspace, dimension (M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date November 2017 */ | |||
| /* > \ingroup complex16HEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlahef_aa_(char *uplo, integer *j1, integer *m, integer | |||
| *nb, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex * | |||
| h__, integer *ldh, doublecomplex *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, h_dim1, h_offset, i__1, i__2; | |||
| doublereal d__1; | |||
| doublecomplex z__1, z__2; | |||
| /* Local variables */ | |||
| integer j, k; | |||
| doublecomplex alpha; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int zscal_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *), zgemv_(char *, integer *, integer *, | |||
| doublecomplex *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *); | |||
| integer i1, k1, i2; | |||
| extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *), zswap_(integer *, doublecomplex *, | |||
| integer *, doublecomplex *, integer *), zaxpy_(integer *, | |||
| doublecomplex *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *); | |||
| integer mj; | |||
| extern /* Subroutine */ int zlacgv_(integer *, doublecomplex *, integer *) | |||
| ; | |||
| extern integer izamax_(integer *, doublecomplex *, integer *); | |||
| extern /* Subroutine */ int zlaset_(char *, integer *, integer *, | |||
| doublecomplex *, doublecomplex *, doublecomplex *, integer *); | |||
| doublecomplex piv; | |||
| /* -- LAPACK computational routine (version 3.8.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* November 2017 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --ipiv; | |||
| h_dim1 = *ldh; | |||
| h_offset = 1 + h_dim1 * 1; | |||
| h__ -= h_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| j = 1; | |||
| /* K1 is the first column of the panel to be factorized */ | |||
| /* i.e., K1 is 2 for the first block column, and 1 for the rest of the blocks */ | |||
| k1 = 2 - *j1 + 1; | |||
| if (lsame_(uplo, "U")) { | |||
| /* ..................................................... */ | |||
| /* Factorize A as U**T*D*U using the upper triangle of A */ | |||
| /* ..................................................... */ | |||
| L10: | |||
| if (j > f2cmin(*m,*nb)) { | |||
| goto L20; | |||
| } | |||
| /* K is the column to be factorized */ | |||
| /* when being called from ZHETRF_AA, */ | |||
| /* > for the first block column, J1 is 1, hence J1+J-1 is J, */ | |||
| /* > for the rest of the columns, J1 is 2, and J1+J-1 is J+1, */ | |||
| k = *j1 + j - 1; | |||
| if (j == *m) { | |||
| /* Only need to compute T(J, J) */ | |||
| mj = 1; | |||
| } else { | |||
| mj = *m - j + 1; | |||
| } | |||
| /* H(J:N, J) := A(J, J:N) - H(J:N, 1:(J-1)) * L(J1:(J-1), J), */ | |||
| /* where H(J:N, J) has been initialized to be A(J, J:N) */ | |||
| if (k > 2) { | |||
| /* K is the column to be factorized */ | |||
| /* > for the first block column, K is J, skipping the first two */ | |||
| /* columns */ | |||
| /* > for the rest of the columns, K is J+1, skipping only the */ | |||
| /* first column */ | |||
| i__1 = j - k1; | |||
| zlacgv_(&i__1, &a[j * a_dim1 + 1], &c__1); | |||
| i__1 = j - k1; | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zgemv_("No transpose", &mj, &i__1, &z__1, &h__[j + k1 * h_dim1], | |||
| ldh, &a[j * a_dim1 + 1], &c__1, &c_b2, &h__[j + j * | |||
| h_dim1], &c__1); | |||
| i__1 = j - k1; | |||
| zlacgv_(&i__1, &a[j * a_dim1 + 1], &c__1); | |||
| } | |||
| /* Copy H(i:n, i) into WORK */ | |||
| zcopy_(&mj, &h__[j + j * h_dim1], &c__1, &work[1], &c__1); | |||
| if (j > k1) { | |||
| /* Compute WORK := WORK - L(J-1, J:N) * T(J-1,J), */ | |||
| /* where A(J-1, J) stores T(J-1, J) and A(J-2, J:N) stores U(J-1, J:N) */ | |||
| d_cnjg(&z__2, &a[k - 1 + j * a_dim1]); | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| zaxpy_(&mj, &alpha, &a[k - 2 + j * a_dim1], lda, &work[1], &c__1); | |||
| } | |||
| /* Set A(J, J) = T(J, J) */ | |||
| i__1 = k + j * a_dim1; | |||
| d__1 = work[1].r; | |||
| a[i__1].r = d__1, a[i__1].i = 0.; | |||
| if (j < *m) { | |||
| /* Compute WORK(2:N) = T(J, J) L(J, (J+1):N) */ | |||
| /* where A(J, J) stores T(J, J) and A(J-1, (J+1):N) stores U(J, (J+1):N) */ | |||
| if (k > 1) { | |||
| i__1 = k + j * a_dim1; | |||
| z__1.r = -a[i__1].r, z__1.i = -a[i__1].i; | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| i__1 = *m - j; | |||
| zaxpy_(&i__1, &alpha, &a[k - 1 + (j + 1) * a_dim1], lda, & | |||
| work[2], &c__1); | |||
| } | |||
| /* Find f2cmax(|WORK(2:n)|) */ | |||
| i__1 = *m - j; | |||
| i2 = izamax_(&i__1, &work[2], &c__1) + 1; | |||
| i__1 = i2; | |||
| piv.r = work[i__1].r, piv.i = work[i__1].i; | |||
| /* Apply hermitian pivot */ | |||
| if (i2 != 2 && (piv.r != 0. || piv.i != 0.)) { | |||
| /* Swap WORK(I1) and WORK(I2) */ | |||
| i1 = 2; | |||
| i__1 = i2; | |||
| i__2 = i1; | |||
| work[i__1].r = work[i__2].r, work[i__1].i = work[i__2].i; | |||
| i__1 = i1; | |||
| work[i__1].r = piv.r, work[i__1].i = piv.i; | |||
| /* Swap A(I1, I1+1:N) with A(I1+1:N, I2) */ | |||
| i1 = i1 + j - 1; | |||
| i2 = i2 + j - 1; | |||
| i__1 = i2 - i1 - 1; | |||
| zswap_(&i__1, &a[*j1 + i1 - 1 + (i1 + 1) * a_dim1], lda, &a[* | |||
| j1 + i1 + i2 * a_dim1], &c__1); | |||
| i__1 = i2 - i1; | |||
| zlacgv_(&i__1, &a[*j1 + i1 - 1 + (i1 + 1) * a_dim1], lda); | |||
| i__1 = i2 - i1 - 1; | |||
| zlacgv_(&i__1, &a[*j1 + i1 + i2 * a_dim1], &c__1); | |||
| /* Swap A(I1, I2+1:N) with A(I2, I2+1:N) */ | |||
| if (i2 < *m) { | |||
| i__1 = *m - i2; | |||
| zswap_(&i__1, &a[*j1 + i1 - 1 + (i2 + 1) * a_dim1], lda, & | |||
| a[*j1 + i2 - 1 + (i2 + 1) * a_dim1], lda); | |||
| } | |||
| /* Swap A(I1, I1) with A(I2,I2) */ | |||
| i__1 = i1 + *j1 - 1 + i1 * a_dim1; | |||
| piv.r = a[i__1].r, piv.i = a[i__1].i; | |||
| i__1 = *j1 + i1 - 1 + i1 * a_dim1; | |||
| i__2 = *j1 + i2 - 1 + i2 * a_dim1; | |||
| a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i; | |||
| i__1 = *j1 + i2 - 1 + i2 * a_dim1; | |||
| a[i__1].r = piv.r, a[i__1].i = piv.i; | |||
| /* Swap H(I1, 1:J1) with H(I2, 1:J1) */ | |||
| i__1 = i1 - 1; | |||
| zswap_(&i__1, &h__[i1 + h_dim1], ldh, &h__[i2 + h_dim1], ldh); | |||
| ipiv[i1] = i2; | |||
| if (i1 > k1 - 1) { | |||
| /* Swap L(1:I1-1, I1) with L(1:I1-1, I2), */ | |||
| /* skipping the first column */ | |||
| i__1 = i1 - k1 + 1; | |||
| zswap_(&i__1, &a[i1 * a_dim1 + 1], &c__1, &a[i2 * a_dim1 | |||
| + 1], &c__1); | |||
| } | |||
| } else { | |||
| ipiv[j + 1] = j + 1; | |||
| } | |||
| /* Set A(J, J+1) = T(J, J+1) */ | |||
| i__1 = k + (j + 1) * a_dim1; | |||
| a[i__1].r = work[2].r, a[i__1].i = work[2].i; | |||
| if (j < *nb) { | |||
| /* Copy A(J+1:N, J+1) into H(J:N, J), */ | |||
| i__1 = *m - j; | |||
| zcopy_(&i__1, &a[k + 1 + (j + 1) * a_dim1], lda, &h__[j + 1 + | |||
| (j + 1) * h_dim1], &c__1); | |||
| } | |||
| /* Compute L(J+2, J+1) = WORK( 3:N ) / T(J, J+1), */ | |||
| /* where A(J, J+1) = T(J, J+1) and A(J+2:N, J) = L(J+2:N, J+1) */ | |||
| if (j < *m - 1) { | |||
| i__1 = k + (j + 1) * a_dim1; | |||
| if (a[i__1].r != 0. || a[i__1].i != 0.) { | |||
| z_div(&z__1, &c_b2, &a[k + (j + 1) * a_dim1]); | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| i__1 = *m - j - 1; | |||
| zcopy_(&i__1, &work[3], &c__1, &a[k + (j + 2) * a_dim1], | |||
| lda); | |||
| i__1 = *m - j - 1; | |||
| zscal_(&i__1, &alpha, &a[k + (j + 2) * a_dim1], lda); | |||
| } else { | |||
| i__1 = *m - j - 1; | |||
| zlaset_("Full", &c__1, &i__1, &c_b1, &c_b1, &a[k + (j + 2) | |||
| * a_dim1], lda); | |||
| } | |||
| } | |||
| } | |||
| ++j; | |||
| goto L10; | |||
| L20: | |||
| ; | |||
| } else { | |||
| /* ..................................................... */ | |||
| /* Factorize A as L*D*L**T using the lower triangle of A */ | |||
| /* ..................................................... */ | |||
| L30: | |||
| if (j > f2cmin(*m,*nb)) { | |||
| goto L40; | |||
| } | |||
| /* K is the column to be factorized */ | |||
| /* when being called from ZHETRF_AA, */ | |||
| /* > for the first block column, J1 is 1, hence J1+J-1 is J, */ | |||
| /* > for the rest of the columns, J1 is 2, and J1+J-1 is J+1, */ | |||
| k = *j1 + j - 1; | |||
| if (j == *m) { | |||
| /* Only need to compute T(J, J) */ | |||
| mj = 1; | |||
| } else { | |||
| mj = *m - j + 1; | |||
| } | |||
| /* H(J:N, J) := A(J:N, J) - H(J:N, 1:(J-1)) * L(J, J1:(J-1))^T, */ | |||
| /* where H(J:N, J) has been initialized to be A(J:N, J) */ | |||
| if (k > 2) { | |||
| /* K is the column to be factorized */ | |||
| /* > for the first block column, K is J, skipping the first two */ | |||
| /* columns */ | |||
| /* > for the rest of the columns, K is J+1, skipping only the */ | |||
| /* first column */ | |||
| i__1 = j - k1; | |||
| zlacgv_(&i__1, &a[j + a_dim1], lda); | |||
| i__1 = j - k1; | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zgemv_("No transpose", &mj, &i__1, &z__1, &h__[j + k1 * h_dim1], | |||
| ldh, &a[j + a_dim1], lda, &c_b2, &h__[j + j * h_dim1], & | |||
| c__1); | |||
| i__1 = j - k1; | |||
| zlacgv_(&i__1, &a[j + a_dim1], lda); | |||
| } | |||
| /* Copy H(J:N, J) into WORK */ | |||
| zcopy_(&mj, &h__[j + j * h_dim1], &c__1, &work[1], &c__1); | |||
| if (j > k1) { | |||
| /* Compute WORK := WORK - L(J:N, J-1) * T(J-1,J), */ | |||
| /* where A(J-1, J) = T(J-1, J) and A(J, J-2) = L(J, J-1) */ | |||
| d_cnjg(&z__2, &a[j + (k - 1) * a_dim1]); | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| zaxpy_(&mj, &alpha, &a[j + (k - 2) * a_dim1], &c__1, &work[1], & | |||
| c__1); | |||
| } | |||
| /* Set A(J, J) = T(J, J) */ | |||
| i__1 = j + k * a_dim1; | |||
| d__1 = work[1].r; | |||
| a[i__1].r = d__1, a[i__1].i = 0.; | |||
| if (j < *m) { | |||
| /* Compute WORK(2:N) = T(J, J) L((J+1):N, J) */ | |||
| /* where A(J, J) = T(J, J) and A((J+1):N, J-1) = L((J+1):N, J) */ | |||
| if (k > 1) { | |||
| i__1 = j + k * a_dim1; | |||
| z__1.r = -a[i__1].r, z__1.i = -a[i__1].i; | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| i__1 = *m - j; | |||
| zaxpy_(&i__1, &alpha, &a[j + 1 + (k - 1) * a_dim1], &c__1, & | |||
| work[2], &c__1); | |||
| } | |||
| /* Find f2cmax(|WORK(2:n)|) */ | |||
| i__1 = *m - j; | |||
| i2 = izamax_(&i__1, &work[2], &c__1) + 1; | |||
| i__1 = i2; | |||
| piv.r = work[i__1].r, piv.i = work[i__1].i; | |||
| /* Apply hermitian pivot */ | |||
| if (i2 != 2 && (piv.r != 0. || piv.i != 0.)) { | |||
| /* Swap WORK(I1) and WORK(I2) */ | |||
| i1 = 2; | |||
| i__1 = i2; | |||
| i__2 = i1; | |||
| work[i__1].r = work[i__2].r, work[i__1].i = work[i__2].i; | |||
| i__1 = i1; | |||
| work[i__1].r = piv.r, work[i__1].i = piv.i; | |||
| /* Swap A(I1+1:N, I1) with A(I2, I1+1:N) */ | |||
| i1 = i1 + j - 1; | |||
| i2 = i2 + j - 1; | |||
| i__1 = i2 - i1 - 1; | |||
| zswap_(&i__1, &a[i1 + 1 + (*j1 + i1 - 1) * a_dim1], &c__1, &a[ | |||
| i2 + (*j1 + i1) * a_dim1], lda); | |||
| i__1 = i2 - i1; | |||
| zlacgv_(&i__1, &a[i1 + 1 + (*j1 + i1 - 1) * a_dim1], &c__1); | |||
| i__1 = i2 - i1 - 1; | |||
| zlacgv_(&i__1, &a[i2 + (*j1 + i1) * a_dim1], lda); | |||
| /* Swap A(I2+1:N, I1) with A(I2+1:N, I2) */ | |||
| if (i2 < *m) { | |||
| i__1 = *m - i2; | |||
| zswap_(&i__1, &a[i2 + 1 + (*j1 + i1 - 1) * a_dim1], &c__1, | |||
| &a[i2 + 1 + (*j1 + i2 - 1) * a_dim1], &c__1); | |||
| } | |||
| /* Swap A(I1, I1) with A(I2, I2) */ | |||
| i__1 = i1 + (*j1 + i1 - 1) * a_dim1; | |||
| piv.r = a[i__1].r, piv.i = a[i__1].i; | |||
| i__1 = i1 + (*j1 + i1 - 1) * a_dim1; | |||
| i__2 = i2 + (*j1 + i2 - 1) * a_dim1; | |||
| a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i; | |||
| i__1 = i2 + (*j1 + i2 - 1) * a_dim1; | |||
| a[i__1].r = piv.r, a[i__1].i = piv.i; | |||
| /* Swap H(I1, I1:J1) with H(I2, I2:J1) */ | |||
| i__1 = i1 - 1; | |||
| zswap_(&i__1, &h__[i1 + h_dim1], ldh, &h__[i2 + h_dim1], ldh); | |||
| ipiv[i1] = i2; | |||
| if (i1 > k1 - 1) { | |||
| /* Swap L(1:I1-1, I1) with L(1:I1-1, I2), */ | |||
| /* skipping the first column */ | |||
| i__1 = i1 - k1 + 1; | |||
| zswap_(&i__1, &a[i1 + a_dim1], lda, &a[i2 + a_dim1], lda); | |||
| } | |||
| } else { | |||
| ipiv[j + 1] = j + 1; | |||
| } | |||
| /* Set A(J+1, J) = T(J+1, J) */ | |||
| i__1 = j + 1 + k * a_dim1; | |||
| a[i__1].r = work[2].r, a[i__1].i = work[2].i; | |||
| if (j < *nb) { | |||
| /* Copy A(J+1:N, J+1) into H(J+1:N, J), */ | |||
| i__1 = *m - j; | |||
| zcopy_(&i__1, &a[j + 1 + (k + 1) * a_dim1], &c__1, &h__[j + 1 | |||
| + (j + 1) * h_dim1], &c__1); | |||
| } | |||
| /* Compute L(J+2, J+1) = WORK( 3:N ) / T(J, J+1), */ | |||
| /* where A(J, J+1) = T(J, J+1) and A(J+2:N, J) = L(J+2:N, J+1) */ | |||
| if (j < *m - 1) { | |||
| i__1 = j + 1 + k * a_dim1; | |||
| if (a[i__1].r != 0. || a[i__1].i != 0.) { | |||
| z_div(&z__1, &c_b2, &a[j + 1 + k * a_dim1]); | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| i__1 = *m - j - 1; | |||
| zcopy_(&i__1, &work[3], &c__1, &a[j + 2 + k * a_dim1], & | |||
| c__1); | |||
| i__1 = *m - j - 1; | |||
| zscal_(&i__1, &alpha, &a[j + 2 + k * a_dim1], &c__1); | |||
| } else { | |||
| i__1 = *m - j - 1; | |||
| zlaset_("Full", &i__1, &c__1, &c_b1, &c_b1, &a[j + 2 + k * | |||
| a_dim1], lda); | |||
| } | |||
| } | |||
| } | |||
| ++j; | |||
| goto L30; | |||
| L40: | |||
| ; | |||
| } | |||
| return 0; | |||
| /* End of ZLAHEF_AA */ | |||
| } /* zlahef_aa__ */ | |||
| @@ -0,0 +1,783 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {0.,0.}; | |||
| static doublecomplex c_b2 = {1.,0.}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLAHR2 reduces the specified number of first columns of a general rectangular matrix A so that | |||
| elements below the specified subdiagonal are zero, and returns auxiliary matrices which are needed to | |||
| apply the transformation to the unreduced part */ | |||
| /* of A. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAHR2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlahr2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlahr2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlahr2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAHR2( N, K, NB, A, LDA, TAU, T, LDT, Y, LDY ) */ | |||
| /* INTEGER K, LDA, LDT, LDY, N, NB */ | |||
| /* COMPLEX*16 A( LDA, * ), T( LDT, NB ), TAU( NB ), */ | |||
| /* $ Y( LDY, NB ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAHR2 reduces the first NB columns of A complex general n-BY-(n-k+1) */ | |||
| /* > matrix A so that elements below the k-th subdiagonal are zero. The */ | |||
| /* > reduction is performed by an unitary similarity transformation */ | |||
| /* > Q**H * A * Q. The routine returns the matrices V and T which determine */ | |||
| /* > Q as a block reflector I - V*T*V**H, and also the matrix Y = A * V * T. */ | |||
| /* > */ | |||
| /* > This is an auxiliary routine called by ZGEHRD. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The offset for the reduction. Elements below the k-th */ | |||
| /* > subdiagonal in the first NB columns are reduced to zero. */ | |||
| /* > K < N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The number of columns to be reduced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N-K+1) */ | |||
| /* > On entry, the n-by-(n-k+1) general matrix A. */ | |||
| /* > On exit, the elements on and above the k-th subdiagonal in */ | |||
| /* > the first NB columns are overwritten with the corresponding */ | |||
| /* > elements of the reduced matrix; the elements below the k-th */ | |||
| /* > subdiagonal, with the array TAU, represent the matrix Q as a */ | |||
| /* > product of elementary reflectors. The other columns of A are */ | |||
| /* > unchanged. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 array, dimension (NB) */ | |||
| /* > The scalar factors of the elementary reflectors. See Further */ | |||
| /* > Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX*16 array, dimension (LDT,NB) */ | |||
| /* > The upper triangular matrix T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= NB. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] Y */ | |||
| /* > \verbatim */ | |||
| /* > Y is COMPLEX*16 array, dimension (LDY,NB) */ | |||
| /* > The n-by-nb matrix Y. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDY */ | |||
| /* > \verbatim */ | |||
| /* > LDY is INTEGER */ | |||
| /* > The leading dimension of the array Y. LDY >= N. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of nb elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(nb). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a complex vector with */ | |||
| /* > v(1:i+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in */ | |||
| /* > A(i+k+1:n,i), and tau in TAU(i). */ | |||
| /* > */ | |||
| /* > The elements of the vectors v together form the (n-k+1)-by-nb matrix */ | |||
| /* > V which is needed, with T and Y, to apply the transformation to the */ | |||
| /* > unreduced part of the matrix, using an update of the form: */ | |||
| /* > A := (I - V*T*V**H) * (A - Y*V**H). */ | |||
| /* > */ | |||
| /* > The contents of A on exit are illustrated by the following example */ | |||
| /* > with n = 7, k = 3 and nb = 2: */ | |||
| /* > */ | |||
| /* > ( a a a a a ) */ | |||
| /* > ( a a a a a ) */ | |||
| /* > ( a a a a a ) */ | |||
| /* > ( h h a a a ) */ | |||
| /* > ( v1 h a a a ) */ | |||
| /* > ( v1 v2 a a a ) */ | |||
| /* > ( v1 v2 a a a ) */ | |||
| /* > */ | |||
| /* > where a denotes an element of the original matrix A, h denotes a */ | |||
| /* > modified element of the upper Hessenberg matrix H, and vi denotes an */ | |||
| /* > element of the vector defining H(i). */ | |||
| /* > */ | |||
| /* > This subroutine is a slight modification of LAPACK-3.0's DLAHRD */ | |||
| /* > incorporating improvements proposed by Quintana-Orti and Van de */ | |||
| /* > Gejin. Note that the entries of A(1:K,2:NB) differ from those */ | |||
| /* > returned by the original LAPACK-3.0's DLAHRD routine. (This */ | |||
| /* > subroutine is not backward compatible with LAPACK-3.0's DLAHRD.) */ | |||
| /* > \endverbatim */ | |||
| /* > \par References: */ | |||
| /* ================ */ | |||
| /* > */ | |||
| /* > Gregorio Quintana-Orti and Robert van de Geijn, "Improving the */ | |||
| /* > performance of reduction to Hessenberg form," ACM Transactions on */ | |||
| /* > Mathematical Software, 32(2):180-194, June 2006. */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlahr2_(integer *n, integer *k, integer *nb, | |||
| doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *t, | |||
| integer *ldt, doublecomplex *y, integer *ldy) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, y_dim1, y_offset, i__1, i__2, | |||
| i__3; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__; | |||
| extern /* Subroutine */ int zscal_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *), zgemm_(char *, char *, integer *, | |||
| integer *, integer *, doublecomplex *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, doublecomplex *, | |||
| integer *), zgemv_(char *, integer *, integer *, | |||
| doublecomplex *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *), | |||
| zcopy_(integer *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *), ztrmm_(char *, char *, char *, char *, integer *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *), | |||
| zaxpy_(integer *, doublecomplex *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *), ztrmv_(char *, char *, char *, | |||
| integer *, doublecomplex *, integer *, doublecomplex *, integer *); | |||
| doublecomplex ei; | |||
| extern /* Subroutine */ int zlarfg_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *), zlacgv_(integer *, | |||
| doublecomplex *, integer *), zlacpy_(char *, integer *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| --tau; | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| y_dim1 = *ldy; | |||
| y_offset = 1 + y_dim1 * 1; | |||
| y -= y_offset; | |||
| /* Function Body */ | |||
| if (*n <= 1) { | |||
| return 0; | |||
| } | |||
| i__1 = *nb; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (i__ > 1) { | |||
| /* Update A(K+1:N,I) */ | |||
| /* Update I-th column of A - Y * V**H */ | |||
| i__2 = i__ - 1; | |||
| zlacgv_(&i__2, &a[*k + i__ - 1 + a_dim1], lda); | |||
| i__2 = *n - *k; | |||
| i__3 = i__ - 1; | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zgemv_("NO TRANSPOSE", &i__2, &i__3, &z__1, &y[*k + 1 + y_dim1], | |||
| ldy, &a[*k + i__ - 1 + a_dim1], lda, &c_b2, &a[*k + 1 + | |||
| i__ * a_dim1], &c__1); | |||
| i__2 = i__ - 1; | |||
| zlacgv_(&i__2, &a[*k + i__ - 1 + a_dim1], lda); | |||
| /* Apply I - V * T**H * V**H to this column (call it b) from the */ | |||
| /* left, using the last column of T as workspace */ | |||
| /* Let V = ( V1 ) and b = ( b1 ) (first I-1 rows) */ | |||
| /* ( V2 ) ( b2 ) */ | |||
| /* where V1 is unit lower triangular */ | |||
| /* w := V1**H * b1 */ | |||
| i__2 = i__ - 1; | |||
| zcopy_(&i__2, &a[*k + 1 + i__ * a_dim1], &c__1, &t[*nb * t_dim1 + | |||
| 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| ztrmv_("Lower", "Conjugate transpose", "UNIT", &i__2, &a[*k + 1 + | |||
| a_dim1], lda, &t[*nb * t_dim1 + 1], &c__1); | |||
| /* w := w + V2**H * b2 */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| zgemv_("Conjugate transpose", &i__2, &i__3, &c_b2, &a[*k + i__ + | |||
| a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b2, & | |||
| t[*nb * t_dim1 + 1], &c__1); | |||
| /* w := T**H * w */ | |||
| i__2 = i__ - 1; | |||
| ztrmv_("Upper", "Conjugate transpose", "NON-UNIT", &i__2, &t[ | |||
| t_offset], ldt, &t[*nb * t_dim1 + 1], &c__1); | |||
| /* b2 := b2 - V2*w */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zgemv_("NO TRANSPOSE", &i__2, &i__3, &z__1, &a[*k + i__ + a_dim1], | |||
| lda, &t[*nb * t_dim1 + 1], &c__1, &c_b2, &a[*k + i__ + | |||
| i__ * a_dim1], &c__1); | |||
| /* b1 := b1 - V1*w */ | |||
| i__2 = i__ - 1; | |||
| ztrmv_("Lower", "NO TRANSPOSE", "UNIT", &i__2, &a[*k + 1 + a_dim1] | |||
| , lda, &t[*nb * t_dim1 + 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zaxpy_(&i__2, &z__1, &t[*nb * t_dim1 + 1], &c__1, &a[*k + 1 + i__ | |||
| * a_dim1], &c__1); | |||
| i__2 = *k + i__ - 1 + (i__ - 1) * a_dim1; | |||
| a[i__2].r = ei.r, a[i__2].i = ei.i; | |||
| } | |||
| /* Generate the elementary reflector H(I) to annihilate */ | |||
| /* A(K+I+1:N,I) */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = *k + i__ + 1; | |||
| zlarfg_(&i__2, &a[*k + i__ + i__ * a_dim1], &a[f2cmin(i__3,*n) + i__ * | |||
| a_dim1], &c__1, &tau[i__]); | |||
| i__2 = *k + i__ + i__ * a_dim1; | |||
| ei.r = a[i__2].r, ei.i = a[i__2].i; | |||
| i__2 = *k + i__ + i__ * a_dim1; | |||
| a[i__2].r = 1., a[i__2].i = 0.; | |||
| /* Compute Y(K+1:N,I) */ | |||
| i__2 = *n - *k; | |||
| i__3 = *n - *k - i__ + 1; | |||
| zgemv_("NO TRANSPOSE", &i__2, &i__3, &c_b2, &a[*k + 1 + (i__ + 1) * | |||
| a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b1, &y[* | |||
| k + 1 + i__ * y_dim1], &c__1); | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| zgemv_("Conjugate transpose", &i__2, &i__3, &c_b2, &a[*k + i__ + | |||
| a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b1, &t[ | |||
| i__ * t_dim1 + 1], &c__1); | |||
| i__2 = *n - *k; | |||
| i__3 = i__ - 1; | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zgemv_("NO TRANSPOSE", &i__2, &i__3, &z__1, &y[*k + 1 + y_dim1], ldy, | |||
| &t[i__ * t_dim1 + 1], &c__1, &c_b2, &y[*k + 1 + i__ * y_dim1], | |||
| &c__1); | |||
| i__2 = *n - *k; | |||
| zscal_(&i__2, &tau[i__], &y[*k + 1 + i__ * y_dim1], &c__1); | |||
| /* Compute T(1:I,I) */ | |||
| i__2 = i__ - 1; | |||
| i__3 = i__; | |||
| z__1.r = -tau[i__3].r, z__1.i = -tau[i__3].i; | |||
| zscal_(&i__2, &z__1, &t[i__ * t_dim1 + 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| ztrmv_("Upper", "No Transpose", "NON-UNIT", &i__2, &t[t_offset], ldt, | |||
| &t[i__ * t_dim1 + 1], &c__1) | |||
| ; | |||
| i__2 = i__ + i__ * t_dim1; | |||
| i__3 = i__; | |||
| t[i__2].r = tau[i__3].r, t[i__2].i = tau[i__3].i; | |||
| /* L10: */ | |||
| } | |||
| i__1 = *k + *nb + *nb * a_dim1; | |||
| a[i__1].r = ei.r, a[i__1].i = ei.i; | |||
| /* Compute Y(1:K,1:NB) */ | |||
| zlacpy_("ALL", k, nb, &a[(a_dim1 << 1) + 1], lda, &y[y_offset], ldy); | |||
| ztrmm_("RIGHT", "Lower", "NO TRANSPOSE", "UNIT", k, nb, &c_b2, &a[*k + 1 | |||
| + a_dim1], lda, &y[y_offset], ldy); | |||
| if (*n > *k + *nb) { | |||
| i__1 = *n - *k - *nb; | |||
| zgemm_("NO TRANSPOSE", "NO TRANSPOSE", k, nb, &i__1, &c_b2, &a[(*nb + | |||
| 2) * a_dim1 + 1], lda, &a[*k + 1 + *nb + a_dim1], lda, &c_b2, | |||
| &y[y_offset], ldy); | |||
| } | |||
| ztrmm_("RIGHT", "Upper", "NO TRANSPOSE", "NON-UNIT", k, nb, &c_b2, &t[ | |||
| t_offset], ldt, &y[y_offset], ldy); | |||
| return 0; | |||
| /* End of ZLAHR2 */ | |||
| } /* zlahr2_ */ | |||
| @@ -0,0 +1,880 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLAIC1 applies one step of incremental condition estimation. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAIC1 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaic1. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaic1. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaic1. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAIC1( JOB, J, X, SEST, W, GAMMA, SESTPR, S, C ) */ | |||
| /* INTEGER J, JOB */ | |||
| /* DOUBLE PRECISION SEST, SESTPR */ | |||
| /* COMPLEX*16 C, GAMMA, S */ | |||
| /* COMPLEX*16 W( J ), X( J ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAIC1 applies one step of incremental condition estimation in */ | |||
| /* > its simplest version: */ | |||
| /* > */ | |||
| /* > Let x, twonorm(x) = 1, be an approximate singular vector of an j-by-j */ | |||
| /* > lower triangular matrix L, such that */ | |||
| /* > twonorm(L*x) = sest */ | |||
| /* > Then ZLAIC1 computes sestpr, s, c such that */ | |||
| /* > the vector */ | |||
| /* > [ s*x ] */ | |||
| /* > xhat = [ c ] */ | |||
| /* > is an approximate singular vector of */ | |||
| /* > [ L 0 ] */ | |||
| /* > Lhat = [ w**H gamma ] */ | |||
| /* > in the sense that */ | |||
| /* > twonorm(Lhat*xhat) = sestpr. */ | |||
| /* > */ | |||
| /* > Depending on JOB, an estimate for the largest or smallest singular */ | |||
| /* > value is computed. */ | |||
| /* > */ | |||
| /* > Note that [s c]**H and sestpr**2 is an eigenpair of the system */ | |||
| /* > */ | |||
| /* > diag(sest*sest, 0) + [alpha gamma] * [ conjg(alpha) ] */ | |||
| /* > [ conjg(gamma) ] */ | |||
| /* > */ | |||
| /* > where alpha = x**H * w. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOB */ | |||
| /* > \verbatim */ | |||
| /* > JOB is INTEGER */ | |||
| /* > = 1: an estimate for the largest singular value is computed. */ | |||
| /* > = 2: an estimate for the smallest singular value is computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] J */ | |||
| /* > \verbatim */ | |||
| /* > J is INTEGER */ | |||
| /* > Length of X and W */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension (J) */ | |||
| /* > The j-vector x. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SEST */ | |||
| /* > \verbatim */ | |||
| /* > SEST is DOUBLE PRECISION */ | |||
| /* > Estimated singular value of j by j matrix L */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] W */ | |||
| /* > \verbatim */ | |||
| /* > W is COMPLEX*16 array, dimension (J) */ | |||
| /* > The j-vector w. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] GAMMA */ | |||
| /* > \verbatim */ | |||
| /* > GAMMA is COMPLEX*16 */ | |||
| /* > The diagonal element gamma. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SESTPR */ | |||
| /* > \verbatim */ | |||
| /* > SESTPR is DOUBLE PRECISION */ | |||
| /* > Estimated singular value of (j+1) by (j+1) matrix Lhat. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] S */ | |||
| /* > \verbatim */ | |||
| /* > S is COMPLEX*16 */ | |||
| /* > Sine needed in forming xhat. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX*16 */ | |||
| /* > Cosine needed in forming xhat. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaic1_(integer *job, integer *j, doublecomplex *x, | |||
| doublereal *sest, doublecomplex *w, doublecomplex *gamma, doublereal * | |||
| sestpr, doublecomplex *s, doublecomplex *c__) | |||
| { | |||
| /* System generated locals */ | |||
| doublereal d__1, d__2; | |||
| doublecomplex z__1, z__2, z__3, z__4, z__5, z__6; | |||
| /* Local variables */ | |||
| doublecomplex sine; | |||
| doublereal test, zeta1, zeta2, b, t; | |||
| doublecomplex alpha; | |||
| doublereal norma; | |||
| extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *); | |||
| doublereal s1, s2; | |||
| extern doublereal dlamch_(char *); | |||
| doublereal absgam, absalp; | |||
| doublecomplex cosine; | |||
| doublereal absest, scl, eps, tmp; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --w; | |||
| --x; | |||
| /* Function Body */ | |||
| eps = dlamch_("Epsilon"); | |||
| zdotc_(&z__1, j, &x[1], &c__1, &w[1], &c__1); | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| absalp = z_abs(&alpha); | |||
| absgam = z_abs(gamma); | |||
| absest = abs(*sest); | |||
| if (*job == 1) { | |||
| /* Estimating largest singular value */ | |||
| /* special cases */ | |||
| if (*sest == 0.) { | |||
| s1 = f2cmax(absgam,absalp); | |||
| if (s1 == 0.) { | |||
| s->r = 0., s->i = 0.; | |||
| c__->r = 1., c__->i = 0.; | |||
| *sestpr = 0.; | |||
| } else { | |||
| z__1.r = alpha.r / s1, z__1.i = alpha.i / s1; | |||
| s->r = z__1.r, s->i = z__1.i; | |||
| z__1.r = gamma->r / s1, z__1.i = gamma->i / s1; | |||
| c__->r = z__1.r, c__->i = z__1.i; | |||
| d_cnjg(&z__4, s); | |||
| z__3.r = s->r * z__4.r - s->i * z__4.i, z__3.i = s->r * | |||
| z__4.i + s->i * z__4.r; | |||
| d_cnjg(&z__6, c__); | |||
| z__5.r = c__->r * z__6.r - c__->i * z__6.i, z__5.i = c__->r * | |||
| z__6.i + c__->i * z__6.r; | |||
| z__2.r = z__3.r + z__5.r, z__2.i = z__3.i + z__5.i; | |||
| z_sqrt(&z__1, &z__2); | |||
| tmp = z__1.r; | |||
| z__1.r = s->r / tmp, z__1.i = s->i / tmp; | |||
| s->r = z__1.r, s->i = z__1.i; | |||
| z__1.r = c__->r / tmp, z__1.i = c__->i / tmp; | |||
| c__->r = z__1.r, c__->i = z__1.i; | |||
| *sestpr = s1 * tmp; | |||
| } | |||
| return 0; | |||
| } else if (absgam <= eps * absest) { | |||
| s->r = 1., s->i = 0.; | |||
| c__->r = 0., c__->i = 0.; | |||
| tmp = f2cmax(absest,absalp); | |||
| s1 = absest / tmp; | |||
| s2 = absalp / tmp; | |||
| *sestpr = tmp * sqrt(s1 * s1 + s2 * s2); | |||
| return 0; | |||
| } else if (absalp <= eps * absest) { | |||
| s1 = absgam; | |||
| s2 = absest; | |||
| if (s1 <= s2) { | |||
| s->r = 1., s->i = 0.; | |||
| c__->r = 0., c__->i = 0.; | |||
| *sestpr = s2; | |||
| } else { | |||
| s->r = 0., s->i = 0.; | |||
| c__->r = 1., c__->i = 0.; | |||
| *sestpr = s1; | |||
| } | |||
| return 0; | |||
| } else if (absest <= eps * absalp || absest <= eps * absgam) { | |||
| s1 = absgam; | |||
| s2 = absalp; | |||
| if (s1 <= s2) { | |||
| tmp = s1 / s2; | |||
| scl = sqrt(tmp * tmp + 1.); | |||
| *sestpr = s2 * scl; | |||
| z__2.r = alpha.r / s2, z__2.i = alpha.i / s2; | |||
| z__1.r = z__2.r / scl, z__1.i = z__2.i / scl; | |||
| s->r = z__1.r, s->i = z__1.i; | |||
| z__2.r = gamma->r / s2, z__2.i = gamma->i / s2; | |||
| z__1.r = z__2.r / scl, z__1.i = z__2.i / scl; | |||
| c__->r = z__1.r, c__->i = z__1.i; | |||
| } else { | |||
| tmp = s2 / s1; | |||
| scl = sqrt(tmp * tmp + 1.); | |||
| *sestpr = s1 * scl; | |||
| z__2.r = alpha.r / s1, z__2.i = alpha.i / s1; | |||
| z__1.r = z__2.r / scl, z__1.i = z__2.i / scl; | |||
| s->r = z__1.r, s->i = z__1.i; | |||
| z__2.r = gamma->r / s1, z__2.i = gamma->i / s1; | |||
| z__1.r = z__2.r / scl, z__1.i = z__2.i / scl; | |||
| c__->r = z__1.r, c__->i = z__1.i; | |||
| } | |||
| return 0; | |||
| } else { | |||
| /* normal case */ | |||
| zeta1 = absalp / absest; | |||
| zeta2 = absgam / absest; | |||
| b = (1. - zeta1 * zeta1 - zeta2 * zeta2) * .5; | |||
| d__1 = zeta1 * zeta1; | |||
| c__->r = d__1, c__->i = 0.; | |||
| if (b > 0.) { | |||
| d__1 = b * b; | |||
| z__4.r = d__1 + c__->r, z__4.i = c__->i; | |||
| z_sqrt(&z__3, &z__4); | |||
| z__2.r = b + z__3.r, z__2.i = z__3.i; | |||
| z_div(&z__1, c__, &z__2); | |||
| t = z__1.r; | |||
| } else { | |||
| d__1 = b * b; | |||
| z__3.r = d__1 + c__->r, z__3.i = c__->i; | |||
| z_sqrt(&z__2, &z__3); | |||
| z__1.r = z__2.r - b, z__1.i = z__2.i; | |||
| t = z__1.r; | |||
| } | |||
| z__3.r = alpha.r / absest, z__3.i = alpha.i / absest; | |||
| z__2.r = -z__3.r, z__2.i = -z__3.i; | |||
| z__1.r = z__2.r / t, z__1.i = z__2.i / t; | |||
| sine.r = z__1.r, sine.i = z__1.i; | |||
| z__3.r = gamma->r / absest, z__3.i = gamma->i / absest; | |||
| z__2.r = -z__3.r, z__2.i = -z__3.i; | |||
| d__1 = t + 1.; | |||
| z__1.r = z__2.r / d__1, z__1.i = z__2.i / d__1; | |||
| cosine.r = z__1.r, cosine.i = z__1.i; | |||
| d_cnjg(&z__4, &sine); | |||
| z__3.r = sine.r * z__4.r - sine.i * z__4.i, z__3.i = sine.r * | |||
| z__4.i + sine.i * z__4.r; | |||
| d_cnjg(&z__6, &cosine); | |||
| z__5.r = cosine.r * z__6.r - cosine.i * z__6.i, z__5.i = cosine.r | |||
| * z__6.i + cosine.i * z__6.r; | |||
| z__2.r = z__3.r + z__5.r, z__2.i = z__3.i + z__5.i; | |||
| z_sqrt(&z__1, &z__2); | |||
| tmp = z__1.r; | |||
| z__1.r = sine.r / tmp, z__1.i = sine.i / tmp; | |||
| s->r = z__1.r, s->i = z__1.i; | |||
| z__1.r = cosine.r / tmp, z__1.i = cosine.i / tmp; | |||
| c__->r = z__1.r, c__->i = z__1.i; | |||
| *sestpr = sqrt(t + 1.) * absest; | |||
| return 0; | |||
| } | |||
| } else if (*job == 2) { | |||
| /* Estimating smallest singular value */ | |||
| /* special cases */ | |||
| if (*sest == 0.) { | |||
| *sestpr = 0.; | |||
| if (f2cmax(absgam,absalp) == 0.) { | |||
| sine.r = 1., sine.i = 0.; | |||
| cosine.r = 0., cosine.i = 0.; | |||
| } else { | |||
| d_cnjg(&z__2, gamma); | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| sine.r = z__1.r, sine.i = z__1.i; | |||
| d_cnjg(&z__1, &alpha); | |||
| cosine.r = z__1.r, cosine.i = z__1.i; | |||
| } | |||
| /* Computing MAX */ | |||
| d__1 = z_abs(&sine), d__2 = z_abs(&cosine); | |||
| s1 = f2cmax(d__1,d__2); | |||
| z__1.r = sine.r / s1, z__1.i = sine.i / s1; | |||
| s->r = z__1.r, s->i = z__1.i; | |||
| z__1.r = cosine.r / s1, z__1.i = cosine.i / s1; | |||
| c__->r = z__1.r, c__->i = z__1.i; | |||
| d_cnjg(&z__4, s); | |||
| z__3.r = s->r * z__4.r - s->i * z__4.i, z__3.i = s->r * z__4.i + | |||
| s->i * z__4.r; | |||
| d_cnjg(&z__6, c__); | |||
| z__5.r = c__->r * z__6.r - c__->i * z__6.i, z__5.i = c__->r * | |||
| z__6.i + c__->i * z__6.r; | |||
| z__2.r = z__3.r + z__5.r, z__2.i = z__3.i + z__5.i; | |||
| z_sqrt(&z__1, &z__2); | |||
| tmp = z__1.r; | |||
| z__1.r = s->r / tmp, z__1.i = s->i / tmp; | |||
| s->r = z__1.r, s->i = z__1.i; | |||
| z__1.r = c__->r / tmp, z__1.i = c__->i / tmp; | |||
| c__->r = z__1.r, c__->i = z__1.i; | |||
| return 0; | |||
| } else if (absgam <= eps * absest) { | |||
| s->r = 0., s->i = 0.; | |||
| c__->r = 1., c__->i = 0.; | |||
| *sestpr = absgam; | |||
| return 0; | |||
| } else if (absalp <= eps * absest) { | |||
| s1 = absgam; | |||
| s2 = absest; | |||
| if (s1 <= s2) { | |||
| s->r = 0., s->i = 0.; | |||
| c__->r = 1., c__->i = 0.; | |||
| *sestpr = s1; | |||
| } else { | |||
| s->r = 1., s->i = 0.; | |||
| c__->r = 0., c__->i = 0.; | |||
| *sestpr = s2; | |||
| } | |||
| return 0; | |||
| } else if (absest <= eps * absalp || absest <= eps * absgam) { | |||
| s1 = absgam; | |||
| s2 = absalp; | |||
| if (s1 <= s2) { | |||
| tmp = s1 / s2; | |||
| scl = sqrt(tmp * tmp + 1.); | |||
| *sestpr = absest * (tmp / scl); | |||
| d_cnjg(&z__4, gamma); | |||
| z__3.r = z__4.r / s2, z__3.i = z__4.i / s2; | |||
| z__2.r = -z__3.r, z__2.i = -z__3.i; | |||
| z__1.r = z__2.r / scl, z__1.i = z__2.i / scl; | |||
| s->r = z__1.r, s->i = z__1.i; | |||
| d_cnjg(&z__3, &alpha); | |||
| z__2.r = z__3.r / s2, z__2.i = z__3.i / s2; | |||
| z__1.r = z__2.r / scl, z__1.i = z__2.i / scl; | |||
| c__->r = z__1.r, c__->i = z__1.i; | |||
| } else { | |||
| tmp = s2 / s1; | |||
| scl = sqrt(tmp * tmp + 1.); | |||
| *sestpr = absest / scl; | |||
| d_cnjg(&z__4, gamma); | |||
| z__3.r = z__4.r / s1, z__3.i = z__4.i / s1; | |||
| z__2.r = -z__3.r, z__2.i = -z__3.i; | |||
| z__1.r = z__2.r / scl, z__1.i = z__2.i / scl; | |||
| s->r = z__1.r, s->i = z__1.i; | |||
| d_cnjg(&z__3, &alpha); | |||
| z__2.r = z__3.r / s1, z__2.i = z__3.i / s1; | |||
| z__1.r = z__2.r / scl, z__1.i = z__2.i / scl; | |||
| c__->r = z__1.r, c__->i = z__1.i; | |||
| } | |||
| return 0; | |||
| } else { | |||
| /* normal case */ | |||
| zeta1 = absalp / absest; | |||
| zeta2 = absgam / absest; | |||
| /* Computing MAX */ | |||
| d__1 = zeta1 * zeta1 + 1. + zeta1 * zeta2, d__2 = zeta1 * zeta2 + | |||
| zeta2 * zeta2; | |||
| norma = f2cmax(d__1,d__2); | |||
| /* See if root is closer to zero or to ONE */ | |||
| test = (zeta1 - zeta2) * 2. * (zeta1 + zeta2) + 1.; | |||
| if (test >= 0.) { | |||
| /* root is close to zero, compute directly */ | |||
| b = (zeta1 * zeta1 + zeta2 * zeta2 + 1.) * .5; | |||
| d__1 = zeta2 * zeta2; | |||
| c__->r = d__1, c__->i = 0.; | |||
| d__2 = b * b; | |||
| z__2.r = d__2 - c__->r, z__2.i = -c__->i; | |||
| d__1 = b + sqrt(z_abs(&z__2)); | |||
| z__1.r = c__->r / d__1, z__1.i = c__->i / d__1; | |||
| t = z__1.r; | |||
| z__2.r = alpha.r / absest, z__2.i = alpha.i / absest; | |||
| d__1 = 1. - t; | |||
| z__1.r = z__2.r / d__1, z__1.i = z__2.i / d__1; | |||
| sine.r = z__1.r, sine.i = z__1.i; | |||
| z__3.r = gamma->r / absest, z__3.i = gamma->i / absest; | |||
| z__2.r = -z__3.r, z__2.i = -z__3.i; | |||
| z__1.r = z__2.r / t, z__1.i = z__2.i / t; | |||
| cosine.r = z__1.r, cosine.i = z__1.i; | |||
| *sestpr = sqrt(t + eps * 4. * eps * norma) * absest; | |||
| } else { | |||
| /* root is closer to ONE, shift by that amount */ | |||
| b = (zeta2 * zeta2 + zeta1 * zeta1 - 1.) * .5; | |||
| d__1 = zeta1 * zeta1; | |||
| c__->r = d__1, c__->i = 0.; | |||
| if (b >= 0.) { | |||
| z__2.r = -c__->r, z__2.i = -c__->i; | |||
| d__1 = b * b; | |||
| z__5.r = d__1 + c__->r, z__5.i = c__->i; | |||
| z_sqrt(&z__4, &z__5); | |||
| z__3.r = b + z__4.r, z__3.i = z__4.i; | |||
| z_div(&z__1, &z__2, &z__3); | |||
| t = z__1.r; | |||
| } else { | |||
| d__1 = b * b; | |||
| z__3.r = d__1 + c__->r, z__3.i = c__->i; | |||
| z_sqrt(&z__2, &z__3); | |||
| z__1.r = b - z__2.r, z__1.i = -z__2.i; | |||
| t = z__1.r; | |||
| } | |||
| z__3.r = alpha.r / absest, z__3.i = alpha.i / absest; | |||
| z__2.r = -z__3.r, z__2.i = -z__3.i; | |||
| z__1.r = z__2.r / t, z__1.i = z__2.i / t; | |||
| sine.r = z__1.r, sine.i = z__1.i; | |||
| z__3.r = gamma->r / absest, z__3.i = gamma->i / absest; | |||
| z__2.r = -z__3.r, z__2.i = -z__3.i; | |||
| d__1 = t + 1.; | |||
| z__1.r = z__2.r / d__1, z__1.i = z__2.i / d__1; | |||
| cosine.r = z__1.r, cosine.i = z__1.i; | |||
| *sestpr = sqrt(t + 1. + eps * 4. * eps * norma) * absest; | |||
| } | |||
| d_cnjg(&z__4, &sine); | |||
| z__3.r = sine.r * z__4.r - sine.i * z__4.i, z__3.i = sine.r * | |||
| z__4.i + sine.i * z__4.r; | |||
| d_cnjg(&z__6, &cosine); | |||
| z__5.r = cosine.r * z__6.r - cosine.i * z__6.i, z__5.i = cosine.r | |||
| * z__6.i + cosine.i * z__6.r; | |||
| z__2.r = z__3.r + z__5.r, z__2.i = z__3.i + z__5.i; | |||
| z_sqrt(&z__1, &z__2); | |||
| tmp = z__1.r; | |||
| z__1.r = sine.r / tmp, z__1.i = sine.i / tmp; | |||
| s->r = z__1.r, s->i = z__1.i; | |||
| z__1.r = cosine.r / tmp, z__1.i = cosine.i / tmp; | |||
| c__->r = z__1.r, c__->i = z__1.i; | |||
| return 0; | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLAIC1 */ | |||
| } /* zlaic1_ */ | |||
| @@ -0,0 +1,846 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__0 = 0; | |||
| /* > \brief \b ZLAMSWLQ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAMSWLQ( SIDE, TRANS, M, N, K, MB, NB, A, LDA, T, */ | |||
| /* $ LDT, C, LDC, WORK, LWORK, INFO ) */ | |||
| /* CHARACTER SIDE, TRANS */ | |||
| /* INTEGER INFO, LDA, M, N, K, MB, NB, LDT, LWORK, LDC */ | |||
| /* COMPLEX*16 A( LDA, * ), WORK( * ), C(LDC, * ), */ | |||
| /* $ T( LDT, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAMQRTS overwrites the general real M-by-N matrix C with */ | |||
| /* > */ | |||
| /* > */ | |||
| /* > SIDE = 'L' SIDE = 'R' */ | |||
| /* > TRANS = 'N': Q * C C * Q */ | |||
| /* > TRANS = 'C': Q**H * C C * Q**H */ | |||
| /* > where Q is a real orthogonal matrix defined as the product of blocked */ | |||
| /* > elementary reflectors computed by short wide LQ */ | |||
| /* > factorization (ZLASWLQ) */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': apply Q or Q**H from the Left; */ | |||
| /* > = 'R': apply Q or Q**H from the Right. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > = 'N': No transpose, apply Q; */ | |||
| /* > = 'C': Conjugate Transpose, apply Q**H. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix C. M >=0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix C. N >= M. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The number of elementary reflectors whose product defines */ | |||
| /* > the matrix Q. */ | |||
| /* > M >= K >= 0; */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > \param[in] MB */ | |||
| /* > \verbatim */ | |||
| /* > MB is INTEGER */ | |||
| /* > The row block size to be used in the blocked QR. */ | |||
| /* > M >= MB >= 1 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The column block size to be used in the blocked QR. */ | |||
| /* > NB > M. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The block size to be used in the blocked QR. */ | |||
| /* > MB > M. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension */ | |||
| /* > (LDA,M) if SIDE = 'L', */ | |||
| /* > (LDA,N) if SIDE = 'R' */ | |||
| /* > The i-th row must contain the vector which defines the blocked */ | |||
| /* > elementary reflector H(i), for i = 1,2,...,k, as returned by */ | |||
| /* > ZLASWLQ in the first k rows of its array argument A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. */ | |||
| /* > If SIDE = 'L', LDA >= f2cmax(1,M); */ | |||
| /* > if SIDE = 'R', LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX*16 array, dimension */ | |||
| /* > ( M * Number of blocks(CEIL(N-K/NB-K)), */ | |||
| /* > The blocked upper triangular block reflectors stored in compact form */ | |||
| /* > as a sequence of upper triangular blocks. See below */ | |||
| /* > for further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= MB. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX*16 array, dimension (LDC,N) */ | |||
| /* > On entry, the M-by-N matrix C. */ | |||
| /* > On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the array C. LDC >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > (workspace) COMPLEX*16 array, dimension (MAX(1,LWORK)) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > If SIDE = 'L', LWORK >= f2cmax(1,NB) * MB; */ | |||
| /* > if SIDE = 'R', LWORK >= f2cmax(1,M) * MB. */ | |||
| /* > If LWORK = -1, then a workspace query is assumed; the routine */ | |||
| /* > only calculates the optimal size of the WORK array, returns */ | |||
| /* > this value as the first entry of the WORK array, and no error */ | |||
| /* > message related to LWORK is issued by XERBLA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > Short-Wide LQ (SWLQ) performs LQ by a sequence of orthogonal transformations, */ | |||
| /* > representing Q as a product of other orthogonal matrices */ | |||
| /* > Q = Q(1) * Q(2) * . . . * Q(k) */ | |||
| /* > where each Q(i) zeros out upper diagonal entries of a block of NB rows of A: */ | |||
| /* > Q(1) zeros out the upper diagonal entries of rows 1:NB of A */ | |||
| /* > Q(2) zeros out the bottom MB-N rows of rows [1:M,NB+1:2*NB-M] of A */ | |||
| /* > Q(3) zeros out the bottom MB-N rows of rows [1:M,2*NB-M+1:3*NB-2*M] of A */ | |||
| /* > . . . */ | |||
| /* > */ | |||
| /* > Q(1) is computed by GELQT, which represents Q(1) by Householder vectors */ | |||
| /* > stored under the diagonal of rows 1:MB of A, and by upper triangular */ | |||
| /* > block reflectors, stored in array T(1:LDT,1:N). */ | |||
| /* > For more information see Further Details in GELQT. */ | |||
| /* > */ | |||
| /* > Q(i) for i>1 is computed by TPLQT, which represents Q(i) by Householder vectors */ | |||
| /* > stored in columns [(i-1)*(NB-M)+M+1:i*(NB-M)+M] of A, and by upper triangular */ | |||
| /* > block reflectors, stored in array T(1:LDT,(i-1)*M+1:i*M). */ | |||
| /* > The last Q(k) may use fewer rows. */ | |||
| /* > For more information see Further Details in TPQRT. */ | |||
| /* > */ | |||
| /* > For more details of the overall algorithm, see the description of */ | |||
| /* > Sequential TSQR in Section 2.2 of [1]. */ | |||
| /* > */ | |||
| /* > [1] “Communication-Optimal Parallel and Sequential QR and LU Factorizations, */ | |||
| /* > J. Demmel, L. Grigori, M. Hoemmen, J. Langou, */ | |||
| /* > SIAM J. Sci. Comput, vol. 34, no. 1, 2012 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlamswlq_(char *side, char *trans, integer *m, integer * | |||
| n, integer *k, integer *mb, integer *nb, doublecomplex *a, integer * | |||
| lda, doublecomplex *t, integer *ldt, doublecomplex *c__, integer *ldc, | |||
| doublecomplex *work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, c_dim1, c_offset, t_dim1, t_offset, i__1, i__2, | |||
| i__3; | |||
| /* Local variables */ | |||
| logical left, tran; | |||
| integer i__; | |||
| extern logical lsame_(char *, char *); | |||
| logical right; | |||
| integer ii, kk, lw; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| logical notran, lquery; | |||
| integer ctr; | |||
| extern /* Subroutine */ int zgemlqt_(char *, char *, integer *, integer *, | |||
| integer *, integer *, doublecomplex *, integer *, doublecomplex * | |||
| , integer *, doublecomplex *, integer *, doublecomplex *, integer | |||
| *), ztpmlqt_(char *, char *, integer *, integer *, | |||
| integer *, integer *, integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *); | |||
| /* -- LAPACK computational routine (version 3.7.1) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2017 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| lquery = *lwork < 0; | |||
| notran = lsame_(trans, "N"); | |||
| tran = lsame_(trans, "C"); | |||
| left = lsame_(side, "L"); | |||
| right = lsame_(side, "R"); | |||
| if (left) { | |||
| lw = *n * *mb; | |||
| } else { | |||
| lw = *m * *mb; | |||
| } | |||
| *info = 0; | |||
| if (! left && ! right) { | |||
| *info = -1; | |||
| } else if (! tran && ! notran) { | |||
| *info = -2; | |||
| } else if (*m < 0) { | |||
| *info = -3; | |||
| } else if (*n < 0) { | |||
| *info = -4; | |||
| } else if (*k < 0) { | |||
| *info = -5; | |||
| } else if (*lda < f2cmax(1,*k)) { | |||
| *info = -9; | |||
| } else if (*ldt < f2cmax(1,*mb)) { | |||
| *info = -11; | |||
| } else if (*ldc < f2cmax(1,*m)) { | |||
| *info = -13; | |||
| } else if (*lwork < f2cmax(1,lw) && ! lquery) { | |||
| *info = -15; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("ZLAMSWLQ", &i__1, (ftnlen)8); | |||
| work[1].r = (doublereal) lw, work[1].i = 0.; | |||
| return 0; | |||
| } else if (lquery) { | |||
| work[1].r = (doublereal) lw, work[1].i = 0.; | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| /* Computing MIN */ | |||
| i__1 = f2cmin(*m,*n); | |||
| if (f2cmin(i__1,*k) == 0) { | |||
| return 0; | |||
| } | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(*m,*n); | |||
| if (*nb <= *k || *nb >= f2cmax(i__1,*k)) { | |||
| zgemlqt_(side, trans, m, n, k, mb, &a[a_offset], lda, &t[t_offset], | |||
| ldt, &c__[c_offset], ldc, &work[1], info); | |||
| return 0; | |||
| } | |||
| if (left && tran) { | |||
| /* Multiply Q to the last block of C */ | |||
| kk = (*m - *k) % (*nb - *k); | |||
| ctr = (*m - *k) / (*nb - *k); | |||
| if (kk > 0) { | |||
| ii = *m - kk + 1; | |||
| ztpmlqt_("L", "C", &kk, n, k, &c__0, mb, &a[ii * a_dim1 + 1], lda, | |||
| &t[(ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + 1], | |||
| ldc, &c__[ii + c_dim1], ldc, &work[1], info); | |||
| } else { | |||
| ii = *m + 1; | |||
| } | |||
| i__1 = *nb + 1; | |||
| i__2 = -(*nb - *k); | |||
| for (i__ = ii - (*nb - *k); i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ | |||
| += i__2) { | |||
| /* Multiply Q to the current block of C (1:M,I:I+NB) */ | |||
| --ctr; | |||
| i__3 = *nb - *k; | |||
| ztpmlqt_("L", "C", &i__3, n, k, &c__0, mb, &a[i__ * a_dim1 + 1], | |||
| lda, &t[(ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + | |||
| 1], ldc, &c__[i__ + c_dim1], ldc, &work[1], info); | |||
| } | |||
| /* Multiply Q to the first block of C (1:M,1:NB) */ | |||
| zgemlqt_("L", "C", nb, n, k, mb, &a[a_dim1 + 1], lda, &t[t_offset], | |||
| ldt, &c__[c_dim1 + 1], ldc, &work[1], info); | |||
| } else if (left && notran) { | |||
| /* Multiply Q to the first block of C */ | |||
| kk = (*m - *k) % (*nb - *k); | |||
| ii = *m - kk + 1; | |||
| ctr = 1; | |||
| zgemlqt_("L", "N", nb, n, k, mb, &a[a_dim1 + 1], lda, &t[t_offset], | |||
| ldt, &c__[c_dim1 + 1], ldc, &work[1], info); | |||
| i__2 = ii - *nb + *k; | |||
| i__1 = *nb - *k; | |||
| for (i__ = *nb + 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) | |||
| { | |||
| /* Multiply Q to the current block of C (I:I+NB,1:N) */ | |||
| i__3 = *nb - *k; | |||
| ztpmlqt_("L", "N", &i__3, n, k, &c__0, mb, &a[i__ * a_dim1 + 1], | |||
| lda, &t[(ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + | |||
| 1], ldc, &c__[i__ + c_dim1], ldc, &work[1], info); | |||
| ++ctr; | |||
| } | |||
| if (ii <= *m) { | |||
| /* Multiply Q to the last block of C */ | |||
| ztpmlqt_("L", "N", &kk, n, k, &c__0, mb, &a[ii * a_dim1 + 1], lda, | |||
| &t[(ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + 1], | |||
| ldc, &c__[ii + c_dim1], ldc, &work[1], info); | |||
| } | |||
| } else if (right && notran) { | |||
| /* Multiply Q to the last block of C */ | |||
| kk = (*n - *k) % (*nb - *k); | |||
| ctr = (*n - *k) / (*nb - *k); | |||
| if (kk > 0) { | |||
| ii = *n - kk + 1; | |||
| ztpmlqt_("R", "N", m, &kk, k, &c__0, mb, &a[ii * a_dim1 + 1], lda, | |||
| &t[(ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + 1], | |||
| ldc, &c__[ii * c_dim1 + 1], ldc, &work[1], info); | |||
| } else { | |||
| ii = *n + 1; | |||
| } | |||
| i__1 = *nb + 1; | |||
| i__2 = -(*nb - *k); | |||
| for (i__ = ii - (*nb - *k); i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ | |||
| += i__2) { | |||
| /* Multiply Q to the current block of C (1:M,I:I+MB) */ | |||
| --ctr; | |||
| i__3 = *nb - *k; | |||
| ztpmlqt_("R", "N", m, &i__3, k, &c__0, mb, &a[i__ * a_dim1 + 1], | |||
| lda, &t[(ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + | |||
| 1], ldc, &c__[i__ * c_dim1 + 1], ldc, &work[1], info); | |||
| } | |||
| /* Multiply Q to the first block of C (1:M,1:MB) */ | |||
| zgemlqt_("R", "N", m, nb, k, mb, &a[a_dim1 + 1], lda, &t[t_offset], | |||
| ldt, &c__[c_dim1 + 1], ldc, &work[1], info); | |||
| } else if (right && tran) { | |||
| /* Multiply Q to the first block of C */ | |||
| kk = (*n - *k) % (*nb - *k); | |||
| ii = *n - kk + 1; | |||
| zgemlqt_("R", "C", m, nb, k, mb, &a[a_dim1 + 1], lda, &t[t_offset], | |||
| ldt, &c__[c_dim1 + 1], ldc, &work[1], info); | |||
| ctr = 1; | |||
| i__2 = ii - *nb + *k; | |||
| i__1 = *nb - *k; | |||
| for (i__ = *nb + 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) | |||
| { | |||
| /* Multiply Q to the current block of C (1:M,I:I+MB) */ | |||
| i__3 = *nb - *k; | |||
| ztpmlqt_("R", "C", m, &i__3, k, &c__0, mb, &a[i__ * a_dim1 + 1], | |||
| lda, &t[(ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + | |||
| 1], ldc, &c__[i__ * c_dim1 + 1], ldc, &work[1], info); | |||
| ++ctr; | |||
| } | |||
| if (ii <= *n) { | |||
| /* Multiply Q to the last block of C */ | |||
| ztpmlqt_("R", "C", m, &kk, k, &c__0, mb, &a[ii * a_dim1 + 1], lda, | |||
| &t[(ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + 1], | |||
| ldc, &c__[ii * c_dim1 + 1], ldc, &work[1], info); | |||
| } | |||
| } | |||
| work[1].r = (doublereal) lw, work[1].i = 0.; | |||
| return 0; | |||
| /* End of ZLAMSWLQ */ | |||
| } /* zlamswlq_ */ | |||
| @@ -0,0 +1,843 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__0 = 0; | |||
| /* > \brief \b ZLAMTSQR */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAMTSQR( SIDE, TRANS, M, N, K, MB, NB, A, LDA, T, */ | |||
| /* $ LDT, C, LDC, WORK, LWORK, INFO ) */ | |||
| /* CHARACTER SIDE, TRANS */ | |||
| /* INTEGER INFO, LDA, M, N, K, MB, NB, LDT, LWORK, LDC */ | |||
| /* COMPLEX*16 A( LDA, * ), WORK( * ), C(LDC, * ), */ | |||
| /* $ T( LDT, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAMTSQR overwrites the general complex M-by-N matrix C with */ | |||
| /* > */ | |||
| /* > */ | |||
| /* > SIDE = 'L' SIDE = 'R' */ | |||
| /* > TRANS = 'N': Q * C C * Q */ | |||
| /* > TRANS = 'C': Q**H * C C * Q**H */ | |||
| /* > where Q is a real orthogonal matrix defined as the product */ | |||
| /* > of blocked elementary reflectors computed by tall skinny */ | |||
| /* > QR factorization (ZLATSQR) */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': apply Q or Q**H from the Left; */ | |||
| /* > = 'R': apply Q or Q**H from the Right. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > = 'N': No transpose, apply Q; */ | |||
| /* > = 'C': Conjugate Transpose, apply Q**H. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >=0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix C. M >= N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The number of elementary reflectors whose product defines */ | |||
| /* > the matrix Q. */ | |||
| /* > N >= K >= 0; */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] MB */ | |||
| /* > \verbatim */ | |||
| /* > MB is INTEGER */ | |||
| /* > The block size to be used in the blocked QR. */ | |||
| /* > MB > N. (must be the same as DLATSQR) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The column block size to be used in the blocked QR. */ | |||
| /* > N >= NB >= 1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,K) */ | |||
| /* > The i-th column must contain the vector which defines the */ | |||
| /* > blockedelementary reflector H(i), for i = 1,2,...,k, as */ | |||
| /* > returned by DLATSQR in the first k columns of */ | |||
| /* > its array argument A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. */ | |||
| /* > If SIDE = 'L', LDA >= f2cmax(1,M); */ | |||
| /* > if SIDE = 'R', LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX*16 array, dimension */ | |||
| /* > ( N * Number of blocks(CEIL(M-K/MB-K)), */ | |||
| /* > The blocked upper triangular block reflectors stored in compact form */ | |||
| /* > as a sequence of upper triangular blocks. See below */ | |||
| /* > for further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= NB. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX*16 array, dimension (LDC,N) */ | |||
| /* > On entry, the M-by-N matrix C. */ | |||
| /* > On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the array C. LDC >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > (workspace) COMPLEX*16 array, dimension (MAX(1,LWORK)) */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > */ | |||
| /* > If SIDE = 'L', LWORK >= f2cmax(1,N)*NB; */ | |||
| /* > if SIDE = 'R', LWORK >= f2cmax(1,MB)*NB. */ | |||
| /* > If LWORK = -1, then a workspace query is assumed; the routine */ | |||
| /* > only calculates the optimal size of the WORK array, returns */ | |||
| /* > this value as the first entry of the WORK array, and no error */ | |||
| /* > message related to LWORK is issued by XERBLA. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > Tall-Skinny QR (TSQR) performs QR by a sequence of orthogonal transformations, */ | |||
| /* > representing Q as a product of other orthogonal matrices */ | |||
| /* > Q = Q(1) * Q(2) * . . . * Q(k) */ | |||
| /* > where each Q(i) zeros out subdiagonal entries of a block of MB rows of A: */ | |||
| /* > Q(1) zeros out the subdiagonal entries of rows 1:MB of A */ | |||
| /* > Q(2) zeros out the bottom MB-N rows of rows [1:N,MB+1:2*MB-N] of A */ | |||
| /* > Q(3) zeros out the bottom MB-N rows of rows [1:N,2*MB-N+1:3*MB-2*N] of A */ | |||
| /* > . . . */ | |||
| /* > */ | |||
| /* > Q(1) is computed by GEQRT, which represents Q(1) by Householder vectors */ | |||
| /* > stored under the diagonal of rows 1:MB of A, and by upper triangular */ | |||
| /* > block reflectors, stored in array T(1:LDT,1:N). */ | |||
| /* > For more information see Further Details in GEQRT. */ | |||
| /* > */ | |||
| /* > Q(i) for i>1 is computed by TPQRT, which represents Q(i) by Householder vectors */ | |||
| /* > stored in rows [(i-1)*(MB-N)+N+1:i*(MB-N)+N] of A, and by upper triangular */ | |||
| /* > block reflectors, stored in array T(1:LDT,(i-1)*N+1:i*N). */ | |||
| /* > The last Q(k) may use fewer rows. */ | |||
| /* > For more information see Further Details in TPQRT. */ | |||
| /* > */ | |||
| /* > For more details of the overall algorithm, see the description of */ | |||
| /* > Sequential TSQR in Section 2.2 of [1]. */ | |||
| /* > */ | |||
| /* > [1] “Communication-Optimal Parallel and Sequential QR and LU Factorizations, */ | |||
| /* > J. Demmel, L. Grigori, M. Hoemmen, J. Langou, */ | |||
| /* > SIAM J. Sci. Comput, vol. 34, no. 1, 2012 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlamtsqr_(char *side, char *trans, integer *m, integer * | |||
| n, integer *k, integer *mb, integer *nb, doublecomplex *a, integer * | |||
| lda, doublecomplex *t, integer *ldt, doublecomplex *c__, integer *ldc, | |||
| doublecomplex *work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, c_dim1, c_offset, t_dim1, t_offset, i__1, i__2, | |||
| i__3; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int ztpmqrt_(char *, char *, integer *, integer *, | |||
| integer *, integer *, integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *); | |||
| logical left, tran; | |||
| integer i__; | |||
| extern logical lsame_(char *, char *); | |||
| logical right; | |||
| integer ii, kk, lw; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| logical notran, lquery; | |||
| integer ctr; | |||
| extern /* Subroutine */ int zgemqrt_(char *, char *, integer *, integer *, | |||
| integer *, integer *, doublecomplex *, integer *, doublecomplex * | |||
| , integer *, doublecomplex *, integer *, doublecomplex *, integer | |||
| *); | |||
| /* -- LAPACK computational routine (version 3.7.1) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2017 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| lquery = *lwork < 0; | |||
| notran = lsame_(trans, "N"); | |||
| tran = lsame_(trans, "C"); | |||
| left = lsame_(side, "L"); | |||
| right = lsame_(side, "R"); | |||
| if (left) { | |||
| lw = *n * *nb; | |||
| } else { | |||
| lw = *m * *nb; | |||
| } | |||
| *info = 0; | |||
| if (! left && ! right) { | |||
| *info = -1; | |||
| } else if (! tran && ! notran) { | |||
| *info = -2; | |||
| } else if (*m < 0) { | |||
| *info = -3; | |||
| } else if (*n < 0) { | |||
| *info = -4; | |||
| } else if (*k < 0) { | |||
| *info = -5; | |||
| } else if (*lda < f2cmax(1,*k)) { | |||
| *info = -9; | |||
| } else if (*ldt < f2cmax(1,*nb)) { | |||
| *info = -11; | |||
| } else if (*ldc < f2cmax(1,*m)) { | |||
| *info = -13; | |||
| } else if (*lwork < f2cmax(1,lw) && ! lquery) { | |||
| *info = -15; | |||
| } | |||
| /* Determine the block size if it is tall skinny or short and wide */ | |||
| if (*info == 0) { | |||
| work[1].r = (doublereal) lw, work[1].i = 0.; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("ZLAMTSQR", &i__1, (ftnlen)8); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| /* Computing MIN */ | |||
| i__1 = f2cmin(*m,*n); | |||
| if (f2cmin(i__1,*k) == 0) { | |||
| return 0; | |||
| } | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(*m,*n); | |||
| if (*mb <= *k || *mb >= f2cmax(i__1,*k)) { | |||
| zgemqrt_(side, trans, m, n, k, nb, &a[a_offset], lda, &t[t_offset], | |||
| ldt, &c__[c_offset], ldc, &work[1], info); | |||
| return 0; | |||
| } | |||
| if (left && notran) { | |||
| /* Multiply Q to the last block of C */ | |||
| kk = (*m - *k) % (*mb - *k); | |||
| ctr = (*m - *k) / (*mb - *k); | |||
| if (kk > 0) { | |||
| ii = *m - kk + 1; | |||
| ztpmqrt_("L", "N", &kk, n, k, &c__0, nb, &a[ii + a_dim1], lda, &t[ | |||
| (ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + 1], ldc, | |||
| &c__[ii + c_dim1], ldc, &work[1], info); | |||
| } else { | |||
| ii = *m + 1; | |||
| } | |||
| i__1 = *mb + 1; | |||
| i__2 = -(*mb - *k); | |||
| for (i__ = ii - (*mb - *k); i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ | |||
| += i__2) { | |||
| /* Multiply Q to the current block of C (I:I+MB,1:N) */ | |||
| --ctr; | |||
| i__3 = *mb - *k; | |||
| ztpmqrt_("L", "N", &i__3, n, k, &c__0, nb, &a[i__ + a_dim1], lda, | |||
| &t[(ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + 1], | |||
| ldc, &c__[i__ + c_dim1], ldc, &work[1], info); | |||
| } | |||
| /* Multiply Q to the first block of C (1:MB,1:N) */ | |||
| zgemqrt_("L", "N", mb, n, k, nb, &a[a_dim1 + 1], lda, &t[t_offset], | |||
| ldt, &c__[c_dim1 + 1], ldc, &work[1], info); | |||
| } else if (left && tran) { | |||
| /* Multiply Q to the first block of C */ | |||
| kk = (*m - *k) % (*mb - *k); | |||
| ii = *m - kk + 1; | |||
| ctr = 1; | |||
| zgemqrt_("L", "C", mb, n, k, nb, &a[a_dim1 + 1], lda, &t[t_offset], | |||
| ldt, &c__[c_dim1 + 1], ldc, &work[1], info); | |||
| i__2 = ii - *mb + *k; | |||
| i__1 = *mb - *k; | |||
| for (i__ = *mb + 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) | |||
| { | |||
| /* Multiply Q to the current block of C (I:I+MB,1:N) */ | |||
| i__3 = *mb - *k; | |||
| ztpmqrt_("L", "C", &i__3, n, k, &c__0, nb, &a[i__ + a_dim1], lda, | |||
| &t[(ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + 1], | |||
| ldc, &c__[i__ + c_dim1], ldc, &work[1], info); | |||
| ++ctr; | |||
| } | |||
| if (ii <= *m) { | |||
| /* Multiply Q to the last block of C */ | |||
| ztpmqrt_("L", "C", &kk, n, k, &c__0, nb, &a[ii + a_dim1], lda, &t[ | |||
| (ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + 1], ldc, | |||
| &c__[ii + c_dim1], ldc, &work[1], info); | |||
| } | |||
| } else if (right && tran) { | |||
| /* Multiply Q to the last block of C */ | |||
| kk = (*n - *k) % (*mb - *k); | |||
| ctr = (*n - *k) / (*mb - *k); | |||
| if (kk > 0) { | |||
| ii = *n - kk + 1; | |||
| ztpmqrt_("R", "C", m, &kk, k, &c__0, nb, &a[ii + a_dim1], lda, &t[ | |||
| (ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + 1], ldc, | |||
| &c__[ii * c_dim1 + 1], ldc, &work[1], info); | |||
| } else { | |||
| ii = *n + 1; | |||
| } | |||
| i__1 = *mb + 1; | |||
| i__2 = -(*mb - *k); | |||
| for (i__ = ii - (*mb - *k); i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ | |||
| += i__2) { | |||
| /* Multiply Q to the current block of C (1:M,I:I+MB) */ | |||
| --ctr; | |||
| i__3 = *mb - *k; | |||
| ztpmqrt_("R", "C", m, &i__3, k, &c__0, nb, &a[i__ + a_dim1], lda, | |||
| &t[(ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + 1], | |||
| ldc, &c__[i__ * c_dim1 + 1], ldc, &work[1], info); | |||
| } | |||
| /* Multiply Q to the first block of C (1:M,1:MB) */ | |||
| zgemqrt_("R", "C", m, mb, k, nb, &a[a_dim1 + 1], lda, &t[t_offset], | |||
| ldt, &c__[c_dim1 + 1], ldc, &work[1], info); | |||
| } else if (right && notran) { | |||
| /* Multiply Q to the first block of C */ | |||
| kk = (*n - *k) % (*mb - *k); | |||
| ii = *n - kk + 1; | |||
| ctr = 1; | |||
| zgemqrt_("R", "N", m, mb, k, nb, &a[a_dim1 + 1], lda, &t[t_offset], | |||
| ldt, &c__[c_dim1 + 1], ldc, &work[1], info); | |||
| i__2 = ii - *mb + *k; | |||
| i__1 = *mb - *k; | |||
| for (i__ = *mb + 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) | |||
| { | |||
| /* Multiply Q to the current block of C (1:M,I:I+MB) */ | |||
| i__3 = *mb - *k; | |||
| ztpmqrt_("R", "N", m, &i__3, k, &c__0, nb, &a[i__ + a_dim1], lda, | |||
| &t[(ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + 1], | |||
| ldc, &c__[i__ * c_dim1 + 1], ldc, &work[1], info); | |||
| ++ctr; | |||
| } | |||
| if (ii <= *n) { | |||
| /* Multiply Q to the last block of C */ | |||
| ztpmqrt_("R", "N", m, &kk, k, &c__0, nb, &a[ii + a_dim1], lda, &t[ | |||
| (ctr * *k + 1) * t_dim1 + 1], ldt, &c__[c_dim1 + 1], ldc, | |||
| &c__[ii * c_dim1 + 1], ldc, &work[1], info); | |||
| } | |||
| } | |||
| work[1].r = (doublereal) lw, work[1].i = 0.; | |||
| return 0; | |||
| /* End of ZLAMTSQR */ | |||
| } /* zlamtsqr_ */ | |||
| @@ -0,0 +1,664 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANGB returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute | |||
| value of any element of general band matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANGB + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlangb. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlangb. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlangb. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANGB( NORM, N, KL, KU, AB, LDAB, */ | |||
| /* WORK ) */ | |||
| /* CHARACTER NORM */ | |||
| /* INTEGER KL, KU, LDAB, N */ | |||
| /* DOUBLE PRECISION WORK( * ) */ | |||
| /* COMPLEX*16 AB( LDAB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANGB returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of an */ | |||
| /* > n by n band matrix A, with kl sub-diagonals and ku super-diagonals. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANGB */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANGB = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANGB as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. When N = 0, ZLANGB is */ | |||
| /* > set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KL */ | |||
| /* > \verbatim */ | |||
| /* > KL is INTEGER */ | |||
| /* > The number of sub-diagonals of the matrix A. KL >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KU */ | |||
| /* > \verbatim */ | |||
| /* > KU is INTEGER */ | |||
| /* > The number of super-diagonals of the matrix A. KU >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX*16 array, dimension (LDAB,N) */ | |||
| /* > The band matrix A, stored in rows 1 to KL+KU+1. The j-th */ | |||
| /* > column of A is stored in the j-th column of the array AB as */ | |||
| /* > follows: */ | |||
| /* > AB(ku+1+i-j,j) = A(i,j) for f2cmax(1,j-ku)<=i<=f2cmin(n,j+kl). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ | |||
| /* > where LWORK >= N when NORM = 'I'; otherwise, WORK is not */ | |||
| /* > referenced. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16GBauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlangb_(char *norm, integer *n, integer *kl, integer *ku, | |||
| doublecomplex *ab, integer *ldab, doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5, i__6; | |||
| doublereal ret_val; | |||
| /* Local variables */ | |||
| doublereal temp; | |||
| extern /* Subroutine */ int dcombssq_(doublereal *, doublereal *); | |||
| integer i__, j, k, l; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal value; | |||
| extern logical disnan_(doublereal *); | |||
| doublereal colssq[2]; | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *); | |||
| doublereal sum, ssq[2]; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (*n == 0) { | |||
| value = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| value = 0.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__2 = *ku + 2 - j; | |||
| /* Computing MIN */ | |||
| i__4 = *n + *ku + 1 - j, i__5 = *kl + *ku + 1; | |||
| i__3 = f2cmin(i__4,i__5); | |||
| for (i__ = f2cmax(i__2,1); i__ <= i__3; ++i__) { | |||
| temp = z_abs(&ab[i__ + j * ab_dim1]); | |||
| if (value < temp || disnan_(&temp)) { | |||
| value = temp; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else if (lsame_(norm, "O") || *(unsigned char *) | |||
| norm == '1') { | |||
| /* Find norm1(A). */ | |||
| value = 0.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| sum = 0.; | |||
| /* Computing MAX */ | |||
| i__3 = *ku + 2 - j; | |||
| /* Computing MIN */ | |||
| i__4 = *n + *ku + 1 - j, i__5 = *kl + *ku + 1; | |||
| i__2 = f2cmin(i__4,i__5); | |||
| for (i__ = f2cmax(i__3,1); i__ <= i__2; ++i__) { | |||
| sum += z_abs(&ab[i__ + j * ab_dim1]); | |||
| /* L30: */ | |||
| } | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } else if (lsame_(norm, "I")) { | |||
| /* Find normI(A). */ | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L50: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| k = *ku + 1 - j; | |||
| /* Computing MAX */ | |||
| i__2 = 1, i__3 = j - *ku; | |||
| /* Computing MIN */ | |||
| i__5 = *n, i__6 = j + *kl; | |||
| i__4 = f2cmin(i__5,i__6); | |||
| for (i__ = f2cmax(i__2,i__3); i__ <= i__4; ++i__) { | |||
| work[i__] += z_abs(&ab[k + i__ + j * ab_dim1]); | |||
| /* L60: */ | |||
| } | |||
| /* L70: */ | |||
| } | |||
| value = 0.; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| temp = work[i__]; | |||
| if (value < temp || disnan_(&temp)) { | |||
| value = temp; | |||
| } | |||
| /* L80: */ | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| /* SSQ(1) is scale */ | |||
| /* SSQ(2) is sum-of-squares */ | |||
| /* For better accuracy, sum each column separately. */ | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__4 = 1, i__2 = j - *ku; | |||
| l = f2cmax(i__4,i__2); | |||
| k = *ku + 1 - j + l; | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| /* Computing MIN */ | |||
| i__2 = *n, i__3 = j + *kl; | |||
| i__4 = f2cmin(i__2,i__3) - l + 1; | |||
| zlassq_(&i__4, &ab[k + j * ab_dim1], &c__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L90: */ | |||
| } | |||
| value = ssq[0] * sqrt(ssq[1]); | |||
| } | |||
| ret_val = value; | |||
| return ret_val; | |||
| /* End of ZLANGB */ | |||
| } /* zlangb_ */ | |||
| @@ -0,0 +1,635 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute | |||
| value of any element of a general rectangular matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANGE + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlange. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlange. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlange. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANGE( NORM, M, N, A, LDA, WORK ) */ | |||
| /* CHARACTER NORM */ | |||
| /* INTEGER LDA, M, N */ | |||
| /* DOUBLE PRECISION WORK( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANGE returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of a */ | |||
| /* > complex matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANGE */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANGE = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANGE as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. When M = 0, */ | |||
| /* > ZLANGE is set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. When N = 0, */ | |||
| /* > ZLANGE is set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > The m by n matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(M,1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ | |||
| /* > where LWORK >= M when NORM = 'I'; otherwise, WORK is not */ | |||
| /* > referenced. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16GEauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlange_(char *norm, integer *m, integer *n, doublecomplex *a, | |||
| integer *lda, doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2; | |||
| doublereal ret_val; | |||
| /* Local variables */ | |||
| doublereal temp; | |||
| extern /* Subroutine */ int dcombssq_(doublereal *, doublereal *); | |||
| integer i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal value; | |||
| extern logical disnan_(doublereal *); | |||
| doublereal colssq[2]; | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *); | |||
| doublereal sum, ssq[2]; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (f2cmin(*m,*n) == 0) { | |||
| value = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| value = 0.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| temp = z_abs(&a[i__ + j * a_dim1]); | |||
| if (value < temp || disnan_(&temp)) { | |||
| value = temp; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else if (lsame_(norm, "O") || *(unsigned char *) | |||
| norm == '1') { | |||
| /* Find norm1(A). */ | |||
| value = 0.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| sum = 0.; | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| sum += z_abs(&a[i__ + j * a_dim1]); | |||
| /* L30: */ | |||
| } | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } else if (lsame_(norm, "I")) { | |||
| /* Find normI(A). */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L50: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| work[i__] += z_abs(&a[i__ + j * a_dim1]); | |||
| /* L60: */ | |||
| } | |||
| /* L70: */ | |||
| } | |||
| value = 0.; | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| temp = work[i__]; | |||
| if (value < temp || disnan_(&temp)) { | |||
| value = temp; | |||
| } | |||
| /* L80: */ | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| /* SSQ(1) is scale */ | |||
| /* SSQ(2) is sum-of-squares */ | |||
| /* For better accuracy, sum each column separately. */ | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| zlassq_(m, &a[j * a_dim1 + 1], &c__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L90: */ | |||
| } | |||
| value = ssq[0] * sqrt(ssq[1]); | |||
| } | |||
| ret_val = value; | |||
| return ret_val; | |||
| /* End of ZLANGE */ | |||
| } /* zlange_ */ | |||
| @@ -0,0 +1,623 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANGT returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute | |||
| value of any element of a general tridiagonal matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANGT + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlangt. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlangt. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlangt. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANGT( NORM, N, DL, D, DU ) */ | |||
| /* CHARACTER NORM */ | |||
| /* INTEGER N */ | |||
| /* COMPLEX*16 D( * ), DL( * ), DU( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANGT returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of a */ | |||
| /* > complex tridiagonal matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANGT */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANGT = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANGT as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. When N = 0, ZLANGT is */ | |||
| /* > set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] DL */ | |||
| /* > \verbatim */ | |||
| /* > DL is COMPLEX*16 array, dimension (N-1) */ | |||
| /* > The (n-1) sub-diagonal elements of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] D */ | |||
| /* > \verbatim */ | |||
| /* > D is COMPLEX*16 array, dimension (N) */ | |||
| /* > The diagonal elements of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] DU */ | |||
| /* > \verbatim */ | |||
| /* > DU is COMPLEX*16 array, dimension (N-1) */ | |||
| /* > The (n-1) super-diagonal elements of A. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlangt_(char *norm, integer *n, doublecomplex *dl, doublecomplex * | |||
| d__, doublecomplex *du) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1; | |||
| doublereal ret_val, d__1; | |||
| /* Local variables */ | |||
| doublereal temp; | |||
| integer i__; | |||
| doublereal scale; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal anorm; | |||
| extern logical disnan_(doublereal *); | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *); | |||
| doublereal sum; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --du; | |||
| --d__; | |||
| --dl; | |||
| /* Function Body */ | |||
| if (*n <= 0) { | |||
| anorm = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| anorm = z_abs(&d__[*n]); | |||
| i__1 = *n - 1; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| d__1 = z_abs(&dl[i__]); | |||
| if (anorm < z_abs(&dl[i__]) || disnan_(&d__1)) { | |||
| anorm = z_abs(&dl[i__]); | |||
| } | |||
| d__1 = z_abs(&d__[i__]); | |||
| if (anorm < z_abs(&d__[i__]) || disnan_(&d__1)) { | |||
| anorm = z_abs(&d__[i__]); | |||
| } | |||
| d__1 = z_abs(&du[i__]); | |||
| if (anorm < z_abs(&du[i__]) || disnan_(&d__1)) { | |||
| anorm = z_abs(&du[i__]); | |||
| } | |||
| /* L10: */ | |||
| } | |||
| } else if (lsame_(norm, "O") || *(unsigned char *) | |||
| norm == '1') { | |||
| /* Find norm1(A). */ | |||
| if (*n == 1) { | |||
| anorm = z_abs(&d__[1]); | |||
| } else { | |||
| anorm = z_abs(&d__[1]) + z_abs(&dl[1]); | |||
| temp = z_abs(&d__[*n]) + z_abs(&du[*n - 1]); | |||
| if (anorm < temp || disnan_(&temp)) { | |||
| anorm = temp; | |||
| } | |||
| i__1 = *n - 1; | |||
| for (i__ = 2; i__ <= i__1; ++i__) { | |||
| temp = z_abs(&d__[i__]) + z_abs(&dl[i__]) + z_abs(&du[i__ - 1] | |||
| ); | |||
| if (anorm < temp || disnan_(&temp)) { | |||
| anorm = temp; | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "I")) { | |||
| /* Find normI(A). */ | |||
| if (*n == 1) { | |||
| anorm = z_abs(&d__[1]); | |||
| } else { | |||
| anorm = z_abs(&d__[1]) + z_abs(&du[1]); | |||
| temp = z_abs(&d__[*n]) + z_abs(&dl[*n - 1]); | |||
| if (anorm < temp || disnan_(&temp)) { | |||
| anorm = temp; | |||
| } | |||
| i__1 = *n - 1; | |||
| for (i__ = 2; i__ <= i__1; ++i__) { | |||
| temp = z_abs(&d__[i__]) + z_abs(&du[i__]) + z_abs(&dl[i__ - 1] | |||
| ); | |||
| if (anorm < temp || disnan_(&temp)) { | |||
| anorm = temp; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| scale = 0.; | |||
| sum = 1.; | |||
| zlassq_(n, &d__[1], &c__1, &scale, &sum); | |||
| if (*n > 1) { | |||
| i__1 = *n - 1; | |||
| zlassq_(&i__1, &dl[1], &c__1, &scale, &sum); | |||
| i__1 = *n - 1; | |||
| zlassq_(&i__1, &du[1], &c__1, &scale, &sum); | |||
| } | |||
| anorm = scale * sqrt(sum); | |||
| } | |||
| ret_val = anorm; | |||
| return ret_val; | |||
| /* End of ZLANGT */ | |||
| } /* zlangt_ */ | |||
| @@ -0,0 +1,747 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANHB returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the ele | |||
| ment of largest absolute value of a Hermitian band matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANHB + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlanhb. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlanhb. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlanhb. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANHB( NORM, UPLO, N, K, AB, LDAB, */ | |||
| /* WORK ) */ | |||
| /* CHARACTER NORM, UPLO */ | |||
| /* INTEGER K, LDAB, N */ | |||
| /* DOUBLE PRECISION WORK( * ) */ | |||
| /* COMPLEX*16 AB( LDAB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANHB returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of an */ | |||
| /* > n by n hermitian band matrix A, with k super-diagonals. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANHB */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANHB = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANHB as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the upper or lower triangular part of the */ | |||
| /* > band matrix A is supplied. */ | |||
| /* > = 'U': Upper triangular */ | |||
| /* > = 'L': Lower triangular */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. When N = 0, ZLANHB is */ | |||
| /* > set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The number of super-diagonals or sub-diagonals of the */ | |||
| /* > band matrix A. K >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX*16 array, dimension (LDAB,N) */ | |||
| /* > The upper or lower triangle of the hermitian band matrix A, */ | |||
| /* > stored in the first K+1 rows of AB. The j-th column of A is */ | |||
| /* > stored in the j-th column of the array AB as follows: */ | |||
| /* > if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for f2cmax(1,j-k)<=i<=j; */ | |||
| /* > if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=f2cmin(n,j+k). */ | |||
| /* > Note that the imaginary parts of the diagonal elements need */ | |||
| /* > not be set and are assumed to be zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= K+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ | |||
| /* > where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */ | |||
| /* > WORK is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlanhb_(char *norm, char *uplo, integer *n, integer *k, | |||
| doublecomplex *ab, integer *ldab, doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4; | |||
| doublereal ret_val, d__1; | |||
| /* Local variables */ | |||
| doublereal absa; | |||
| extern /* Subroutine */ int dcombssq_(doublereal *, doublereal *); | |||
| integer i__, j, l; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal value; | |||
| extern logical disnan_(doublereal *); | |||
| doublereal colssq[2]; | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *); | |||
| doublereal sum, ssq[2]; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (*n == 0) { | |||
| value = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__2 = *k + 2 - j; | |||
| i__3 = *k; | |||
| for (i__ = f2cmax(i__2,1); i__ <= i__3; ++i__) { | |||
| sum = z_abs(&ab[i__ + j * ab_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| i__3 = *k + 1 + j * ab_dim1; | |||
| sum = (d__1 = ab[i__3].r, abs(d__1)); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__3 = j * ab_dim1 + 1; | |||
| sum = (d__1 = ab[i__3].r, abs(d__1)); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* Computing MIN */ | |||
| i__2 = *n + 1 - j, i__4 = *k + 1; | |||
| i__3 = f2cmin(i__2,i__4); | |||
| for (i__ = 2; i__ <= i__3; ++i__) { | |||
| sum = z_abs(&ab[i__ + j * ab_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') { | |||
| /* Find normI(A) ( = norm1(A), since A is hermitian). */ | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| sum = 0.; | |||
| l = *k + 1 - j; | |||
| /* Computing MAX */ | |||
| i__3 = 1, i__2 = j - *k; | |||
| i__4 = j - 1; | |||
| for (i__ = f2cmax(i__3,i__2); i__ <= i__4; ++i__) { | |||
| absa = z_abs(&ab[l + i__ + j * ab_dim1]); | |||
| sum += absa; | |||
| work[i__] += absa; | |||
| /* L50: */ | |||
| } | |||
| i__4 = *k + 1 + j * ab_dim1; | |||
| work[j] = sum + (d__1 = ab[i__4].r, abs(d__1)); | |||
| /* L60: */ | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| sum = work[i__]; | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L70: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L80: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__4 = j * ab_dim1 + 1; | |||
| sum = work[j] + (d__1 = ab[i__4].r, abs(d__1)); | |||
| l = 1 - j; | |||
| /* Computing MIN */ | |||
| i__3 = *n, i__2 = j + *k; | |||
| i__4 = f2cmin(i__3,i__2); | |||
| for (i__ = j + 1; i__ <= i__4; ++i__) { | |||
| absa = z_abs(&ab[l + i__ + j * ab_dim1]); | |||
| sum += absa; | |||
| work[i__] += absa; | |||
| /* L90: */ | |||
| } | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L100: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| /* SSQ(1) is scale */ | |||
| /* SSQ(2) is sum-of-squares */ | |||
| /* For better accuracy, sum each column separately. */ | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| /* Sum off-diagonals */ | |||
| if (*k > 0) { | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 2; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| /* Computing MIN */ | |||
| i__3 = j - 1; | |||
| i__4 = f2cmin(i__3,*k); | |||
| /* Computing MAX */ | |||
| i__2 = *k + 2 - j; | |||
| zlassq_(&i__4, &ab[f2cmax(i__2,1) + j * ab_dim1], &c__1, | |||
| colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L110: */ | |||
| } | |||
| l = *k + 1; | |||
| } else { | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| /* Computing MIN */ | |||
| i__3 = *n - j; | |||
| i__4 = f2cmin(i__3,*k); | |||
| zlassq_(&i__4, &ab[j * ab_dim1 + 2], &c__1, colssq, & | |||
| colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L120: */ | |||
| } | |||
| l = 1; | |||
| } | |||
| ssq[1] *= 2; | |||
| } else { | |||
| l = 1; | |||
| } | |||
| /* Sum diagonal */ | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__4 = l + j * ab_dim1; | |||
| if (ab[i__4].r != 0.) { | |||
| i__4 = l + j * ab_dim1; | |||
| absa = (d__1 = ab[i__4].r, abs(d__1)); | |||
| if (colssq[0] < absa) { | |||
| /* Computing 2nd power */ | |||
| d__1 = colssq[0] / absa; | |||
| colssq[1] = colssq[1] * (d__1 * d__1) + 1.; | |||
| colssq[0] = absa; | |||
| } else { | |||
| /* Computing 2nd power */ | |||
| d__1 = absa / colssq[0]; | |||
| colssq[1] += d__1 * d__1; | |||
| } | |||
| } | |||
| /* L130: */ | |||
| } | |||
| dcombssq_(ssq, colssq); | |||
| value = ssq[0] * sqrt(ssq[1]); | |||
| } | |||
| ret_val = value; | |||
| return ret_val; | |||
| /* End of ZLANHB */ | |||
| } /* zlanhb_ */ | |||
| @@ -0,0 +1,714 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANHE returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the ele | |||
| ment of largest absolute value of a complex Hermitian matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANHE + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlanhe. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlanhe. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlanhe. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANHE( NORM, UPLO, N, A, LDA, WORK ) */ | |||
| /* CHARACTER NORM, UPLO */ | |||
| /* INTEGER LDA, N */ | |||
| /* DOUBLE PRECISION WORK( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANHE returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of a */ | |||
| /* > complex hermitian matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANHE */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANHE = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANHE as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the upper or lower triangular part of the */ | |||
| /* > hermitian matrix A is to be referenced. */ | |||
| /* > = 'U': Upper triangular part of A is referenced */ | |||
| /* > = 'L': Lower triangular part of A is referenced */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. When N = 0, ZLANHE is */ | |||
| /* > set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > The hermitian matrix A. If UPLO = 'U', the leading n by n */ | |||
| /* > upper triangular part of A contains the upper triangular part */ | |||
| /* > of the matrix A, and the strictly lower triangular part of A */ | |||
| /* > is not referenced. If UPLO = 'L', the leading n by n lower */ | |||
| /* > triangular part of A contains the lower triangular part of */ | |||
| /* > the matrix A, and the strictly upper triangular part of A is */ | |||
| /* > not referenced. Note that the imaginary parts of the diagonal */ | |||
| /* > elements need not be set and are assumed to be zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(N,1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ | |||
| /* > where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */ | |||
| /* > WORK is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16HEauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlanhe_(char *norm, char *uplo, integer *n, doublecomplex *a, | |||
| integer *lda, doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2; | |||
| doublereal ret_val, d__1; | |||
| /* Local variables */ | |||
| doublereal absa; | |||
| extern /* Subroutine */ int dcombssq_(doublereal *, doublereal *); | |||
| integer i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal value; | |||
| extern logical disnan_(doublereal *); | |||
| doublereal colssq[2]; | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *); | |||
| doublereal sum, ssq[2]; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (*n == 0) { | |||
| value = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = j - 1; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&a[i__ + j * a_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| i__2 = j + j * a_dim1; | |||
| sum = (d__1 = a[i__2].r, abs(d__1)); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = j + j * a_dim1; | |||
| sum = (d__1 = a[i__2].r, abs(d__1)); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| i__2 = *n; | |||
| for (i__ = j + 1; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&a[i__ + j * a_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') { | |||
| /* Find normI(A) ( = norm1(A), since A is hermitian). */ | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| sum = 0.; | |||
| i__2 = j - 1; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| absa = z_abs(&a[i__ + j * a_dim1]); | |||
| sum += absa; | |||
| work[i__] += absa; | |||
| /* L50: */ | |||
| } | |||
| i__2 = j + j * a_dim1; | |||
| work[j] = sum + (d__1 = a[i__2].r, abs(d__1)); | |||
| /* L60: */ | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| sum = work[i__]; | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L70: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L80: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = j + j * a_dim1; | |||
| sum = work[j] + (d__1 = a[i__2].r, abs(d__1)); | |||
| i__2 = *n; | |||
| for (i__ = j + 1; i__ <= i__2; ++i__) { | |||
| absa = z_abs(&a[i__ + j * a_dim1]); | |||
| sum += absa; | |||
| work[i__] += absa; | |||
| /* L90: */ | |||
| } | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L100: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| /* SSQ(1) is scale */ | |||
| /* SSQ(2) is sum-of-squares */ | |||
| /* For better accuracy, sum each column separately. */ | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| /* Sum off-diagonals */ | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 2; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = j - 1; | |||
| zlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = *n - j; | |||
| zlassq_(&i__2, &a[j + 1 + j * a_dim1], &c__1, colssq, &colssq[ | |||
| 1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L120: */ | |||
| } | |||
| } | |||
| ssq[1] *= 2; | |||
| /* Sum diagonal */ | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__ + i__ * a_dim1; | |||
| if (a[i__2].r != 0.) { | |||
| i__2 = i__ + i__ * a_dim1; | |||
| absa = (d__1 = a[i__2].r, abs(d__1)); | |||
| if (ssq[0] < absa) { | |||
| /* Computing 2nd power */ | |||
| d__1 = ssq[0] / absa; | |||
| ssq[1] = ssq[1] * (d__1 * d__1) + 1.; | |||
| ssq[0] = absa; | |||
| } else { | |||
| /* Computing 2nd power */ | |||
| d__1 = absa / ssq[0]; | |||
| ssq[1] += d__1 * d__1; | |||
| } | |||
| } | |||
| /* L130: */ | |||
| } | |||
| value = ssq[0] * sqrt(ssq[1]); | |||
| } | |||
| ret_val = value; | |||
| return ret_val; | |||
| /* End of ZLANHE */ | |||
| } /* zlanhe_ */ | |||
| @@ -0,0 +1,725 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANHP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the ele | |||
| ment of largest absolute value of a complex Hermitian matrix supplied in packed form. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANHP + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlanhp. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlanhp. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlanhp. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANHP( NORM, UPLO, N, AP, WORK ) */ | |||
| /* CHARACTER NORM, UPLO */ | |||
| /* INTEGER N */ | |||
| /* DOUBLE PRECISION WORK( * ) */ | |||
| /* COMPLEX*16 AP( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANHP returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of a */ | |||
| /* > complex hermitian matrix A, supplied in packed form. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANHP */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANHP = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANHP as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the upper or lower triangular part of the */ | |||
| /* > hermitian matrix A is supplied. */ | |||
| /* > = 'U': Upper triangular part of A is supplied */ | |||
| /* > = 'L': Lower triangular part of A is supplied */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. When N = 0, ZLANHP is */ | |||
| /* > set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AP */ | |||
| /* > \verbatim */ | |||
| /* > AP is COMPLEX*16 array, dimension (N*(N+1)/2) */ | |||
| /* > The upper or lower triangle of the hermitian matrix A, packed */ | |||
| /* > columnwise in a linear array. The j-th column of A is stored */ | |||
| /* > in the array AP as follows: */ | |||
| /* > if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ | |||
| /* > if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ | |||
| /* > Note that the imaginary parts of the diagonal elements need */ | |||
| /* > not be set and are assumed to be zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ | |||
| /* > where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */ | |||
| /* > WORK is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlanhp_(char *norm, char *uplo, integer *n, doublecomplex *ap, | |||
| doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2; | |||
| doublereal ret_val, d__1; | |||
| /* Local variables */ | |||
| doublereal absa; | |||
| extern /* Subroutine */ int dcombssq_(doublereal *, doublereal *); | |||
| integer i__, j, k; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal value; | |||
| extern logical disnan_(doublereal *); | |||
| doublereal colssq[2]; | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *); | |||
| doublereal sum, ssq[2]; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --work; | |||
| --ap; | |||
| /* Function Body */ | |||
| if (*n == 0) { | |||
| value = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| k = 0; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = k + j - 1; | |||
| for (i__ = k + 1; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&ap[i__]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| k += j; | |||
| i__2 = k; | |||
| sum = (d__1 = ap[i__2].r, abs(d__1)); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| k = 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = k; | |||
| sum = (d__1 = ap[i__2].r, abs(d__1)); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| i__2 = k + *n - j; | |||
| for (i__ = k + 1; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&ap[i__]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| k = k + *n - j + 1; | |||
| /* L40: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') { | |||
| /* Find normI(A) ( = norm1(A), since A is hermitian). */ | |||
| value = 0.; | |||
| k = 1; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| sum = 0.; | |||
| i__2 = j - 1; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| absa = z_abs(&ap[k]); | |||
| sum += absa; | |||
| work[i__] += absa; | |||
| ++k; | |||
| /* L50: */ | |||
| } | |||
| i__2 = k; | |||
| work[j] = sum + (d__1 = ap[i__2].r, abs(d__1)); | |||
| ++k; | |||
| /* L60: */ | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| sum = work[i__]; | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L70: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L80: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = k; | |||
| sum = work[j] + (d__1 = ap[i__2].r, abs(d__1)); | |||
| ++k; | |||
| i__2 = *n; | |||
| for (i__ = j + 1; i__ <= i__2; ++i__) { | |||
| absa = z_abs(&ap[k]); | |||
| sum += absa; | |||
| work[i__] += absa; | |||
| ++k; | |||
| /* L90: */ | |||
| } | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L100: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| /* SSQ(1) is scale */ | |||
| /* SSQ(2) is sum-of-squares */ | |||
| /* For better accuracy, sum each column separately. */ | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| /* Sum off-diagonals */ | |||
| k = 2; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 2; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = j - 1; | |||
| zlassq_(&i__2, &ap[k], &c__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| k += j; | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = *n - j; | |||
| zlassq_(&i__2, &ap[k], &c__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| k = k + *n - j + 1; | |||
| /* L120: */ | |||
| } | |||
| } | |||
| ssq[1] *= 2; | |||
| /* Sum diagonal */ | |||
| k = 1; | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = k; | |||
| if (ap[i__2].r != 0.) { | |||
| i__2 = k; | |||
| absa = (d__1 = ap[i__2].r, abs(d__1)); | |||
| if (colssq[0] < absa) { | |||
| /* Computing 2nd power */ | |||
| d__1 = colssq[0] / absa; | |||
| colssq[1] = colssq[1] * (d__1 * d__1) + 1.; | |||
| colssq[0] = absa; | |||
| } else { | |||
| /* Computing 2nd power */ | |||
| d__1 = absa / colssq[0]; | |||
| colssq[1] += d__1 * d__1; | |||
| } | |||
| } | |||
| if (lsame_(uplo, "U")) { | |||
| k = k + i__ + 1; | |||
| } else { | |||
| k = k + *n - i__ + 1; | |||
| } | |||
| /* L130: */ | |||
| } | |||
| dcombssq_(ssq, colssq); | |||
| value = ssq[0] * sqrt(ssq[1]); | |||
| } | |||
| ret_val = value; | |||
| return ret_val; | |||
| /* End of ZLANHP */ | |||
| } /* zlanhp_ */ | |||
| @@ -0,0 +1,637 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANHS returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute | |||
| value of any element of an upper Hessenberg matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANHS + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlanhs. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlanhs. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlanhs. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANHS( NORM, N, A, LDA, WORK ) */ | |||
| /* CHARACTER NORM */ | |||
| /* INTEGER LDA, N */ | |||
| /* DOUBLE PRECISION WORK( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANHS returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of a */ | |||
| /* > Hessenberg matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANHS */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANHS = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANHS as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. When N = 0, ZLANHS is */ | |||
| /* > set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > The n by n upper Hessenberg matrix A; the part of A below the */ | |||
| /* > first sub-diagonal is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(N,1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ | |||
| /* > where LWORK >= N when NORM = 'I'; otherwise, WORK is not */ | |||
| /* > referenced. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlanhs_(char *norm, integer *n, doublecomplex *a, integer *lda, | |||
| doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| doublereal ret_val; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int dcombssq_(doublereal *, doublereal *); | |||
| integer i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal value; | |||
| extern logical disnan_(doublereal *); | |||
| doublereal colssq[2]; | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *); | |||
| doublereal sum, ssq[2]; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (*n == 0) { | |||
| value = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| value = 0.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__3 = *n, i__4 = j + 1; | |||
| i__2 = f2cmin(i__3,i__4); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&a[i__ + j * a_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else if (lsame_(norm, "O") || *(unsigned char *) | |||
| norm == '1') { | |||
| /* Find norm1(A). */ | |||
| value = 0.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| sum = 0.; | |||
| /* Computing MIN */ | |||
| i__3 = *n, i__4 = j + 1; | |||
| i__2 = f2cmin(i__3,i__4); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| sum += z_abs(&a[i__ + j * a_dim1]); | |||
| /* L30: */ | |||
| } | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } else if (lsame_(norm, "I")) { | |||
| /* Find normI(A). */ | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L50: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__3 = *n, i__4 = j + 1; | |||
| i__2 = f2cmin(i__3,i__4); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| work[i__] += z_abs(&a[i__ + j * a_dim1]); | |||
| /* L60: */ | |||
| } | |||
| /* L70: */ | |||
| } | |||
| value = 0.; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| sum = work[i__]; | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L80: */ | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| /* SSQ(1) is scale */ | |||
| /* SSQ(2) is sum-of-squares */ | |||
| /* For better accuracy, sum each column separately. */ | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| /* Computing MIN */ | |||
| i__3 = *n, i__4 = j + 1; | |||
| i__2 = f2cmin(i__3,i__4); | |||
| zlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L90: */ | |||
| } | |||
| value = ssq[0] * sqrt(ssq[1]); | |||
| } | |||
| ret_val = value; | |||
| return ret_val; | |||
| /* End of ZLANHS */ | |||
| } /* zlanhs_ */ | |||
| @@ -0,0 +1,589 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANHT returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the ele | |||
| ment of largest absolute value of a complex Hermitian tridiagonal matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANHT + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlanht. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlanht. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlanht. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANHT( NORM, N, D, E ) */ | |||
| /* CHARACTER NORM */ | |||
| /* INTEGER N */ | |||
| /* DOUBLE PRECISION D( * ) */ | |||
| /* COMPLEX*16 E( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANHT returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of a */ | |||
| /* > complex Hermitian tridiagonal matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANHT */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANHT = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANHT as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. When N = 0, ZLANHT is */ | |||
| /* > set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] D */ | |||
| /* > \verbatim */ | |||
| /* > D is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The diagonal elements of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] E */ | |||
| /* > \verbatim */ | |||
| /* > E is COMPLEX*16 array, dimension (N-1) */ | |||
| /* > The (n-1) sub-diagonal or super-diagonal elements of A. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlanht_(char *norm, integer *n, doublereal *d__, doublecomplex *e) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1; | |||
| doublereal ret_val, d__1; | |||
| /* Local variables */ | |||
| integer i__; | |||
| doublereal scale; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal anorm; | |||
| extern logical disnan_(doublereal *); | |||
| extern /* Subroutine */ int dlassq_(integer *, doublereal *, integer *, | |||
| doublereal *, doublereal *), zlassq_(integer *, doublecomplex *, | |||
| integer *, doublereal *, doublereal *); | |||
| doublereal sum; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --e; | |||
| --d__; | |||
| /* Function Body */ | |||
| if (*n <= 0) { | |||
| anorm = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| anorm = (d__1 = d__[*n], abs(d__1)); | |||
| i__1 = *n - 1; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| sum = (d__1 = d__[i__], abs(d__1)); | |||
| if (anorm < sum || disnan_(&sum)) { | |||
| anorm = sum; | |||
| } | |||
| sum = z_abs(&e[i__]); | |||
| if (anorm < sum || disnan_(&sum)) { | |||
| anorm = sum; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| } else if (lsame_(norm, "O") || *(unsigned char *) | |||
| norm == '1' || lsame_(norm, "I")) { | |||
| /* Find norm1(A). */ | |||
| if (*n == 1) { | |||
| anorm = abs(d__[1]); | |||
| } else { | |||
| anorm = abs(d__[1]) + z_abs(&e[1]); | |||
| sum = z_abs(&e[*n - 1]) + (d__1 = d__[*n], abs(d__1)); | |||
| if (anorm < sum || disnan_(&sum)) { | |||
| anorm = sum; | |||
| } | |||
| i__1 = *n - 1; | |||
| for (i__ = 2; i__ <= i__1; ++i__) { | |||
| sum = (d__1 = d__[i__], abs(d__1)) + z_abs(&e[i__]) + z_abs(& | |||
| e[i__ - 1]); | |||
| if (anorm < sum || disnan_(&sum)) { | |||
| anorm = sum; | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| scale = 0.; | |||
| sum = 1.; | |||
| if (*n > 1) { | |||
| i__1 = *n - 1; | |||
| zlassq_(&i__1, &e[1], &c__1, &scale, &sum); | |||
| sum *= 2; | |||
| } | |||
| dlassq_(n, &d__[1], &c__1, &scale, &sum); | |||
| anorm = scale * sqrt(sum); | |||
| } | |||
| ret_val = anorm; | |||
| return ret_val; | |||
| /* End of ZLANHT */ | |||
| } /* zlanht_ */ | |||
| @@ -0,0 +1,715 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANSB returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the ele | |||
| ment of largest absolute value of a symmetric band matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANSB + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlansb. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlansb. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlansb. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANSB( NORM, UPLO, N, K, AB, LDAB, */ | |||
| /* WORK ) */ | |||
| /* CHARACTER NORM, UPLO */ | |||
| /* INTEGER K, LDAB, N */ | |||
| /* DOUBLE PRECISION WORK( * ) */ | |||
| /* COMPLEX*16 AB( LDAB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANSB returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of an */ | |||
| /* > n by n symmetric band matrix A, with k super-diagonals. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANSB */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANSB = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANSB as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the upper or lower triangular part of the */ | |||
| /* > band matrix A is supplied. */ | |||
| /* > = 'U': Upper triangular part is supplied */ | |||
| /* > = 'L': Lower triangular part is supplied */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. When N = 0, ZLANSB is */ | |||
| /* > set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The number of super-diagonals or sub-diagonals of the */ | |||
| /* > band matrix A. K >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX*16 array, dimension (LDAB,N) */ | |||
| /* > The upper or lower triangle of the symmetric band matrix A, */ | |||
| /* > stored in the first K+1 rows of AB. The j-th column of A is */ | |||
| /* > stored in the j-th column of the array AB as follows: */ | |||
| /* > if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for f2cmax(1,j-k)<=i<=j; */ | |||
| /* > if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=f2cmin(n,j+k). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= K+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ | |||
| /* > where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */ | |||
| /* > WORK is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlansb_(char *norm, char *uplo, integer *n, integer *k, | |||
| doublecomplex *ab, integer *ldab, doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4; | |||
| doublereal ret_val; | |||
| /* Local variables */ | |||
| doublereal absa; | |||
| extern /* Subroutine */ int dcombssq_(doublereal *, doublereal *); | |||
| integer i__, j, l; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal value; | |||
| extern logical disnan_(doublereal *); | |||
| doublereal colssq[2]; | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *); | |||
| doublereal sum, ssq[2]; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (*n == 0) { | |||
| value = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__2 = *k + 2 - j; | |||
| i__3 = *k + 1; | |||
| for (i__ = f2cmax(i__2,1); i__ <= i__3; ++i__) { | |||
| sum = z_abs(&ab[i__ + j * ab_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__2 = *n + 1 - j, i__4 = *k + 1; | |||
| i__3 = f2cmin(i__2,i__4); | |||
| for (i__ = 1; i__ <= i__3; ++i__) { | |||
| sum = z_abs(&ab[i__ + j * ab_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') { | |||
| /* Find normI(A) ( = norm1(A), since A is symmetric). */ | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| sum = 0.; | |||
| l = *k + 1 - j; | |||
| /* Computing MAX */ | |||
| i__3 = 1, i__2 = j - *k; | |||
| i__4 = j - 1; | |||
| for (i__ = f2cmax(i__3,i__2); i__ <= i__4; ++i__) { | |||
| absa = z_abs(&ab[l + i__ + j * ab_dim1]); | |||
| sum += absa; | |||
| work[i__] += absa; | |||
| /* L50: */ | |||
| } | |||
| work[j] = sum + z_abs(&ab[*k + 1 + j * ab_dim1]); | |||
| /* L60: */ | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| sum = work[i__]; | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L70: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L80: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| sum = work[j] + z_abs(&ab[j * ab_dim1 + 1]); | |||
| l = 1 - j; | |||
| /* Computing MIN */ | |||
| i__3 = *n, i__2 = j + *k; | |||
| i__4 = f2cmin(i__3,i__2); | |||
| for (i__ = j + 1; i__ <= i__4; ++i__) { | |||
| absa = z_abs(&ab[l + i__ + j * ab_dim1]); | |||
| sum += absa; | |||
| work[i__] += absa; | |||
| /* L90: */ | |||
| } | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L100: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| /* SSQ(1) is scale */ | |||
| /* SSQ(2) is sum-of-squares */ | |||
| /* For better accuracy, sum each column separately. */ | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| /* Sum off-diagonals */ | |||
| if (*k > 0) { | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 2; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| /* Computing MIN */ | |||
| i__3 = j - 1; | |||
| i__4 = f2cmin(i__3,*k); | |||
| /* Computing MAX */ | |||
| i__2 = *k + 2 - j; | |||
| zlassq_(&i__4, &ab[f2cmax(i__2,1) + j * ab_dim1], &c__1, | |||
| colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L110: */ | |||
| } | |||
| l = *k + 1; | |||
| } else { | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| /* Computing MIN */ | |||
| i__3 = *n - j; | |||
| i__4 = f2cmin(i__3,*k); | |||
| zlassq_(&i__4, &ab[j * ab_dim1 + 2], &c__1, colssq, & | |||
| colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L120: */ | |||
| } | |||
| l = 1; | |||
| } | |||
| ssq[1] *= 2; | |||
| } else { | |||
| l = 1; | |||
| } | |||
| /* Sum diagonal */ | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| zlassq_(n, &ab[l + ab_dim1], ldab, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| value = ssq[0] * sqrt(ssq[1]); | |||
| } | |||
| ret_val = value; | |||
| return ret_val; | |||
| /* End of ZLANSB */ | |||
| } /* zlansb_ */ | |||
| @@ -0,0 +1,724 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANSP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the ele | |||
| ment of largest absolute value of a symmetric matrix supplied in packed form. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANSP + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlansp. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlansp. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlansp. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANSP( NORM, UPLO, N, AP, WORK ) */ | |||
| /* CHARACTER NORM, UPLO */ | |||
| /* INTEGER N */ | |||
| /* DOUBLE PRECISION WORK( * ) */ | |||
| /* COMPLEX*16 AP( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANSP returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of a */ | |||
| /* > complex symmetric matrix A, supplied in packed form. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANSP */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANSP = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANSP as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the upper or lower triangular part of the */ | |||
| /* > symmetric matrix A is supplied. */ | |||
| /* > = 'U': Upper triangular part of A is supplied */ | |||
| /* > = 'L': Lower triangular part of A is supplied */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. When N = 0, ZLANSP is */ | |||
| /* > set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AP */ | |||
| /* > \verbatim */ | |||
| /* > AP is COMPLEX*16 array, dimension (N*(N+1)/2) */ | |||
| /* > The upper or lower triangle of the symmetric matrix A, packed */ | |||
| /* > columnwise in a linear array. The j-th column of A is stored */ | |||
| /* > in the array AP as follows: */ | |||
| /* > if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ | |||
| /* > if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ | |||
| /* > where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */ | |||
| /* > WORK is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlansp_(char *norm, char *uplo, integer *n, doublecomplex *ap, | |||
| doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2; | |||
| doublereal ret_val, d__1; | |||
| /* Local variables */ | |||
| doublereal absa; | |||
| extern /* Subroutine */ int dcombssq_(doublereal *, doublereal *); | |||
| integer i__, j, k; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal value; | |||
| extern logical disnan_(doublereal *); | |||
| doublereal colssq[2]; | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *); | |||
| doublereal sum, ssq[2]; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --work; | |||
| --ap; | |||
| /* Function Body */ | |||
| if (*n == 0) { | |||
| value = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| k = 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = k + j - 1; | |||
| for (i__ = k; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&ap[i__]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| k += j; | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| k = 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = k + *n - j; | |||
| for (i__ = k; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&ap[i__]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| k = k + *n - j + 1; | |||
| /* L40: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') { | |||
| /* Find normI(A) ( = norm1(A), since A is symmetric). */ | |||
| value = 0.; | |||
| k = 1; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| sum = 0.; | |||
| i__2 = j - 1; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| absa = z_abs(&ap[k]); | |||
| sum += absa; | |||
| work[i__] += absa; | |||
| ++k; | |||
| /* L50: */ | |||
| } | |||
| work[j] = sum + z_abs(&ap[k]); | |||
| ++k; | |||
| /* L60: */ | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| sum = work[i__]; | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L70: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L80: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| sum = work[j] + z_abs(&ap[k]); | |||
| ++k; | |||
| i__2 = *n; | |||
| for (i__ = j + 1; i__ <= i__2; ++i__) { | |||
| absa = z_abs(&ap[k]); | |||
| sum += absa; | |||
| work[i__] += absa; | |||
| ++k; | |||
| /* L90: */ | |||
| } | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L100: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| /* SSQ(1) is scale */ | |||
| /* SSQ(2) is sum-of-squares */ | |||
| /* For better accuracy, sum each column separately. */ | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| /* Sum off-diagonals */ | |||
| k = 2; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 2; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = j - 1; | |||
| zlassq_(&i__2, &ap[k], &c__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| k += j; | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = *n - j; | |||
| zlassq_(&i__2, &ap[k], &c__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| k = k + *n - j + 1; | |||
| /* L120: */ | |||
| } | |||
| } | |||
| ssq[1] *= 2; | |||
| /* Sum diagonal */ | |||
| k = 1; | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = k; | |||
| if (ap[i__2].r != 0.) { | |||
| i__2 = k; | |||
| absa = (d__1 = ap[i__2].r, abs(d__1)); | |||
| if (colssq[0] < absa) { | |||
| /* Computing 2nd power */ | |||
| d__1 = colssq[0] / absa; | |||
| colssq[1] = colssq[1] * (d__1 * d__1) + 1.; | |||
| colssq[0] = absa; | |||
| } else { | |||
| /* Computing 2nd power */ | |||
| d__1 = absa / colssq[0]; | |||
| colssq[1] += d__1 * d__1; | |||
| } | |||
| } | |||
| if (d_imag(&ap[k]) != 0.) { | |||
| absa = (d__1 = d_imag(&ap[k]), abs(d__1)); | |||
| if (colssq[0] < absa) { | |||
| /* Computing 2nd power */ | |||
| d__1 = colssq[0] / absa; | |||
| colssq[1] = colssq[1] * (d__1 * d__1) + 1.; | |||
| colssq[0] = absa; | |||
| } else { | |||
| /* Computing 2nd power */ | |||
| d__1 = absa / colssq[0]; | |||
| colssq[1] += d__1 * d__1; | |||
| } | |||
| } | |||
| if (lsame_(uplo, "U")) { | |||
| k = k + i__ + 1; | |||
| } else { | |||
| k = k + *n - i__ + 1; | |||
| } | |||
| /* L130: */ | |||
| } | |||
| dcombssq_(ssq, colssq); | |||
| value = ssq[0] * sqrt(ssq[1]); | |||
| } | |||
| ret_val = value; | |||
| return ret_val; | |||
| /* End of ZLANSP */ | |||
| } /* zlansp_ */ | |||
| @@ -0,0 +1,687 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the ele | |||
| ment of largest absolute value of a complex symmetric matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANSY + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlansy. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlansy. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlansy. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANSY( NORM, UPLO, N, A, LDA, WORK ) */ | |||
| /* CHARACTER NORM, UPLO */ | |||
| /* INTEGER LDA, N */ | |||
| /* DOUBLE PRECISION WORK( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANSY returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of a */ | |||
| /* > complex symmetric matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANSY */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANSY = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANSY as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the upper or lower triangular part of the */ | |||
| /* > symmetric matrix A is to be referenced. */ | |||
| /* > = 'U': Upper triangular part of A is referenced */ | |||
| /* > = 'L': Lower triangular part of A is referenced */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. When N = 0, ZLANSY is */ | |||
| /* > set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > The symmetric matrix A. If UPLO = 'U', the leading n by n */ | |||
| /* > upper triangular part of A contains the upper triangular part */ | |||
| /* > of the matrix A, and the strictly lower triangular part of A */ | |||
| /* > is not referenced. If UPLO = 'L', the leading n by n lower */ | |||
| /* > triangular part of A contains the lower triangular part of */ | |||
| /* > the matrix A, and the strictly upper triangular part of A is */ | |||
| /* > not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(N,1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ | |||
| /* > where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */ | |||
| /* > WORK is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16SYauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlansy_(char *norm, char *uplo, integer *n, doublecomplex *a, | |||
| integer *lda, doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2; | |||
| doublereal ret_val; | |||
| /* Local variables */ | |||
| doublereal absa; | |||
| extern /* Subroutine */ int dcombssq_(doublereal *, doublereal *); | |||
| integer i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal value; | |||
| extern logical disnan_(doublereal *); | |||
| doublereal colssq[2]; | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *); | |||
| doublereal sum, ssq[2]; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (*n == 0) { | |||
| value = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = j; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&a[i__ + j * a_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = j; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&a[i__ + j * a_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') { | |||
| /* Find normI(A) ( = norm1(A), since A is symmetric). */ | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| sum = 0.; | |||
| i__2 = j - 1; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| absa = z_abs(&a[i__ + j * a_dim1]); | |||
| sum += absa; | |||
| work[i__] += absa; | |||
| /* L50: */ | |||
| } | |||
| work[j] = sum + z_abs(&a[j + j * a_dim1]); | |||
| /* L60: */ | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| sum = work[i__]; | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L70: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L80: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| sum = work[j] + z_abs(&a[j + j * a_dim1]); | |||
| i__2 = *n; | |||
| for (i__ = j + 1; i__ <= i__2; ++i__) { | |||
| absa = z_abs(&a[i__ + j * a_dim1]); | |||
| sum += absa; | |||
| work[i__] += absa; | |||
| /* L90: */ | |||
| } | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L100: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| /* SSQ(1) is scale */ | |||
| /* SSQ(2) is sum-of-squares */ | |||
| /* For better accuracy, sum each column separately. */ | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| /* Sum off-diagonals */ | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 2; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = j - 1; | |||
| zlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = *n - j; | |||
| zlassq_(&i__2, &a[j + 1 + j * a_dim1], &c__1, colssq, &colssq[ | |||
| 1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L120: */ | |||
| } | |||
| } | |||
| ssq[1] *= 2; | |||
| /* Sum diagonal */ | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__1 = *lda + 1; | |||
| zlassq_(n, &a[a_offset], &i__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| value = ssq[0] * sqrt(ssq[1]); | |||
| } | |||
| ret_val = value; | |||
| return ret_val; | |||
| /* End of ZLANSY */ | |||
| } /* zlansy_ */ | |||
| @@ -0,0 +1,883 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANTB returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the ele | |||
| ment of largest absolute value of a triangular band matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANTB + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlantb. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlantb. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlantb. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANTB( NORM, UPLO, DIAG, N, K, AB, */ | |||
| /* LDAB, WORK ) */ | |||
| /* CHARACTER DIAG, NORM, UPLO */ | |||
| /* INTEGER K, LDAB, N */ | |||
| /* DOUBLE PRECISION WORK( * ) */ | |||
| /* COMPLEX*16 AB( LDAB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANTB returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of an */ | |||
| /* > n by n triangular band matrix A, with ( k + 1 ) diagonals. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANTB */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANTB = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANTB as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the matrix A is upper or lower triangular. */ | |||
| /* > = 'U': Upper triangular */ | |||
| /* > = 'L': Lower triangular */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] DIAG */ | |||
| /* > \verbatim */ | |||
| /* > DIAG is CHARACTER*1 */ | |||
| /* > Specifies whether or not the matrix A is unit triangular. */ | |||
| /* > = 'N': Non-unit triangular */ | |||
| /* > = 'U': Unit triangular */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. When N = 0, ZLANTB is */ | |||
| /* > set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The number of super-diagonals of the matrix A if UPLO = 'U', */ | |||
| /* > or the number of sub-diagonals of the matrix A if UPLO = 'L'. */ | |||
| /* > K >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX*16 array, dimension (LDAB,N) */ | |||
| /* > The upper or lower triangular band matrix A, stored in the */ | |||
| /* > first k+1 rows of AB. The j-th column of A is stored */ | |||
| /* > in the j-th column of the array AB as follows: */ | |||
| /* > if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for f2cmax(1,j-k)<=i<=j; */ | |||
| /* > if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=f2cmin(n,j+k). */ | |||
| /* > Note that when DIAG = 'U', the elements of the array AB */ | |||
| /* > corresponding to the diagonal elements of the matrix A are */ | |||
| /* > not referenced, but are assumed to be one. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= K+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ | |||
| /* > where LWORK >= N when NORM = 'I'; otherwise, WORK is not */ | |||
| /* > referenced. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlantb_(char *norm, char *uplo, char *diag, integer *n, integer *k, | |||
| doublecomplex *ab, integer *ldab, doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5; | |||
| doublereal ret_val; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int dcombssq_(doublereal *, doublereal *); | |||
| integer i__, j, l; | |||
| logical udiag; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal value; | |||
| extern logical disnan_(doublereal *); | |||
| doublereal colssq[2]; | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *); | |||
| doublereal sum, ssq[2]; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (*n == 0) { | |||
| value = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| if (lsame_(diag, "U")) { | |||
| value = 1.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__2 = *k + 2 - j; | |||
| i__3 = *k; | |||
| for (i__ = f2cmax(i__2,1); i__ <= i__3; ++i__) { | |||
| sum = z_abs(&ab[i__ + j * ab_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__2 = *n + 1 - j, i__4 = *k + 1; | |||
| i__3 = f2cmin(i__2,i__4); | |||
| for (i__ = 2; i__ <= i__3; ++i__) { | |||
| sum = z_abs(&ab[i__ + j * ab_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| } else { | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__3 = *k + 2 - j; | |||
| i__2 = *k + 1; | |||
| for (i__ = f2cmax(i__3,1); i__ <= i__2; ++i__) { | |||
| sum = z_abs(&ab[i__ + j * ab_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L50: */ | |||
| } | |||
| /* L60: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__3 = *n + 1 - j, i__4 = *k + 1; | |||
| i__2 = f2cmin(i__3,i__4); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&ab[i__ + j * ab_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L70: */ | |||
| } | |||
| /* L80: */ | |||
| } | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "O") || *(unsigned char *) | |||
| norm == '1') { | |||
| /* Find norm1(A). */ | |||
| value = 0.; | |||
| udiag = lsame_(diag, "U"); | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (udiag) { | |||
| sum = 1.; | |||
| /* Computing MAX */ | |||
| i__2 = *k + 2 - j; | |||
| i__3 = *k; | |||
| for (i__ = f2cmax(i__2,1); i__ <= i__3; ++i__) { | |||
| sum += z_abs(&ab[i__ + j * ab_dim1]); | |||
| /* L90: */ | |||
| } | |||
| } else { | |||
| sum = 0.; | |||
| /* Computing MAX */ | |||
| i__3 = *k + 2 - j; | |||
| i__2 = *k + 1; | |||
| for (i__ = f2cmax(i__3,1); i__ <= i__2; ++i__) { | |||
| sum += z_abs(&ab[i__ + j * ab_dim1]); | |||
| /* L100: */ | |||
| } | |||
| } | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (udiag) { | |||
| sum = 1.; | |||
| /* Computing MIN */ | |||
| i__3 = *n + 1 - j, i__4 = *k + 1; | |||
| i__2 = f2cmin(i__3,i__4); | |||
| for (i__ = 2; i__ <= i__2; ++i__) { | |||
| sum += z_abs(&ab[i__ + j * ab_dim1]); | |||
| /* L120: */ | |||
| } | |||
| } else { | |||
| sum = 0.; | |||
| /* Computing MIN */ | |||
| i__3 = *n + 1 - j, i__4 = *k + 1; | |||
| i__2 = f2cmin(i__3,i__4); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| sum += z_abs(&ab[i__ + j * ab_dim1]); | |||
| /* L130: */ | |||
| } | |||
| } | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L140: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "I")) { | |||
| /* Find normI(A). */ | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| if (lsame_(diag, "U")) { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 1.; | |||
| /* L150: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| l = *k + 1 - j; | |||
| /* Computing MAX */ | |||
| i__2 = 1, i__3 = j - *k; | |||
| i__4 = j - 1; | |||
| for (i__ = f2cmax(i__2,i__3); i__ <= i__4; ++i__) { | |||
| work[i__] += z_abs(&ab[l + i__ + j * ab_dim1]); | |||
| /* L160: */ | |||
| } | |||
| /* L170: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L180: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| l = *k + 1 - j; | |||
| /* Computing MAX */ | |||
| i__4 = 1, i__2 = j - *k; | |||
| i__3 = j; | |||
| for (i__ = f2cmax(i__4,i__2); i__ <= i__3; ++i__) { | |||
| work[i__] += z_abs(&ab[l + i__ + j * ab_dim1]); | |||
| /* L190: */ | |||
| } | |||
| /* L200: */ | |||
| } | |||
| } | |||
| } else { | |||
| if (lsame_(diag, "U")) { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 1.; | |||
| /* L210: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| l = 1 - j; | |||
| /* Computing MIN */ | |||
| i__4 = *n, i__2 = j + *k; | |||
| i__3 = f2cmin(i__4,i__2); | |||
| for (i__ = j + 1; i__ <= i__3; ++i__) { | |||
| work[i__] += z_abs(&ab[l + i__ + j * ab_dim1]); | |||
| /* L220: */ | |||
| } | |||
| /* L230: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L240: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| l = 1 - j; | |||
| /* Computing MIN */ | |||
| i__4 = *n, i__2 = j + *k; | |||
| i__3 = f2cmin(i__4,i__2); | |||
| for (i__ = j; i__ <= i__3; ++i__) { | |||
| work[i__] += z_abs(&ab[l + i__ + j * ab_dim1]); | |||
| /* L250: */ | |||
| } | |||
| /* L260: */ | |||
| } | |||
| } | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| sum = work[i__]; | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L270: */ | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| /* SSQ(1) is scale */ | |||
| /* SSQ(2) is sum-of-squares */ | |||
| /* For better accuracy, sum each column separately. */ | |||
| if (lsame_(uplo, "U")) { | |||
| if (lsame_(diag, "U")) { | |||
| ssq[0] = 1.; | |||
| ssq[1] = (doublereal) (*n); | |||
| if (*k > 0) { | |||
| i__1 = *n; | |||
| for (j = 2; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| /* Computing MIN */ | |||
| i__4 = j - 1; | |||
| i__3 = f2cmin(i__4,*k); | |||
| /* Computing MAX */ | |||
| i__2 = *k + 2 - j; | |||
| zlassq_(&i__3, &ab[f2cmax(i__2,1) + j * ab_dim1], &c__1, | |||
| colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L280: */ | |||
| } | |||
| } | |||
| } else { | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| /* Computing MIN */ | |||
| i__4 = j, i__2 = *k + 1; | |||
| i__3 = f2cmin(i__4,i__2); | |||
| /* Computing MAX */ | |||
| i__5 = *k + 2 - j; | |||
| zlassq_(&i__3, &ab[f2cmax(i__5,1) + j * ab_dim1], &c__1, | |||
| colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L290: */ | |||
| } | |||
| } | |||
| } else { | |||
| if (lsame_(diag, "U")) { | |||
| ssq[0] = 1.; | |||
| ssq[1] = (doublereal) (*n); | |||
| if (*k > 0) { | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| /* Computing MIN */ | |||
| i__4 = *n - j; | |||
| i__3 = f2cmin(i__4,*k); | |||
| zlassq_(&i__3, &ab[j * ab_dim1 + 2], &c__1, colssq, & | |||
| colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L300: */ | |||
| } | |||
| } | |||
| } else { | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| /* Computing MIN */ | |||
| i__4 = *n - j + 1, i__2 = *k + 1; | |||
| i__3 = f2cmin(i__4,i__2); | |||
| zlassq_(&i__3, &ab[j * ab_dim1 + 1], &c__1, colssq, & | |||
| colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L310: */ | |||
| } | |||
| } | |||
| } | |||
| value = ssq[0] * sqrt(ssq[1]); | |||
| } | |||
| ret_val = value; | |||
| return ret_val; | |||
| /* End of ZLANTB */ | |||
| } /* zlantb_ */ | |||
| @@ -0,0 +1,840 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANTP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the ele | |||
| ment of largest absolute value of a triangular matrix supplied in packed form. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANTP + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlantp. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlantp. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlantp. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANTP( NORM, UPLO, DIAG, N, AP, WORK ) */ | |||
| /* CHARACTER DIAG, NORM, UPLO */ | |||
| /* INTEGER N */ | |||
| /* DOUBLE PRECISION WORK( * ) */ | |||
| /* COMPLEX*16 AP( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANTP returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of a */ | |||
| /* > triangular matrix A, supplied in packed form. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANTP */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANTP = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANTP as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the matrix A is upper or lower triangular. */ | |||
| /* > = 'U': Upper triangular */ | |||
| /* > = 'L': Lower triangular */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] DIAG */ | |||
| /* > \verbatim */ | |||
| /* > DIAG is CHARACTER*1 */ | |||
| /* > Specifies whether or not the matrix A is unit triangular. */ | |||
| /* > = 'N': Non-unit triangular */ | |||
| /* > = 'U': Unit triangular */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. When N = 0, ZLANTP is */ | |||
| /* > set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AP */ | |||
| /* > \verbatim */ | |||
| /* > AP is COMPLEX*16 array, dimension (N*(N+1)/2) */ | |||
| /* > The upper or lower triangular matrix A, packed columnwise in */ | |||
| /* > a linear array. The j-th column of A is stored in the array */ | |||
| /* > AP as follows: */ | |||
| /* > if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ | |||
| /* > if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ | |||
| /* > Note that when DIAG = 'U', the elements of the array AP */ | |||
| /* > corresponding to the diagonal elements of the matrix A are */ | |||
| /* > not referenced, but are assumed to be one. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ | |||
| /* > where LWORK >= N when NORM = 'I'; otherwise, WORK is not */ | |||
| /* > referenced. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlantp_(char *norm, char *uplo, char *diag, integer *n, | |||
| doublecomplex *ap, doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2; | |||
| doublereal ret_val; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int dcombssq_(doublereal *, doublereal *); | |||
| integer i__, j, k; | |||
| logical udiag; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal value; | |||
| extern logical disnan_(doublereal *); | |||
| doublereal colssq[2]; | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *); | |||
| doublereal sum, ssq[2]; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --work; | |||
| --ap; | |||
| /* Function Body */ | |||
| if (*n == 0) { | |||
| value = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| k = 1; | |||
| if (lsame_(diag, "U")) { | |||
| value = 1.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = k + j - 2; | |||
| for (i__ = k; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&ap[i__]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| k += j; | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = k + *n - j; | |||
| for (i__ = k + 1; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&ap[i__]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| k = k + *n - j + 1; | |||
| /* L40: */ | |||
| } | |||
| } | |||
| } else { | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = k + j - 1; | |||
| for (i__ = k; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&ap[i__]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L50: */ | |||
| } | |||
| k += j; | |||
| /* L60: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = k + *n - j; | |||
| for (i__ = k; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&ap[i__]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L70: */ | |||
| } | |||
| k = k + *n - j + 1; | |||
| /* L80: */ | |||
| } | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "O") || *(unsigned char *) | |||
| norm == '1') { | |||
| /* Find norm1(A). */ | |||
| value = 0.; | |||
| k = 1; | |||
| udiag = lsame_(diag, "U"); | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (udiag) { | |||
| sum = 1.; | |||
| i__2 = k + j - 2; | |||
| for (i__ = k; i__ <= i__2; ++i__) { | |||
| sum += z_abs(&ap[i__]); | |||
| /* L90: */ | |||
| } | |||
| } else { | |||
| sum = 0.; | |||
| i__2 = k + j - 1; | |||
| for (i__ = k; i__ <= i__2; ++i__) { | |||
| sum += z_abs(&ap[i__]); | |||
| /* L100: */ | |||
| } | |||
| } | |||
| k += j; | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (udiag) { | |||
| sum = 1.; | |||
| i__2 = k + *n - j; | |||
| for (i__ = k + 1; i__ <= i__2; ++i__) { | |||
| sum += z_abs(&ap[i__]); | |||
| /* L120: */ | |||
| } | |||
| } else { | |||
| sum = 0.; | |||
| i__2 = k + *n - j; | |||
| for (i__ = k; i__ <= i__2; ++i__) { | |||
| sum += z_abs(&ap[i__]); | |||
| /* L130: */ | |||
| } | |||
| } | |||
| k = k + *n - j + 1; | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L140: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "I")) { | |||
| /* Find normI(A). */ | |||
| k = 1; | |||
| if (lsame_(uplo, "U")) { | |||
| if (lsame_(diag, "U")) { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 1.; | |||
| /* L150: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = j - 1; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| work[i__] += z_abs(&ap[k]); | |||
| ++k; | |||
| /* L160: */ | |||
| } | |||
| ++k; | |||
| /* L170: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L180: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = j; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| work[i__] += z_abs(&ap[k]); | |||
| ++k; | |||
| /* L190: */ | |||
| } | |||
| /* L200: */ | |||
| } | |||
| } | |||
| } else { | |||
| if (lsame_(diag, "U")) { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 1.; | |||
| /* L210: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| ++k; | |||
| i__2 = *n; | |||
| for (i__ = j + 1; i__ <= i__2; ++i__) { | |||
| work[i__] += z_abs(&ap[k]); | |||
| ++k; | |||
| /* L220: */ | |||
| } | |||
| /* L230: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L240: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = j; i__ <= i__2; ++i__) { | |||
| work[i__] += z_abs(&ap[k]); | |||
| ++k; | |||
| /* L250: */ | |||
| } | |||
| /* L260: */ | |||
| } | |||
| } | |||
| } | |||
| value = 0.; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| sum = work[i__]; | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L270: */ | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| /* SSQ(1) is scale */ | |||
| /* SSQ(2) is sum-of-squares */ | |||
| /* For better accuracy, sum each column separately. */ | |||
| if (lsame_(uplo, "U")) { | |||
| if (lsame_(diag, "U")) { | |||
| ssq[0] = 1.; | |||
| ssq[1] = (doublereal) (*n); | |||
| k = 2; | |||
| i__1 = *n; | |||
| for (j = 2; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = j - 1; | |||
| zlassq_(&i__2, &ap[k], &c__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| k += j; | |||
| /* L280: */ | |||
| } | |||
| } else { | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| k = 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| zlassq_(&j, &ap[k], &c__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| k += j; | |||
| /* L290: */ | |||
| } | |||
| } | |||
| } else { | |||
| if (lsame_(diag, "U")) { | |||
| ssq[0] = 1.; | |||
| ssq[1] = (doublereal) (*n); | |||
| k = 2; | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = *n - j; | |||
| zlassq_(&i__2, &ap[k], &c__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| k = k + *n - j + 1; | |||
| /* L300: */ | |||
| } | |||
| } else { | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| k = 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = *n - j + 1; | |||
| zlassq_(&i__2, &ap[k], &c__1, colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| k = k + *n - j + 1; | |||
| /* L310: */ | |||
| } | |||
| } | |||
| } | |||
| value = ssq[0] * sqrt(ssq[1]); | |||
| } | |||
| ret_val = value; | |||
| return ret_val; | |||
| /* End of ZLANTP */ | |||
| } /* zlantp_ */ | |||
| @@ -0,0 +1,853 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLANTR returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the ele | |||
| ment of largest absolute value of a trapezoidal or triangular matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLANTR + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlantr. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlantr. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlantr. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION ZLANTR( NORM, UPLO, DIAG, M, N, A, LDA, */ | |||
| /* WORK ) */ | |||
| /* CHARACTER DIAG, NORM, UPLO */ | |||
| /* INTEGER LDA, M, N */ | |||
| /* DOUBLE PRECISION WORK( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANTR returns the value of the one norm, or the Frobenius norm, or */ | |||
| /* > the infinity norm, or the element of largest absolute value of a */ | |||
| /* > trapezoidal or triangular matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \return ZLANTR */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLANTR = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ | |||
| /* > ( */ | |||
| /* > ( norm1(A), NORM = '1', 'O' or 'o' */ | |||
| /* > ( */ | |||
| /* > ( normI(A), NORM = 'I' or 'i' */ | |||
| /* > ( */ | |||
| /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ | |||
| /* > */ | |||
| /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ | |||
| /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ | |||
| /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ | |||
| /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies the value to be returned in ZLANTR as described */ | |||
| /* > above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the matrix A is upper or lower trapezoidal. */ | |||
| /* > = 'U': Upper trapezoidal */ | |||
| /* > = 'L': Lower trapezoidal */ | |||
| /* > Note that A is triangular instead of trapezoidal if M = N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] DIAG */ | |||
| /* > \verbatim */ | |||
| /* > DIAG is CHARACTER*1 */ | |||
| /* > Specifies whether or not the matrix A has unit diagonal. */ | |||
| /* > = 'N': Non-unit diagonal */ | |||
| /* > = 'U': Unit diagonal */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0, and if */ | |||
| /* > UPLO = 'U', M <= N. When M = 0, ZLANTR is set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0, and if */ | |||
| /* > UPLO = 'L', N <= M. When N = 0, ZLANTR is set to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > The trapezoidal matrix A (A is triangular if M = N). */ | |||
| /* > If UPLO = 'U', the leading m by n upper trapezoidal part of */ | |||
| /* > the array A contains the upper trapezoidal matrix, and the */ | |||
| /* > strictly lower triangular part of A is not referenced. */ | |||
| /* > If UPLO = 'L', the leading m by n lower trapezoidal part of */ | |||
| /* > the array A contains the lower trapezoidal matrix, and the */ | |||
| /* > strictly upper triangular part of A is not referenced. Note */ | |||
| /* > that when DIAG = 'U', the diagonal elements of A are not */ | |||
| /* > referenced and are assumed to be one. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(M,1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ | |||
| /* > where LWORK >= M when NORM = 'I'; otherwise, WORK is not */ | |||
| /* > referenced. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal zlantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, | |||
| doublecomplex *a, integer *lda, doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| doublereal ret_val; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int dcombssq_(doublereal *, doublereal *); | |||
| integer i__, j; | |||
| logical udiag; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal value; | |||
| extern logical disnan_(doublereal *); | |||
| doublereal colssq[2]; | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *); | |||
| doublereal sum, ssq[2]; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (f2cmin(*m,*n) == 0) { | |||
| value = 0.; | |||
| } else if (lsame_(norm, "M")) { | |||
| /* Find f2cmax(abs(A(i,j))). */ | |||
| if (lsame_(diag, "U")) { | |||
| value = 1.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__3 = *m, i__4 = j - 1; | |||
| i__2 = f2cmin(i__3,i__4); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&a[i__ + j * a_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = j + 1; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&a[i__ + j * a_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| } else { | |||
| value = 0.; | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = f2cmin(*m,j); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&a[i__ + j * a_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L50: */ | |||
| } | |||
| /* L60: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = j; i__ <= i__2; ++i__) { | |||
| sum = z_abs(&a[i__ + j * a_dim1]); | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L70: */ | |||
| } | |||
| /* L80: */ | |||
| } | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "O") || *(unsigned char *) | |||
| norm == '1') { | |||
| /* Find norm1(A). */ | |||
| value = 0.; | |||
| udiag = lsame_(diag, "U"); | |||
| if (lsame_(uplo, "U")) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (udiag && j <= *m) { | |||
| sum = 1.; | |||
| i__2 = j - 1; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| sum += z_abs(&a[i__ + j * a_dim1]); | |||
| /* L90: */ | |||
| } | |||
| } else { | |||
| sum = 0.; | |||
| i__2 = f2cmin(*m,j); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| sum += z_abs(&a[i__ + j * a_dim1]); | |||
| /* L100: */ | |||
| } | |||
| } | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (udiag) { | |||
| sum = 1.; | |||
| i__2 = *m; | |||
| for (i__ = j + 1; i__ <= i__2; ++i__) { | |||
| sum += z_abs(&a[i__ + j * a_dim1]); | |||
| /* L120: */ | |||
| } | |||
| } else { | |||
| sum = 0.; | |||
| i__2 = *m; | |||
| for (i__ = j; i__ <= i__2; ++i__) { | |||
| sum += z_abs(&a[i__ + j * a_dim1]); | |||
| /* L130: */ | |||
| } | |||
| } | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L140: */ | |||
| } | |||
| } | |||
| } else if (lsame_(norm, "I")) { | |||
| /* Find normI(A). */ | |||
| if (lsame_(uplo, "U")) { | |||
| if (lsame_(diag, "U")) { | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 1.; | |||
| /* L150: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__3 = *m, i__4 = j - 1; | |||
| i__2 = f2cmin(i__3,i__4); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| work[i__] += z_abs(&a[i__ + j * a_dim1]); | |||
| /* L160: */ | |||
| } | |||
| /* L170: */ | |||
| } | |||
| } else { | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L180: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = f2cmin(*m,j); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| work[i__] += z_abs(&a[i__ + j * a_dim1]); | |||
| /* L190: */ | |||
| } | |||
| /* L200: */ | |||
| } | |||
| } | |||
| } else { | |||
| if (lsame_(diag, "U")) { | |||
| i__1 = f2cmin(*m,*n); | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 1.; | |||
| /* L210: */ | |||
| } | |||
| i__1 = *m; | |||
| for (i__ = *n + 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L220: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = j + 1; i__ <= i__2; ++i__) { | |||
| work[i__] += z_abs(&a[i__ + j * a_dim1]); | |||
| /* L230: */ | |||
| } | |||
| /* L240: */ | |||
| } | |||
| } else { | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[i__] = 0.; | |||
| /* L250: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = j; i__ <= i__2; ++i__) { | |||
| work[i__] += z_abs(&a[i__ + j * a_dim1]); | |||
| /* L260: */ | |||
| } | |||
| /* L270: */ | |||
| } | |||
| } | |||
| } | |||
| value = 0.; | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| sum = work[i__]; | |||
| if (value < sum || disnan_(&sum)) { | |||
| value = sum; | |||
| } | |||
| /* L280: */ | |||
| } | |||
| } else if (lsame_(norm, "F") || lsame_(norm, "E")) { | |||
| /* Find normF(A). */ | |||
| /* SSQ(1) is scale */ | |||
| /* SSQ(2) is sum-of-squares */ | |||
| /* For better accuracy, sum each column separately. */ | |||
| if (lsame_(uplo, "U")) { | |||
| if (lsame_(diag, "U")) { | |||
| ssq[0] = 1.; | |||
| ssq[1] = (doublereal) f2cmin(*m,*n); | |||
| i__1 = *n; | |||
| for (j = 2; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| /* Computing MIN */ | |||
| i__3 = *m, i__4 = j - 1; | |||
| i__2 = f2cmin(i__3,i__4); | |||
| zlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, colssq, &colssq[ | |||
| 1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L290: */ | |||
| } | |||
| } else { | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = f2cmin(*m,j); | |||
| zlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, colssq, &colssq[ | |||
| 1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L300: */ | |||
| } | |||
| } | |||
| } else { | |||
| if (lsame_(diag, "U")) { | |||
| ssq[0] = 1.; | |||
| ssq[1] = (doublereal) f2cmin(*m,*n); | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = *m - j; | |||
| /* Computing MIN */ | |||
| i__3 = *m, i__4 = j + 1; | |||
| zlassq_(&i__2, &a[f2cmin(i__3,i__4) + j * a_dim1], &c__1, | |||
| colssq, &colssq[1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L310: */ | |||
| } | |||
| } else { | |||
| ssq[0] = 0.; | |||
| ssq[1] = 1.; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| colssq[0] = 0.; | |||
| colssq[1] = 1.; | |||
| i__2 = *m - j + 1; | |||
| zlassq_(&i__2, &a[j + j * a_dim1], &c__1, colssq, &colssq[ | |||
| 1]); | |||
| dcombssq_(ssq, colssq); | |||
| /* L320: */ | |||
| } | |||
| } | |||
| } | |||
| value = ssq[0] * sqrt(ssq[1]); | |||
| } | |||
| ret_val = value; | |||
| return ret_val; | |||
| /* End of ZLANTR */ | |||
| } /* zlantr_ */ | |||
| @@ -0,0 +1,565 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAPLL measures the linear dependence of two vectors. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAPLL + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlapll. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlapll. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlapll. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAPLL( N, X, INCX, Y, INCY, SSMIN ) */ | |||
| /* INTEGER INCX, INCY, N */ | |||
| /* DOUBLE PRECISION SSMIN */ | |||
| /* COMPLEX*16 X( * ), Y( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > Given two column vectors X and Y, let */ | |||
| /* > */ | |||
| /* > A = ( X Y ). */ | |||
| /* > */ | |||
| /* > The subroutine first computes the QR factorization of A = Q*R, */ | |||
| /* > and then computes the SVD of the 2-by-2 upper triangular matrix R. */ | |||
| /* > The smaller singular value of R is returned in SSMIN, which is used */ | |||
| /* > as the measurement of the linear dependency of the vectors X and Y. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The length of the vectors X and Y. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension (1+(N-1)*INCX) */ | |||
| /* > On entry, X contains the N-vector X. */ | |||
| /* > On exit, X is overwritten. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCX */ | |||
| /* > \verbatim */ | |||
| /* > INCX is INTEGER */ | |||
| /* > The increment between successive elements of X. INCX > 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] Y */ | |||
| /* > \verbatim */ | |||
| /* > Y is COMPLEX*16 array, dimension (1+(N-1)*INCY) */ | |||
| /* > On entry, Y contains the N-vector Y. */ | |||
| /* > On exit, Y is overwritten. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCY */ | |||
| /* > \verbatim */ | |||
| /* > INCY is INTEGER */ | |||
| /* > The increment between successive elements of Y. INCY > 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SSMIN */ | |||
| /* > \verbatim */ | |||
| /* > SSMIN is DOUBLE PRECISION */ | |||
| /* > The smallest singular value of the N-by-2 matrix A = ( X Y ). */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlapll_(integer *n, doublecomplex *x, integer *incx, | |||
| doublecomplex *y, integer *incy, doublereal *ssmin) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1; | |||
| doublereal d__1, d__2, d__3; | |||
| doublecomplex z__1, z__2, z__3, z__4; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int dlas2_(doublereal *, doublereal *, doublereal | |||
| *, doublereal *, doublereal *); | |||
| doublecomplex c__; | |||
| extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *); | |||
| doublereal ssmax; | |||
| extern /* Subroutine */ int zaxpy_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *); | |||
| doublecomplex a11, a12, a22; | |||
| extern /* Subroutine */ int zlarfg_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *); | |||
| doublecomplex tau; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| --y; | |||
| --x; | |||
| /* Function Body */ | |||
| if (*n <= 1) { | |||
| *ssmin = 0.; | |||
| return 0; | |||
| } | |||
| /* Compute the QR factorization of the N-by-2 matrix ( X Y ) */ | |||
| zlarfg_(n, &x[1], &x[*incx + 1], incx, &tau); | |||
| a11.r = x[1].r, a11.i = x[1].i; | |||
| x[1].r = 1., x[1].i = 0.; | |||
| d_cnjg(&z__3, &tau); | |||
| z__2.r = -z__3.r, z__2.i = -z__3.i; | |||
| zdotc_(&z__4, n, &x[1], incx, &y[1], incy); | |||
| z__1.r = z__2.r * z__4.r - z__2.i * z__4.i, z__1.i = z__2.r * z__4.i + | |||
| z__2.i * z__4.r; | |||
| c__.r = z__1.r, c__.i = z__1.i; | |||
| zaxpy_(n, &c__, &x[1], incx, &y[1], incy); | |||
| i__1 = *n - 1; | |||
| zlarfg_(&i__1, &y[*incy + 1], &y[(*incy << 1) + 1], incy, &tau); | |||
| a12.r = y[1].r, a12.i = y[1].i; | |||
| i__1 = *incy + 1; | |||
| a22.r = y[i__1].r, a22.i = y[i__1].i; | |||
| /* Compute the SVD of 2-by-2 Upper triangular matrix. */ | |||
| d__1 = z_abs(&a11); | |||
| d__2 = z_abs(&a12); | |||
| d__3 = z_abs(&a22); | |||
| dlas2_(&d__1, &d__2, &d__3, ssmin, &ssmax); | |||
| return 0; | |||
| /* End of ZLAPLL */ | |||
| } /* zlapll_ */ | |||
| @@ -0,0 +1,619 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAPMR rearranges rows of a matrix as specified by a permutation vector. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAPMR + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlapmr. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlapmr. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlapmr. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAPMR( FORWRD, M, N, X, LDX, K ) */ | |||
| /* LOGICAL FORWRD */ | |||
| /* INTEGER LDX, M, N */ | |||
| /* INTEGER K( * ) */ | |||
| /* COMPLEX*16 X( LDX, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAPMR rearranges the rows of the M by N matrix X as specified */ | |||
| /* > by the permutation K(1),K(2),...,K(M) of the integers 1,...,M. */ | |||
| /* > If FORWRD = .TRUE., forward permutation: */ | |||
| /* > */ | |||
| /* > X(K(I),*) is moved X(I,*) for I = 1,2,...,M. */ | |||
| /* > */ | |||
| /* > If FORWRD = .FALSE., backward permutation: */ | |||
| /* > */ | |||
| /* > X(I,*) is moved to X(K(I),*) for I = 1,2,...,M. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] FORWRD */ | |||
| /* > \verbatim */ | |||
| /* > FORWRD is LOGICAL */ | |||
| /* > = .TRUE., forward permutation */ | |||
| /* > = .FALSE., backward permutation */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix X. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix X. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension (LDX,N) */ | |||
| /* > On entry, the M by N matrix X. */ | |||
| /* > On exit, X contains the permuted matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDX */ | |||
| /* > \verbatim */ | |||
| /* > LDX is INTEGER */ | |||
| /* > The leading dimension of the array X, LDX >= MAX(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER array, dimension (M) */ | |||
| /* > On entry, K contains the permutation vector. K is used as */ | |||
| /* > internal workspace, but reset to its original value on */ | |||
| /* > output. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlapmr_(logical *forwrd, integer *m, integer *n, | |||
| doublecomplex *x, integer *ldx, integer *k) | |||
| { | |||
| /* System generated locals */ | |||
| integer x_dim1, x_offset, i__1, i__2, i__3, i__4; | |||
| /* Local variables */ | |||
| doublecomplex temp; | |||
| integer i__, j, jj, in; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| x_dim1 = *ldx; | |||
| x_offset = 1 + x_dim1 * 1; | |||
| x -= x_offset; | |||
| --k; | |||
| /* Function Body */ | |||
| if (*m <= 1) { | |||
| return 0; | |||
| } | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| k[i__] = -k[i__]; | |||
| /* L10: */ | |||
| } | |||
| if (*forwrd) { | |||
| /* Forward permutation */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (k[i__] > 0) { | |||
| goto L40; | |||
| } | |||
| j = i__; | |||
| k[j] = -k[j]; | |||
| in = k[j]; | |||
| L20: | |||
| if (k[in] > 0) { | |||
| goto L40; | |||
| } | |||
| i__2 = *n; | |||
| for (jj = 1; jj <= i__2; ++jj) { | |||
| i__3 = j + jj * x_dim1; | |||
| temp.r = x[i__3].r, temp.i = x[i__3].i; | |||
| i__3 = j + jj * x_dim1; | |||
| i__4 = in + jj * x_dim1; | |||
| x[i__3].r = x[i__4].r, x[i__3].i = x[i__4].i; | |||
| i__3 = in + jj * x_dim1; | |||
| x[i__3].r = temp.r, x[i__3].i = temp.i; | |||
| /* L30: */ | |||
| } | |||
| k[in] = -k[in]; | |||
| j = in; | |||
| in = k[in]; | |||
| goto L20; | |||
| L40: | |||
| /* L50: */ | |||
| ; | |||
| } | |||
| } else { | |||
| /* Backward permutation */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (k[i__] > 0) { | |||
| goto L80; | |||
| } | |||
| k[i__] = -k[i__]; | |||
| j = k[i__]; | |||
| L60: | |||
| if (j == i__) { | |||
| goto L80; | |||
| } | |||
| i__2 = *n; | |||
| for (jj = 1; jj <= i__2; ++jj) { | |||
| i__3 = i__ + jj * x_dim1; | |||
| temp.r = x[i__3].r, temp.i = x[i__3].i; | |||
| i__3 = i__ + jj * x_dim1; | |||
| i__4 = j + jj * x_dim1; | |||
| x[i__3].r = x[i__4].r, x[i__3].i = x[i__4].i; | |||
| i__3 = j + jj * x_dim1; | |||
| x[i__3].r = temp.r, x[i__3].i = temp.i; | |||
| /* L70: */ | |||
| } | |||
| k[j] = -k[j]; | |||
| j = k[j]; | |||
| goto L60; | |||
| L80: | |||
| /* L90: */ | |||
| ; | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLAPMT */ | |||
| } /* zlapmr_ */ | |||
| @@ -0,0 +1,619 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAPMT performs a forward or backward permutation of the columns of a matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAPMT + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlapmt. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlapmt. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlapmt. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAPMT( FORWRD, M, N, X, LDX, K ) */ | |||
| /* LOGICAL FORWRD */ | |||
| /* INTEGER LDX, M, N */ | |||
| /* INTEGER K( * ) */ | |||
| /* COMPLEX*16 X( LDX, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAPMT rearranges the columns of the M by N matrix X as specified */ | |||
| /* > by the permutation K(1),K(2),...,K(N) of the integers 1,...,N. */ | |||
| /* > If FORWRD = .TRUE., forward permutation: */ | |||
| /* > */ | |||
| /* > X(*,K(J)) is moved X(*,J) for J = 1,2,...,N. */ | |||
| /* > */ | |||
| /* > If FORWRD = .FALSE., backward permutation: */ | |||
| /* > */ | |||
| /* > X(*,J) is moved to X(*,K(J)) for J = 1,2,...,N. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] FORWRD */ | |||
| /* > \verbatim */ | |||
| /* > FORWRD is LOGICAL */ | |||
| /* > = .TRUE., forward permutation */ | |||
| /* > = .FALSE., backward permutation */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix X. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix X. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension (LDX,N) */ | |||
| /* > On entry, the M by N matrix X. */ | |||
| /* > On exit, X contains the permuted matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDX */ | |||
| /* > \verbatim */ | |||
| /* > LDX is INTEGER */ | |||
| /* > The leading dimension of the array X, LDX >= MAX(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER array, dimension (N) */ | |||
| /* > On entry, K contains the permutation vector. K is used as */ | |||
| /* > internal workspace, but reset to its original value on */ | |||
| /* > output. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlapmt_(logical *forwrd, integer *m, integer *n, | |||
| doublecomplex *x, integer *ldx, integer *k) | |||
| { | |||
| /* System generated locals */ | |||
| integer x_dim1, x_offset, i__1, i__2, i__3, i__4; | |||
| /* Local variables */ | |||
| doublecomplex temp; | |||
| integer i__, j, ii, in; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| x_dim1 = *ldx; | |||
| x_offset = 1 + x_dim1 * 1; | |||
| x -= x_offset; | |||
| --k; | |||
| /* Function Body */ | |||
| if (*n <= 1) { | |||
| return 0; | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| k[i__] = -k[i__]; | |||
| /* L10: */ | |||
| } | |||
| if (*forwrd) { | |||
| /* Forward permutation */ | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (k[i__] > 0) { | |||
| goto L40; | |||
| } | |||
| j = i__; | |||
| k[j] = -k[j]; | |||
| in = k[j]; | |||
| L20: | |||
| if (k[in] > 0) { | |||
| goto L40; | |||
| } | |||
| i__2 = *m; | |||
| for (ii = 1; ii <= i__2; ++ii) { | |||
| i__3 = ii + j * x_dim1; | |||
| temp.r = x[i__3].r, temp.i = x[i__3].i; | |||
| i__3 = ii + j * x_dim1; | |||
| i__4 = ii + in * x_dim1; | |||
| x[i__3].r = x[i__4].r, x[i__3].i = x[i__4].i; | |||
| i__3 = ii + in * x_dim1; | |||
| x[i__3].r = temp.r, x[i__3].i = temp.i; | |||
| /* L30: */ | |||
| } | |||
| k[in] = -k[in]; | |||
| j = in; | |||
| in = k[in]; | |||
| goto L20; | |||
| L40: | |||
| /* L50: */ | |||
| ; | |||
| } | |||
| } else { | |||
| /* Backward permutation */ | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (k[i__] > 0) { | |||
| goto L80; | |||
| } | |||
| k[i__] = -k[i__]; | |||
| j = k[i__]; | |||
| L60: | |||
| if (j == i__) { | |||
| goto L80; | |||
| } | |||
| i__2 = *m; | |||
| for (ii = 1; ii <= i__2; ++ii) { | |||
| i__3 = ii + i__ * x_dim1; | |||
| temp.r = x[i__3].r, temp.i = x[i__3].i; | |||
| i__3 = ii + i__ * x_dim1; | |||
| i__4 = ii + j * x_dim1; | |||
| x[i__3].r = x[i__4].r, x[i__3].i = x[i__4].i; | |||
| i__3 = ii + j * x_dim1; | |||
| x[i__3].r = temp.r, x[i__3].i = temp.i; | |||
| /* L70: */ | |||
| } | |||
| k[j] = -k[j]; | |||
| j = k[j]; | |||
| goto L60; | |||
| L80: | |||
| /* L90: */ | |||
| ; | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLAPMT */ | |||
| } /* zlapmt_ */ | |||
| @@ -0,0 +1,677 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAQGB scales a general band matrix, using row and column scaling factors computed by sgbequ. | |||
| */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAQGB + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqgb. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqgb. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqgb. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAQGB( M, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND, */ | |||
| /* AMAX, EQUED ) */ | |||
| /* CHARACTER EQUED */ | |||
| /* INTEGER KL, KU, LDAB, M, N */ | |||
| /* DOUBLE PRECISION AMAX, COLCND, ROWCND */ | |||
| /* DOUBLE PRECISION C( * ), R( * ) */ | |||
| /* COMPLEX*16 AB( LDAB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAQGB equilibrates a general M by N band matrix A with KL */ | |||
| /* > subdiagonals and KU superdiagonals using the row and scaling factors */ | |||
| /* > in the vectors R and C. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KL */ | |||
| /* > \verbatim */ | |||
| /* > KL is INTEGER */ | |||
| /* > The number of subdiagonals within the band of A. KL >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KU */ | |||
| /* > \verbatim */ | |||
| /* > KU is INTEGER */ | |||
| /* > The number of superdiagonals within the band of A. KU >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX*16 array, dimension (LDAB,N) */ | |||
| /* > On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */ | |||
| /* > The j-th column of A is stored in the j-th column of the */ | |||
| /* > array AB as follows: */ | |||
| /* > AB(ku+1+i-j,j) = A(i,j) for f2cmax(1,j-ku)<=i<=f2cmin(m,j+kl) */ | |||
| /* > */ | |||
| /* > On exit, the equilibrated matrix, in the same storage format */ | |||
| /* > as A. See EQUED for the form of the equilibrated matrix. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDA >= KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] R */ | |||
| /* > \verbatim */ | |||
| /* > R is DOUBLE PRECISION array, dimension (M) */ | |||
| /* > The row scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] C */ | |||
| /* > \verbatim */ | |||
| /* > C is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The column scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ROWCND */ | |||
| /* > \verbatim */ | |||
| /* > ROWCND is DOUBLE PRECISION */ | |||
| /* > Ratio of the smallest R(i) to the largest R(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] COLCND */ | |||
| /* > \verbatim */ | |||
| /* > COLCND is DOUBLE PRECISION */ | |||
| /* > Ratio of the smallest C(i) to the largest C(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is DOUBLE PRECISION */ | |||
| /* > Absolute value of largest matrix entry. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] EQUED */ | |||
| /* > \verbatim */ | |||
| /* > EQUED is CHARACTER*1 */ | |||
| /* > Specifies the form of equilibration that was done. */ | |||
| /* > = 'N': No equilibration */ | |||
| /* > = 'R': Row equilibration, i.e., A has been premultiplied by */ | |||
| /* > diag(R). */ | |||
| /* > = 'C': Column equilibration, i.e., A has been postmultiplied */ | |||
| /* > by diag(C). */ | |||
| /* > = 'B': Both row and column equilibration, i.e., A has been */ | |||
| /* > replaced by diag(R) * A * diag(C). */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > THRESH is a threshold value used to decide if row or column scaling */ | |||
| /* > should be done based on the ratio of the row or column scaling */ | |||
| /* > factors. If ROWCND < THRESH, row scaling is done, and if */ | |||
| /* > COLCND < THRESH, column scaling is done. */ | |||
| /* > */ | |||
| /* > LARGE and SMALL are threshold values used to decide if row scaling */ | |||
| /* > should be done based on the absolute size of the largest matrix */ | |||
| /* > element. If AMAX > LARGE or AMAX < SMALL, row scaling is done. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16GBauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaqgb_(integer *m, integer *n, integer *kl, integer *ku, | |||
| doublecomplex *ab, integer *ldab, doublereal *r__, doublereal *c__, | |||
| doublereal *rowcnd, doublereal *colcnd, doublereal *amax, char *equed) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5, i__6; | |||
| doublereal d__1; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| doublereal large, small, cj; | |||
| extern doublereal dlamch_(char *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --r__; | |||
| --c__; | |||
| /* Function Body */ | |||
| if (*m <= 0 || *n <= 0) { | |||
| *(unsigned char *)equed = 'N'; | |||
| return 0; | |||
| } | |||
| /* Initialize LARGE and SMALL. */ | |||
| small = dlamch_("Safe minimum") / dlamch_("Precision"); | |||
| large = 1. / small; | |||
| if (*rowcnd >= .1 && *amax >= small && *amax <= large) { | |||
| /* No row scaling */ | |||
| if (*colcnd >= .1) { | |||
| /* No column scaling */ | |||
| *(unsigned char *)equed = 'N'; | |||
| } else { | |||
| /* Column scaling */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = c__[j]; | |||
| /* Computing MAX */ | |||
| i__2 = 1, i__3 = j - *ku; | |||
| /* Computing MIN */ | |||
| i__5 = *m, i__6 = j + *kl; | |||
| i__4 = f2cmin(i__5,i__6); | |||
| for (i__ = f2cmax(i__2,i__3); i__ <= i__4; ++i__) { | |||
| i__2 = *ku + 1 + i__ - j + j * ab_dim1; | |||
| i__3 = *ku + 1 + i__ - j + j * ab_dim1; | |||
| z__1.r = cj * ab[i__3].r, z__1.i = cj * ab[i__3].i; | |||
| ab[i__2].r = z__1.r, ab[i__2].i = z__1.i; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| *(unsigned char *)equed = 'C'; | |||
| } | |||
| } else if (*colcnd >= .1) { | |||
| /* Row scaling, no column scaling */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__4 = 1, i__2 = j - *ku; | |||
| /* Computing MIN */ | |||
| i__5 = *m, i__6 = j + *kl; | |||
| i__3 = f2cmin(i__5,i__6); | |||
| for (i__ = f2cmax(i__4,i__2); i__ <= i__3; ++i__) { | |||
| i__4 = *ku + 1 + i__ - j + j * ab_dim1; | |||
| i__2 = i__; | |||
| i__5 = *ku + 1 + i__ - j + j * ab_dim1; | |||
| z__1.r = r__[i__2] * ab[i__5].r, z__1.i = r__[i__2] * ab[i__5] | |||
| .i; | |||
| ab[i__4].r = z__1.r, ab[i__4].i = z__1.i; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| *(unsigned char *)equed = 'R'; | |||
| } else { | |||
| /* Row and column scaling */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = c__[j]; | |||
| /* Computing MAX */ | |||
| i__3 = 1, i__4 = j - *ku; | |||
| /* Computing MIN */ | |||
| i__5 = *m, i__6 = j + *kl; | |||
| i__2 = f2cmin(i__5,i__6); | |||
| for (i__ = f2cmax(i__3,i__4); i__ <= i__2; ++i__) { | |||
| i__3 = *ku + 1 + i__ - j + j * ab_dim1; | |||
| d__1 = cj * r__[i__]; | |||
| i__4 = *ku + 1 + i__ - j + j * ab_dim1; | |||
| z__1.r = d__1 * ab[i__4].r, z__1.i = d__1 * ab[i__4].i; | |||
| ab[i__3].r = z__1.r, ab[i__3].i = z__1.i; | |||
| /* L50: */ | |||
| } | |||
| /* L60: */ | |||
| } | |||
| *(unsigned char *)equed = 'B'; | |||
| } | |||
| return 0; | |||
| /* End of ZLAQGB */ | |||
| } /* zlaqgb_ */ | |||
| @@ -0,0 +1,648 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAQGE scales a general rectangular matrix, using row and column scaling factors computed by sg | |||
| eequ. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAQGE + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqge. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqge. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqge. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAQGE( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX, */ | |||
| /* EQUED ) */ | |||
| /* CHARACTER EQUED */ | |||
| /* INTEGER LDA, M, N */ | |||
| /* DOUBLE PRECISION AMAX, COLCND, ROWCND */ | |||
| /* DOUBLE PRECISION C( * ), R( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAQGE equilibrates a general M by N matrix A using the row and */ | |||
| /* > column scaling factors in the vectors R and C. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the M by N matrix A. */ | |||
| /* > On exit, the equilibrated matrix. See EQUED for the form of */ | |||
| /* > the equilibrated matrix. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(M,1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] R */ | |||
| /* > \verbatim */ | |||
| /* > R is DOUBLE PRECISION array, dimension (M) */ | |||
| /* > The row scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] C */ | |||
| /* > \verbatim */ | |||
| /* > C is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The column scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ROWCND */ | |||
| /* > \verbatim */ | |||
| /* > ROWCND is DOUBLE PRECISION */ | |||
| /* > Ratio of the smallest R(i) to the largest R(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] COLCND */ | |||
| /* > \verbatim */ | |||
| /* > COLCND is DOUBLE PRECISION */ | |||
| /* > Ratio of the smallest C(i) to the largest C(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is DOUBLE PRECISION */ | |||
| /* > Absolute value of largest matrix entry. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] EQUED */ | |||
| /* > \verbatim */ | |||
| /* > EQUED is CHARACTER*1 */ | |||
| /* > Specifies the form of equilibration that was done. */ | |||
| /* > = 'N': No equilibration */ | |||
| /* > = 'R': Row equilibration, i.e., A has been premultiplied by */ | |||
| /* > diag(R). */ | |||
| /* > = 'C': Column equilibration, i.e., A has been postmultiplied */ | |||
| /* > by diag(C). */ | |||
| /* > = 'B': Both row and column equilibration, i.e., A has been */ | |||
| /* > replaced by diag(R) * A * diag(C). */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > THRESH is a threshold value used to decide if row or column scaling */ | |||
| /* > should be done based on the ratio of the row or column scaling */ | |||
| /* > factors. If ROWCND < THRESH, row scaling is done, and if */ | |||
| /* > COLCND < THRESH, column scaling is done. */ | |||
| /* > */ | |||
| /* > LARGE and SMALL are threshold values used to decide if row scaling */ | |||
| /* > should be done based on the absolute size of the largest matrix */ | |||
| /* > element. If AMAX > LARGE or AMAX < SMALL, row scaling is done. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16GEauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaqge_(integer *m, integer *n, doublecomplex *a, | |||
| integer *lda, doublereal *r__, doublereal *c__, doublereal *rowcnd, | |||
| doublereal *colcnd, doublereal *amax, char *equed) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5; | |||
| doublereal d__1; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| doublereal large, small, cj; | |||
| extern doublereal dlamch_(char *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --r__; | |||
| --c__; | |||
| /* Function Body */ | |||
| if (*m <= 0 || *n <= 0) { | |||
| *(unsigned char *)equed = 'N'; | |||
| return 0; | |||
| } | |||
| /* Initialize LARGE and SMALL. */ | |||
| small = dlamch_("Safe minimum") / dlamch_("Precision"); | |||
| large = 1. / small; | |||
| if (*rowcnd >= .1 && *amax >= small && *amax <= large) { | |||
| /* No row scaling */ | |||
| if (*colcnd >= .1) { | |||
| /* No column scaling */ | |||
| *(unsigned char *)equed = 'N'; | |||
| } else { | |||
| /* Column scaling */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = c__[j]; | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| z__1.r = cj * a[i__4].r, z__1.i = cj * a[i__4].i; | |||
| a[i__3].r = z__1.r, a[i__3].i = z__1.i; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| *(unsigned char *)equed = 'C'; | |||
| } | |||
| } else if (*colcnd >= .1) { | |||
| /* Row scaling, no column scaling */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| i__4 = i__; | |||
| i__5 = i__ + j * a_dim1; | |||
| z__1.r = r__[i__4] * a[i__5].r, z__1.i = r__[i__4] * a[i__5] | |||
| .i; | |||
| a[i__3].r = z__1.r, a[i__3].i = z__1.i; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| *(unsigned char *)equed = 'R'; | |||
| } else { | |||
| /* Row and column scaling */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = c__[j]; | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| d__1 = cj * r__[i__]; | |||
| i__4 = i__ + j * a_dim1; | |||
| z__1.r = d__1 * a[i__4].r, z__1.i = d__1 * a[i__4].i; | |||
| a[i__3].r = z__1.r, a[i__3].i = z__1.i; | |||
| /* L50: */ | |||
| } | |||
| /* L60: */ | |||
| } | |||
| *(unsigned char *)equed = 'B'; | |||
| } | |||
| return 0; | |||
| /* End of ZLAQGE */ | |||
| } /* zlaqge_ */ | |||
| @@ -0,0 +1,640 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAQHB scales a Hermitian band matrix, using scaling factors computed by cpbequ. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAQHB + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqhb. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqhb. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqhb. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAQHB( UPLO, N, KD, AB, LDAB, S, SCOND, AMAX, EQUED ) */ | |||
| /* CHARACTER EQUED, UPLO */ | |||
| /* INTEGER KD, LDAB, N */ | |||
| /* DOUBLE PRECISION AMAX, SCOND */ | |||
| /* DOUBLE PRECISION S( * ) */ | |||
| /* COMPLEX*16 AB( LDAB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAQHB equilibrates a Hermitian band matrix A */ | |||
| /* > using the scaling factors in the vector S. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the upper or lower triangular part of the */ | |||
| /* > symmetric matrix A is stored. */ | |||
| /* > = 'U': Upper triangular */ | |||
| /* > = 'L': Lower triangular */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KD */ | |||
| /* > \verbatim */ | |||
| /* > KD is INTEGER */ | |||
| /* > The number of super-diagonals of the matrix A if UPLO = 'U', */ | |||
| /* > or the number of sub-diagonals if UPLO = 'L'. KD >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX*16 array, dimension (LDAB,N) */ | |||
| /* > On entry, the upper or lower triangle of the symmetric band */ | |||
| /* > matrix A, stored in the first KD+1 rows of the array. The */ | |||
| /* > j-th column of A is stored in the j-th column of the array AB */ | |||
| /* > as follows: */ | |||
| /* > if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for f2cmax(1,j-kd)<=i<=j; */ | |||
| /* > if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=f2cmin(n,j+kd). */ | |||
| /* > */ | |||
| /* > On exit, if INFO = 0, the triangular factor U or L from the */ | |||
| /* > Cholesky factorization A = U**H *U or A = L*L**H of the band */ | |||
| /* > matrix A, in the same storage format as A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= KD+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] S */ | |||
| /* > \verbatim */ | |||
| /* > S is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SCOND */ | |||
| /* > \verbatim */ | |||
| /* > SCOND is DOUBLE PRECISION */ | |||
| /* > Ratio of the smallest S(i) to the largest S(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is DOUBLE PRECISION */ | |||
| /* > Absolute value of largest matrix entry. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] EQUED */ | |||
| /* > \verbatim */ | |||
| /* > EQUED is CHARACTER*1 */ | |||
| /* > Specifies whether or not equilibration was done. */ | |||
| /* > = 'N': No equilibration. */ | |||
| /* > = 'Y': Equilibration was done, i.e., A has been replaced by */ | |||
| /* > diag(S) * A * diag(S). */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > THRESH is a threshold value used to decide if scaling should be done */ | |||
| /* > based on the ratio of the scaling factors. If SCOND < THRESH, */ | |||
| /* > scaling is done. */ | |||
| /* > */ | |||
| /* > LARGE and SMALL are threshold values used to decide if scaling should */ | |||
| /* > be done based on the absolute size of the largest matrix element. */ | |||
| /* > If AMAX > LARGE or AMAX < SMALL, scaling is done. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaqhb_(char *uplo, integer *n, integer *kd, | |||
| doublecomplex *ab, integer *ldab, doublereal *s, doublereal *scond, | |||
| doublereal *amax, char *equed) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4; | |||
| doublereal d__1; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| doublereal large; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal small, cj; | |||
| extern doublereal dlamch_(char *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --s; | |||
| /* Function Body */ | |||
| if (*n <= 0) { | |||
| *(unsigned char *)equed = 'N'; | |||
| return 0; | |||
| } | |||
| /* Initialize LARGE and SMALL. */ | |||
| small = dlamch_("Safe minimum") / dlamch_("Precision"); | |||
| large = 1. / small; | |||
| if (*scond >= .1 && *amax >= small && *amax <= large) { | |||
| /* No equilibration */ | |||
| *(unsigned char *)equed = 'N'; | |||
| } else { | |||
| /* Replace A by diag(S) * A * diag(S). */ | |||
| if (lsame_(uplo, "U")) { | |||
| /* Upper triangle of A is stored in band format. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = s[j]; | |||
| /* Computing MAX */ | |||
| i__2 = 1, i__3 = j - *kd; | |||
| i__4 = j - 1; | |||
| for (i__ = f2cmax(i__2,i__3); i__ <= i__4; ++i__) { | |||
| i__2 = *kd + 1 + i__ - j + j * ab_dim1; | |||
| d__1 = cj * s[i__]; | |||
| i__3 = *kd + 1 + i__ - j + j * ab_dim1; | |||
| z__1.r = d__1 * ab[i__3].r, z__1.i = d__1 * ab[i__3].i; | |||
| ab[i__2].r = z__1.r, ab[i__2].i = z__1.i; | |||
| /* L10: */ | |||
| } | |||
| i__4 = *kd + 1 + j * ab_dim1; | |||
| i__2 = *kd + 1 + j * ab_dim1; | |||
| d__1 = cj * cj * ab[i__2].r; | |||
| ab[i__4].r = d__1, ab[i__4].i = 0.; | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| /* Lower triangle of A is stored. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = s[j]; | |||
| i__4 = j * ab_dim1 + 1; | |||
| i__2 = j * ab_dim1 + 1; | |||
| d__1 = cj * cj * ab[i__2].r; | |||
| ab[i__4].r = d__1, ab[i__4].i = 0.; | |||
| /* Computing MIN */ | |||
| i__2 = *n, i__3 = j + *kd; | |||
| i__4 = f2cmin(i__2,i__3); | |||
| for (i__ = j + 1; i__ <= i__4; ++i__) { | |||
| i__2 = i__ + 1 - j + j * ab_dim1; | |||
| d__1 = cj * s[i__]; | |||
| i__3 = i__ + 1 - j + j * ab_dim1; | |||
| z__1.r = d__1 * ab[i__3].r, z__1.i = d__1 * ab[i__3].i; | |||
| ab[i__2].r = z__1.r, ab[i__2].i = z__1.i; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| *(unsigned char *)equed = 'Y'; | |||
| } | |||
| return 0; | |||
| /* End of ZLAQHB */ | |||
| } /* zlaqhb_ */ | |||
| @@ -0,0 +1,629 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAQHE scales a Hermitian matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAQHE + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqhe. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqhe. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqhe. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAQHE( UPLO, N, A, LDA, S, SCOND, AMAX, EQUED ) */ | |||
| /* CHARACTER EQUED, UPLO */ | |||
| /* INTEGER LDA, N */ | |||
| /* DOUBLE PRECISION AMAX, SCOND */ | |||
| /* DOUBLE PRECISION S( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAQHE equilibrates a Hermitian matrix A using the scaling factors */ | |||
| /* > in the vector S. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the upper or lower triangular part of the */ | |||
| /* > Hermitian matrix A is stored. */ | |||
| /* > = 'U': Upper triangular */ | |||
| /* > = 'L': Lower triangular */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the Hermitian matrix A. If UPLO = 'U', the leading */ | |||
| /* > n by n upper triangular part of A contains the upper */ | |||
| /* > triangular part of the matrix A, and the strictly lower */ | |||
| /* > triangular part of A is not referenced. If UPLO = 'L', the */ | |||
| /* > leading n by n lower triangular part of A contains the lower */ | |||
| /* > triangular part of the matrix A, and the strictly upper */ | |||
| /* > triangular part of A is not referenced. */ | |||
| /* > */ | |||
| /* > On exit, if EQUED = 'Y', the equilibrated matrix: */ | |||
| /* > diag(S) * A * diag(S). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(N,1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] S */ | |||
| /* > \verbatim */ | |||
| /* > S is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SCOND */ | |||
| /* > \verbatim */ | |||
| /* > SCOND is DOUBLE PRECISION */ | |||
| /* > Ratio of the smallest S(i) to the largest S(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is DOUBLE PRECISION */ | |||
| /* > Absolute value of largest matrix entry. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] EQUED */ | |||
| /* > \verbatim */ | |||
| /* > EQUED is CHARACTER*1 */ | |||
| /* > Specifies whether or not equilibration was done. */ | |||
| /* > = 'N': No equilibration. */ | |||
| /* > = 'Y': Equilibration was done, i.e., A has been replaced by */ | |||
| /* > diag(S) * A * diag(S). */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > THRESH is a threshold value used to decide if scaling should be done */ | |||
| /* > based on the ratio of the scaling factors. If SCOND < THRESH, */ | |||
| /* > scaling is done. */ | |||
| /* > */ | |||
| /* > LARGE and SMALL are threshold values used to decide if scaling should */ | |||
| /* > be done based on the absolute size of the largest matrix element. */ | |||
| /* > If AMAX > LARGE or AMAX < SMALL, scaling is done. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16HEauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaqhe_(char *uplo, integer *n, doublecomplex *a, | |||
| integer *lda, doublereal *s, doublereal *scond, doublereal *amax, | |||
| char *equed) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| doublereal d__1; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| doublereal large; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal small, cj; | |||
| extern doublereal dlamch_(char *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --s; | |||
| /* Function Body */ | |||
| if (*n <= 0) { | |||
| *(unsigned char *)equed = 'N'; | |||
| return 0; | |||
| } | |||
| /* Initialize LARGE and SMALL. */ | |||
| small = dlamch_("Safe minimum") / dlamch_("Precision"); | |||
| large = 1. / small; | |||
| if (*scond >= .1 && *amax >= small && *amax <= large) { | |||
| /* No equilibration */ | |||
| *(unsigned char *)equed = 'N'; | |||
| } else { | |||
| /* Replace A by diag(S) * A * diag(S). */ | |||
| if (lsame_(uplo, "U")) { | |||
| /* Upper triangle of A is stored. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = s[j]; | |||
| i__2 = j - 1; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| d__1 = cj * s[i__]; | |||
| i__4 = i__ + j * a_dim1; | |||
| z__1.r = d__1 * a[i__4].r, z__1.i = d__1 * a[i__4].i; | |||
| a[i__3].r = z__1.r, a[i__3].i = z__1.i; | |||
| /* L10: */ | |||
| } | |||
| i__2 = j + j * a_dim1; | |||
| i__3 = j + j * a_dim1; | |||
| d__1 = cj * cj * a[i__3].r; | |||
| a[i__2].r = d__1, a[i__2].i = 0.; | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| /* Lower triangle of A is stored. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = s[j]; | |||
| i__2 = j + j * a_dim1; | |||
| i__3 = j + j * a_dim1; | |||
| d__1 = cj * cj * a[i__3].r; | |||
| a[i__2].r = d__1, a[i__2].i = 0.; | |||
| i__2 = *n; | |||
| for (i__ = j + 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| d__1 = cj * s[i__]; | |||
| i__4 = i__ + j * a_dim1; | |||
| z__1.r = d__1 * a[i__4].r, z__1.i = d__1 * a[i__4].i; | |||
| a[i__3].r = z__1.r, a[i__3].i = z__1.i; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| *(unsigned char *)equed = 'Y'; | |||
| } | |||
| return 0; | |||
| /* End of ZLAQHE */ | |||
| } /* zlaqhe_ */ | |||
| @@ -0,0 +1,624 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAQHP scales a Hermitian matrix stored in packed form. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAQHP + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqhp. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqhp. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqhp. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAQHP( UPLO, N, AP, S, SCOND, AMAX, EQUED ) */ | |||
| /* CHARACTER EQUED, UPLO */ | |||
| /* INTEGER N */ | |||
| /* DOUBLE PRECISION AMAX, SCOND */ | |||
| /* DOUBLE PRECISION S( * ) */ | |||
| /* COMPLEX*16 AP( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAQHP equilibrates a Hermitian matrix A using the scaling factors */ | |||
| /* > in the vector S. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the upper or lower triangular part of the */ | |||
| /* > Hermitian matrix A is stored. */ | |||
| /* > = 'U': Upper triangular */ | |||
| /* > = 'L': Lower triangular */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] AP */ | |||
| /* > \verbatim */ | |||
| /* > AP is COMPLEX*16 array, dimension (N*(N+1)/2) */ | |||
| /* > On entry, the upper or lower triangle of the Hermitian matrix */ | |||
| /* > A, packed columnwise in a linear array. The j-th column of A */ | |||
| /* > is stored in the array AP as follows: */ | |||
| /* > if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ | |||
| /* > if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ | |||
| /* > */ | |||
| /* > On exit, the equilibrated matrix: diag(S) * A * diag(S), in */ | |||
| /* > the same storage format as A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] S */ | |||
| /* > \verbatim */ | |||
| /* > S is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SCOND */ | |||
| /* > \verbatim */ | |||
| /* > SCOND is DOUBLE PRECISION */ | |||
| /* > Ratio of the smallest S(i) to the largest S(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is DOUBLE PRECISION */ | |||
| /* > Absolute value of largest matrix entry. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] EQUED */ | |||
| /* > \verbatim */ | |||
| /* > EQUED is CHARACTER*1 */ | |||
| /* > Specifies whether or not equilibration was done. */ | |||
| /* > = 'N': No equilibration. */ | |||
| /* > = 'Y': Equilibration was done, i.e., A has been replaced by */ | |||
| /* > diag(S) * A * diag(S). */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > THRESH is a threshold value used to decide if scaling should be done */ | |||
| /* > based on the ratio of the scaling factors. If SCOND < THRESH, */ | |||
| /* > scaling is done. */ | |||
| /* > */ | |||
| /* > LARGE and SMALL are threshold values used to decide if scaling should */ | |||
| /* > be done based on the absolute size of the largest matrix element. */ | |||
| /* > If AMAX > LARGE or AMAX < SMALL, scaling is done. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaqhp_(char *uplo, integer *n, doublecomplex *ap, | |||
| doublereal *s, doublereal *scond, doublereal *amax, char *equed) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2, i__3, i__4; | |||
| doublereal d__1; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| doublereal large; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal small; | |||
| integer jc; | |||
| doublereal cj; | |||
| extern doublereal dlamch_(char *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| --s; | |||
| --ap; | |||
| /* Function Body */ | |||
| if (*n <= 0) { | |||
| *(unsigned char *)equed = 'N'; | |||
| return 0; | |||
| } | |||
| /* Initialize LARGE and SMALL. */ | |||
| small = dlamch_("Safe minimum") / dlamch_("Precision"); | |||
| large = 1. / small; | |||
| if (*scond >= .1 && *amax >= small && *amax <= large) { | |||
| /* No equilibration */ | |||
| *(unsigned char *)equed = 'N'; | |||
| } else { | |||
| /* Replace A by diag(S) * A * diag(S). */ | |||
| if (lsame_(uplo, "U")) { | |||
| /* Upper triangle of A is stored. */ | |||
| jc = 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = s[j]; | |||
| i__2 = j - 1; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = jc + i__ - 1; | |||
| d__1 = cj * s[i__]; | |||
| i__4 = jc + i__ - 1; | |||
| z__1.r = d__1 * ap[i__4].r, z__1.i = d__1 * ap[i__4].i; | |||
| ap[i__3].r = z__1.r, ap[i__3].i = z__1.i; | |||
| /* L10: */ | |||
| } | |||
| i__2 = jc + j - 1; | |||
| i__3 = jc + j - 1; | |||
| d__1 = cj * cj * ap[i__3].r; | |||
| ap[i__2].r = d__1, ap[i__2].i = 0.; | |||
| jc += j; | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| /* Lower triangle of A is stored. */ | |||
| jc = 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = s[j]; | |||
| i__2 = jc; | |||
| i__3 = jc; | |||
| d__1 = cj * cj * ap[i__3].r; | |||
| ap[i__2].r = d__1, ap[i__2].i = 0.; | |||
| i__2 = *n; | |||
| for (i__ = j + 1; i__ <= i__2; ++i__) { | |||
| i__3 = jc + i__ - j; | |||
| d__1 = cj * s[i__]; | |||
| i__4 = jc + i__ - j; | |||
| z__1.r = d__1 * ap[i__4].r, z__1.i = d__1 * ap[i__4].i; | |||
| ap[i__3].r = z__1.r, ap[i__3].i = z__1.i; | |||
| /* L30: */ | |||
| } | |||
| jc = jc + *n - j + 1; | |||
| /* L40: */ | |||
| } | |||
| } | |||
| *(unsigned char *)equed = 'Y'; | |||
| } | |||
| return 0; | |||
| /* End of ZLAQHP */ | |||
| } /* zlaqhp_ */ | |||
| @@ -0,0 +1,684 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLAQP2 computes a QR factorization with column pivoting of the matrix block. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAQP2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqp2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqp2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqp2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAQP2( M, N, OFFSET, A, LDA, JPVT, TAU, VN1, VN2, */ | |||
| /* WORK ) */ | |||
| /* INTEGER LDA, M, N, OFFSET */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* DOUBLE PRECISION VN1( * ), VN2( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAQP2 computes a QR factorization with column pivoting of */ | |||
| /* > the block A(OFFSET+1:M,1:N). */ | |||
| /* > The block A(1:OFFSET,1:N) is accordingly pivoted, but not factorized. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] OFFSET */ | |||
| /* > \verbatim */ | |||
| /* > OFFSET is INTEGER */ | |||
| /* > The number of rows of the matrix A that must be pivoted */ | |||
| /* > but no factorized. OFFSET >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the upper triangle of block A(OFFSET+1:M,1:N) is */ | |||
| /* > the triangular factor obtained; the elements in block */ | |||
| /* > A(OFFSET+1:M,1:N) below the diagonal, together with the */ | |||
| /* > array TAU, represent the orthogonal matrix Q as a product of */ | |||
| /* > elementary reflectors. Block A(1:OFFSET,1:N) has been */ | |||
| /* > accordingly pivoted, but no factorized. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] JPVT */ | |||
| /* > \verbatim */ | |||
| /* > JPVT is INTEGER array, dimension (N) */ | |||
| /* > On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted */ | |||
| /* > to the front of A*P (a leading column); if JPVT(i) = 0, */ | |||
| /* > the i-th column of A is a free column. */ | |||
| /* > On exit, if JPVT(i) = k, then the i-th column of A*P */ | |||
| /* > was the k-th column of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] VN1 */ | |||
| /* > \verbatim */ | |||
| /* > VN1 is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The vector with the partial column norms. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] VN2 */ | |||
| /* > \verbatim */ | |||
| /* > VN2 is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The vector with the exact column norms. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX*16 array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain */ | |||
| /* > X. Sun, Computer Science Dept., Duke University, USA */ | |||
| /* > \n */ | |||
| /* > Partial column norm updating strategy modified on April 2011 */ | |||
| /* > Z. Drmac and Z. Bujanovic, Dept. of Mathematics, */ | |||
| /* > University of Zagreb, Croatia. */ | |||
| /* > \par References: */ | |||
| /* ================ */ | |||
| /* > */ | |||
| /* > LAPACK Working Note 176 */ | |||
| /* > \htmlonly */ | |||
| /* > <a href="http://www.netlib.org/lapack/lawnspdf/lawn176.pdf">[PDF]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaqp2_(integer *m, integer *n, integer *offset, | |||
| doublecomplex *a, integer *lda, integer *jpvt, doublecomplex *tau, | |||
| doublereal *vn1, doublereal *vn2, doublecomplex *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| doublereal d__1; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| doublereal temp, temp2; | |||
| integer i__, j; | |||
| doublereal tol3z; | |||
| integer offpi, itemp; | |||
| extern /* Subroutine */ int zlarf_(char *, integer *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, doublecomplex *, | |||
| integer *, doublecomplex *), zswap_(integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *); | |||
| extern doublereal dznrm2_(integer *, doublecomplex *, integer *), dlamch_( | |||
| char *); | |||
| integer mn; | |||
| extern integer idamax_(integer *, doublereal *, integer *); | |||
| extern /* Subroutine */ int zlarfg_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *); | |||
| doublecomplex aii; | |||
| integer pvt; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --jpvt; | |||
| --tau; | |||
| --vn1; | |||
| --vn2; | |||
| --work; | |||
| /* Function Body */ | |||
| /* Computing MIN */ | |||
| i__1 = *m - *offset; | |||
| mn = f2cmin(i__1,*n); | |||
| tol3z = sqrt(dlamch_("Epsilon")); | |||
| /* Compute factorization. */ | |||
| i__1 = mn; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| offpi = *offset + i__; | |||
| /* Determine ith pivot column and swap if necessary. */ | |||
| i__2 = *n - i__ + 1; | |||
| pvt = i__ - 1 + idamax_(&i__2, &vn1[i__], &c__1); | |||
| if (pvt != i__) { | |||
| zswap_(m, &a[pvt * a_dim1 + 1], &c__1, &a[i__ * a_dim1 + 1], & | |||
| c__1); | |||
| itemp = jpvt[pvt]; | |||
| jpvt[pvt] = jpvt[i__]; | |||
| jpvt[i__] = itemp; | |||
| vn1[pvt] = vn1[i__]; | |||
| vn2[pvt] = vn2[i__]; | |||
| } | |||
| /* Generate elementary reflector H(i). */ | |||
| if (offpi < *m) { | |||
| i__2 = *m - offpi + 1; | |||
| zlarfg_(&i__2, &a[offpi + i__ * a_dim1], &a[offpi + 1 + i__ * | |||
| a_dim1], &c__1, &tau[i__]); | |||
| } else { | |||
| zlarfg_(&c__1, &a[*m + i__ * a_dim1], &a[*m + i__ * a_dim1], & | |||
| c__1, &tau[i__]); | |||
| } | |||
| if (i__ < *n) { | |||
| /* Apply H(i)**H to A(offset+i:m,i+1:n) from the left. */ | |||
| i__2 = offpi + i__ * a_dim1; | |||
| aii.r = a[i__2].r, aii.i = a[i__2].i; | |||
| i__2 = offpi + i__ * a_dim1; | |||
| a[i__2].r = 1., a[i__2].i = 0.; | |||
| i__2 = *m - offpi + 1; | |||
| i__3 = *n - i__; | |||
| d_cnjg(&z__1, &tau[i__]); | |||
| zlarf_("Left", &i__2, &i__3, &a[offpi + i__ * a_dim1], &c__1, & | |||
| z__1, &a[offpi + (i__ + 1) * a_dim1], lda, &work[1]); | |||
| i__2 = offpi + i__ * a_dim1; | |||
| a[i__2].r = aii.r, a[i__2].i = aii.i; | |||
| } | |||
| /* Update partial column norms. */ | |||
| i__2 = *n; | |||
| for (j = i__ + 1; j <= i__2; ++j) { | |||
| if (vn1[j] != 0.) { | |||
| /* NOTE: The following 4 lines follow from the analysis in */ | |||
| /* Lapack Working Note 176. */ | |||
| /* Computing 2nd power */ | |||
| d__1 = z_abs(&a[offpi + j * a_dim1]) / vn1[j]; | |||
| temp = 1. - d__1 * d__1; | |||
| temp = f2cmax(temp,0.); | |||
| /* Computing 2nd power */ | |||
| d__1 = vn1[j] / vn2[j]; | |||
| temp2 = temp * (d__1 * d__1); | |||
| if (temp2 <= tol3z) { | |||
| if (offpi < *m) { | |||
| i__3 = *m - offpi; | |||
| vn1[j] = dznrm2_(&i__3, &a[offpi + 1 + j * a_dim1], & | |||
| c__1); | |||
| vn2[j] = vn1[j]; | |||
| } else { | |||
| vn1[j] = 0.; | |||
| vn2[j] = 0.; | |||
| } | |||
| } else { | |||
| vn1[j] *= sqrt(temp); | |||
| } | |||
| } | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| return 0; | |||
| /* End of ZLAQP2 */ | |||
| } /* zlaqp2_ */ | |||
| @@ -0,0 +1,823 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {0.,0.}; | |||
| static doublecomplex c_b2 = {1.,0.}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLAQPS computes a step of QR factorization with column pivoting of a real m-by-n matrix A by us | |||
| ing BLAS level 3. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAQPS + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqps. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqps. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqps. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAQPS( M, N, OFFSET, NB, KB, A, LDA, JPVT, TAU, VN1, */ | |||
| /* VN2, AUXV, F, LDF ) */ | |||
| /* INTEGER KB, LDA, LDF, M, N, NB, OFFSET */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* DOUBLE PRECISION VN1( * ), VN2( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAQPS computes a step of QR factorization with column pivoting */ | |||
| /* > of a complex M-by-N matrix A by using Blas-3. It tries to factorize */ | |||
| /* > NB columns from A starting from the row OFFSET+1, and updates all */ | |||
| /* > of the matrix with Blas-3 xGEMM. */ | |||
| /* > */ | |||
| /* > In some cases, due to catastrophic cancellations, it cannot */ | |||
| /* > factorize NB columns. Hence, the actual number of factorized */ | |||
| /* > columns is returned in KB. */ | |||
| /* > */ | |||
| /* > Block A(1:OFFSET,1:N) is accordingly pivoted, but not factorized. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] OFFSET */ | |||
| /* > \verbatim */ | |||
| /* > OFFSET is INTEGER */ | |||
| /* > The number of rows of A that have been factorized in */ | |||
| /* > previous steps. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The number of columns to factorize. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] KB */ | |||
| /* > \verbatim */ | |||
| /* > KB is INTEGER */ | |||
| /* > The number of columns actually factorized. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, block A(OFFSET+1:M,1:KB) is the triangular */ | |||
| /* > factor obtained and block A(1:OFFSET,1:N) has been */ | |||
| /* > accordingly pivoted, but no factorized. */ | |||
| /* > The rest of the matrix, block A(OFFSET+1:M,KB+1:N) has */ | |||
| /* > been updated. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] JPVT */ | |||
| /* > \verbatim */ | |||
| /* > JPVT is INTEGER array, dimension (N) */ | |||
| /* > JPVT(I) = K <==> Column K of the full matrix A has been */ | |||
| /* > permuted into position I in AP. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 array, dimension (KB) */ | |||
| /* > The scalar factors of the elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] VN1 */ | |||
| /* > \verbatim */ | |||
| /* > VN1 is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The vector with the partial column norms. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] VN2 */ | |||
| /* > \verbatim */ | |||
| /* > VN2 is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The vector with the exact column norms. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] AUXV */ | |||
| /* > \verbatim */ | |||
| /* > AUXV is COMPLEX*16 array, dimension (NB) */ | |||
| /* > Auxiliary vector. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] F */ | |||
| /* > \verbatim */ | |||
| /* > F is COMPLEX*16 array, dimension (LDF,NB) */ | |||
| /* > Matrix F**H = L * Y**H * A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDF */ | |||
| /* > \verbatim */ | |||
| /* > LDF is INTEGER */ | |||
| /* > The leading dimension of the array F. LDF >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain */ | |||
| /* > X. Sun, Computer Science Dept., Duke University, USA */ | |||
| /* > \n */ | |||
| /* > Partial column norm updating strategy modified on April 2011 */ | |||
| /* > Z. Drmac and Z. Bujanovic, Dept. of Mathematics, */ | |||
| /* > University of Zagreb, Croatia. */ | |||
| /* > \par References: */ | |||
| /* ================ */ | |||
| /* > */ | |||
| /* > LAPACK Working Note 176 */ | |||
| /* > \htmlonly */ | |||
| /* > <a href="http://www.netlib.org/lapack/lawnspdf/lawn176.pdf">[PDF]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaqps_(integer *m, integer *n, integer *offset, integer | |||
| *nb, integer *kb, doublecomplex *a, integer *lda, integer *jpvt, | |||
| doublecomplex *tau, doublereal *vn1, doublereal *vn2, doublecomplex * | |||
| auxv, doublecomplex *f, integer *ldf) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, f_dim1, f_offset, i__1, i__2, i__3; | |||
| doublereal d__1, d__2; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| doublereal temp, temp2; | |||
| integer j, k; | |||
| doublereal tol3z; | |||
| integer itemp; | |||
| extern /* Subroutine */ int zgemm_(char *, char *, integer *, integer *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, doublecomplex *, | |||
| integer *), zgemv_(char *, integer *, integer *, | |||
| doublecomplex *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *), | |||
| zswap_(integer *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *); | |||
| extern doublereal dznrm2_(integer *, doublecomplex *, integer *), dlamch_( | |||
| char *); | |||
| integer rk; | |||
| extern integer idamax_(integer *, doublereal *, integer *); | |||
| integer lsticc; | |||
| extern /* Subroutine */ int zlarfg_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *); | |||
| integer lastrk; | |||
| doublecomplex akk; | |||
| integer pvt; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --jpvt; | |||
| --tau; | |||
| --vn1; | |||
| --vn2; | |||
| --auxv; | |||
| f_dim1 = *ldf; | |||
| f_offset = 1 + f_dim1 * 1; | |||
| f -= f_offset; | |||
| /* Function Body */ | |||
| /* Computing MIN */ | |||
| i__1 = *m, i__2 = *n + *offset; | |||
| lastrk = f2cmin(i__1,i__2); | |||
| lsticc = 0; | |||
| k = 0; | |||
| tol3z = sqrt(dlamch_("Epsilon")); | |||
| /* Beginning of while loop. */ | |||
| L10: | |||
| if (k < *nb && lsticc == 0) { | |||
| ++k; | |||
| rk = *offset + k; | |||
| /* Determine ith pivot column and swap if necessary */ | |||
| i__1 = *n - k + 1; | |||
| pvt = k - 1 + idamax_(&i__1, &vn1[k], &c__1); | |||
| if (pvt != k) { | |||
| zswap_(m, &a[pvt * a_dim1 + 1], &c__1, &a[k * a_dim1 + 1], &c__1); | |||
| i__1 = k - 1; | |||
| zswap_(&i__1, &f[pvt + f_dim1], ldf, &f[k + f_dim1], ldf); | |||
| itemp = jpvt[pvt]; | |||
| jpvt[pvt] = jpvt[k]; | |||
| jpvt[k] = itemp; | |||
| vn1[pvt] = vn1[k]; | |||
| vn2[pvt] = vn2[k]; | |||
| } | |||
| /* Apply previous Householder reflectors to column K: */ | |||
| /* A(RK:M,K) := A(RK:M,K) - A(RK:M,1:K-1)*F(K,1:K-1)**H. */ | |||
| if (k > 1) { | |||
| i__1 = k - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = k + j * f_dim1; | |||
| d_cnjg(&z__1, &f[k + j * f_dim1]); | |||
| f[i__2].r = z__1.r, f[i__2].i = z__1.i; | |||
| /* L20: */ | |||
| } | |||
| i__1 = *m - rk + 1; | |||
| i__2 = k - 1; | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zgemv_("No transpose", &i__1, &i__2, &z__1, &a[rk + a_dim1], lda, | |||
| &f[k + f_dim1], ldf, &c_b2, &a[rk + k * a_dim1], &c__1); | |||
| i__1 = k - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = k + j * f_dim1; | |||
| d_cnjg(&z__1, &f[k + j * f_dim1]); | |||
| f[i__2].r = z__1.r, f[i__2].i = z__1.i; | |||
| /* L30: */ | |||
| } | |||
| } | |||
| /* Generate elementary reflector H(k). */ | |||
| if (rk < *m) { | |||
| i__1 = *m - rk + 1; | |||
| zlarfg_(&i__1, &a[rk + k * a_dim1], &a[rk + 1 + k * a_dim1], & | |||
| c__1, &tau[k]); | |||
| } else { | |||
| zlarfg_(&c__1, &a[rk + k * a_dim1], &a[rk + k * a_dim1], &c__1, & | |||
| tau[k]); | |||
| } | |||
| i__1 = rk + k * a_dim1; | |||
| akk.r = a[i__1].r, akk.i = a[i__1].i; | |||
| i__1 = rk + k * a_dim1; | |||
| a[i__1].r = 1., a[i__1].i = 0.; | |||
| /* Compute Kth column of F: */ | |||
| /* Compute F(K+1:N,K) := tau(K)*A(RK:M,K+1:N)**H*A(RK:M,K). */ | |||
| if (k < *n) { | |||
| i__1 = *m - rk + 1; | |||
| i__2 = *n - k; | |||
| zgemv_("Conjugate transpose", &i__1, &i__2, &tau[k], &a[rk + (k + | |||
| 1) * a_dim1], lda, &a[rk + k * a_dim1], &c__1, &c_b1, &f[ | |||
| k + 1 + k * f_dim1], &c__1); | |||
| } | |||
| /* Padding F(1:K,K) with zeros. */ | |||
| i__1 = k; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = j + k * f_dim1; | |||
| f[i__2].r = 0., f[i__2].i = 0.; | |||
| /* L40: */ | |||
| } | |||
| /* Incremental updating of F: */ | |||
| /* F(1:N,K) := F(1:N,K) - tau(K)*F(1:N,1:K-1)*A(RK:M,1:K-1)**H */ | |||
| /* *A(RK:M,K). */ | |||
| if (k > 1) { | |||
| i__1 = *m - rk + 1; | |||
| i__2 = k - 1; | |||
| i__3 = k; | |||
| z__1.r = -tau[i__3].r, z__1.i = -tau[i__3].i; | |||
| zgemv_("Conjugate transpose", &i__1, &i__2, &z__1, &a[rk + a_dim1] | |||
| , lda, &a[rk + k * a_dim1], &c__1, &c_b1, &auxv[1], &c__1); | |||
| i__1 = k - 1; | |||
| zgemv_("No transpose", n, &i__1, &c_b2, &f[f_dim1 + 1], ldf, & | |||
| auxv[1], &c__1, &c_b2, &f[k * f_dim1 + 1], &c__1); | |||
| } | |||
| /* Update the current row of A: */ | |||
| /* A(RK,K+1:N) := A(RK,K+1:N) - A(RK,1:K)*F(K+1:N,1:K)**H. */ | |||
| if (k < *n) { | |||
| i__1 = *n - k; | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zgemm_("No transpose", "Conjugate transpose", &c__1, &i__1, &k, & | |||
| z__1, &a[rk + a_dim1], lda, &f[k + 1 + f_dim1], ldf, & | |||
| c_b2, &a[rk + (k + 1) * a_dim1], lda); | |||
| } | |||
| /* Update partial column norms. */ | |||
| if (rk < lastrk) { | |||
| i__1 = *n; | |||
| for (j = k + 1; j <= i__1; ++j) { | |||
| if (vn1[j] != 0.) { | |||
| /* NOTE: The following 4 lines follow from the analysis in */ | |||
| /* Lapack Working Note 176. */ | |||
| temp = z_abs(&a[rk + j * a_dim1]) / vn1[j]; | |||
| /* Computing MAX */ | |||
| d__1 = 0., d__2 = (temp + 1.) * (1. - temp); | |||
| temp = f2cmax(d__1,d__2); | |||
| /* Computing 2nd power */ | |||
| d__1 = vn1[j] / vn2[j]; | |||
| temp2 = temp * (d__1 * d__1); | |||
| if (temp2 <= tol3z) { | |||
| vn2[j] = (doublereal) lsticc; | |||
| lsticc = j; | |||
| } else { | |||
| vn1[j] *= sqrt(temp); | |||
| } | |||
| } | |||
| /* L50: */ | |||
| } | |||
| } | |||
| i__1 = rk + k * a_dim1; | |||
| a[i__1].r = akk.r, a[i__1].i = akk.i; | |||
| /* End of while loop. */ | |||
| goto L10; | |||
| } | |||
| *kb = k; | |||
| rk = *offset + *kb; | |||
| /* Apply the block reflector to the rest of the matrix: */ | |||
| /* A(OFFSET+KB+1:M,KB+1:N) := A(OFFSET+KB+1:M,KB+1:N) - */ | |||
| /* A(OFFSET+KB+1:M,1:KB)*F(KB+1:N,1:KB)**H. */ | |||
| /* Computing MIN */ | |||
| i__1 = *n, i__2 = *m - *offset; | |||
| if (*kb < f2cmin(i__1,i__2)) { | |||
| i__1 = *m - rk; | |||
| i__2 = *n - *kb; | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zgemm_("No transpose", "Conjugate transpose", &i__1, &i__2, kb, &z__1, | |||
| &a[rk + 1 + a_dim1], lda, &f[*kb + 1 + f_dim1], ldf, &c_b2, & | |||
| a[rk + 1 + (*kb + 1) * a_dim1], lda); | |||
| } | |||
| /* Recomputation of difficult columns. */ | |||
| L60: | |||
| if (lsticc > 0) { | |||
| itemp = i_dnnt(&vn2[lsticc]); | |||
| i__1 = *m - rk; | |||
| vn1[lsticc] = dznrm2_(&i__1, &a[rk + 1 + lsticc * a_dim1], &c__1); | |||
| /* NOTE: The computation of VN1( LSTICC ) relies on the fact that */ | |||
| /* SNRM2 does not fail on vectors with norm below the value of */ | |||
| /* SQRT(DLAMCH('S')) */ | |||
| vn2[lsticc] = vn1[lsticc]; | |||
| lsticc = itemp; | |||
| goto L60; | |||
| } | |||
| return 0; | |||
| /* End of ZLAQPS */ | |||
| } /* zlaqps_ */ | |||
| @@ -0,0 +1,635 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAQR1 sets a scalar multiple of the first column of the product of 2-by-2 or 3-by-3 matrix H a | |||
| nd specified shifts. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAQR1 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqr1. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqr1. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqr1. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAQR1( N, H, LDH, S1, S2, V ) */ | |||
| /* COMPLEX*16 S1, S2 */ | |||
| /* INTEGER LDH, N */ | |||
| /* COMPLEX*16 H( LDH, * ), V( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > Given a 2-by-2 or 3-by-3 matrix H, ZLAQR1 sets v to a */ | |||
| /* > scalar multiple of the first column of the product */ | |||
| /* > */ | |||
| /* > (*) K = (H - s1*I)*(H - s2*I) */ | |||
| /* > */ | |||
| /* > scaling to avoid overflows and most underflows. */ | |||
| /* > */ | |||
| /* > This is useful for starting double implicit shift bulges */ | |||
| /* > in the QR algorithm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > Order of the matrix H. N must be either 2 or 3. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] H */ | |||
| /* > \verbatim */ | |||
| /* > H is COMPLEX*16 array, dimension (LDH,N) */ | |||
| /* > The 2-by-2 or 3-by-3 matrix H in (*). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDH */ | |||
| /* > \verbatim */ | |||
| /* > LDH is INTEGER */ | |||
| /* > The leading dimension of H as declared in */ | |||
| /* > the calling procedure. LDH >= N */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] S1 */ | |||
| /* > \verbatim */ | |||
| /* > S1 is COMPLEX*16 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] S2 */ | |||
| /* > \verbatim */ | |||
| /* > S2 is COMPLEX*16 */ | |||
| /* > */ | |||
| /* > S1 and S2 are the shifts defining K in (*) above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX*16 array, dimension (N) */ | |||
| /* > A scalar multiple of the first column of the */ | |||
| /* > matrix K in (*). */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2017 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > Karen Braman and Ralph Byers, Department of Mathematics, */ | |||
| /* > University of Kansas, USA */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaqr1_(integer *n, doublecomplex *h__, integer *ldh, | |||
| doublecomplex *s1, doublecomplex *s2, doublecomplex *v) | |||
| { | |||
| /* System generated locals */ | |||
| integer h_dim1, h_offset, i__1, i__2, i__3, i__4; | |||
| doublereal d__1, d__2, d__3, d__4, d__5, d__6; | |||
| doublecomplex z__1, z__2, z__3, z__4, z__5, z__6, z__7, z__8; | |||
| /* Local variables */ | |||
| doublereal s; | |||
| doublecomplex h21s, h31s; | |||
| /* -- LAPACK auxiliary routine (version 3.7.1) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2017 */ | |||
| /* ================================================================ */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| h_dim1 = *ldh; | |||
| h_offset = 1 + h_dim1 * 1; | |||
| h__ -= h_offset; | |||
| --v; | |||
| /* Function Body */ | |||
| if (*n != 2 && *n != 3) { | |||
| return 0; | |||
| } | |||
| if (*n == 2) { | |||
| i__1 = h_dim1 + 1; | |||
| z__2.r = h__[i__1].r - s2->r, z__2.i = h__[i__1].i - s2->i; | |||
| z__1.r = z__2.r, z__1.i = z__2.i; | |||
| i__2 = h_dim1 + 2; | |||
| s = (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1), abs(d__2)) + ( | |||
| (d__3 = h__[i__2].r, abs(d__3)) + (d__4 = d_imag(&h__[h_dim1 | |||
| + 2]), abs(d__4))); | |||
| if (s == 0.) { | |||
| v[1].r = 0., v[1].i = 0.; | |||
| v[2].r = 0., v[2].i = 0.; | |||
| } else { | |||
| i__1 = h_dim1 + 2; | |||
| z__1.r = h__[i__1].r / s, z__1.i = h__[i__1].i / s; | |||
| h21s.r = z__1.r, h21s.i = z__1.i; | |||
| i__1 = (h_dim1 << 1) + 1; | |||
| z__2.r = h21s.r * h__[i__1].r - h21s.i * h__[i__1].i, z__2.i = | |||
| h21s.r * h__[i__1].i + h21s.i * h__[i__1].r; | |||
| i__2 = h_dim1 + 1; | |||
| z__4.r = h__[i__2].r - s1->r, z__4.i = h__[i__2].i - s1->i; | |||
| i__3 = h_dim1 + 1; | |||
| z__6.r = h__[i__3].r - s2->r, z__6.i = h__[i__3].i - s2->i; | |||
| z__5.r = z__6.r / s, z__5.i = z__6.i / s; | |||
| z__3.r = z__4.r * z__5.r - z__4.i * z__5.i, z__3.i = z__4.r * | |||
| z__5.i + z__4.i * z__5.r; | |||
| z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; | |||
| v[1].r = z__1.r, v[1].i = z__1.i; | |||
| i__1 = h_dim1 + 1; | |||
| i__2 = (h_dim1 << 1) + 2; | |||
| z__4.r = h__[i__1].r + h__[i__2].r, z__4.i = h__[i__1].i + h__[ | |||
| i__2].i; | |||
| z__3.r = z__4.r - s1->r, z__3.i = z__4.i - s1->i; | |||
| z__2.r = z__3.r - s2->r, z__2.i = z__3.i - s2->i; | |||
| z__1.r = h21s.r * z__2.r - h21s.i * z__2.i, z__1.i = h21s.r * | |||
| z__2.i + h21s.i * z__2.r; | |||
| v[2].r = z__1.r, v[2].i = z__1.i; | |||
| } | |||
| } else { | |||
| i__1 = h_dim1 + 1; | |||
| z__2.r = h__[i__1].r - s2->r, z__2.i = h__[i__1].i - s2->i; | |||
| z__1.r = z__2.r, z__1.i = z__2.i; | |||
| i__2 = h_dim1 + 2; | |||
| i__3 = h_dim1 + 3; | |||
| s = (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1), abs(d__2)) + ( | |||
| (d__3 = h__[i__2].r, abs(d__3)) + (d__4 = d_imag(&h__[h_dim1 | |||
| + 2]), abs(d__4))) + ((d__5 = h__[i__3].r, abs(d__5)) + (d__6 | |||
| = d_imag(&h__[h_dim1 + 3]), abs(d__6))); | |||
| if (s == 0.) { | |||
| v[1].r = 0., v[1].i = 0.; | |||
| v[2].r = 0., v[2].i = 0.; | |||
| v[3].r = 0., v[3].i = 0.; | |||
| } else { | |||
| i__1 = h_dim1 + 2; | |||
| z__1.r = h__[i__1].r / s, z__1.i = h__[i__1].i / s; | |||
| h21s.r = z__1.r, h21s.i = z__1.i; | |||
| i__1 = h_dim1 + 3; | |||
| z__1.r = h__[i__1].r / s, z__1.i = h__[i__1].i / s; | |||
| h31s.r = z__1.r, h31s.i = z__1.i; | |||
| i__1 = h_dim1 + 1; | |||
| z__4.r = h__[i__1].r - s1->r, z__4.i = h__[i__1].i - s1->i; | |||
| i__2 = h_dim1 + 1; | |||
| z__6.r = h__[i__2].r - s2->r, z__6.i = h__[i__2].i - s2->i; | |||
| z__5.r = z__6.r / s, z__5.i = z__6.i / s; | |||
| z__3.r = z__4.r * z__5.r - z__4.i * z__5.i, z__3.i = z__4.r * | |||
| z__5.i + z__4.i * z__5.r; | |||
| i__3 = (h_dim1 << 1) + 1; | |||
| z__7.r = h__[i__3].r * h21s.r - h__[i__3].i * h21s.i, z__7.i = | |||
| h__[i__3].r * h21s.i + h__[i__3].i * h21s.r; | |||
| z__2.r = z__3.r + z__7.r, z__2.i = z__3.i + z__7.i; | |||
| i__4 = h_dim1 * 3 + 1; | |||
| z__8.r = h__[i__4].r * h31s.r - h__[i__4].i * h31s.i, z__8.i = | |||
| h__[i__4].r * h31s.i + h__[i__4].i * h31s.r; | |||
| z__1.r = z__2.r + z__8.r, z__1.i = z__2.i + z__8.i; | |||
| v[1].r = z__1.r, v[1].i = z__1.i; | |||
| i__1 = h_dim1 + 1; | |||
| i__2 = (h_dim1 << 1) + 2; | |||
| z__5.r = h__[i__1].r + h__[i__2].r, z__5.i = h__[i__1].i + h__[ | |||
| i__2].i; | |||
| z__4.r = z__5.r - s1->r, z__4.i = z__5.i - s1->i; | |||
| z__3.r = z__4.r - s2->r, z__3.i = z__4.i - s2->i; | |||
| z__2.r = h21s.r * z__3.r - h21s.i * z__3.i, z__2.i = h21s.r * | |||
| z__3.i + h21s.i * z__3.r; | |||
| i__3 = h_dim1 * 3 + 2; | |||
| z__6.r = h__[i__3].r * h31s.r - h__[i__3].i * h31s.i, z__6.i = | |||
| h__[i__3].r * h31s.i + h__[i__3].i * h31s.r; | |||
| z__1.r = z__2.r + z__6.r, z__1.i = z__2.i + z__6.i; | |||
| v[2].r = z__1.r, v[2].i = z__1.i; | |||
| i__1 = h_dim1 + 1; | |||
| i__2 = h_dim1 * 3 + 3; | |||
| z__5.r = h__[i__1].r + h__[i__2].r, z__5.i = h__[i__1].i + h__[ | |||
| i__2].i; | |||
| z__4.r = z__5.r - s1->r, z__4.i = z__5.i - s1->i; | |||
| z__3.r = z__4.r - s2->r, z__3.i = z__4.i - s2->i; | |||
| z__2.r = h31s.r * z__3.r - h31s.i * z__3.i, z__2.i = h31s.r * | |||
| z__3.i + h31s.i * z__3.r; | |||
| i__3 = (h_dim1 << 1) + 3; | |||
| z__6.r = h21s.r * h__[i__3].r - h21s.i * h__[i__3].i, z__6.i = | |||
| h21s.r * h__[i__3].i + h21s.i * h__[i__3].r; | |||
| z__1.r = z__2.r + z__6.r, z__1.i = z__2.i + z__6.i; | |||
| v[3].r = z__1.r, v[3].i = z__1.i; | |||
| } | |||
| } | |||
| return 0; | |||
| } /* zlaqr1_ */ | |||
| @@ -0,0 +1,632 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAQSB scales a symmetric/Hermitian band matrix, using scaling factors computed by spbequ. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAQSB + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqsb. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqsb. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqsb. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAQSB( UPLO, N, KD, AB, LDAB, S, SCOND, AMAX, EQUED ) */ | |||
| /* CHARACTER EQUED, UPLO */ | |||
| /* INTEGER KD, LDAB, N */ | |||
| /* DOUBLE PRECISION AMAX, SCOND */ | |||
| /* DOUBLE PRECISION S( * ) */ | |||
| /* COMPLEX*16 AB( LDAB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAQSB equilibrates a symmetric band matrix A using the scaling */ | |||
| /* > factors in the vector S. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the upper or lower triangular part of the */ | |||
| /* > symmetric matrix A is stored. */ | |||
| /* > = 'U': Upper triangular */ | |||
| /* > = 'L': Lower triangular */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KD */ | |||
| /* > \verbatim */ | |||
| /* > KD is INTEGER */ | |||
| /* > The number of super-diagonals of the matrix A if UPLO = 'U', */ | |||
| /* > or the number of sub-diagonals if UPLO = 'L'. KD >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX*16 array, dimension (LDAB,N) */ | |||
| /* > On entry, the upper or lower triangle of the symmetric band */ | |||
| /* > matrix A, stored in the first KD+1 rows of the array. The */ | |||
| /* > j-th column of A is stored in the j-th column of the array AB */ | |||
| /* > as follows: */ | |||
| /* > if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for f2cmax(1,j-kd)<=i<=j; */ | |||
| /* > if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=f2cmin(n,j+kd). */ | |||
| /* > */ | |||
| /* > On exit, if INFO = 0, the triangular factor U or L from the */ | |||
| /* > Cholesky factorization A = U**H *U or A = L*L**H of the band */ | |||
| /* > matrix A, in the same storage format as A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= KD+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] S */ | |||
| /* > \verbatim */ | |||
| /* > S is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SCOND */ | |||
| /* > \verbatim */ | |||
| /* > SCOND is DOUBLE PRECISION */ | |||
| /* > Ratio of the smallest S(i) to the largest S(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is DOUBLE PRECISION */ | |||
| /* > Absolute value of largest matrix entry. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] EQUED */ | |||
| /* > \verbatim */ | |||
| /* > EQUED is CHARACTER*1 */ | |||
| /* > Specifies whether or not equilibration was done. */ | |||
| /* > = 'N': No equilibration. */ | |||
| /* > = 'Y': Equilibration was done, i.e., A has been replaced by */ | |||
| /* > diag(S) * A * diag(S). */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > THRESH is a threshold value used to decide if scaling should be done */ | |||
| /* > based on the ratio of the scaling factors. If SCOND < THRESH, */ | |||
| /* > scaling is done. */ | |||
| /* > */ | |||
| /* > LARGE and SMALL are threshold values used to decide if scaling should */ | |||
| /* > be done based on the absolute size of the largest matrix element. */ | |||
| /* > If AMAX > LARGE or AMAX < SMALL, scaling is done. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaqsb_(char *uplo, integer *n, integer *kd, | |||
| doublecomplex *ab, integer *ldab, doublereal *s, doublereal *scond, | |||
| doublereal *amax, char *equed) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4; | |||
| doublereal d__1; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| doublereal large; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal small, cj; | |||
| extern doublereal dlamch_(char *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --s; | |||
| /* Function Body */ | |||
| if (*n <= 0) { | |||
| *(unsigned char *)equed = 'N'; | |||
| return 0; | |||
| } | |||
| /* Initialize LARGE and SMALL. */ | |||
| small = dlamch_("Safe minimum") / dlamch_("Precision"); | |||
| large = 1. / small; | |||
| if (*scond >= .1 && *amax >= small && *amax <= large) { | |||
| /* No equilibration */ | |||
| *(unsigned char *)equed = 'N'; | |||
| } else { | |||
| /* Replace A by diag(S) * A * diag(S). */ | |||
| if (lsame_(uplo, "U")) { | |||
| /* Upper triangle of A is stored in band format. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = s[j]; | |||
| /* Computing MAX */ | |||
| i__2 = 1, i__3 = j - *kd; | |||
| i__4 = j; | |||
| for (i__ = f2cmax(i__2,i__3); i__ <= i__4; ++i__) { | |||
| i__2 = *kd + 1 + i__ - j + j * ab_dim1; | |||
| d__1 = cj * s[i__]; | |||
| i__3 = *kd + 1 + i__ - j + j * ab_dim1; | |||
| z__1.r = d__1 * ab[i__3].r, z__1.i = d__1 * ab[i__3].i; | |||
| ab[i__2].r = z__1.r, ab[i__2].i = z__1.i; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| /* Lower triangle of A is stored. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = s[j]; | |||
| /* Computing MIN */ | |||
| i__2 = *n, i__3 = j + *kd; | |||
| i__4 = f2cmin(i__2,i__3); | |||
| for (i__ = j; i__ <= i__4; ++i__) { | |||
| i__2 = i__ + 1 - j + j * ab_dim1; | |||
| d__1 = cj * s[i__]; | |||
| i__3 = i__ + 1 - j + j * ab_dim1; | |||
| z__1.r = d__1 * ab[i__3].r, z__1.i = d__1 * ab[i__3].i; | |||
| ab[i__2].r = z__1.r, ab[i__2].i = z__1.i; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| *(unsigned char *)equed = 'Y'; | |||
| } | |||
| return 0; | |||
| /* End of ZLAQSB */ | |||
| } /* zlaqsb_ */ | |||
| @@ -0,0 +1,617 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAQSP scales a symmetric/Hermitian matrix in packed storage, using scaling factors computed by | |||
| sppequ. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAQSP + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqsp. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqsp. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqsp. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAQSP( UPLO, N, AP, S, SCOND, AMAX, EQUED ) */ | |||
| /* CHARACTER EQUED, UPLO */ | |||
| /* INTEGER N */ | |||
| /* DOUBLE PRECISION AMAX, SCOND */ | |||
| /* DOUBLE PRECISION S( * ) */ | |||
| /* COMPLEX*16 AP( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAQSP equilibrates a symmetric matrix A using the scaling factors */ | |||
| /* > in the vector S. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the upper or lower triangular part of the */ | |||
| /* > symmetric matrix A is stored. */ | |||
| /* > = 'U': Upper triangular */ | |||
| /* > = 'L': Lower triangular */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] AP */ | |||
| /* > \verbatim */ | |||
| /* > AP is COMPLEX*16 array, dimension (N*(N+1)/2) */ | |||
| /* > On entry, the upper or lower triangle of the symmetric matrix */ | |||
| /* > A, packed columnwise in a linear array. The j-th column of A */ | |||
| /* > is stored in the array AP as follows: */ | |||
| /* > if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ | |||
| /* > if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ | |||
| /* > */ | |||
| /* > On exit, the equilibrated matrix: diag(S) * A * diag(S), in */ | |||
| /* > the same storage format as A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] S */ | |||
| /* > \verbatim */ | |||
| /* > S is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SCOND */ | |||
| /* > \verbatim */ | |||
| /* > SCOND is DOUBLE PRECISION */ | |||
| /* > Ratio of the smallest S(i) to the largest S(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is DOUBLE PRECISION */ | |||
| /* > Absolute value of largest matrix entry. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] EQUED */ | |||
| /* > \verbatim */ | |||
| /* > EQUED is CHARACTER*1 */ | |||
| /* > Specifies whether or not equilibration was done. */ | |||
| /* > = 'N': No equilibration. */ | |||
| /* > = 'Y': Equilibration was done, i.e., A has been replaced by */ | |||
| /* > diag(S) * A * diag(S). */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > THRESH is a threshold value used to decide if scaling should be done */ | |||
| /* > based on the ratio of the scaling factors. If SCOND < THRESH, */ | |||
| /* > scaling is done. */ | |||
| /* > */ | |||
| /* > LARGE and SMALL are threshold values used to decide if scaling should */ | |||
| /* > be done based on the absolute size of the largest matrix element. */ | |||
| /* > If AMAX > LARGE or AMAX < SMALL, scaling is done. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaqsp_(char *uplo, integer *n, doublecomplex *ap, | |||
| doublereal *s, doublereal *scond, doublereal *amax, char *equed) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2, i__3, i__4; | |||
| doublereal d__1; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| doublereal large; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal small; | |||
| integer jc; | |||
| doublereal cj; | |||
| extern doublereal dlamch_(char *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| --s; | |||
| --ap; | |||
| /* Function Body */ | |||
| if (*n <= 0) { | |||
| *(unsigned char *)equed = 'N'; | |||
| return 0; | |||
| } | |||
| /* Initialize LARGE and SMALL. */ | |||
| small = dlamch_("Safe minimum") / dlamch_("Precision"); | |||
| large = 1. / small; | |||
| if (*scond >= .1 && *amax >= small && *amax <= large) { | |||
| /* No equilibration */ | |||
| *(unsigned char *)equed = 'N'; | |||
| } else { | |||
| /* Replace A by diag(S) * A * diag(S). */ | |||
| if (lsame_(uplo, "U")) { | |||
| /* Upper triangle of A is stored. */ | |||
| jc = 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = s[j]; | |||
| i__2 = j; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = jc + i__ - 1; | |||
| d__1 = cj * s[i__]; | |||
| i__4 = jc + i__ - 1; | |||
| z__1.r = d__1 * ap[i__4].r, z__1.i = d__1 * ap[i__4].i; | |||
| ap[i__3].r = z__1.r, ap[i__3].i = z__1.i; | |||
| /* L10: */ | |||
| } | |||
| jc += j; | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| /* Lower triangle of A is stored. */ | |||
| jc = 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = s[j]; | |||
| i__2 = *n; | |||
| for (i__ = j; i__ <= i__2; ++i__) { | |||
| i__3 = jc + i__ - j; | |||
| d__1 = cj * s[i__]; | |||
| i__4 = jc + i__ - j; | |||
| z__1.r = d__1 * ap[i__4].r, z__1.i = d__1 * ap[i__4].i; | |||
| ap[i__3].r = z__1.r, ap[i__3].i = z__1.i; | |||
| /* L30: */ | |||
| } | |||
| jc = jc + *n - j + 1; | |||
| /* L40: */ | |||
| } | |||
| } | |||
| *(unsigned char *)equed = 'Y'; | |||
| } | |||
| return 0; | |||
| /* End of ZLAQSP */ | |||
| } /* zlaqsp_ */ | |||
| @@ -0,0 +1,621 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAQSY scales a symmetric/Hermitian matrix, using scaling factors computed by spoequ. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAQSY + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqsy. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqsy. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqsy. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAQSY( UPLO, N, A, LDA, S, SCOND, AMAX, EQUED ) */ | |||
| /* CHARACTER EQUED, UPLO */ | |||
| /* INTEGER LDA, N */ | |||
| /* DOUBLE PRECISION AMAX, SCOND */ | |||
| /* DOUBLE PRECISION S( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAQSY equilibrates a symmetric matrix A using the scaling factors */ | |||
| /* > in the vector S. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the upper or lower triangular part of the */ | |||
| /* > symmetric matrix A is stored. */ | |||
| /* > = 'U': Upper triangular */ | |||
| /* > = 'L': Lower triangular */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the symmetric matrix A. If UPLO = 'U', the leading */ | |||
| /* > n by n upper triangular part of A contains the upper */ | |||
| /* > triangular part of the matrix A, and the strictly lower */ | |||
| /* > triangular part of A is not referenced. If UPLO = 'L', the */ | |||
| /* > leading n by n lower triangular part of A contains the lower */ | |||
| /* > triangular part of the matrix A, and the strictly upper */ | |||
| /* > triangular part of A is not referenced. */ | |||
| /* > */ | |||
| /* > On exit, if EQUED = 'Y', the equilibrated matrix: */ | |||
| /* > diag(S) * A * diag(S). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(N,1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] S */ | |||
| /* > \verbatim */ | |||
| /* > S is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SCOND */ | |||
| /* > \verbatim */ | |||
| /* > SCOND is DOUBLE PRECISION */ | |||
| /* > Ratio of the smallest S(i) to the largest S(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is DOUBLE PRECISION */ | |||
| /* > Absolute value of largest matrix entry. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] EQUED */ | |||
| /* > \verbatim */ | |||
| /* > EQUED is CHARACTER*1 */ | |||
| /* > Specifies whether or not equilibration was done. */ | |||
| /* > = 'N': No equilibration. */ | |||
| /* > = 'Y': Equilibration was done, i.e., A has been replaced by */ | |||
| /* > diag(S) * A * diag(S). */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > THRESH is a threshold value used to decide if scaling should be done */ | |||
| /* > based on the ratio of the scaling factors. If SCOND < THRESH, */ | |||
| /* > scaling is done. */ | |||
| /* > */ | |||
| /* > LARGE and SMALL are threshold values used to decide if scaling should */ | |||
| /* > be done based on the absolute size of the largest matrix element. */ | |||
| /* > If AMAX > LARGE or AMAX < SMALL, scaling is done. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16SYauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaqsy_(char *uplo, integer *n, doublecomplex *a, | |||
| integer *lda, doublereal *s, doublereal *scond, doublereal *amax, | |||
| char *equed) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| doublereal d__1; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| doublereal large; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal small, cj; | |||
| extern doublereal dlamch_(char *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --s; | |||
| /* Function Body */ | |||
| if (*n <= 0) { | |||
| *(unsigned char *)equed = 'N'; | |||
| return 0; | |||
| } | |||
| /* Initialize LARGE and SMALL. */ | |||
| small = dlamch_("Safe minimum") / dlamch_("Precision"); | |||
| large = 1. / small; | |||
| if (*scond >= .1 && *amax >= small && *amax <= large) { | |||
| /* No equilibration */ | |||
| *(unsigned char *)equed = 'N'; | |||
| } else { | |||
| /* Replace A by diag(S) * A * diag(S). */ | |||
| if (lsame_(uplo, "U")) { | |||
| /* Upper triangle of A is stored. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = s[j]; | |||
| i__2 = j; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| d__1 = cj * s[i__]; | |||
| i__4 = i__ + j * a_dim1; | |||
| z__1.r = d__1 * a[i__4].r, z__1.i = d__1 * a[i__4].i; | |||
| a[i__3].r = z__1.r, a[i__3].i = z__1.i; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| /* Lower triangle of A is stored. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| cj = s[j]; | |||
| i__2 = *n; | |||
| for (i__ = j; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| d__1 = cj * s[i__]; | |||
| i__4 = i__ + j * a_dim1; | |||
| z__1.r = d__1 * a[i__4].r, z__1.i = d__1 * a[i__4].i; | |||
| a[i__3].r = z__1.r, a[i__3].i = z__1.i; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| *(unsigned char *)equed = 'Y'; | |||
| } | |||
| return 0; | |||
| /* End of ZLAQSY */ | |||
| } /* zlaqsy_ */ | |||
| @@ -0,0 +1,975 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAR1V computes the (scaled) r-th column of the inverse of the submatrix in rows b1 through bn | |||
| of the tridiagonal matrix LDLT - λI. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAR1V + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlar1v. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlar1v. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlar1v. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAR1V( N, B1, BN, LAMBDA, D, L, LD, LLD, */ | |||
| /* PIVMIN, GAPTOL, Z, WANTNC, NEGCNT, ZTZ, MINGMA, */ | |||
| /* R, ISUPPZ, NRMINV, RESID, RQCORR, WORK ) */ | |||
| /* LOGICAL WANTNC */ | |||
| /* INTEGER B1, BN, N, NEGCNT, R */ | |||
| /* DOUBLE PRECISION GAPTOL, LAMBDA, MINGMA, NRMINV, PIVMIN, RESID, */ | |||
| /* $ RQCORR, ZTZ */ | |||
| /* INTEGER ISUPPZ( * ) */ | |||
| /* DOUBLE PRECISION D( * ), L( * ), LD( * ), LLD( * ), */ | |||
| /* $ WORK( * ) */ | |||
| /* COMPLEX*16 Z( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAR1V computes the (scaled) r-th column of the inverse of */ | |||
| /* > the sumbmatrix in rows B1 through BN of the tridiagonal matrix */ | |||
| /* > L D L**T - sigma I. When sigma is close to an eigenvalue, the */ | |||
| /* > computed vector is an accurate eigenvector. Usually, r corresponds */ | |||
| /* > to the index where the eigenvector is largest in magnitude. */ | |||
| /* > The following steps accomplish this computation : */ | |||
| /* > (a) Stationary qd transform, L D L**T - sigma I = L(+) D(+) L(+)**T, */ | |||
| /* > (b) Progressive qd transform, L D L**T - sigma I = U(-) D(-) U(-)**T, */ | |||
| /* > (c) Computation of the diagonal elements of the inverse of */ | |||
| /* > L D L**T - sigma I by combining the above transforms, and choosing */ | |||
| /* > r as the index where the diagonal of the inverse is (one of the) */ | |||
| /* > largest in magnitude. */ | |||
| /* > (d) Computation of the (scaled) r-th column of the inverse using the */ | |||
| /* > twisted factorization obtained by combining the top part of the */ | |||
| /* > the stationary and the bottom part of the progressive transform. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix L D L**T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] B1 */ | |||
| /* > \verbatim */ | |||
| /* > B1 is INTEGER */ | |||
| /* > First index of the submatrix of L D L**T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] BN */ | |||
| /* > \verbatim */ | |||
| /* > BN is INTEGER */ | |||
| /* > Last index of the submatrix of L D L**T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LAMBDA */ | |||
| /* > \verbatim */ | |||
| /* > LAMBDA is DOUBLE PRECISION */ | |||
| /* > The shift. In order to compute an accurate eigenvector, */ | |||
| /* > LAMBDA should be a good approximation to an eigenvalue */ | |||
| /* > of L D L**T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] L */ | |||
| /* > \verbatim */ | |||
| /* > L is DOUBLE PRECISION array, dimension (N-1) */ | |||
| /* > The (n-1) subdiagonal elements of the unit bidiagonal matrix */ | |||
| /* > L, in elements 1 to N-1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] D */ | |||
| /* > \verbatim */ | |||
| /* > D is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > The n diagonal elements of the diagonal matrix D. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LD */ | |||
| /* > \verbatim */ | |||
| /* > LD is DOUBLE PRECISION array, dimension (N-1) */ | |||
| /* > The n-1 elements L(i)*D(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LLD */ | |||
| /* > \verbatim */ | |||
| /* > LLD is DOUBLE PRECISION array, dimension (N-1) */ | |||
| /* > The n-1 elements L(i)*L(i)*D(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] PIVMIN */ | |||
| /* > \verbatim */ | |||
| /* > PIVMIN is DOUBLE PRECISION */ | |||
| /* > The minimum pivot in the Sturm sequence. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] GAPTOL */ | |||
| /* > \verbatim */ | |||
| /* > GAPTOL is DOUBLE PRECISION */ | |||
| /* > Tolerance that indicates when eigenvector entries are negligible */ | |||
| /* > w.r.t. their contribution to the residual. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] Z */ | |||
| /* > \verbatim */ | |||
| /* > Z is COMPLEX*16 array, dimension (N) */ | |||
| /* > On input, all entries of Z must be set to 0. */ | |||
| /* > On output, Z contains the (scaled) r-th column of the */ | |||
| /* > inverse. The scaling is such that Z(R) equals 1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] WANTNC */ | |||
| /* > \verbatim */ | |||
| /* > WANTNC is LOGICAL */ | |||
| /* > Specifies whether NEGCNT has to be computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] NEGCNT */ | |||
| /* > \verbatim */ | |||
| /* > NEGCNT is INTEGER */ | |||
| /* > If WANTNC is .TRUE. then NEGCNT = the number of pivots < pivmin */ | |||
| /* > in the matrix factorization L D L**T, and NEGCNT = -1 otherwise. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ZTZ */ | |||
| /* > \verbatim */ | |||
| /* > ZTZ is DOUBLE PRECISION */ | |||
| /* > The square of the 2-norm of Z. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] MINGMA */ | |||
| /* > \verbatim */ | |||
| /* > MINGMA is DOUBLE PRECISION */ | |||
| /* > The reciprocal of the largest (in magnitude) diagonal */ | |||
| /* > element of the inverse of L D L**T - sigma I. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] R */ | |||
| /* > \verbatim */ | |||
| /* > R is INTEGER */ | |||
| /* > The twist index for the twisted factorization used to */ | |||
| /* > compute Z. */ | |||
| /* > On input, 0 <= R <= N. If R is input as 0, R is set to */ | |||
| /* > the index where (L D L**T - sigma I)^{-1} is largest */ | |||
| /* > in magnitude. If 1 <= R <= N, R is unchanged. */ | |||
| /* > On output, R contains the twist index used to compute Z. */ | |||
| /* > Ideally, R designates the position of the maximum entry in the */ | |||
| /* > eigenvector. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ISUPPZ */ | |||
| /* > \verbatim */ | |||
| /* > ISUPPZ is INTEGER array, dimension (2) */ | |||
| /* > The support of the vector in Z, i.e., the vector Z is */ | |||
| /* > nonzero only in elements ISUPPZ(1) through ISUPPZ( 2 ). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] NRMINV */ | |||
| /* > \verbatim */ | |||
| /* > NRMINV is DOUBLE PRECISION */ | |||
| /* > NRMINV = 1/SQRT( ZTZ ) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RESID */ | |||
| /* > \verbatim */ | |||
| /* > RESID is DOUBLE PRECISION */ | |||
| /* > The residual of the FP vector. */ | |||
| /* > RESID = ABS( MINGMA )/SQRT( ZTZ ) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RQCORR */ | |||
| /* > \verbatim */ | |||
| /* > RQCORR is DOUBLE PRECISION */ | |||
| /* > The Rayleigh Quotient correction to LAMBDA. */ | |||
| /* > RQCORR = MINGMA*TMP */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (4*N) */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > Beresford Parlett, University of California, Berkeley, USA \n */ | |||
| /* > Jim Demmel, University of California, Berkeley, USA \n */ | |||
| /* > Inderjit Dhillon, University of Texas, Austin, USA \n */ | |||
| /* > Osni Marques, LBNL/NERSC, USA \n */ | |||
| /* > Christof Voemel, University of California, Berkeley, USA */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlar1v_(integer *n, integer *b1, integer *bn, doublereal | |||
| *lambda, doublereal *d__, doublereal *l, doublereal *ld, doublereal * | |||
| lld, doublereal *pivmin, doublereal *gaptol, doublecomplex *z__, | |||
| logical *wantnc, integer *negcnt, doublereal *ztz, doublereal *mingma, | |||
| integer *r__, integer *isuppz, doublereal *nrminv, doublereal *resid, | |||
| doublereal *rqcorr, doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2, i__3, i__4; | |||
| doublereal d__1; | |||
| doublecomplex z__1, z__2; | |||
| /* Local variables */ | |||
| integer indp, inds, i__; | |||
| doublereal s, dplus; | |||
| integer r1, r2; | |||
| extern doublereal dlamch_(char *); | |||
| extern logical disnan_(doublereal *); | |||
| integer indlpl, indumn; | |||
| doublereal dminus; | |||
| logical sawnan1, sawnan2; | |||
| doublereal eps, tmp; | |||
| integer neg1, neg2; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --work; | |||
| --isuppz; | |||
| --z__; | |||
| --lld; | |||
| --ld; | |||
| --l; | |||
| --d__; | |||
| /* Function Body */ | |||
| eps = dlamch_("Precision"); | |||
| if (*r__ == 0) { | |||
| r1 = *b1; | |||
| r2 = *bn; | |||
| } else { | |||
| r1 = *r__; | |||
| r2 = *r__; | |||
| } | |||
| /* Storage for LPLUS */ | |||
| indlpl = 0; | |||
| /* Storage for UMINUS */ | |||
| indumn = *n; | |||
| inds = (*n << 1) + 1; | |||
| indp = *n * 3 + 1; | |||
| if (*b1 == 1) { | |||
| work[inds] = 0.; | |||
| } else { | |||
| work[inds + *b1 - 1] = lld[*b1 - 1]; | |||
| } | |||
| /* Compute the stationary transform (using the differential form) */ | |||
| /* until the index R2. */ | |||
| sawnan1 = FALSE_; | |||
| neg1 = 0; | |||
| s = work[inds + *b1 - 1] - *lambda; | |||
| i__1 = r1 - 1; | |||
| for (i__ = *b1; i__ <= i__1; ++i__) { | |||
| dplus = d__[i__] + s; | |||
| work[indlpl + i__] = ld[i__] / dplus; | |||
| if (dplus < 0.) { | |||
| ++neg1; | |||
| } | |||
| work[inds + i__] = s * work[indlpl + i__] * l[i__]; | |||
| s = work[inds + i__] - *lambda; | |||
| /* L50: */ | |||
| } | |||
| sawnan1 = disnan_(&s); | |||
| if (sawnan1) { | |||
| goto L60; | |||
| } | |||
| i__1 = r2 - 1; | |||
| for (i__ = r1; i__ <= i__1; ++i__) { | |||
| dplus = d__[i__] + s; | |||
| work[indlpl + i__] = ld[i__] / dplus; | |||
| work[inds + i__] = s * work[indlpl + i__] * l[i__]; | |||
| s = work[inds + i__] - *lambda; | |||
| /* L51: */ | |||
| } | |||
| sawnan1 = disnan_(&s); | |||
| L60: | |||
| if (sawnan1) { | |||
| /* Runs a slower version of the above loop if a NaN is detected */ | |||
| neg1 = 0; | |||
| s = work[inds + *b1 - 1] - *lambda; | |||
| i__1 = r1 - 1; | |||
| for (i__ = *b1; i__ <= i__1; ++i__) { | |||
| dplus = d__[i__] + s; | |||
| if (abs(dplus) < *pivmin) { | |||
| dplus = -(*pivmin); | |||
| } | |||
| work[indlpl + i__] = ld[i__] / dplus; | |||
| if (dplus < 0.) { | |||
| ++neg1; | |||
| } | |||
| work[inds + i__] = s * work[indlpl + i__] * l[i__]; | |||
| if (work[indlpl + i__] == 0.) { | |||
| work[inds + i__] = lld[i__]; | |||
| } | |||
| s = work[inds + i__] - *lambda; | |||
| /* L70: */ | |||
| } | |||
| i__1 = r2 - 1; | |||
| for (i__ = r1; i__ <= i__1; ++i__) { | |||
| dplus = d__[i__] + s; | |||
| if (abs(dplus) < *pivmin) { | |||
| dplus = -(*pivmin); | |||
| } | |||
| work[indlpl + i__] = ld[i__] / dplus; | |||
| work[inds + i__] = s * work[indlpl + i__] * l[i__]; | |||
| if (work[indlpl + i__] == 0.) { | |||
| work[inds + i__] = lld[i__]; | |||
| } | |||
| s = work[inds + i__] - *lambda; | |||
| /* L71: */ | |||
| } | |||
| } | |||
| /* Compute the progressive transform (using the differential form) */ | |||
| /* until the index R1 */ | |||
| sawnan2 = FALSE_; | |||
| neg2 = 0; | |||
| work[indp + *bn - 1] = d__[*bn] - *lambda; | |||
| i__1 = r1; | |||
| for (i__ = *bn - 1; i__ >= i__1; --i__) { | |||
| dminus = lld[i__] + work[indp + i__]; | |||
| tmp = d__[i__] / dminus; | |||
| if (dminus < 0.) { | |||
| ++neg2; | |||
| } | |||
| work[indumn + i__] = l[i__] * tmp; | |||
| work[indp + i__ - 1] = work[indp + i__] * tmp - *lambda; | |||
| /* L80: */ | |||
| } | |||
| tmp = work[indp + r1 - 1]; | |||
| sawnan2 = disnan_(&tmp); | |||
| if (sawnan2) { | |||
| /* Runs a slower version of the above loop if a NaN is detected */ | |||
| neg2 = 0; | |||
| i__1 = r1; | |||
| for (i__ = *bn - 1; i__ >= i__1; --i__) { | |||
| dminus = lld[i__] + work[indp + i__]; | |||
| if (abs(dminus) < *pivmin) { | |||
| dminus = -(*pivmin); | |||
| } | |||
| tmp = d__[i__] / dminus; | |||
| if (dminus < 0.) { | |||
| ++neg2; | |||
| } | |||
| work[indumn + i__] = l[i__] * tmp; | |||
| work[indp + i__ - 1] = work[indp + i__] * tmp - *lambda; | |||
| if (tmp == 0.) { | |||
| work[indp + i__ - 1] = d__[i__] - *lambda; | |||
| } | |||
| /* L100: */ | |||
| } | |||
| } | |||
| /* Find the index (from R1 to R2) of the largest (in magnitude) */ | |||
| /* diagonal element of the inverse */ | |||
| *mingma = work[inds + r1 - 1] + work[indp + r1 - 1]; | |||
| if (*mingma < 0.) { | |||
| ++neg1; | |||
| } | |||
| if (*wantnc) { | |||
| *negcnt = neg1 + neg2; | |||
| } else { | |||
| *negcnt = -1; | |||
| } | |||
| if (abs(*mingma) == 0.) { | |||
| *mingma = eps * work[inds + r1 - 1]; | |||
| } | |||
| *r__ = r1; | |||
| i__1 = r2 - 1; | |||
| for (i__ = r1; i__ <= i__1; ++i__) { | |||
| tmp = work[inds + i__] + work[indp + i__]; | |||
| if (tmp == 0.) { | |||
| tmp = eps * work[inds + i__]; | |||
| } | |||
| if (abs(tmp) <= abs(*mingma)) { | |||
| *mingma = tmp; | |||
| *r__ = i__ + 1; | |||
| } | |||
| /* L110: */ | |||
| } | |||
| /* Compute the FP vector: solve N^T v = e_r */ | |||
| isuppz[1] = *b1; | |||
| isuppz[2] = *bn; | |||
| i__1 = *r__; | |||
| z__[i__1].r = 1., z__[i__1].i = 0.; | |||
| *ztz = 1.; | |||
| /* Compute the FP vector upwards from R */ | |||
| if (! sawnan1 && ! sawnan2) { | |||
| i__1 = *b1; | |||
| for (i__ = *r__ - 1; i__ >= i__1; --i__) { | |||
| i__2 = i__; | |||
| i__3 = indlpl + i__; | |||
| i__4 = i__ + 1; | |||
| z__2.r = work[i__3] * z__[i__4].r, z__2.i = work[i__3] * z__[i__4] | |||
| .i; | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| z__[i__2].r = z__1.r, z__[i__2].i = z__1.i; | |||
| if ((z_abs(&z__[i__]) + z_abs(&z__[i__ + 1])) * (d__1 = ld[i__], | |||
| abs(d__1)) < *gaptol) { | |||
| i__2 = i__; | |||
| z__[i__2].r = 0., z__[i__2].i = 0.; | |||
| isuppz[1] = i__ + 1; | |||
| goto L220; | |||
| } | |||
| i__2 = i__; | |||
| i__3 = i__; | |||
| z__1.r = z__[i__2].r * z__[i__3].r - z__[i__2].i * z__[i__3].i, | |||
| z__1.i = z__[i__2].r * z__[i__3].i + z__[i__2].i * z__[ | |||
| i__3].r; | |||
| *ztz += z__1.r; | |||
| /* L210: */ | |||
| } | |||
| L220: | |||
| ; | |||
| } else { | |||
| /* Run slower loop if NaN occurred. */ | |||
| i__1 = *b1; | |||
| for (i__ = *r__ - 1; i__ >= i__1; --i__) { | |||
| i__2 = i__ + 1; | |||
| if (z__[i__2].r == 0. && z__[i__2].i == 0.) { | |||
| i__2 = i__; | |||
| d__1 = -(ld[i__ + 1] / ld[i__]); | |||
| i__3 = i__ + 2; | |||
| z__1.r = d__1 * z__[i__3].r, z__1.i = d__1 * z__[i__3].i; | |||
| z__[i__2].r = z__1.r, z__[i__2].i = z__1.i; | |||
| } else { | |||
| i__2 = i__; | |||
| i__3 = indlpl + i__; | |||
| i__4 = i__ + 1; | |||
| z__2.r = work[i__3] * z__[i__4].r, z__2.i = work[i__3] * z__[ | |||
| i__4].i; | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| z__[i__2].r = z__1.r, z__[i__2].i = z__1.i; | |||
| } | |||
| if ((z_abs(&z__[i__]) + z_abs(&z__[i__ + 1])) * (d__1 = ld[i__], | |||
| abs(d__1)) < *gaptol) { | |||
| i__2 = i__; | |||
| z__[i__2].r = 0., z__[i__2].i = 0.; | |||
| isuppz[1] = i__ + 1; | |||
| goto L240; | |||
| } | |||
| i__2 = i__; | |||
| i__3 = i__; | |||
| z__1.r = z__[i__2].r * z__[i__3].r - z__[i__2].i * z__[i__3].i, | |||
| z__1.i = z__[i__2].r * z__[i__3].i + z__[i__2].i * z__[ | |||
| i__3].r; | |||
| *ztz += z__1.r; | |||
| /* L230: */ | |||
| } | |||
| L240: | |||
| ; | |||
| } | |||
| /* Compute the FP vector downwards from R in blocks of size BLKSIZ */ | |||
| if (! sawnan1 && ! sawnan2) { | |||
| i__1 = *bn - 1; | |||
| for (i__ = *r__; i__ <= i__1; ++i__) { | |||
| i__2 = i__ + 1; | |||
| i__3 = indumn + i__; | |||
| i__4 = i__; | |||
| z__2.r = work[i__3] * z__[i__4].r, z__2.i = work[i__3] * z__[i__4] | |||
| .i; | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| z__[i__2].r = z__1.r, z__[i__2].i = z__1.i; | |||
| if ((z_abs(&z__[i__]) + z_abs(&z__[i__ + 1])) * (d__1 = ld[i__], | |||
| abs(d__1)) < *gaptol) { | |||
| i__2 = i__ + 1; | |||
| z__[i__2].r = 0., z__[i__2].i = 0.; | |||
| isuppz[2] = i__; | |||
| goto L260; | |||
| } | |||
| i__2 = i__ + 1; | |||
| i__3 = i__ + 1; | |||
| z__1.r = z__[i__2].r * z__[i__3].r - z__[i__2].i * z__[i__3].i, | |||
| z__1.i = z__[i__2].r * z__[i__3].i + z__[i__2].i * z__[ | |||
| i__3].r; | |||
| *ztz += z__1.r; | |||
| /* L250: */ | |||
| } | |||
| L260: | |||
| ; | |||
| } else { | |||
| /* Run slower loop if NaN occurred. */ | |||
| i__1 = *bn - 1; | |||
| for (i__ = *r__; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| if (z__[i__2].r == 0. && z__[i__2].i == 0.) { | |||
| i__2 = i__ + 1; | |||
| d__1 = -(ld[i__ - 1] / ld[i__]); | |||
| i__3 = i__ - 1; | |||
| z__1.r = d__1 * z__[i__3].r, z__1.i = d__1 * z__[i__3].i; | |||
| z__[i__2].r = z__1.r, z__[i__2].i = z__1.i; | |||
| } else { | |||
| i__2 = i__ + 1; | |||
| i__3 = indumn + i__; | |||
| i__4 = i__; | |||
| z__2.r = work[i__3] * z__[i__4].r, z__2.i = work[i__3] * z__[ | |||
| i__4].i; | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| z__[i__2].r = z__1.r, z__[i__2].i = z__1.i; | |||
| } | |||
| if ((z_abs(&z__[i__]) + z_abs(&z__[i__ + 1])) * (d__1 = ld[i__], | |||
| abs(d__1)) < *gaptol) { | |||
| i__2 = i__ + 1; | |||
| z__[i__2].r = 0., z__[i__2].i = 0.; | |||
| isuppz[2] = i__; | |||
| goto L280; | |||
| } | |||
| i__2 = i__ + 1; | |||
| i__3 = i__ + 1; | |||
| z__1.r = z__[i__2].r * z__[i__3].r - z__[i__2].i * z__[i__3].i, | |||
| z__1.i = z__[i__2].r * z__[i__3].i + z__[i__2].i * z__[ | |||
| i__3].r; | |||
| *ztz += z__1.r; | |||
| /* L270: */ | |||
| } | |||
| L280: | |||
| ; | |||
| } | |||
| /* Compute quantities for convergence test */ | |||
| tmp = 1. / *ztz; | |||
| *nrminv = sqrt(tmp); | |||
| *resid = abs(*mingma) * *nrminv; | |||
| *rqcorr = *mingma * tmp; | |||
| return 0; | |||
| /* End of ZLAR1V */ | |||
| } /* zlar1v_ */ | |||
| @@ -0,0 +1,593 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAR2V applies a vector of plane rotations with real cosines and complex sines from both sides | |||
| to a sequence of 2-by-2 symmetric/Hermitian matrices. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAR2V + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlar2v. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlar2v. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlar2v. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAR2V( N, X, Y, Z, INCX, C, S, INCC ) */ | |||
| /* INTEGER INCC, INCX, N */ | |||
| /* DOUBLE PRECISION C( * ) */ | |||
| /* COMPLEX*16 S( * ), X( * ), Y( * ), Z( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAR2V applies a vector of complex plane rotations with real cosines */ | |||
| /* > from both sides to a sequence of 2-by-2 complex Hermitian matrices, */ | |||
| /* > defined by the elements of the vectors x, y and z. For i = 1,2,...,n */ | |||
| /* > */ | |||
| /* > ( x(i) z(i) ) := */ | |||
| /* > ( conjg(z(i)) y(i) ) */ | |||
| /* > */ | |||
| /* > ( c(i) conjg(s(i)) ) ( x(i) z(i) ) ( c(i) -conjg(s(i)) ) */ | |||
| /* > ( -s(i) c(i) ) ( conjg(z(i)) y(i) ) ( s(i) c(i) ) */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of plane rotations to be applied. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension (1+(N-1)*INCX) */ | |||
| /* > The vector x; the elements of x are assumed to be real. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] Y */ | |||
| /* > \verbatim */ | |||
| /* > Y is COMPLEX*16 array, dimension (1+(N-1)*INCX) */ | |||
| /* > The vector y; the elements of y are assumed to be real. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] Z */ | |||
| /* > \verbatim */ | |||
| /* > Z is COMPLEX*16 array, dimension (1+(N-1)*INCX) */ | |||
| /* > The vector z. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCX */ | |||
| /* > \verbatim */ | |||
| /* > INCX is INTEGER */ | |||
| /* > The increment between elements of X, Y and Z. INCX > 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] C */ | |||
| /* > \verbatim */ | |||
| /* > C is DOUBLE PRECISION array, dimension (1+(N-1)*INCC) */ | |||
| /* > The cosines of the plane rotations. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] S */ | |||
| /* > \verbatim */ | |||
| /* > S is COMPLEX*16 array, dimension (1+(N-1)*INCC) */ | |||
| /* > The sines of the plane rotations. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCC */ | |||
| /* > \verbatim */ | |||
| /* > INCC is INTEGER */ | |||
| /* > The increment between elements of C and S. INCC > 0. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlar2v_(integer *n, doublecomplex *x, doublecomplex *y, | |||
| doublecomplex *z__, integer *incx, doublereal *c__, doublecomplex *s, | |||
| integer *incc) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2; | |||
| doublereal d__1; | |||
| doublecomplex z__1, z__2, z__3, z__4, z__5; | |||
| /* Local variables */ | |||
| integer i__; | |||
| doublecomplex t2, t3, t4; | |||
| doublereal t5, t6; | |||
| integer ic; | |||
| doublereal ci; | |||
| doublecomplex si; | |||
| integer ix; | |||
| doublereal xi, yi; | |||
| doublecomplex zi; | |||
| doublereal t1i, t1r, sii, zii, sir, zir; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --s; | |||
| --c__; | |||
| --z__; | |||
| --y; | |||
| --x; | |||
| /* Function Body */ | |||
| ix = 1; | |||
| ic = 1; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = ix; | |||
| xi = x[i__2].r; | |||
| i__2 = ix; | |||
| yi = y[i__2].r; | |||
| i__2 = ix; | |||
| zi.r = z__[i__2].r, zi.i = z__[i__2].i; | |||
| zir = zi.r; | |||
| zii = d_imag(&zi); | |||
| ci = c__[ic]; | |||
| i__2 = ic; | |||
| si.r = s[i__2].r, si.i = s[i__2].i; | |||
| sir = si.r; | |||
| sii = d_imag(&si); | |||
| t1r = sir * zir - sii * zii; | |||
| t1i = sir * zii + sii * zir; | |||
| z__1.r = ci * zi.r, z__1.i = ci * zi.i; | |||
| t2.r = z__1.r, t2.i = z__1.i; | |||
| d_cnjg(&z__3, &si); | |||
| z__2.r = xi * z__3.r, z__2.i = xi * z__3.i; | |||
| z__1.r = t2.r - z__2.r, z__1.i = t2.i - z__2.i; | |||
| t3.r = z__1.r, t3.i = z__1.i; | |||
| d_cnjg(&z__2, &t2); | |||
| z__3.r = yi * si.r, z__3.i = yi * si.i; | |||
| z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; | |||
| t4.r = z__1.r, t4.i = z__1.i; | |||
| t5 = ci * xi + t1r; | |||
| t6 = ci * yi - t1r; | |||
| i__2 = ix; | |||
| d__1 = ci * t5 + (sir * t4.r + sii * d_imag(&t4)); | |||
| x[i__2].r = d__1, x[i__2].i = 0.; | |||
| i__2 = ix; | |||
| d__1 = ci * t6 - (sir * t3.r - sii * d_imag(&t3)); | |||
| y[i__2].r = d__1, y[i__2].i = 0.; | |||
| i__2 = ix; | |||
| z__2.r = ci * t3.r, z__2.i = ci * t3.i; | |||
| d_cnjg(&z__4, &si); | |||
| z__5.r = t6, z__5.i = t1i; | |||
| z__3.r = z__4.r * z__5.r - z__4.i * z__5.i, z__3.i = z__4.r * z__5.i | |||
| + z__4.i * z__5.r; | |||
| z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; | |||
| z__[i__2].r = z__1.r, z__[i__2].i = z__1.i; | |||
| ix += *incx; | |||
| ic += *incc; | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* End of ZLAR2V */ | |||
| } /* zlar2v_ */ | |||
| @@ -0,0 +1,609 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublereal c_b6 = 1.; | |||
| static doublereal c_b7 = 0.; | |||
| /* > \brief \b ZLARCM copies all or part of a real two-dimensional array to a complex array. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLARCM + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarcm. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarcm. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarcm. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARCM( M, N, A, LDA, B, LDB, C, LDC, RWORK ) */ | |||
| /* INTEGER LDA, LDB, LDC, M, N */ | |||
| /* DOUBLE PRECISION A( LDA, * ), RWORK( * ) */ | |||
| /* COMPLEX*16 B( LDB, * ), C( LDC, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARCM performs a very simple matrix-matrix multiplication: */ | |||
| /* > C := A * B, */ | |||
| /* > where A is M by M and real; B is M by N and complex; */ | |||
| /* > C is M by N and complex. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A and of the matrix C. */ | |||
| /* > M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns and rows of the matrix B and */ | |||
| /* > the number of columns of the matrix C. */ | |||
| /* > N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is DOUBLE PRECISION array, dimension (LDA, M) */ | |||
| /* > On entry, A contains the M by M matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >=f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX*16 array, dimension (LDB, N) */ | |||
| /* > On entry, B contains the M by N matrix B. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >=f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX*16 array, dimension (LDC, N) */ | |||
| /* > On exit, C contains the M by N matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the array C. LDC >=f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is DOUBLE PRECISION array, dimension (2*M*N) */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlarcm_(integer *m, integer *n, doublereal *a, integer * | |||
| lda, doublecomplex *b, integer *ldb, doublecomplex *c__, integer *ldc, | |||
| doublereal *rwork) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2, | |||
| i__3, i__4, i__5; | |||
| doublereal d__1; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__, j, l; | |||
| extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *, | |||
| integer *, doublereal *, doublereal *, integer *, doublereal *, | |||
| integer *, doublereal *, doublereal *, integer *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible. */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| --rwork; | |||
| /* Function Body */ | |||
| if (*m == 0 || *n == 0) { | |||
| return 0; | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| rwork[(j - 1) * *m + i__] = b[i__3].r; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| l = *m * *n + 1; | |||
| dgemm_("N", "N", m, n, m, &c_b6, &a[a_offset], lda, &rwork[1], m, &c_b7, & | |||
| rwork[l], m); | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * c_dim1; | |||
| i__4 = l + (j - 1) * *m + i__ - 1; | |||
| c__[i__3].r = rwork[i__4], c__[i__3].i = 0.; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| rwork[(j - 1) * *m + i__] = d_imag(&b[i__ + j * b_dim1]); | |||
| /* L50: */ | |||
| } | |||
| /* L60: */ | |||
| } | |||
| dgemm_("N", "N", m, n, m, &c_b6, &a[a_offset], lda, &rwork[1], m, &c_b7, & | |||
| rwork[l], m); | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * c_dim1; | |||
| i__4 = i__ + j * c_dim1; | |||
| d__1 = c__[i__4].r; | |||
| i__5 = l + (j - 1) * *m + i__ - 1; | |||
| z__1.r = d__1, z__1.i = rwork[i__5]; | |||
| c__[i__3].r = z__1.r, c__[i__3].i = z__1.i; | |||
| /* L70: */ | |||
| } | |||
| /* L80: */ | |||
| } | |||
| return 0; | |||
| /* End of ZLARCM */ | |||
| } /* zlarcm_ */ | |||
| @@ -0,0 +1,636 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {1.,0.}; | |||
| static doublecomplex c_b2 = {0.,0.}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLARF applies an elementary reflector to a general rectangular matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLARF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarf.f | |||
| "> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarf.f | |||
| "> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarf.f | |||
| "> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARF( SIDE, M, N, V, INCV, TAU, C, LDC, WORK ) */ | |||
| /* CHARACTER SIDE */ | |||
| /* INTEGER INCV, LDC, M, N */ | |||
| /* COMPLEX*16 TAU */ | |||
| /* COMPLEX*16 C( LDC, * ), V( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARF applies a complex elementary reflector H to a complex M-by-N */ | |||
| /* > matrix C, from either the left or the right. H is represented in the */ | |||
| /* > form */ | |||
| /* > */ | |||
| /* > H = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar and v is a complex vector. */ | |||
| /* > */ | |||
| /* > If tau = 0, then H is taken to be the unit matrix. */ | |||
| /* > */ | |||
| /* > To apply H**H, supply conjg(tau) instead */ | |||
| /* > tau. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': form H * C */ | |||
| /* > = 'R': form C * H */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX*16 array, dimension */ | |||
| /* > (1 + (M-1)*abs(INCV)) if SIDE = 'L' */ | |||
| /* > or (1 + (N-1)*abs(INCV)) if SIDE = 'R' */ | |||
| /* > The vector v in the representation of H. V is not used if */ | |||
| /* > TAU = 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCV */ | |||
| /* > \verbatim */ | |||
| /* > INCV is INTEGER */ | |||
| /* > The increment between elements of v. INCV <> 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 */ | |||
| /* > The value tau in the representation of H. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX*16 array, dimension (LDC,N) */ | |||
| /* > On entry, the M-by-N matrix C. */ | |||
| /* > On exit, C is overwritten by the matrix H * C if SIDE = 'L', */ | |||
| /* > or C * H if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the array C. LDC >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX*16 array, dimension */ | |||
| /* > (N) if SIDE = 'L' */ | |||
| /* > or (M) if SIDE = 'R' */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlarf_(char *side, integer *m, integer *n, doublecomplex | |||
| *v, integer *incv, doublecomplex *tau, doublecomplex *c__, integer * | |||
| ldc, doublecomplex *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer c_dim1, c_offset, i__1; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__; | |||
| extern logical lsame_(char *, char *); | |||
| integer lastc; | |||
| extern /* Subroutine */ int zgerc_(integer *, integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *), zgemv_(char *, integer *, integer *, | |||
| doublecomplex *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *); | |||
| integer lastv; | |||
| logical applyleft; | |||
| extern integer ilazlc_(integer *, integer *, doublecomplex *, integer *), | |||
| ilazlr_(integer *, integer *, doublecomplex *, integer *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --v; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| applyleft = lsame_(side, "L"); | |||
| lastv = 0; | |||
| lastc = 0; | |||
| if (tau->r != 0. || tau->i != 0.) { | |||
| /* Set up variables for scanning V. LASTV begins pointing to the end */ | |||
| /* of V. */ | |||
| if (applyleft) { | |||
| lastv = *m; | |||
| } else { | |||
| lastv = *n; | |||
| } | |||
| if (*incv > 0) { | |||
| i__ = (lastv - 1) * *incv + 1; | |||
| } else { | |||
| i__ = 1; | |||
| } | |||
| /* Look for the last non-zero row in V. */ | |||
| for(;;) { /* while(complicated condition) */ | |||
| i__1 = i__; | |||
| if (!(lastv > 0 && (v[i__1].r == 0. && v[i__1].i == 0.))) | |||
| break; | |||
| --lastv; | |||
| i__ -= *incv; | |||
| } | |||
| if (applyleft) { | |||
| /* Scan for the last non-zero column in C(1:lastv,:). */ | |||
| lastc = ilazlc_(&lastv, n, &c__[c_offset], ldc); | |||
| } else { | |||
| /* Scan for the last non-zero row in C(:,1:lastv). */ | |||
| lastc = ilazlr_(m, &lastv, &c__[c_offset], ldc); | |||
| } | |||
| } | |||
| /* Note that lastc.eq.0 renders the BLAS operations null; no special */ | |||
| /* case is needed at this level. */ | |||
| if (applyleft) { | |||
| /* Form H * C */ | |||
| if (lastv > 0) { | |||
| /* w(1:lastc,1) := C(1:lastv,1:lastc)**H * v(1:lastv,1) */ | |||
| zgemv_("Conjugate transpose", &lastv, &lastc, &c_b1, &c__[ | |||
| c_offset], ldc, &v[1], incv, &c_b2, &work[1], &c__1); | |||
| /* C(1:lastv,1:lastc) := C(...) - v(1:lastv,1) * w(1:lastc,1)**H */ | |||
| z__1.r = -tau->r, z__1.i = -tau->i; | |||
| zgerc_(&lastv, &lastc, &z__1, &v[1], incv, &work[1], &c__1, &c__[ | |||
| c_offset], ldc); | |||
| } | |||
| } else { | |||
| /* Form C * H */ | |||
| if (lastv > 0) { | |||
| /* w(1:lastc,1) := C(1:lastc,1:lastv) * v(1:lastv,1) */ | |||
| zgemv_("No transpose", &lastc, &lastv, &c_b1, &c__[c_offset], ldc, | |||
| &v[1], incv, &c_b2, &work[1], &c__1); | |||
| /* C(1:lastc,1:lastv) := C(...) - w(1:lastc,1) * v(1:lastv,1)**H */ | |||
| z__1.r = -tau->r, z__1.i = -tau->i; | |||
| zgerc_(&lastc, &lastv, &z__1, &work[1], &c__1, &v[1], incv, &c__[ | |||
| c_offset], ldc); | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLARF */ | |||
| } /* zlarf_ */ | |||
| @@ -0,0 +1,611 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b5 = {1.,0.}; | |||
| /* > \brief \b ZLARFG generates an elementary reflector (Householder matrix). */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLARFG + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarfg. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarfg. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarfg. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARFG( N, ALPHA, X, INCX, TAU ) */ | |||
| /* INTEGER INCX, N */ | |||
| /* COMPLEX*16 ALPHA, TAU */ | |||
| /* COMPLEX*16 X( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARFG generates a complex elementary reflector H of order n, such */ | |||
| /* > that */ | |||
| /* > */ | |||
| /* > H**H * ( alpha ) = ( beta ), H**H * H = I. */ | |||
| /* > ( x ) ( 0 ) */ | |||
| /* > */ | |||
| /* > where alpha and beta are scalars, with beta real, and x is an */ | |||
| /* > (n-1)-element complex vector. H is represented in the form */ | |||
| /* > */ | |||
| /* > H = I - tau * ( 1 ) * ( 1 v**H ) , */ | |||
| /* > ( v ) */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar and v is a complex (n-1)-element */ | |||
| /* > vector. Note that H is not hermitian. */ | |||
| /* > */ | |||
| /* > If the elements of x are all zero and alpha is real, then tau = 0 */ | |||
| /* > and H is taken to be the unit matrix. */ | |||
| /* > */ | |||
| /* > Otherwise 1 <= real(tau) <= 2 and abs(tau-1) <= 1 . */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the elementary reflector. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] ALPHA */ | |||
| /* > \verbatim */ | |||
| /* > ALPHA is COMPLEX*16 */ | |||
| /* > On entry, the value alpha. */ | |||
| /* > On exit, it is overwritten with the value beta. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension */ | |||
| /* > (1+(N-2)*abs(INCX)) */ | |||
| /* > On entry, the vector x. */ | |||
| /* > On exit, it is overwritten with the vector v. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCX */ | |||
| /* > \verbatim */ | |||
| /* > INCX is INTEGER */ | |||
| /* > The increment between elements of X. INCX > 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 */ | |||
| /* > The value tau. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date November 2017 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlarfg_(integer *n, doublecomplex *alpha, doublecomplex * | |||
| x, integer *incx, doublecomplex *tau) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1; | |||
| doublereal d__1, d__2; | |||
| doublecomplex z__1, z__2; | |||
| /* Local variables */ | |||
| doublereal beta; | |||
| integer j; | |||
| doublereal alphi, alphr; | |||
| extern /* Subroutine */ int zscal_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *); | |||
| doublereal xnorm; | |||
| extern doublereal dlapy3_(doublereal *, doublereal *, doublereal *), | |||
| dznrm2_(integer *, doublecomplex *, integer *), dlamch_(char *); | |||
| doublereal safmin; | |||
| extern /* Subroutine */ int zdscal_(integer *, doublereal *, | |||
| doublecomplex *, integer *); | |||
| doublereal rsafmn; | |||
| extern /* Double Complex */ VOID zladiv_(doublecomplex *, doublecomplex *, | |||
| doublecomplex *); | |||
| integer knt; | |||
| /* -- LAPACK auxiliary routine (version 3.8.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* November 2017 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --x; | |||
| /* Function Body */ | |||
| if (*n <= 0) { | |||
| tau->r = 0., tau->i = 0.; | |||
| return 0; | |||
| } | |||
| i__1 = *n - 1; | |||
| xnorm = dznrm2_(&i__1, &x[1], incx); | |||
| alphr = alpha->r; | |||
| alphi = d_imag(alpha); | |||
| if (xnorm == 0. && alphi == 0.) { | |||
| /* H = I */ | |||
| tau->r = 0., tau->i = 0.; | |||
| } else { | |||
| /* general case */ | |||
| d__1 = dlapy3_(&alphr, &alphi, &xnorm); | |||
| beta = -d_sign(&d__1, &alphr); | |||
| safmin = dlamch_("S") / dlamch_("E"); | |||
| rsafmn = 1. / safmin; | |||
| knt = 0; | |||
| if (abs(beta) < safmin) { | |||
| /* XNORM, BETA may be inaccurate; scale X and recompute them */ | |||
| L10: | |||
| ++knt; | |||
| i__1 = *n - 1; | |||
| zdscal_(&i__1, &rsafmn, &x[1], incx); | |||
| beta *= rsafmn; | |||
| alphi *= rsafmn; | |||
| alphr *= rsafmn; | |||
| if (abs(beta) < safmin && knt < 20) { | |||
| goto L10; | |||
| } | |||
| /* New BETA is at most 1, at least SAFMIN */ | |||
| i__1 = *n - 1; | |||
| xnorm = dznrm2_(&i__1, &x[1], incx); | |||
| z__1.r = alphr, z__1.i = alphi; | |||
| alpha->r = z__1.r, alpha->i = z__1.i; | |||
| d__1 = dlapy3_(&alphr, &alphi, &xnorm); | |||
| beta = -d_sign(&d__1, &alphr); | |||
| } | |||
| d__1 = (beta - alphr) / beta; | |||
| d__2 = -alphi / beta; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| tau->r = z__1.r, tau->i = z__1.i; | |||
| z__2.r = alpha->r - beta, z__2.i = alpha->i; | |||
| zladiv_(&z__1, &c_b5, &z__2); | |||
| alpha->r = z__1.r, alpha->i = z__1.i; | |||
| i__1 = *n - 1; | |||
| zscal_(&i__1, alpha, &x[1], incx); | |||
| /* If ALPHA is subnormal, it may lose relative accuracy */ | |||
| i__1 = knt; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| beta *= safmin; | |||
| /* L20: */ | |||
| } | |||
| alpha->r = beta, alpha->i = 0.; | |||
| } | |||
| return 0; | |||
| /* End of ZLARFG */ | |||
| } /* zlarfg_ */ | |||
| @@ -0,0 +1,701 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b5 = {1.,0.}; | |||
| /* > \brief \b ZLARFGP generates an elementary reflector (Householder matrix) with non-negative beta. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLARFGP + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarfgp | |||
| .f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarfgp | |||
| .f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarfgp | |||
| .f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARFGP( N, ALPHA, X, INCX, TAU ) */ | |||
| /* INTEGER INCX, N */ | |||
| /* COMPLEX*16 ALPHA, TAU */ | |||
| /* COMPLEX*16 X( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARFGP generates a complex elementary reflector H of order n, such */ | |||
| /* > that */ | |||
| /* > */ | |||
| /* > H**H * ( alpha ) = ( beta ), H**H * H = I. */ | |||
| /* > ( x ) ( 0 ) */ | |||
| /* > */ | |||
| /* > where alpha and beta are scalars, beta is real and non-negative, and */ | |||
| /* > x is an (n-1)-element complex vector. H is represented in the form */ | |||
| /* > */ | |||
| /* > H = I - tau * ( 1 ) * ( 1 v**H ) , */ | |||
| /* > ( v ) */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar and v is a complex (n-1)-element */ | |||
| /* > vector. Note that H is not hermitian. */ | |||
| /* > */ | |||
| /* > If the elements of x are all zero and alpha is real, then tau = 0 */ | |||
| /* > and H is taken to be the unit matrix. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the elementary reflector. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] ALPHA */ | |||
| /* > \verbatim */ | |||
| /* > ALPHA is COMPLEX*16 */ | |||
| /* > On entry, the value alpha. */ | |||
| /* > On exit, it is overwritten with the value beta. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension */ | |||
| /* > (1+(N-2)*abs(INCX)) */ | |||
| /* > On entry, the vector x. */ | |||
| /* > On exit, it is overwritten with the vector v. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCX */ | |||
| /* > \verbatim */ | |||
| /* > INCX is INTEGER */ | |||
| /* > The increment between elements of X. INCX > 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 */ | |||
| /* > The value tau. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date November 2017 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlarfgp_(integer *n, doublecomplex *alpha, doublecomplex | |||
| *x, integer *incx, doublecomplex *tau) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2; | |||
| doublereal d__1, d__2; | |||
| doublecomplex z__1, z__2; | |||
| /* Local variables */ | |||
| doublereal beta; | |||
| integer j; | |||
| doublereal alphi, alphr; | |||
| extern /* Subroutine */ int zscal_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *); | |||
| doublecomplex savealpha; | |||
| doublereal xnorm; | |||
| extern doublereal dlapy2_(doublereal *, doublereal *), dlapy3_(doublereal | |||
| *, doublereal *, doublereal *), dznrm2_(integer *, doublecomplex * | |||
| , integer *), dlamch_(char *); | |||
| extern /* Subroutine */ int zdscal_(integer *, doublereal *, | |||
| doublecomplex *, integer *); | |||
| doublereal bignum; | |||
| extern /* Double Complex */ VOID zladiv_(doublecomplex *, doublecomplex *, | |||
| doublecomplex *); | |||
| doublereal smlnum; | |||
| integer knt; | |||
| /* -- LAPACK auxiliary routine (version 3.8.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* November 2017 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --x; | |||
| /* Function Body */ | |||
| if (*n <= 0) { | |||
| tau->r = 0., tau->i = 0.; | |||
| return 0; | |||
| } | |||
| i__1 = *n - 1; | |||
| xnorm = dznrm2_(&i__1, &x[1], incx); | |||
| alphr = alpha->r; | |||
| alphi = d_imag(alpha); | |||
| if (xnorm == 0.) { | |||
| /* H = [1-alpha/abs(alpha) 0; 0 I], sign chosen so ALPHA >= 0. */ | |||
| if (alphi == 0.) { | |||
| if (alphr >= 0.) { | |||
| /* When TAU.eq.ZERO, the vector is special-cased to be */ | |||
| /* all zeros in the application routines. We do not need */ | |||
| /* to clear it. */ | |||
| tau->r = 0., tau->i = 0.; | |||
| } else { | |||
| /* However, the application routines rely on explicit */ | |||
| /* zero checks when TAU.ne.ZERO, and we must clear X. */ | |||
| tau->r = 2., tau->i = 0.; | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = (j - 1) * *incx + 1; | |||
| x[i__2].r = 0., x[i__2].i = 0.; | |||
| } | |||
| z__1.r = -alpha->r, z__1.i = -alpha->i; | |||
| alpha->r = z__1.r, alpha->i = z__1.i; | |||
| } | |||
| } else { | |||
| /* Only "reflecting" the diagonal entry to be real and non-negative. */ | |||
| xnorm = dlapy2_(&alphr, &alphi); | |||
| d__1 = 1. - alphr / xnorm; | |||
| d__2 = -alphi / xnorm; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| tau->r = z__1.r, tau->i = z__1.i; | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = (j - 1) * *incx + 1; | |||
| x[i__2].r = 0., x[i__2].i = 0.; | |||
| } | |||
| alpha->r = xnorm, alpha->i = 0.; | |||
| } | |||
| } else { | |||
| /* general case */ | |||
| d__1 = dlapy3_(&alphr, &alphi, &xnorm); | |||
| beta = d_sign(&d__1, &alphr); | |||
| smlnum = dlamch_("S") / dlamch_("E"); | |||
| bignum = 1. / smlnum; | |||
| knt = 0; | |||
| if (abs(beta) < smlnum) { | |||
| /* XNORM, BETA may be inaccurate; scale X and recompute them */ | |||
| L10: | |||
| ++knt; | |||
| i__1 = *n - 1; | |||
| zdscal_(&i__1, &bignum, &x[1], incx); | |||
| beta *= bignum; | |||
| alphi *= bignum; | |||
| alphr *= bignum; | |||
| if (abs(beta) < smlnum && knt < 20) { | |||
| goto L10; | |||
| } | |||
| /* New BETA is at most 1, at least SMLNUM */ | |||
| i__1 = *n - 1; | |||
| xnorm = dznrm2_(&i__1, &x[1], incx); | |||
| z__1.r = alphr, z__1.i = alphi; | |||
| alpha->r = z__1.r, alpha->i = z__1.i; | |||
| d__1 = dlapy3_(&alphr, &alphi, &xnorm); | |||
| beta = d_sign(&d__1, &alphr); | |||
| } | |||
| savealpha.r = alpha->r, savealpha.i = alpha->i; | |||
| z__1.r = alpha->r + beta, z__1.i = alpha->i; | |||
| alpha->r = z__1.r, alpha->i = z__1.i; | |||
| if (beta < 0.) { | |||
| beta = -beta; | |||
| z__2.r = -alpha->r, z__2.i = -alpha->i; | |||
| z__1.r = z__2.r / beta, z__1.i = z__2.i / beta; | |||
| tau->r = z__1.r, tau->i = z__1.i; | |||
| } else { | |||
| alphr = alphi * (alphi / alpha->r); | |||
| alphr += xnorm * (xnorm / alpha->r); | |||
| d__1 = alphr / beta; | |||
| d__2 = -alphi / beta; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| tau->r = z__1.r, tau->i = z__1.i; | |||
| d__1 = -alphr; | |||
| z__1.r = d__1, z__1.i = alphi; | |||
| alpha->r = z__1.r, alpha->i = z__1.i; | |||
| } | |||
| zladiv_(&z__1, &c_b5, alpha); | |||
| alpha->r = z__1.r, alpha->i = z__1.i; | |||
| if (z_abs(tau) <= smlnum) { | |||
| /* In the case where the computed TAU ends up being a denormalized number, */ | |||
| /* it loses relative accuracy. This is a BIG problem. Solution: flush TAU */ | |||
| /* to ZERO (or TWO or whatever makes a nonnegative real number for BETA). */ | |||
| /* (Bug report provided by Pat Quillen from MathWorks on Jul 29, 2009.) */ | |||
| /* (Thanks Pat. Thanks MathWorks.) */ | |||
| alphr = savealpha.r; | |||
| alphi = d_imag(&savealpha); | |||
| if (alphi == 0.) { | |||
| if (alphr >= 0.) { | |||
| tau->r = 0., tau->i = 0.; | |||
| } else { | |||
| tau->r = 2., tau->i = 0.; | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = (j - 1) * *incx + 1; | |||
| x[i__2].r = 0., x[i__2].i = 0.; | |||
| } | |||
| z__1.r = -savealpha.r, z__1.i = -savealpha.i; | |||
| beta = z__1.r; | |||
| } | |||
| } else { | |||
| xnorm = dlapy2_(&alphr, &alphi); | |||
| d__1 = 1. - alphr / xnorm; | |||
| d__2 = -alphi / xnorm; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| tau->r = z__1.r, tau->i = z__1.i; | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = (j - 1) * *incx + 1; | |||
| x[i__2].r = 0., x[i__2].i = 0.; | |||
| } | |||
| beta = xnorm; | |||
| } | |||
| } else { | |||
| /* This is the general case. */ | |||
| i__1 = *n - 1; | |||
| zscal_(&i__1, alpha, &x[1], incx); | |||
| } | |||
| /* If BETA is subnormal, it may lose relative accuracy */ | |||
| i__1 = knt; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| beta *= smlnum; | |||
| /* L20: */ | |||
| } | |||
| alpha->r = beta, alpha->i = 0.; | |||
| } | |||
| return 0; | |||
| /* End of ZLARFGP */ | |||
| } /* zlarfgp_ */ | |||
| @@ -0,0 +1,809 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {1.,0.}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLARFT forms the triangular factor T of a block reflector H = I - vtvH */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLARFT + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarft. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarft. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarft. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARFT( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT ) */ | |||
| /* CHARACTER DIRECT, STOREV */ | |||
| /* INTEGER K, LDT, LDV, N */ | |||
| /* COMPLEX*16 T( LDT, * ), TAU( * ), V( LDV, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARFT forms the triangular factor T of a complex block reflector H */ | |||
| /* > of order n, which is defined as a product of k elementary reflectors. */ | |||
| /* > */ | |||
| /* > If DIRECT = 'F', H = H(1) H(2) . . . H(k) and T is upper triangular; */ | |||
| /* > */ | |||
| /* > If DIRECT = 'B', H = H(k) . . . H(2) H(1) and T is lower triangular. */ | |||
| /* > */ | |||
| /* > If STOREV = 'C', the vector which defines the elementary reflector */ | |||
| /* > H(i) is stored in the i-th column of the array V, and */ | |||
| /* > */ | |||
| /* > H = I - V * T * V**H */ | |||
| /* > */ | |||
| /* > If STOREV = 'R', the vector which defines the elementary reflector */ | |||
| /* > H(i) is stored in the i-th row of the array V, and */ | |||
| /* > */ | |||
| /* > H = I - V**H * T * V */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] DIRECT */ | |||
| /* > \verbatim */ | |||
| /* > DIRECT is CHARACTER*1 */ | |||
| /* > Specifies the order in which the elementary reflectors are */ | |||
| /* > multiplied to form the block reflector: */ | |||
| /* > = 'F': H = H(1) H(2) . . . H(k) (Forward) */ | |||
| /* > = 'B': H = H(k) . . . H(2) H(1) (Backward) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] STOREV */ | |||
| /* > \verbatim */ | |||
| /* > STOREV is CHARACTER*1 */ | |||
| /* > Specifies how the vectors which define the elementary */ | |||
| /* > reflectors are stored (see also Further Details): */ | |||
| /* > = 'C': columnwise */ | |||
| /* > = 'R': rowwise */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the block reflector H. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The order of the triangular factor T (= the number of */ | |||
| /* > elementary reflectors). K >= 1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX*16 array, dimension */ | |||
| /* > (LDV,K) if STOREV = 'C' */ | |||
| /* > (LDV,N) if STOREV = 'R' */ | |||
| /* > The matrix V. See further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the array V. */ | |||
| /* > If STOREV = 'C', LDV >= f2cmax(1,N); if STOREV = 'R', LDV >= K. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 array, dimension (K) */ | |||
| /* > TAU(i) must contain the scalar factor of the elementary */ | |||
| /* > reflector H(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX*16 array, dimension (LDT,K) */ | |||
| /* > The k by k triangular factor T of the block reflector. */ | |||
| /* > If DIRECT = 'F', T is upper triangular; if DIRECT = 'B', T is */ | |||
| /* > lower triangular. The rest of the array is not used. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= K. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The shape of the matrix V and the storage of the vectors which define */ | |||
| /* > the H(i) is best illustrated by the following example with n = 5 and */ | |||
| /* > k = 3. The elements equal to 1 are not stored. */ | |||
| /* > */ | |||
| /* > DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R': */ | |||
| /* > */ | |||
| /* > V = ( 1 ) V = ( 1 v1 v1 v1 v1 ) */ | |||
| /* > ( v1 1 ) ( 1 v2 v2 v2 ) */ | |||
| /* > ( v1 v2 1 ) ( 1 v3 v3 ) */ | |||
| /* > ( v1 v2 v3 ) */ | |||
| /* > ( v1 v2 v3 ) */ | |||
| /* > */ | |||
| /* > DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R': */ | |||
| /* > */ | |||
| /* > V = ( v1 v2 v3 ) V = ( v1 v1 1 ) */ | |||
| /* > ( v1 v2 v3 ) ( v2 v2 v2 1 ) */ | |||
| /* > ( 1 v2 v3 ) ( v3 v3 v3 v3 1 ) */ | |||
| /* > ( 1 v3 ) */ | |||
| /* > ( 1 ) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlarft_(char *direct, char *storev, integer *n, integer * | |||
| k, doublecomplex *v, integer *ldv, doublecomplex *tau, doublecomplex * | |||
| t, integer *ldt) | |||
| { | |||
| /* System generated locals */ | |||
| integer t_dim1, t_offset, v_dim1, v_offset, i__1, i__2, i__3, i__4, i__5; | |||
| doublecomplex z__1, z__2, z__3; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int zgemm_(char *, char *, integer *, integer *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, doublecomplex *, | |||
| integer *), zgemv_(char *, integer *, integer *, | |||
| doublecomplex *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *); | |||
| integer lastv; | |||
| extern /* Subroutine */ int ztrmv_(char *, char *, char *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *); | |||
| integer prevlastv; | |||
| extern /* Subroutine */ int mecago_(); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| v_dim1 = *ldv; | |||
| v_offset = 1 + v_dim1 * 1; | |||
| v -= v_offset; | |||
| --tau; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| /* Function Body */ | |||
| if (*n == 0) { | |||
| return 0; | |||
| } | |||
| if (lsame_(direct, "F")) { | |||
| prevlastv = *n; | |||
| i__1 = *k; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| prevlastv = f2cmax(prevlastv,i__); | |||
| i__2 = i__; | |||
| if (tau[i__2].r == 0. && tau[i__2].i == 0.) { | |||
| /* H(i) = I */ | |||
| i__2 = i__; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| i__3 = j + i__ * t_dim1; | |||
| t[i__3].r = 0., t[i__3].i = 0.; | |||
| } | |||
| } else { | |||
| /* general case */ | |||
| if (lsame_(storev, "C")) { | |||
| /* Skip any trailing zeros. */ | |||
| i__2 = i__ + 1; | |||
| for (lastv = *n; lastv >= i__2; --lastv) { | |||
| i__3 = lastv + i__ * v_dim1; | |||
| if (v[i__3].r != 0. || v[i__3].i != 0.) { | |||
| myexit_(); | |||
| } | |||
| } | |||
| i__2 = i__ - 1; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| i__3 = j + i__ * t_dim1; | |||
| i__4 = i__; | |||
| z__2.r = -tau[i__4].r, z__2.i = -tau[i__4].i; | |||
| d_cnjg(&z__3, &v[i__ + j * v_dim1]); | |||
| z__1.r = z__2.r * z__3.r - z__2.i * z__3.i, z__1.i = | |||
| z__2.r * z__3.i + z__2.i * z__3.r; | |||
| t[i__3].r = z__1.r, t[i__3].i = z__1.i; | |||
| } | |||
| j = f2cmin(lastv,prevlastv); | |||
| /* T(1:i-1,i) := - tau(i) * V(i:j,1:i-1)**H * V(i:j,i) */ | |||
| i__2 = j - i__; | |||
| i__3 = i__ - 1; | |||
| i__4 = i__; | |||
| z__1.r = -tau[i__4].r, z__1.i = -tau[i__4].i; | |||
| zgemv_("Conjugate transpose", &i__2, &i__3, &z__1, &v[i__ | |||
| + 1 + v_dim1], ldv, &v[i__ + 1 + i__ * v_dim1], & | |||
| c__1, &c_b1, &t[i__ * t_dim1 + 1], &c__1); | |||
| } else { | |||
| /* Skip any trailing zeros. */ | |||
| i__2 = i__ + 1; | |||
| for (lastv = *n; lastv >= i__2; --lastv) { | |||
| i__3 = i__ + lastv * v_dim1; | |||
| if (v[i__3].r != 0. || v[i__3].i != 0.) { | |||
| myexit_(); | |||
| } | |||
| } | |||
| i__2 = i__ - 1; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| i__3 = j + i__ * t_dim1; | |||
| i__4 = i__; | |||
| z__2.r = -tau[i__4].r, z__2.i = -tau[i__4].i; | |||
| i__5 = j + i__ * v_dim1; | |||
| z__1.r = z__2.r * v[i__5].r - z__2.i * v[i__5].i, | |||
| z__1.i = z__2.r * v[i__5].i + z__2.i * v[i__5] | |||
| .r; | |||
| t[i__3].r = z__1.r, t[i__3].i = z__1.i; | |||
| } | |||
| j = f2cmin(lastv,prevlastv); | |||
| /* T(1:i-1,i) := - tau(i) * V(1:i-1,i:j) * V(i,i:j)**H */ | |||
| i__2 = i__ - 1; | |||
| i__3 = j - i__; | |||
| i__4 = i__; | |||
| z__1.r = -tau[i__4].r, z__1.i = -tau[i__4].i; | |||
| zgemm_("N", "C", &i__2, &c__1, &i__3, &z__1, &v[(i__ + 1) | |||
| * v_dim1 + 1], ldv, &v[i__ + (i__ + 1) * v_dim1], | |||
| ldv, &c_b1, &t[i__ * t_dim1 + 1], ldt); | |||
| } | |||
| /* T(1:i-1,i) := T(1:i-1,1:i-1) * T(1:i-1,i) */ | |||
| i__2 = i__ - 1; | |||
| ztrmv_("Upper", "No transpose", "Non-unit", &i__2, &t[ | |||
| t_offset], ldt, &t[i__ * t_dim1 + 1], &c__1); | |||
| i__2 = i__ + i__ * t_dim1; | |||
| i__3 = i__; | |||
| t[i__2].r = tau[i__3].r, t[i__2].i = tau[i__3].i; | |||
| if (i__ > 1) { | |||
| prevlastv = f2cmax(prevlastv,lastv); | |||
| } else { | |||
| prevlastv = lastv; | |||
| } | |||
| } | |||
| } | |||
| } else { | |||
| prevlastv = 1; | |||
| for (i__ = *k; i__ >= 1; --i__) { | |||
| i__1 = i__; | |||
| if (tau[i__1].r == 0. && tau[i__1].i == 0.) { | |||
| /* H(i) = I */ | |||
| i__1 = *k; | |||
| for (j = i__; j <= i__1; ++j) { | |||
| i__2 = j + i__ * t_dim1; | |||
| t[i__2].r = 0., t[i__2].i = 0.; | |||
| } | |||
| } else { | |||
| /* general case */ | |||
| if (i__ < *k) { | |||
| if (lsame_(storev, "C")) { | |||
| /* Skip any leading zeros. */ | |||
| i__1 = i__ - 1; | |||
| for (lastv = 1; lastv <= i__1; ++lastv) { | |||
| i__2 = lastv + i__ * v_dim1; | |||
| if (v[i__2].r != 0. || v[i__2].i != 0.) { | |||
| myexit_(); | |||
| } | |||
| } | |||
| i__1 = *k; | |||
| for (j = i__ + 1; j <= i__1; ++j) { | |||
| i__2 = j + i__ * t_dim1; | |||
| i__3 = i__; | |||
| z__2.r = -tau[i__3].r, z__2.i = -tau[i__3].i; | |||
| d_cnjg(&z__3, &v[*n - *k + i__ + j * v_dim1]); | |||
| z__1.r = z__2.r * z__3.r - z__2.i * z__3.i, | |||
| z__1.i = z__2.r * z__3.i + z__2.i * | |||
| z__3.r; | |||
| t[i__2].r = z__1.r, t[i__2].i = z__1.i; | |||
| } | |||
| j = f2cmax(lastv,prevlastv); | |||
| /* T(i+1:k,i) = -tau(i) * V(j:n-k+i,i+1:k)**H * V(j:n-k+i,i) */ | |||
| i__1 = *n - *k + i__ - j; | |||
| i__2 = *k - i__; | |||
| i__3 = i__; | |||
| z__1.r = -tau[i__3].r, z__1.i = -tau[i__3].i; | |||
| zgemv_("Conjugate transpose", &i__1, &i__2, &z__1, &v[ | |||
| j + (i__ + 1) * v_dim1], ldv, &v[j + i__ * | |||
| v_dim1], &c__1, &c_b1, &t[i__ + 1 + i__ * | |||
| t_dim1], &c__1); | |||
| } else { | |||
| /* Skip any leading zeros. */ | |||
| i__1 = i__ - 1; | |||
| for (lastv = 1; lastv <= i__1; ++lastv) { | |||
| i__2 = i__ + lastv * v_dim1; | |||
| if (v[i__2].r != 0. || v[i__2].i != 0.) { | |||
| myexit_(); | |||
| } | |||
| } | |||
| i__1 = *k; | |||
| for (j = i__ + 1; j <= i__1; ++j) { | |||
| i__2 = j + i__ * t_dim1; | |||
| i__3 = i__; | |||
| z__2.r = -tau[i__3].r, z__2.i = -tau[i__3].i; | |||
| i__4 = j + (*n - *k + i__) * v_dim1; | |||
| z__1.r = z__2.r * v[i__4].r - z__2.i * v[i__4].i, | |||
| z__1.i = z__2.r * v[i__4].i + z__2.i * v[ | |||
| i__4].r; | |||
| t[i__2].r = z__1.r, t[i__2].i = z__1.i; | |||
| } | |||
| j = f2cmax(lastv,prevlastv); | |||
| /* T(i+1:k,i) = -tau(i) * V(i+1:k,j:n-k+i) * V(i,j:n-k+i)**H */ | |||
| i__1 = *k - i__; | |||
| i__2 = *n - *k + i__ - j; | |||
| i__3 = i__; | |||
| z__1.r = -tau[i__3].r, z__1.i = -tau[i__3].i; | |||
| zgemm_("N", "C", &i__1, &c__1, &i__2, &z__1, &v[i__ + | |||
| 1 + j * v_dim1], ldv, &v[i__ + j * v_dim1], | |||
| ldv, &c_b1, &t[i__ + 1 + i__ * t_dim1], ldt); | |||
| } | |||
| /* T(i+1:k,i) := T(i+1:k,i+1:k) * T(i+1:k,i) */ | |||
| i__1 = *k - i__; | |||
| ztrmv_("Lower", "No transpose", "Non-unit", &i__1, &t[i__ | |||
| + 1 + (i__ + 1) * t_dim1], ldt, &t[i__ + 1 + i__ * | |||
| t_dim1], &c__1) | |||
| ; | |||
| if (i__ > 1) { | |||
| prevlastv = f2cmin(prevlastv,lastv); | |||
| } else { | |||
| prevlastv = lastv; | |||
| } | |||
| } | |||
| i__1 = i__ + i__ * t_dim1; | |||
| i__2 = i__; | |||
| t[i__1].r = tau[i__2].r, t[i__1].i = tau[i__2].i; | |||
| } | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLARFT */ | |||
| } /* zlarft_ */ | |||
| @@ -0,0 +1,566 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {1.,0.}; | |||
| static doublecomplex c_b2 = {0.,0.}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLARFY */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARFY( UPLO, N, V, INCV, TAU, C, LDC, WORK ) */ | |||
| /* CHARACTER UPLO */ | |||
| /* INTEGER INCV, LDC, N */ | |||
| /* COMPLEX*16 TAU */ | |||
| /* COMPLEX*16 C( LDC, * ), V( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARFY applies an elementary reflector, or Householder matrix, H, */ | |||
| /* > to an n x n Hermitian matrix C, from both the left and the right. */ | |||
| /* > */ | |||
| /* > H is represented in the form */ | |||
| /* > */ | |||
| /* > H = I - tau * v * v' */ | |||
| /* > */ | |||
| /* > where tau is a scalar and v is a vector. */ | |||
| /* > */ | |||
| /* > If tau is zero, then H is taken to be the unit matrix. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies whether the upper or lower triangular part of the */ | |||
| /* > Hermitian matrix C is stored. */ | |||
| /* > = 'U': Upper triangle */ | |||
| /* > = 'L': Lower triangle */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of rows and columns of the matrix C. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX*16 array, dimension */ | |||
| /* > (1 + (N-1)*abs(INCV)) */ | |||
| /* > The vector v as described above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCV */ | |||
| /* > \verbatim */ | |||
| /* > INCV is INTEGER */ | |||
| /* > The increment between successive elements of v. INCV must */ | |||
| /* > not be zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 */ | |||
| /* > The value tau as described above. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX*16 array, dimension (LDC, N) */ | |||
| /* > On entry, the matrix C. */ | |||
| /* > On exit, C is overwritten by H * C * H'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the array C. LDC >= f2cmax( 1, N ). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX*16 array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlarfy_(char *uplo, integer *n, doublecomplex *v, | |||
| integer *incv, doublecomplex *tau, doublecomplex *c__, integer *ldc, | |||
| doublecomplex *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer c_dim1, c_offset; | |||
| doublecomplex z__1, z__2, z__3, z__4; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int zher2_(char *, integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *); | |||
| doublecomplex alpha; | |||
| extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *); | |||
| extern /* Subroutine */ int zhemv_(char *, integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *, | |||
| doublecomplex *, doublecomplex *, integer *), zaxpy_( | |||
| integer *, doublecomplex *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *); | |||
| /* -- LAPACK test routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --v; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (tau->r == 0. && tau->i == 0.) { | |||
| return 0; | |||
| } | |||
| /* Form w:= C * v */ | |||
| zhemv_(uplo, n, &c_b1, &c__[c_offset], ldc, &v[1], incv, &c_b2, &work[1], | |||
| &c__1); | |||
| z__3.r = -.5, z__3.i = 0.; | |||
| z__2.r = z__3.r * tau->r - z__3.i * tau->i, z__2.i = z__3.r * tau->i + | |||
| z__3.i * tau->r; | |||
| zdotc_(&z__4, n, &work[1], &c__1, &v[1], incv); | |||
| z__1.r = z__2.r * z__4.r - z__2.i * z__4.i, z__1.i = z__2.r * z__4.i + | |||
| z__2.i * z__4.r; | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| zaxpy_(n, &alpha, &v[1], incv, &work[1], &c__1); | |||
| /* C := C - v * w' - w * v' */ | |||
| z__1.r = -tau->r, z__1.i = -tau->i; | |||
| zher2_(uplo, n, &z__1, &v[1], incv, &work[1], &c__1, &c__[c_offset], ldc); | |||
| return 0; | |||
| /* End of ZLARFY */ | |||
| } /* zlarfy_ */ | |||
| @@ -0,0 +1,754 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLARGV generates a vector of plane rotations with real cosines and complex sines. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLARGV + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlargv. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlargv. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlargv. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARGV( N, X, INCX, Y, INCY, C, INCC ) */ | |||
| /* INTEGER INCC, INCX, INCY, N */ | |||
| /* DOUBLE PRECISION C( * ) */ | |||
| /* COMPLEX*16 X( * ), Y( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARGV generates a vector of complex plane rotations with real */ | |||
| /* > cosines, determined by elements of the complex vectors x and y. */ | |||
| /* > For i = 1,2,...,n */ | |||
| /* > */ | |||
| /* > ( c(i) s(i) ) ( x(i) ) = ( r(i) ) */ | |||
| /* > ( -conjg(s(i)) c(i) ) ( y(i) ) = ( 0 ) */ | |||
| /* > */ | |||
| /* > where c(i)**2 + ABS(s(i))**2 = 1 */ | |||
| /* > */ | |||
| /* > The following conventions are used (these are the same as in ZLARTG, */ | |||
| /* > but differ from the BLAS1 routine ZROTG): */ | |||
| /* > If y(i)=0, then c(i)=1 and s(i)=0. */ | |||
| /* > If x(i)=0, then c(i)=0 and s(i) is chosen so that r(i) is real. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of plane rotations to be generated. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension (1+(N-1)*INCX) */ | |||
| /* > On entry, the vector x. */ | |||
| /* > On exit, x(i) is overwritten by r(i), for i = 1,...,n. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCX */ | |||
| /* > \verbatim */ | |||
| /* > INCX is INTEGER */ | |||
| /* > The increment between elements of X. INCX > 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] Y */ | |||
| /* > \verbatim */ | |||
| /* > Y is COMPLEX*16 array, dimension (1+(N-1)*INCY) */ | |||
| /* > On entry, the vector y. */ | |||
| /* > On exit, the sines of the plane rotations. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCY */ | |||
| /* > \verbatim */ | |||
| /* > INCY is INTEGER */ | |||
| /* > The increment between elements of Y. INCY > 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is DOUBLE PRECISION array, dimension (1+(N-1)*INCC) */ | |||
| /* > The cosines of the plane rotations. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCC */ | |||
| /* > \verbatim */ | |||
| /* > INCC is INTEGER */ | |||
| /* > The increment between elements of C. INCC > 0. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > 6-6-96 - Modified with a new algorithm by W. Kahan and J. Demmel */ | |||
| /* > */ | |||
| /* > This version has a few statements commented out for thread safety */ | |||
| /* > (machine parameters are computed on each entry). 10 feb 03, SJH. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlargv_(integer *n, doublecomplex *x, integer *incx, | |||
| doublecomplex *y, integer *incy, doublereal *c__, integer *incc) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2; | |||
| doublereal d__1, d__2, d__3, d__4, d__5, d__6, d__7, d__8, d__9, d__10; | |||
| doublecomplex z__1, z__2, z__3; | |||
| /* Local variables */ | |||
| doublereal d__; | |||
| doublecomplex f, g; | |||
| integer i__, j; | |||
| doublecomplex r__; | |||
| doublereal scale; | |||
| integer count; | |||
| doublereal f2, g2, safmn2; | |||
| extern doublereal dlapy2_(doublereal *, doublereal *); | |||
| doublereal safmx2; | |||
| integer ic; | |||
| doublereal di; | |||
| doublecomplex ff; | |||
| doublereal cs, dr; | |||
| extern doublereal dlamch_(char *); | |||
| doublecomplex fs, gs; | |||
| integer ix, iy; | |||
| doublecomplex sn; | |||
| doublereal safmin, f2s, g2s, eps; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* LOGICAL FIRST */ | |||
| /* SAVE FIRST, SAFMX2, SAFMIN, SAFMN2 */ | |||
| /* DATA FIRST / .TRUE. / */ | |||
| /* IF( FIRST ) THEN */ | |||
| /* FIRST = .FALSE. */ | |||
| /* Parameter adjustments */ | |||
| --c__; | |||
| --y; | |||
| --x; | |||
| /* Function Body */ | |||
| safmin = dlamch_("S"); | |||
| eps = dlamch_("E"); | |||
| d__1 = dlamch_("B"); | |||
| i__1 = (integer) (log(safmin / eps) / log(dlamch_("B")) / 2.); | |||
| safmn2 = pow_di(&d__1, &i__1); | |||
| safmx2 = 1. / safmn2; | |||
| /* END IF */ | |||
| ix = 1; | |||
| iy = 1; | |||
| ic = 1; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = ix; | |||
| f.r = x[i__2].r, f.i = x[i__2].i; | |||
| i__2 = iy; | |||
| g.r = y[i__2].r, g.i = y[i__2].i; | |||
| /* Use identical algorithm as in ZLARTG */ | |||
| /* Computing MAX */ | |||
| /* Computing MAX */ | |||
| d__7 = (d__1 = f.r, abs(d__1)), d__8 = (d__2 = d_imag(&f), abs(d__2)); | |||
| /* Computing MAX */ | |||
| d__9 = (d__3 = g.r, abs(d__3)), d__10 = (d__4 = d_imag(&g), abs(d__4)) | |||
| ; | |||
| d__5 = f2cmax(d__7,d__8), d__6 = f2cmax(d__9,d__10); | |||
| scale = f2cmax(d__5,d__6); | |||
| fs.r = f.r, fs.i = f.i; | |||
| gs.r = g.r, gs.i = g.i; | |||
| count = 0; | |||
| if (scale >= safmx2) { | |||
| L10: | |||
| ++count; | |||
| z__1.r = safmn2 * fs.r, z__1.i = safmn2 * fs.i; | |||
| fs.r = z__1.r, fs.i = z__1.i; | |||
| z__1.r = safmn2 * gs.r, z__1.i = safmn2 * gs.i; | |||
| gs.r = z__1.r, gs.i = z__1.i; | |||
| scale *= safmn2; | |||
| if (scale >= safmx2 && count < 20) { | |||
| goto L10; | |||
| } | |||
| } else if (scale <= safmn2) { | |||
| if (g.r == 0. && g.i == 0.) { | |||
| cs = 1.; | |||
| sn.r = 0., sn.i = 0.; | |||
| r__.r = f.r, r__.i = f.i; | |||
| goto L50; | |||
| } | |||
| L20: | |||
| --count; | |||
| z__1.r = safmx2 * fs.r, z__1.i = safmx2 * fs.i; | |||
| fs.r = z__1.r, fs.i = z__1.i; | |||
| z__1.r = safmx2 * gs.r, z__1.i = safmx2 * gs.i; | |||
| gs.r = z__1.r, gs.i = z__1.i; | |||
| scale *= safmx2; | |||
| if (scale <= safmn2) { | |||
| goto L20; | |||
| } | |||
| } | |||
| /* Computing 2nd power */ | |||
| d__1 = fs.r; | |||
| /* Computing 2nd power */ | |||
| d__2 = d_imag(&fs); | |||
| f2 = d__1 * d__1 + d__2 * d__2; | |||
| /* Computing 2nd power */ | |||
| d__1 = gs.r; | |||
| /* Computing 2nd power */ | |||
| d__2 = d_imag(&gs); | |||
| g2 = d__1 * d__1 + d__2 * d__2; | |||
| if (f2 <= f2cmax(g2,1.) * safmin) { | |||
| /* This is a rare case: F is very small. */ | |||
| if (f.r == 0. && f.i == 0.) { | |||
| cs = 0.; | |||
| d__2 = g.r; | |||
| d__3 = d_imag(&g); | |||
| d__1 = dlapy2_(&d__2, &d__3); | |||
| r__.r = d__1, r__.i = 0.; | |||
| /* Do complex/real division explicitly with two real */ | |||
| /* divisions */ | |||
| d__1 = gs.r; | |||
| d__2 = d_imag(&gs); | |||
| d__ = dlapy2_(&d__1, &d__2); | |||
| d__1 = gs.r / d__; | |||
| d__2 = -d_imag(&gs) / d__; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| sn.r = z__1.r, sn.i = z__1.i; | |||
| goto L50; | |||
| } | |||
| d__1 = fs.r; | |||
| d__2 = d_imag(&fs); | |||
| f2s = dlapy2_(&d__1, &d__2); | |||
| /* G2 and G2S are accurate */ | |||
| /* G2 is at least SAFMIN, and G2S is at least SAFMN2 */ | |||
| g2s = sqrt(g2); | |||
| /* Error in CS from underflow in F2S is at most */ | |||
| /* UNFL / SAFMN2 .lt. sqrt(UNFL*EPS) .lt. EPS */ | |||
| /* If MAX(G2,ONE)=G2, then F2 .lt. G2*SAFMIN, */ | |||
| /* and so CS .lt. sqrt(SAFMIN) */ | |||
| /* If MAX(G2,ONE)=ONE, then F2 .lt. SAFMIN */ | |||
| /* and so CS .lt. sqrt(SAFMIN)/SAFMN2 = sqrt(EPS) */ | |||
| /* Therefore, CS = F2S/G2S / sqrt( 1 + (F2S/G2S)**2 ) = F2S/G2S */ | |||
| cs = f2s / g2s; | |||
| /* Make sure abs(FF) = 1 */ | |||
| /* Do complex/real division explicitly with 2 real divisions */ | |||
| /* Computing MAX */ | |||
| d__3 = (d__1 = f.r, abs(d__1)), d__4 = (d__2 = d_imag(&f), abs( | |||
| d__2)); | |||
| if (f2cmax(d__3,d__4) > 1.) { | |||
| d__1 = f.r; | |||
| d__2 = d_imag(&f); | |||
| d__ = dlapy2_(&d__1, &d__2); | |||
| d__1 = f.r / d__; | |||
| d__2 = d_imag(&f) / d__; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| ff.r = z__1.r, ff.i = z__1.i; | |||
| } else { | |||
| dr = safmx2 * f.r; | |||
| di = safmx2 * d_imag(&f); | |||
| d__ = dlapy2_(&dr, &di); | |||
| d__1 = dr / d__; | |||
| d__2 = di / d__; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| ff.r = z__1.r, ff.i = z__1.i; | |||
| } | |||
| d__1 = gs.r / g2s; | |||
| d__2 = -d_imag(&gs) / g2s; | |||
| z__2.r = d__1, z__2.i = d__2; | |||
| z__1.r = ff.r * z__2.r - ff.i * z__2.i, z__1.i = ff.r * z__2.i + | |||
| ff.i * z__2.r; | |||
| sn.r = z__1.r, sn.i = z__1.i; | |||
| z__2.r = cs * f.r, z__2.i = cs * f.i; | |||
| z__3.r = sn.r * g.r - sn.i * g.i, z__3.i = sn.r * g.i + sn.i * | |||
| g.r; | |||
| z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; | |||
| r__.r = z__1.r, r__.i = z__1.i; | |||
| } else { | |||
| /* This is the most common case. */ | |||
| /* Neither F2 nor F2/G2 are less than SAFMIN */ | |||
| /* F2S cannot overflow, and it is accurate */ | |||
| f2s = sqrt(g2 / f2 + 1.); | |||
| /* Do the F2S(real)*FS(complex) multiply with two real */ | |||
| /* multiplies */ | |||
| d__1 = f2s * fs.r; | |||
| d__2 = f2s * d_imag(&fs); | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| r__.r = z__1.r, r__.i = z__1.i; | |||
| cs = 1. / f2s; | |||
| d__ = f2 + g2; | |||
| /* Do complex/real division explicitly with two real divisions */ | |||
| d__1 = r__.r / d__; | |||
| d__2 = d_imag(&r__) / d__; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| sn.r = z__1.r, sn.i = z__1.i; | |||
| d_cnjg(&z__2, &gs); | |||
| z__1.r = sn.r * z__2.r - sn.i * z__2.i, z__1.i = sn.r * z__2.i + | |||
| sn.i * z__2.r; | |||
| sn.r = z__1.r, sn.i = z__1.i; | |||
| if (count != 0) { | |||
| if (count > 0) { | |||
| i__2 = count; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| z__1.r = safmx2 * r__.r, z__1.i = safmx2 * r__.i; | |||
| r__.r = z__1.r, r__.i = z__1.i; | |||
| /* L30: */ | |||
| } | |||
| } else { | |||
| i__2 = -count; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| z__1.r = safmn2 * r__.r, z__1.i = safmn2 * r__.i; | |||
| r__.r = z__1.r, r__.i = z__1.i; | |||
| /* L40: */ | |||
| } | |||
| } | |||
| } | |||
| } | |||
| L50: | |||
| c__[ic] = cs; | |||
| i__2 = iy; | |||
| y[i__2].r = sn.r, y[i__2].i = sn.i; | |||
| i__2 = ix; | |||
| x[i__2].r = r__.r, x[i__2].i = r__.i; | |||
| ic += *incc; | |||
| iy += *incy; | |||
| ix += *incx; | |||
| /* L60: */ | |||
| } | |||
| return 0; | |||
| /* End of ZLARGV */ | |||
| } /* zlargv_ */ | |||
| @@ -0,0 +1,607 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLARNV returns a vector of random numbers from a uniform or normal distribution. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLARNV + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarnv. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarnv. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarnv. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARNV( IDIST, ISEED, N, X ) */ | |||
| /* INTEGER IDIST, N */ | |||
| /* INTEGER ISEED( 4 ) */ | |||
| /* COMPLEX*16 X( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARNV returns a vector of n random complex numbers from a uniform or */ | |||
| /* > normal distribution. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] IDIST */ | |||
| /* > \verbatim */ | |||
| /* > IDIST is INTEGER */ | |||
| /* > Specifies the distribution of the random numbers: */ | |||
| /* > = 1: real and imaginary parts each uniform (0,1) */ | |||
| /* > = 2: real and imaginary parts each uniform (-1,1) */ | |||
| /* > = 3: real and imaginary parts each normal (0,1) */ | |||
| /* > = 4: uniformly distributed on the disc abs(z) < 1 */ | |||
| /* > = 5: uniformly distributed on the circle abs(z) = 1 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] ISEED */ | |||
| /* > \verbatim */ | |||
| /* > ISEED is INTEGER array, dimension (4) */ | |||
| /* > On entry, the seed of the random number generator; the array */ | |||
| /* > elements must be between 0 and 4095, and ISEED(4) must be */ | |||
| /* > odd. */ | |||
| /* > On exit, the seed is updated. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of random numbers to be generated. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension (N) */ | |||
| /* > The generated random numbers. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine calls the auxiliary routine DLARUV to generate random */ | |||
| /* > real numbers from a uniform (0,1) distribution, in batches of up to */ | |||
| /* > 128 using vectorisable code. The Box-Muller method is used to */ | |||
| /* > transform numbers from a uniform to a normal distribution. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlarnv_(integer *idist, integer *iseed, integer *n, | |||
| doublecomplex *x) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2, i__3, i__4, i__5; | |||
| doublereal d__1, d__2; | |||
| doublecomplex z__1, z__2, z__3; | |||
| /* Local variables */ | |||
| integer i__; | |||
| doublereal u[128]; | |||
| integer il, iv; | |||
| extern /* Subroutine */ int dlaruv_(integer *, integer *, doublereal *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --x; | |||
| --iseed; | |||
| /* Function Body */ | |||
| i__1 = *n; | |||
| for (iv = 1; iv <= i__1; iv += 64) { | |||
| /* Computing MIN */ | |||
| i__2 = 64, i__3 = *n - iv + 1; | |||
| il = f2cmin(i__2,i__3); | |||
| /* Call DLARUV to generate 2*IL real numbers from a uniform (0,1) */ | |||
| /* distribution (2*IL <= LV) */ | |||
| i__2 = il << 1; | |||
| dlaruv_(&iseed[1], &i__2, u); | |||
| if (*idist == 1) { | |||
| /* Copy generated numbers */ | |||
| i__2 = il; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = iv + i__ - 1; | |||
| i__4 = (i__ << 1) - 2; | |||
| i__5 = (i__ << 1) - 1; | |||
| z__1.r = u[i__4], z__1.i = u[i__5]; | |||
| x[i__3].r = z__1.r, x[i__3].i = z__1.i; | |||
| /* L10: */ | |||
| } | |||
| } else if (*idist == 2) { | |||
| /* Convert generated numbers to uniform (-1,1) distribution */ | |||
| i__2 = il; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = iv + i__ - 1; | |||
| d__1 = u[(i__ << 1) - 2] * 2. - 1.; | |||
| d__2 = u[(i__ << 1) - 1] * 2. - 1.; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| x[i__3].r = z__1.r, x[i__3].i = z__1.i; | |||
| /* L20: */ | |||
| } | |||
| } else if (*idist == 3) { | |||
| /* Convert generated numbers to normal (0,1) distribution */ | |||
| i__2 = il; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = iv + i__ - 1; | |||
| d__1 = sqrt(log(u[(i__ << 1) - 2]) * -2.); | |||
| d__2 = u[(i__ << 1) - 1] * 6.2831853071795864769252867663; | |||
| z__3.r = 0., z__3.i = d__2; | |||
| z_exp(&z__2, &z__3); | |||
| z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i; | |||
| x[i__3].r = z__1.r, x[i__3].i = z__1.i; | |||
| /* L30: */ | |||
| } | |||
| } else if (*idist == 4) { | |||
| /* Convert generated numbers to complex numbers uniformly */ | |||
| /* distributed on the unit disk */ | |||
| i__2 = il; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = iv + i__ - 1; | |||
| d__1 = sqrt(u[(i__ << 1) - 2]); | |||
| d__2 = u[(i__ << 1) - 1] * 6.2831853071795864769252867663; | |||
| z__3.r = 0., z__3.i = d__2; | |||
| z_exp(&z__2, &z__3); | |||
| z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i; | |||
| x[i__3].r = z__1.r, x[i__3].i = z__1.i; | |||
| /* L40: */ | |||
| } | |||
| } else if (*idist == 5) { | |||
| /* Convert generated numbers to complex numbers uniformly */ | |||
| /* distributed on the unit circle */ | |||
| i__2 = il; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = iv + i__ - 1; | |||
| d__1 = u[(i__ << 1) - 1] * 6.2831853071795864769252867663; | |||
| z__2.r = 0., z__2.i = d__1; | |||
| z_exp(&z__1, &z__2); | |||
| x[i__3].r = z__1.r, x[i__3].i = z__1.i; | |||
| /* L50: */ | |||
| } | |||
| } | |||
| /* L60: */ | |||
| } | |||
| return 0; | |||
| /* End of ZLARNV */ | |||
| } /* zlarnv_ */ | |||
| @@ -0,0 +1,519 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLARSCL2 performs reciprocal diagonal scaling on a vector. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLARSCL2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarscl | |||
| 2.f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarscl | |||
| 2.f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarscl | |||
| 2.f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARSCL2 ( M, N, D, X, LDX ) */ | |||
| /* INTEGER M, N, LDX */ | |||
| /* COMPLEX*16 X( LDX, * ) */ | |||
| /* DOUBLE PRECISION D( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARSCL2 performs a reciprocal diagonal scaling on an vector: */ | |||
| /* > x <-- inv(D) * x */ | |||
| /* > where the DOUBLE PRECISION diagonal matrix D is stored as a vector. */ | |||
| /* > */ | |||
| /* > Eventually to be replaced by BLAS_zge_diag_scale in the new BLAS */ | |||
| /* > standard. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of D and X. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of X. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] D */ | |||
| /* > \verbatim */ | |||
| /* > D is DOUBLE PRECISION array, length M */ | |||
| /* > Diagonal matrix D, stored as a vector of length M. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension (LDX,N) */ | |||
| /* > On entry, the vector X to be scaled by D. */ | |||
| /* > On exit, the scaled vector. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDX */ | |||
| /* > \verbatim */ | |||
| /* > LDX is INTEGER */ | |||
| /* > The leading dimension of the vector X. LDX >= M. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complex16OTHERcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlarscl2_(integer *m, integer *n, doublereal *d__, | |||
| doublecomplex *x, integer *ldx) | |||
| { | |||
| /* System generated locals */ | |||
| integer x_dim1, x_offset, i__1, i__2, i__3, i__4, i__5; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --d__; | |||
| x_dim1 = *ldx; | |||
| x_offset = 1 + x_dim1 * 1; | |||
| x -= x_offset; | |||
| /* Function Body */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * x_dim1; | |||
| i__4 = i__ + j * x_dim1; | |||
| i__5 = i__; | |||
| z__1.r = x[i__4].r / d__[i__5], z__1.i = x[i__4].i / d__[i__5]; | |||
| x[i__3].r = z__1.r, x[i__3].i = z__1.i; | |||
| } | |||
| } | |||
| return 0; | |||
| } /* zlarscl2_ */ | |||
| @@ -0,0 +1,695 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLARTG generates a plane rotation with real cosine and complex sine. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLARTG + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlartg. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlartg. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlartg. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARTG( F, G, CS, SN, R ) */ | |||
| /* DOUBLE PRECISION CS */ | |||
| /* COMPLEX*16 F, G, R, SN */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARTG generates a plane rotation so that */ | |||
| /* > */ | |||
| /* > [ CS SN ] [ F ] [ R ] */ | |||
| /* > [ __ ] . [ ] = [ ] where CS**2 + |SN|**2 = 1. */ | |||
| /* > [ -SN CS ] [ G ] [ 0 ] */ | |||
| /* > */ | |||
| /* > This is a faster version of the BLAS1 routine ZROTG, except for */ | |||
| /* > the following differences: */ | |||
| /* > F and G are unchanged on return. */ | |||
| /* > If G=0, then CS=1 and SN=0. */ | |||
| /* > If F=0, then CS=0 and SN is chosen so that R is real. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] F */ | |||
| /* > \verbatim */ | |||
| /* > F is COMPLEX*16 */ | |||
| /* > The first component of vector to be rotated. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] G */ | |||
| /* > \verbatim */ | |||
| /* > G is COMPLEX*16 */ | |||
| /* > The second component of vector to be rotated. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] CS */ | |||
| /* > \verbatim */ | |||
| /* > CS is DOUBLE PRECISION */ | |||
| /* > The cosine of the rotation. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SN */ | |||
| /* > \verbatim */ | |||
| /* > SN is COMPLEX*16 */ | |||
| /* > The sine of the rotation. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] R */ | |||
| /* > \verbatim */ | |||
| /* > R is COMPLEX*16 */ | |||
| /* > The nonzero component of the rotated vector. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > 3-5-96 - Modified with a new algorithm by W. Kahan and J. Demmel */ | |||
| /* > */ | |||
| /* > This version has a few statements commented out for thread safety */ | |||
| /* > (machine parameters are computed on each entry). 10 feb 03, SJH. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlartg_(doublecomplex *f, doublecomplex *g, doublereal * | |||
| cs, doublecomplex *sn, doublecomplex *r__) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1; | |||
| doublereal d__1, d__2, d__3, d__4, d__5, d__6, d__7, d__8, d__9, d__10; | |||
| doublecomplex z__1, z__2, z__3; | |||
| /* Local variables */ | |||
| doublereal d__; | |||
| integer i__; | |||
| doublereal scale; | |||
| integer count; | |||
| doublereal f2, g2, safmn2; | |||
| extern doublereal dlapy2_(doublereal *, doublereal *); | |||
| doublereal safmx2; | |||
| doublecomplex ff; | |||
| doublereal di, dr; | |||
| extern doublereal dlamch_(char *); | |||
| doublecomplex fs, gs; | |||
| extern logical disnan_(doublereal *); | |||
| doublereal safmin, f2s, g2s, eps; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* LOGICAL FIRST */ | |||
| safmin = dlamch_("S"); | |||
| eps = dlamch_("E"); | |||
| d__1 = dlamch_("B"); | |||
| i__1 = (integer) (log(safmin / eps) / log(dlamch_("B")) / 2.); | |||
| safmn2 = pow_di(&d__1, &i__1); | |||
| safmx2 = 1. / safmn2; | |||
| /* Computing MAX */ | |||
| /* Computing MAX */ | |||
| d__7 = (d__1 = f->r, abs(d__1)), d__8 = (d__2 = d_imag(f), abs(d__2)); | |||
| /* Computing MAX */ | |||
| d__9 = (d__3 = g->r, abs(d__3)), d__10 = (d__4 = d_imag(g), abs(d__4)); | |||
| d__5 = f2cmax(d__7,d__8), d__6 = f2cmax(d__9,d__10); | |||
| scale = f2cmax(d__5,d__6); | |||
| fs.r = f->r, fs.i = f->i; | |||
| gs.r = g->r, gs.i = g->i; | |||
| count = 0; | |||
| if (scale >= safmx2) { | |||
| L10: | |||
| ++count; | |||
| z__1.r = safmn2 * fs.r, z__1.i = safmn2 * fs.i; | |||
| fs.r = z__1.r, fs.i = z__1.i; | |||
| z__1.r = safmn2 * gs.r, z__1.i = safmn2 * gs.i; | |||
| gs.r = z__1.r, gs.i = z__1.i; | |||
| scale *= safmn2; | |||
| if (scale >= safmx2 && count < 20) { | |||
| goto L10; | |||
| } | |||
| } else if (scale <= safmn2) { | |||
| d__1 = z_abs(g); | |||
| if (g->r == 0. && g->i == 0. || disnan_(&d__1)) { | |||
| *cs = 1.; | |||
| sn->r = 0., sn->i = 0.; | |||
| r__->r = f->r, r__->i = f->i; | |||
| return 0; | |||
| } | |||
| L20: | |||
| --count; | |||
| z__1.r = safmx2 * fs.r, z__1.i = safmx2 * fs.i; | |||
| fs.r = z__1.r, fs.i = z__1.i; | |||
| z__1.r = safmx2 * gs.r, z__1.i = safmx2 * gs.i; | |||
| gs.r = z__1.r, gs.i = z__1.i; | |||
| scale *= safmx2; | |||
| if (scale <= safmn2) { | |||
| goto L20; | |||
| } | |||
| } | |||
| /* Computing 2nd power */ | |||
| d__1 = fs.r; | |||
| /* Computing 2nd power */ | |||
| d__2 = d_imag(&fs); | |||
| f2 = d__1 * d__1 + d__2 * d__2; | |||
| /* Computing 2nd power */ | |||
| d__1 = gs.r; | |||
| /* Computing 2nd power */ | |||
| d__2 = d_imag(&gs); | |||
| g2 = d__1 * d__1 + d__2 * d__2; | |||
| if (f2 <= f2cmax(g2,1.) * safmin) { | |||
| /* This is a rare case: F is very small. */ | |||
| if (f->r == 0. && f->i == 0.) { | |||
| *cs = 0.; | |||
| d__2 = g->r; | |||
| d__3 = d_imag(g); | |||
| d__1 = dlapy2_(&d__2, &d__3); | |||
| r__->r = d__1, r__->i = 0.; | |||
| /* Do complex/real division explicitly with two real divisions */ | |||
| d__1 = gs.r; | |||
| d__2 = d_imag(&gs); | |||
| d__ = dlapy2_(&d__1, &d__2); | |||
| d__1 = gs.r / d__; | |||
| d__2 = -d_imag(&gs) / d__; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| sn->r = z__1.r, sn->i = z__1.i; | |||
| return 0; | |||
| } | |||
| d__1 = fs.r; | |||
| d__2 = d_imag(&fs); | |||
| f2s = dlapy2_(&d__1, &d__2); | |||
| /* G2 and G2S are accurate */ | |||
| /* G2 is at least SAFMIN, and G2S is at least SAFMN2 */ | |||
| g2s = sqrt(g2); | |||
| /* Error in CS from underflow in F2S is at most */ | |||
| /* UNFL / SAFMN2 .lt. sqrt(UNFL*EPS) .lt. EPS */ | |||
| /* If MAX(G2,ONE)=G2, then F2 .lt. G2*SAFMIN, */ | |||
| /* and so CS .lt. sqrt(SAFMIN) */ | |||
| /* If MAX(G2,ONE)=ONE, then F2 .lt. SAFMIN */ | |||
| /* and so CS .lt. sqrt(SAFMIN)/SAFMN2 = sqrt(EPS) */ | |||
| /* Therefore, CS = F2S/G2S / sqrt( 1 + (F2S/G2S)**2 ) = F2S/G2S */ | |||
| *cs = f2s / g2s; | |||
| /* Make sure abs(FF) = 1 */ | |||
| /* Do complex/real division explicitly with 2 real divisions */ | |||
| /* Computing MAX */ | |||
| d__3 = (d__1 = f->r, abs(d__1)), d__4 = (d__2 = d_imag(f), abs(d__2)); | |||
| if (f2cmax(d__3,d__4) > 1.) { | |||
| d__1 = f->r; | |||
| d__2 = d_imag(f); | |||
| d__ = dlapy2_(&d__1, &d__2); | |||
| d__1 = f->r / d__; | |||
| d__2 = d_imag(f) / d__; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| ff.r = z__1.r, ff.i = z__1.i; | |||
| } else { | |||
| dr = safmx2 * f->r; | |||
| di = safmx2 * d_imag(f); | |||
| d__ = dlapy2_(&dr, &di); | |||
| d__1 = dr / d__; | |||
| d__2 = di / d__; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| ff.r = z__1.r, ff.i = z__1.i; | |||
| } | |||
| d__1 = gs.r / g2s; | |||
| d__2 = -d_imag(&gs) / g2s; | |||
| z__2.r = d__1, z__2.i = d__2; | |||
| z__1.r = ff.r * z__2.r - ff.i * z__2.i, z__1.i = ff.r * z__2.i + ff.i | |||
| * z__2.r; | |||
| sn->r = z__1.r, sn->i = z__1.i; | |||
| z__2.r = *cs * f->r, z__2.i = *cs * f->i; | |||
| z__3.r = sn->r * g->r - sn->i * g->i, z__3.i = sn->r * g->i + sn->i * | |||
| g->r; | |||
| z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; | |||
| r__->r = z__1.r, r__->i = z__1.i; | |||
| } else { | |||
| /* This is the most common case. */ | |||
| /* Neither F2 nor F2/G2 are less than SAFMIN */ | |||
| /* F2S cannot overflow, and it is accurate */ | |||
| f2s = sqrt(g2 / f2 + 1.); | |||
| /* Do the F2S(real)*FS(complex) multiply with two real multiplies */ | |||
| d__1 = f2s * fs.r; | |||
| d__2 = f2s * d_imag(&fs); | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| r__->r = z__1.r, r__->i = z__1.i; | |||
| *cs = 1. / f2s; | |||
| d__ = f2 + g2; | |||
| /* Do complex/real division explicitly with two real divisions */ | |||
| d__1 = r__->r / d__; | |||
| d__2 = d_imag(r__) / d__; | |||
| z__1.r = d__1, z__1.i = d__2; | |||
| sn->r = z__1.r, sn->i = z__1.i; | |||
| d_cnjg(&z__2, &gs); | |||
| z__1.r = sn->r * z__2.r - sn->i * z__2.i, z__1.i = sn->r * z__2.i + | |||
| sn->i * z__2.r; | |||
| sn->r = z__1.r, sn->i = z__1.i; | |||
| if (count != 0) { | |||
| if (count > 0) { | |||
| i__1 = count; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| z__1.r = safmx2 * r__->r, z__1.i = safmx2 * r__->i; | |||
| r__->r = z__1.r, r__->i = z__1.i; | |||
| /* L30: */ | |||
| } | |||
| } else { | |||
| i__1 = -count; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| z__1.r = safmn2 * r__->r, z__1.i = safmn2 * r__->i; | |||
| r__->r = z__1.r, r__->i = z__1.i; | |||
| /* L40: */ | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLARTG */ | |||
| } /* zlartg_ */ | |||
| @@ -0,0 +1,560 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLARTV applies a vector of plane rotations with real cosines and complex sines to the elements | |||
| of a pair of vectors. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLARTV + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlartv. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlartv. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlartv. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARTV( N, X, INCX, Y, INCY, C, S, INCC ) */ | |||
| /* INTEGER INCC, INCX, INCY, N */ | |||
| /* DOUBLE PRECISION C( * ) */ | |||
| /* COMPLEX*16 S( * ), X( * ), Y( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARTV applies a vector of complex plane rotations with real cosines */ | |||
| /* > to elements of the complex vectors x and y. For i = 1,2,...,n */ | |||
| /* > */ | |||
| /* > ( x(i) ) := ( c(i) s(i) ) ( x(i) ) */ | |||
| /* > ( y(i) ) ( -conjg(s(i)) c(i) ) ( y(i) ) */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of plane rotations to be applied. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension (1+(N-1)*INCX) */ | |||
| /* > The vector x. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCX */ | |||
| /* > \verbatim */ | |||
| /* > INCX is INTEGER */ | |||
| /* > The increment between elements of X. INCX > 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] Y */ | |||
| /* > \verbatim */ | |||
| /* > Y is COMPLEX*16 array, dimension (1+(N-1)*INCY) */ | |||
| /* > The vector y. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCY */ | |||
| /* > \verbatim */ | |||
| /* > INCY is INTEGER */ | |||
| /* > The increment between elements of Y. INCY > 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] C */ | |||
| /* > \verbatim */ | |||
| /* > C is DOUBLE PRECISION array, dimension (1+(N-1)*INCC) */ | |||
| /* > The cosines of the plane rotations. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] S */ | |||
| /* > \verbatim */ | |||
| /* > S is COMPLEX*16 array, dimension (1+(N-1)*INCC) */ | |||
| /* > The sines of the plane rotations. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCC */ | |||
| /* > \verbatim */ | |||
| /* > INCC is INTEGER */ | |||
| /* > The increment between elements of C and S. INCC > 0. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlartv_(integer *n, doublecomplex *x, integer *incx, | |||
| doublecomplex *y, integer *incy, doublereal *c__, doublecomplex *s, | |||
| integer *incc) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2, i__3, i__4; | |||
| doublecomplex z__1, z__2, z__3, z__4; | |||
| /* Local variables */ | |||
| integer i__, ic, ix, iy; | |||
| doublecomplex xi, yi; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --s; | |||
| --c__; | |||
| --y; | |||
| --x; | |||
| /* Function Body */ | |||
| ix = 1; | |||
| iy = 1; | |||
| ic = 1; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = ix; | |||
| xi.r = x[i__2].r, xi.i = x[i__2].i; | |||
| i__2 = iy; | |||
| yi.r = y[i__2].r, yi.i = y[i__2].i; | |||
| i__2 = ix; | |||
| i__3 = ic; | |||
| z__2.r = c__[i__3] * xi.r, z__2.i = c__[i__3] * xi.i; | |||
| i__4 = ic; | |||
| z__3.r = s[i__4].r * yi.r - s[i__4].i * yi.i, z__3.i = s[i__4].r * | |||
| yi.i + s[i__4].i * yi.r; | |||
| z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; | |||
| x[i__2].r = z__1.r, x[i__2].i = z__1.i; | |||
| i__2 = iy; | |||
| i__3 = ic; | |||
| z__2.r = c__[i__3] * yi.r, z__2.i = c__[i__3] * yi.i; | |||
| d_cnjg(&z__4, &s[ic]); | |||
| z__3.r = z__4.r * xi.r - z__4.i * xi.i, z__3.i = z__4.r * xi.i + | |||
| z__4.i * xi.r; | |||
| z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i; | |||
| y[i__2].r = z__1.r, y[i__2].i = z__1.i; | |||
| ix += *incx; | |||
| iy += *incy; | |||
| ic += *incc; | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* End of ZLARTV */ | |||
| } /* zlartv_ */ | |||
| @@ -0,0 +1,646 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {1.,0.}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLARZ applies an elementary reflector (as returned by stzrzf) to a general matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLARZ + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarz.f | |||
| "> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarz.f | |||
| "> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarz.f | |||
| "> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARZ( SIDE, M, N, L, V, INCV, TAU, C, LDC, WORK ) */ | |||
| /* CHARACTER SIDE */ | |||
| /* INTEGER INCV, L, LDC, M, N */ | |||
| /* COMPLEX*16 TAU */ | |||
| /* COMPLEX*16 C( LDC, * ), V( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARZ applies a complex elementary reflector H to a complex */ | |||
| /* > M-by-N matrix C, from either the left or the right. H is represented */ | |||
| /* > in the form */ | |||
| /* > */ | |||
| /* > H = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar and v is a complex vector. */ | |||
| /* > */ | |||
| /* > If tau = 0, then H is taken to be the unit matrix. */ | |||
| /* > */ | |||
| /* > To apply H**H (the conjugate transpose of H), supply conjg(tau) instead */ | |||
| /* > tau. */ | |||
| /* > */ | |||
| /* > H is a product of k elementary reflectors as returned by ZTZRZF. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': form H * C */ | |||
| /* > = 'R': form C * H */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] L */ | |||
| /* > \verbatim */ | |||
| /* > L is INTEGER */ | |||
| /* > The number of entries of the vector V containing */ | |||
| /* > the meaningful part of the Householder vectors. */ | |||
| /* > If SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX*16 array, dimension (1+(L-1)*abs(INCV)) */ | |||
| /* > The vector v in the representation of H as returned by */ | |||
| /* > ZTZRZF. V is not used if TAU = 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCV */ | |||
| /* > \verbatim */ | |||
| /* > INCV is INTEGER */ | |||
| /* > The increment between elements of v. INCV <> 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 */ | |||
| /* > The value tau in the representation of H. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX*16 array, dimension (LDC,N) */ | |||
| /* > On entry, the M-by-N matrix C. */ | |||
| /* > On exit, C is overwritten by the matrix H * C if SIDE = 'L', */ | |||
| /* > or C * H if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the array C. LDC >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX*16 array, dimension */ | |||
| /* > (N) if SIDE = 'L' */ | |||
| /* > or (M) if SIDE = 'R' */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERcomputational */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlarz_(char *side, integer *m, integer *n, integer *l, | |||
| doublecomplex *v, integer *incv, doublecomplex *tau, doublecomplex * | |||
| c__, integer *ldc, doublecomplex *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer c_dim1, c_offset; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int zgerc_(integer *, integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *), zgemv_(char *, integer *, integer *, | |||
| doublecomplex *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *), | |||
| zgeru_(integer *, integer *, doublecomplex *, doublecomplex *, | |||
| integer *, doublecomplex *, integer *, doublecomplex *, integer *) | |||
| , zcopy_(integer *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *), zaxpy_(integer *, doublecomplex *, doublecomplex *, | |||
| integer *, doublecomplex *, integer *), zlacgv_(integer *, | |||
| doublecomplex *, integer *); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --v; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (lsame_(side, "L")) { | |||
| /* Form H * C */ | |||
| if (tau->r != 0. || tau->i != 0.) { | |||
| /* w( 1:n ) = conjg( C( 1, 1:n ) ) */ | |||
| zcopy_(n, &c__[c_offset], ldc, &work[1], &c__1); | |||
| zlacgv_(n, &work[1], &c__1); | |||
| /* w( 1:n ) = conjg( w( 1:n ) + C( m-l+1:m, 1:n )**H * v( 1:l ) ) */ | |||
| zgemv_("Conjugate transpose", l, n, &c_b1, &c__[*m - *l + 1 + | |||
| c_dim1], ldc, &v[1], incv, &c_b1, &work[1], &c__1); | |||
| zlacgv_(n, &work[1], &c__1); | |||
| /* C( 1, 1:n ) = C( 1, 1:n ) - tau * w( 1:n ) */ | |||
| z__1.r = -tau->r, z__1.i = -tau->i; | |||
| zaxpy_(n, &z__1, &work[1], &c__1, &c__[c_offset], ldc); | |||
| /* C( m-l+1:m, 1:n ) = C( m-l+1:m, 1:n ) - ... */ | |||
| /* tau * v( 1:l ) * w( 1:n )**H */ | |||
| z__1.r = -tau->r, z__1.i = -tau->i; | |||
| zgeru_(l, n, &z__1, &v[1], incv, &work[1], &c__1, &c__[*m - *l + | |||
| 1 + c_dim1], ldc); | |||
| } | |||
| } else { | |||
| /* Form C * H */ | |||
| if (tau->r != 0. || tau->i != 0.) { | |||
| /* w( 1:m ) = C( 1:m, 1 ) */ | |||
| zcopy_(m, &c__[c_offset], &c__1, &work[1], &c__1); | |||
| /* w( 1:m ) = w( 1:m ) + C( 1:m, n-l+1:n, 1:n ) * v( 1:l ) */ | |||
| zgemv_("No transpose", m, l, &c_b1, &c__[(*n - *l + 1) * c_dim1 + | |||
| 1], ldc, &v[1], incv, &c_b1, &work[1], &c__1); | |||
| /* C( 1:m, 1 ) = C( 1:m, 1 ) - tau * w( 1:m ) */ | |||
| z__1.r = -tau->r, z__1.i = -tau->i; | |||
| zaxpy_(m, &z__1, &work[1], &c__1, &c__[c_offset], &c__1); | |||
| /* C( 1:m, n-l+1:n ) = C( 1:m, n-l+1:n ) - ... */ | |||
| /* tau * w( 1:m ) * v( 1:l )**H */ | |||
| z__1.r = -tau->r, z__1.i = -tau->i; | |||
| zgerc_(m, l, &z__1, &work[1], &c__1, &v[1], incv, &c__[(*n - *l + | |||
| 1) * c_dim1 + 1], ldc); | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLARZ */ | |||
| } /* zlarz_ */ | |||
| @@ -0,0 +1,786 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {1.,0.}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLARZB applies a block reflector or its conjugate-transpose to a general matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLARZB + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarzb. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarzb. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarzb. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARZB( SIDE, TRANS, DIRECT, STOREV, M, N, K, L, V, */ | |||
| /* LDV, T, LDT, C, LDC, WORK, LDWORK ) */ | |||
| /* CHARACTER DIRECT, SIDE, STOREV, TRANS */ | |||
| /* INTEGER K, L, LDC, LDT, LDV, LDWORK, M, N */ | |||
| /* COMPLEX*16 C( LDC, * ), T( LDT, * ), V( LDV, * ), */ | |||
| /* $ WORK( LDWORK, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARZB applies a complex block reflector H or its transpose H**H */ | |||
| /* > to a complex distributed M-by-N C from the left or the right. */ | |||
| /* > */ | |||
| /* > Currently, only STOREV = 'R' and DIRECT = 'B' are supported. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': apply H or H**H from the Left */ | |||
| /* > = 'R': apply H or H**H from the Right */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > = 'N': apply H (No transpose) */ | |||
| /* > = 'C': apply H**H (Conjugate transpose) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] DIRECT */ | |||
| /* > \verbatim */ | |||
| /* > DIRECT is CHARACTER*1 */ | |||
| /* > Indicates how H is formed from a product of elementary */ | |||
| /* > reflectors */ | |||
| /* > = 'F': H = H(1) H(2) . . . H(k) (Forward, not supported yet) */ | |||
| /* > = 'B': H = H(k) . . . H(2) H(1) (Backward) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] STOREV */ | |||
| /* > \verbatim */ | |||
| /* > STOREV is CHARACTER*1 */ | |||
| /* > Indicates how the vectors which define the elementary */ | |||
| /* > reflectors are stored: */ | |||
| /* > = 'C': Columnwise (not supported yet) */ | |||
| /* > = 'R': Rowwise */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The order of the matrix T (= the number of elementary */ | |||
| /* > reflectors whose product defines the block reflector). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] L */ | |||
| /* > \verbatim */ | |||
| /* > L is INTEGER */ | |||
| /* > The number of columns of the matrix V containing the */ | |||
| /* > meaningful part of the Householder reflectors. */ | |||
| /* > If SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX*16 array, dimension (LDV,NV). */ | |||
| /* > If STOREV = 'C', NV = K; if STOREV = 'R', NV = L. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the array V. */ | |||
| /* > If STOREV = 'C', LDV >= L; if STOREV = 'R', LDV >= K. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX*16 array, dimension (LDT,K) */ | |||
| /* > The triangular K-by-K matrix T in the representation of the */ | |||
| /* > block reflector. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= K. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX*16 array, dimension (LDC,N) */ | |||
| /* > On entry, the M-by-N matrix C. */ | |||
| /* > On exit, C is overwritten by H*C or H**H*C or C*H or C*H**H. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the array C. LDC >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX*16 array, dimension (LDWORK,K) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDWORK */ | |||
| /* > \verbatim */ | |||
| /* > LDWORK is INTEGER */ | |||
| /* > The leading dimension of the array WORK. */ | |||
| /* > If SIDE = 'L', LDWORK >= f2cmax(1,N); */ | |||
| /* > if SIDE = 'R', LDWORK >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERcomputational */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlarzb_(char *side, char *trans, char *direct, char * | |||
| storev, integer *m, integer *n, integer *k, integer *l, doublecomplex | |||
| *v, integer *ldv, doublecomplex *t, integer *ldt, doublecomplex *c__, | |||
| integer *ldc, doublecomplex *work, integer *ldwork) | |||
| { | |||
| /* System generated locals */ | |||
| integer c_dim1, c_offset, t_dim1, t_offset, v_dim1, v_offset, work_dim1, | |||
| work_offset, i__1, i__2, i__3, i__4, i__5; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer info, i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int zgemm_(char *, char *, integer *, integer *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, doublecomplex *, | |||
| integer *), zcopy_(integer *, doublecomplex *, | |||
| integer *, doublecomplex *, integer *), ztrmm_(char *, char *, | |||
| char *, char *, integer *, integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *), xerbla_(char *, integer *, ftnlen), | |||
| zlacgv_(integer *, doublecomplex *, integer *); | |||
| char transt[1]; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| v_dim1 = *ldv; | |||
| v_offset = 1 + v_dim1 * 1; | |||
| v -= v_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| work_dim1 = *ldwork; | |||
| work_offset = 1 + work_dim1 * 1; | |||
| work -= work_offset; | |||
| /* Function Body */ | |||
| if (*m <= 0 || *n <= 0) { | |||
| return 0; | |||
| } | |||
| /* Check for currently supported options */ | |||
| info = 0; | |||
| if (! lsame_(direct, "B")) { | |||
| info = -3; | |||
| } else if (! lsame_(storev, "R")) { | |||
| info = -4; | |||
| } | |||
| if (info != 0) { | |||
| i__1 = -info; | |||
| xerbla_("ZLARZB", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| if (lsame_(trans, "N")) { | |||
| *(unsigned char *)transt = 'C'; | |||
| } else { | |||
| *(unsigned char *)transt = 'N'; | |||
| } | |||
| if (lsame_(side, "L")) { | |||
| /* Form H * C or H**H * C */ | |||
| /* W( 1:n, 1:k ) = C( 1:k, 1:n )**H */ | |||
| i__1 = *k; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| zcopy_(n, &c__[j + c_dim1], ldc, &work[j * work_dim1 + 1], &c__1); | |||
| /* L10: */ | |||
| } | |||
| /* W( 1:n, 1:k ) = W( 1:n, 1:k ) + ... */ | |||
| /* C( m-l+1:m, 1:n )**H * V( 1:k, 1:l )**T */ | |||
| if (*l > 0) { | |||
| zgemm_("Transpose", "Conjugate transpose", n, k, l, &c_b1, &c__[* | |||
| m - *l + 1 + c_dim1], ldc, &v[v_offset], ldv, &c_b1, & | |||
| work[work_offset], ldwork); | |||
| } | |||
| /* W( 1:n, 1:k ) = W( 1:n, 1:k ) * T**T or W( 1:m, 1:k ) * T */ | |||
| ztrmm_("Right", "Lower", transt, "Non-unit", n, k, &c_b1, &t[t_offset] | |||
| , ldt, &work[work_offset], ldwork); | |||
| /* C( 1:k, 1:n ) = C( 1:k, 1:n ) - W( 1:n, 1:k )**H */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *k; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * c_dim1; | |||
| i__4 = i__ + j * c_dim1; | |||
| i__5 = j + i__ * work_dim1; | |||
| z__1.r = c__[i__4].r - work[i__5].r, z__1.i = c__[i__4].i - | |||
| work[i__5].i; | |||
| c__[i__3].r = z__1.r, c__[i__3].i = z__1.i; | |||
| /* L20: */ | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* C( m-l+1:m, 1:n ) = C( m-l+1:m, 1:n ) - ... */ | |||
| /* V( 1:k, 1:l )**H * W( 1:n, 1:k )**H */ | |||
| if (*l > 0) { | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zgemm_("Transpose", "Transpose", l, n, k, &z__1, &v[v_offset], | |||
| ldv, &work[work_offset], ldwork, &c_b1, &c__[*m - *l + 1 | |||
| + c_dim1], ldc); | |||
| } | |||
| } else if (lsame_(side, "R")) { | |||
| /* Form C * H or C * H**H */ | |||
| /* W( 1:m, 1:k ) = C( 1:m, 1:k ) */ | |||
| i__1 = *k; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| zcopy_(m, &c__[j * c_dim1 + 1], &c__1, &work[j * work_dim1 + 1], & | |||
| c__1); | |||
| /* L40: */ | |||
| } | |||
| /* W( 1:m, 1:k ) = W( 1:m, 1:k ) + ... */ | |||
| /* C( 1:m, n-l+1:n ) * V( 1:k, 1:l )**H */ | |||
| if (*l > 0) { | |||
| zgemm_("No transpose", "Transpose", m, k, l, &c_b1, &c__[(*n - *l | |||
| + 1) * c_dim1 + 1], ldc, &v[v_offset], ldv, &c_b1, &work[ | |||
| work_offset], ldwork); | |||
| } | |||
| /* W( 1:m, 1:k ) = W( 1:m, 1:k ) * conjg( T ) or */ | |||
| /* W( 1:m, 1:k ) * T**H */ | |||
| i__1 = *k; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *k - j + 1; | |||
| zlacgv_(&i__2, &t[j + j * t_dim1], &c__1); | |||
| /* L50: */ | |||
| } | |||
| ztrmm_("Right", "Lower", trans, "Non-unit", m, k, &c_b1, &t[t_offset], | |||
| ldt, &work[work_offset], ldwork); | |||
| i__1 = *k; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *k - j + 1; | |||
| zlacgv_(&i__2, &t[j + j * t_dim1], &c__1); | |||
| /* L60: */ | |||
| } | |||
| /* C( 1:m, 1:k ) = C( 1:m, 1:k ) - W( 1:m, 1:k ) */ | |||
| i__1 = *k; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * c_dim1; | |||
| i__4 = i__ + j * c_dim1; | |||
| i__5 = i__ + j * work_dim1; | |||
| z__1.r = c__[i__4].r - work[i__5].r, z__1.i = c__[i__4].i - | |||
| work[i__5].i; | |||
| c__[i__3].r = z__1.r, c__[i__3].i = z__1.i; | |||
| /* L70: */ | |||
| } | |||
| /* L80: */ | |||
| } | |||
| /* C( 1:m, n-l+1:n ) = C( 1:m, n-l+1:n ) - ... */ | |||
| /* W( 1:m, 1:k ) * conjg( V( 1:k, 1:l ) ) */ | |||
| i__1 = *l; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| zlacgv_(k, &v[j * v_dim1 + 1], &c__1); | |||
| /* L90: */ | |||
| } | |||
| if (*l > 0) { | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zgemm_("No transpose", "No transpose", m, l, k, &z__1, &work[ | |||
| work_offset], ldwork, &v[v_offset], ldv, &c_b1, &c__[(*n | |||
| - *l + 1) * c_dim1 + 1], ldc); | |||
| } | |||
| i__1 = *l; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| zlacgv_(k, &v[j * v_dim1 + 1], &c__1); | |||
| /* L100: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLARZB */ | |||
| } /* zlarzb_ */ | |||
| @@ -0,0 +1,678 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {0.,0.}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLARZT forms the triangular factor T of a block reflector H = I - vtvH. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLARZT + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarzt. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarzt. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarzt. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLARZT( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT ) */ | |||
| /* CHARACTER DIRECT, STOREV */ | |||
| /* INTEGER K, LDT, LDV, N */ | |||
| /* COMPLEX*16 T( LDT, * ), TAU( * ), V( LDV, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLARZT forms the triangular factor T of a complex block reflector */ | |||
| /* > H of order > n, which is defined as a product of k elementary */ | |||
| /* > reflectors. */ | |||
| /* > */ | |||
| /* > If DIRECT = 'F', H = H(1) H(2) . . . H(k) and T is upper triangular; */ | |||
| /* > */ | |||
| /* > If DIRECT = 'B', H = H(k) . . . H(2) H(1) and T is lower triangular. */ | |||
| /* > */ | |||
| /* > If STOREV = 'C', the vector which defines the elementary reflector */ | |||
| /* > H(i) is stored in the i-th column of the array V, and */ | |||
| /* > */ | |||
| /* > H = I - V * T * V**H */ | |||
| /* > */ | |||
| /* > If STOREV = 'R', the vector which defines the elementary reflector */ | |||
| /* > H(i) is stored in the i-th row of the array V, and */ | |||
| /* > */ | |||
| /* > H = I - V**H * T * V */ | |||
| /* > */ | |||
| /* > Currently, only STOREV = 'R' and DIRECT = 'B' are supported. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] DIRECT */ | |||
| /* > \verbatim */ | |||
| /* > DIRECT is CHARACTER*1 */ | |||
| /* > Specifies the order in which the elementary reflectors are */ | |||
| /* > multiplied to form the block reflector: */ | |||
| /* > = 'F': H = H(1) H(2) . . . H(k) (Forward, not supported yet) */ | |||
| /* > = 'B': H = H(k) . . . H(2) H(1) (Backward) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] STOREV */ | |||
| /* > \verbatim */ | |||
| /* > STOREV is CHARACTER*1 */ | |||
| /* > Specifies how the vectors which define the elementary */ | |||
| /* > reflectors are stored (see also Further Details): */ | |||
| /* > = 'C': columnwise (not supported yet) */ | |||
| /* > = 'R': rowwise */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the block reflector H. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The order of the triangular factor T (= the number of */ | |||
| /* > elementary reflectors). K >= 1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX*16 array, dimension */ | |||
| /* > (LDV,K) if STOREV = 'C' */ | |||
| /* > (LDV,N) if STOREV = 'R' */ | |||
| /* > The matrix V. See further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the array V. */ | |||
| /* > If STOREV = 'C', LDV >= f2cmax(1,N); if STOREV = 'R', LDV >= K. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 array, dimension (K) */ | |||
| /* > TAU(i) must contain the scalar factor of the elementary */ | |||
| /* > reflector H(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX*16 array, dimension (LDT,K) */ | |||
| /* > The k by k triangular factor T of the block reflector. */ | |||
| /* > If DIRECT = 'F', T is upper triangular; if DIRECT = 'B', T is */ | |||
| /* > lower triangular. The rest of the array is not used. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= K. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERcomputational */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The shape of the matrix V and the storage of the vectors which define */ | |||
| /* > the H(i) is best illustrated by the following example with n = 5 and */ | |||
| /* > k = 3. The elements equal to 1 are not stored; the corresponding */ | |||
| /* > array elements are modified but restored on exit. The rest of the */ | |||
| /* > array is not used. */ | |||
| /* > */ | |||
| /* > DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R': */ | |||
| /* > */ | |||
| /* > ______V_____ */ | |||
| /* > ( v1 v2 v3 ) / \ */ | |||
| /* > ( v1 v2 v3 ) ( v1 v1 v1 v1 v1 . . . . 1 ) */ | |||
| /* > V = ( v1 v2 v3 ) ( v2 v2 v2 v2 v2 . . . 1 ) */ | |||
| /* > ( v1 v2 v3 ) ( v3 v3 v3 v3 v3 . . 1 ) */ | |||
| /* > ( v1 v2 v3 ) */ | |||
| /* > . . . */ | |||
| /* > . . . */ | |||
| /* > 1 . . */ | |||
| /* > 1 . */ | |||
| /* > 1 */ | |||
| /* > */ | |||
| /* > DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R': */ | |||
| /* > */ | |||
| /* > ______V_____ */ | |||
| /* > 1 / \ */ | |||
| /* > . 1 ( 1 . . . . v1 v1 v1 v1 v1 ) */ | |||
| /* > . . 1 ( . 1 . . . v2 v2 v2 v2 v2 ) */ | |||
| /* > . . . ( . . 1 . . v3 v3 v3 v3 v3 ) */ | |||
| /* > . . . */ | |||
| /* > ( v1 v2 v3 ) */ | |||
| /* > ( v1 v2 v3 ) */ | |||
| /* > V = ( v1 v2 v3 ) */ | |||
| /* > ( v1 v2 v3 ) */ | |||
| /* > ( v1 v2 v3 ) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlarzt_(char *direct, char *storev, integer *n, integer * | |||
| k, doublecomplex *v, integer *ldv, doublecomplex *tau, doublecomplex * | |||
| t, integer *ldt) | |||
| { | |||
| /* System generated locals */ | |||
| integer t_dim1, t_offset, v_dim1, v_offset, i__1, i__2; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer info, i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int zgemv_(char *, integer *, integer *, | |||
| doublecomplex *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *), | |||
| ztrmv_(char *, char *, char *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, integer *), | |||
| xerbla_(char *, integer *, ftnlen), zlacgv_(integer *, | |||
| doublecomplex *, integer *); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Check for currently supported options */ | |||
| /* Parameter adjustments */ | |||
| v_dim1 = *ldv; | |||
| v_offset = 1 + v_dim1 * 1; | |||
| v -= v_offset; | |||
| --tau; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| /* Function Body */ | |||
| info = 0; | |||
| if (! lsame_(direct, "B")) { | |||
| info = -1; | |||
| } else if (! lsame_(storev, "R")) { | |||
| info = -2; | |||
| } | |||
| if (info != 0) { | |||
| i__1 = -info; | |||
| xerbla_("ZLARZT", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| for (i__ = *k; i__ >= 1; --i__) { | |||
| i__1 = i__; | |||
| if (tau[i__1].r == 0. && tau[i__1].i == 0.) { | |||
| /* H(i) = I */ | |||
| i__1 = *k; | |||
| for (j = i__; j <= i__1; ++j) { | |||
| i__2 = j + i__ * t_dim1; | |||
| t[i__2].r = 0., t[i__2].i = 0.; | |||
| /* L10: */ | |||
| } | |||
| } else { | |||
| /* general case */ | |||
| if (i__ < *k) { | |||
| /* T(i+1:k,i) = - tau(i) * V(i+1:k,1:n) * V(i,1:n)**H */ | |||
| zlacgv_(n, &v[i__ + v_dim1], ldv); | |||
| i__1 = *k - i__; | |||
| i__2 = i__; | |||
| z__1.r = -tau[i__2].r, z__1.i = -tau[i__2].i; | |||
| zgemv_("No transpose", &i__1, n, &z__1, &v[i__ + 1 + v_dim1], | |||
| ldv, &v[i__ + v_dim1], ldv, &c_b1, &t[i__ + 1 + i__ * | |||
| t_dim1], &c__1); | |||
| zlacgv_(n, &v[i__ + v_dim1], ldv); | |||
| /* T(i+1:k,i) = T(i+1:k,i+1:k) * T(i+1:k,i) */ | |||
| i__1 = *k - i__; | |||
| ztrmv_("Lower", "No transpose", "Non-unit", &i__1, &t[i__ + 1 | |||
| + (i__ + 1) * t_dim1], ldt, &t[i__ + 1 + i__ * t_dim1] | |||
| , &c__1); | |||
| } | |||
| i__1 = i__ + i__ * t_dim1; | |||
| i__2 = i__; | |||
| t[i__1].r = tau[i__2].r, t[i__1].i = tau[i__2].i; | |||
| } | |||
| /* L20: */ | |||
| } | |||
| return 0; | |||
| /* End of ZLARZT */ | |||
| } /* zlarzt_ */ | |||
| @@ -0,0 +1,818 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLASCL + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlascl. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlascl. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlascl. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLASCL( TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO ) */ | |||
| /* CHARACTER TYPE */ | |||
| /* INTEGER INFO, KL, KU, LDA, M, N */ | |||
| /* DOUBLE PRECISION CFROM, CTO */ | |||
| /* COMPLEX*16 A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLASCL multiplies the M by N complex matrix A by the real scalar */ | |||
| /* > CTO/CFROM. This is done without over/underflow as long as the final */ | |||
| /* > result CTO*A(I,J)/CFROM does not over/underflow. TYPE specifies that */ | |||
| /* > A may be full, upper triangular, lower triangular, upper Hessenberg, */ | |||
| /* > or banded. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] TYPE */ | |||
| /* > \verbatim */ | |||
| /* > TYPE is CHARACTER*1 */ | |||
| /* > TYPE indices the storage type of the input matrix. */ | |||
| /* > = 'G': A is a full matrix. */ | |||
| /* > = 'L': A is a lower triangular matrix. */ | |||
| /* > = 'U': A is an upper triangular matrix. */ | |||
| /* > = 'H': A is an upper Hessenberg matrix. */ | |||
| /* > = 'B': A is a symmetric band matrix with lower bandwidth KL */ | |||
| /* > and upper bandwidth KU and with the only the lower */ | |||
| /* > half stored. */ | |||
| /* > = 'Q': A is a symmetric band matrix with lower bandwidth KL */ | |||
| /* > and upper bandwidth KU and with the only the upper */ | |||
| /* > half stored. */ | |||
| /* > = 'Z': A is a band matrix with lower bandwidth KL and upper */ | |||
| /* > bandwidth KU. See ZGBTRF for storage details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KL */ | |||
| /* > \verbatim */ | |||
| /* > KL is INTEGER */ | |||
| /* > The lower bandwidth of A. Referenced only if TYPE = 'B', */ | |||
| /* > 'Q' or 'Z'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KU */ | |||
| /* > \verbatim */ | |||
| /* > KU is INTEGER */ | |||
| /* > The upper bandwidth of A. Referenced only if TYPE = 'B', */ | |||
| /* > 'Q' or 'Z'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] CFROM */ | |||
| /* > \verbatim */ | |||
| /* > CFROM is DOUBLE PRECISION */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] CTO */ | |||
| /* > \verbatim */ | |||
| /* > CTO is DOUBLE PRECISION */ | |||
| /* > */ | |||
| /* > The matrix A is multiplied by CTO/CFROM. A(I,J) is computed */ | |||
| /* > without over/underflow if the final result CTO*A(I,J)/CFROM */ | |||
| /* > can be represented without over/underflow. CFROM must be */ | |||
| /* > nonzero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > The matrix to be multiplied by CTO/CFROM. See TYPE for the */ | |||
| /* > storage type. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. */ | |||
| /* > If TYPE = 'G', 'L', 'U', 'H', LDA >= f2cmax(1,M); */ | |||
| /* > TYPE = 'B', LDA >= KL+1; */ | |||
| /* > TYPE = 'Q', LDA >= KU+1; */ | |||
| /* > TYPE = 'Z', LDA >= 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > 0 - successful exit */ | |||
| /* > <0 - if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlascl_(char *type__, integer *kl, integer *ku, | |||
| doublereal *cfrom, doublereal *cto, integer *m, integer *n, | |||
| doublecomplex *a, integer *lda, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| logical done; | |||
| doublereal ctoc; | |||
| integer i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| integer itype, k1, k2, k3, k4; | |||
| doublereal cfrom1; | |||
| extern doublereal dlamch_(char *); | |||
| doublereal cfromc; | |||
| extern logical disnan_(doublereal *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| doublereal bignum, smlnum, mul, cto1; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (lsame_(type__, "G")) { | |||
| itype = 0; | |||
| } else if (lsame_(type__, "L")) { | |||
| itype = 1; | |||
| } else if (lsame_(type__, "U")) { | |||
| itype = 2; | |||
| } else if (lsame_(type__, "H")) { | |||
| itype = 3; | |||
| } else if (lsame_(type__, "B")) { | |||
| itype = 4; | |||
| } else if (lsame_(type__, "Q")) { | |||
| itype = 5; | |||
| } else if (lsame_(type__, "Z")) { | |||
| itype = 6; | |||
| } else { | |||
| itype = -1; | |||
| } | |||
| if (itype == -1) { | |||
| *info = -1; | |||
| } else if (*cfrom == 0. || disnan_(cfrom)) { | |||
| *info = -4; | |||
| } else if (disnan_(cto)) { | |||
| *info = -5; | |||
| } else if (*m < 0) { | |||
| *info = -6; | |||
| } else if (*n < 0 || itype == 4 && *n != *m || itype == 5 && *n != *m) { | |||
| *info = -7; | |||
| } else if (itype <= 3 && *lda < f2cmax(1,*m)) { | |||
| *info = -9; | |||
| } else if (itype >= 4) { | |||
| /* Computing MAX */ | |||
| i__1 = *m - 1; | |||
| if (*kl < 0 || *kl > f2cmax(i__1,0)) { | |||
| *info = -2; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = *n - 1; | |||
| if (*ku < 0 || *ku > f2cmax(i__1,0) || (itype == 4 || itype == 5) && | |||
| *kl != *ku) { | |||
| *info = -3; | |||
| } else if (itype == 4 && *lda < *kl + 1 || itype == 5 && *lda < * | |||
| ku + 1 || itype == 6 && *lda < (*kl << 1) + *ku + 1) { | |||
| *info = -9; | |||
| } | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("ZLASCL", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0 || *m == 0) { | |||
| return 0; | |||
| } | |||
| /* Get machine parameters */ | |||
| smlnum = dlamch_("S"); | |||
| bignum = 1. / smlnum; | |||
| cfromc = *cfrom; | |||
| ctoc = *cto; | |||
| L10: | |||
| cfrom1 = cfromc * smlnum; | |||
| if (cfrom1 == cfromc) { | |||
| /* CFROMC is an inf. Multiply by a correctly signed zero for */ | |||
| /* finite CTOC, or a NaN if CTOC is infinite. */ | |||
| mul = ctoc / cfromc; | |||
| done = TRUE_; | |||
| cto1 = ctoc; | |||
| } else { | |||
| cto1 = ctoc / bignum; | |||
| if (cto1 == ctoc) { | |||
| /* CTOC is either 0 or an inf. In both cases, CTOC itself */ | |||
| /* serves as the correct multiplication factor. */ | |||
| mul = ctoc; | |||
| done = TRUE_; | |||
| cfromc = 1.; | |||
| } else if (abs(cfrom1) > abs(ctoc) && ctoc != 0.) { | |||
| mul = smlnum; | |||
| done = FALSE_; | |||
| cfromc = cfrom1; | |||
| } else if (abs(cto1) > abs(cfromc)) { | |||
| mul = bignum; | |||
| done = FALSE_; | |||
| ctoc = cto1; | |||
| } else { | |||
| mul = ctoc / cfromc; | |||
| done = TRUE_; | |||
| } | |||
| } | |||
| if (itype == 0) { | |||
| /* Full matrix */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i; | |||
| a[i__3].r = z__1.r, a[i__3].i = z__1.i; | |||
| /* L20: */ | |||
| } | |||
| /* L30: */ | |||
| } | |||
| } else if (itype == 1) { | |||
| /* Lower triangular matrix */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = j; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i; | |||
| a[i__3].r = z__1.r, a[i__3].i = z__1.i; | |||
| /* L40: */ | |||
| } | |||
| /* L50: */ | |||
| } | |||
| } else if (itype == 2) { | |||
| /* Upper triangular matrix */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = f2cmin(j,*m); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i; | |||
| a[i__3].r = z__1.r, a[i__3].i = z__1.i; | |||
| /* L60: */ | |||
| } | |||
| /* L70: */ | |||
| } | |||
| } else if (itype == 3) { | |||
| /* Upper Hessenberg matrix */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__3 = j + 1; | |||
| i__2 = f2cmin(i__3,*m); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i; | |||
| a[i__3].r = z__1.r, a[i__3].i = z__1.i; | |||
| /* L80: */ | |||
| } | |||
| /* L90: */ | |||
| } | |||
| } else if (itype == 4) { | |||
| /* Lower half of a symmetric band matrix */ | |||
| k3 = *kl + 1; | |||
| k4 = *n + 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__3 = k3, i__4 = k4 - j; | |||
| i__2 = f2cmin(i__3,i__4); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i; | |||
| a[i__3].r = z__1.r, a[i__3].i = z__1.i; | |||
| /* L100: */ | |||
| } | |||
| /* L110: */ | |||
| } | |||
| } else if (itype == 5) { | |||
| /* Upper half of a symmetric band matrix */ | |||
| k1 = *ku + 2; | |||
| k3 = *ku + 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__2 = k1 - j; | |||
| i__3 = k3; | |||
| for (i__ = f2cmax(i__2,1); i__ <= i__3; ++i__) { | |||
| i__2 = i__ + j * a_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i; | |||
| a[i__2].r = z__1.r, a[i__2].i = z__1.i; | |||
| /* L120: */ | |||
| } | |||
| /* L130: */ | |||
| } | |||
| } else if (itype == 6) { | |||
| /* Band matrix */ | |||
| k1 = *kl + *ku + 2; | |||
| k2 = *kl + 1; | |||
| k3 = (*kl << 1) + *ku + 1; | |||
| k4 = *kl + *ku + 1 + *m; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__3 = k1 - j; | |||
| /* Computing MIN */ | |||
| i__4 = k3, i__5 = k4 - j; | |||
| i__2 = f2cmin(i__4,i__5); | |||
| for (i__ = f2cmax(i__3,k2); i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i; | |||
| a[i__3].r = z__1.r, a[i__3].i = z__1.i; | |||
| /* L140: */ | |||
| } | |||
| /* L150: */ | |||
| } | |||
| } | |||
| if (! done) { | |||
| goto L10; | |||
| } | |||
| return 0; | |||
| /* End of ZLASCL */ | |||
| } /* zlascl_ */ | |||
| @@ -0,0 +1,519 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLASCL2 performs diagonal scaling on a vector. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLASCL2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlascl2 | |||
| .f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlascl2 | |||
| .f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlascl2 | |||
| .f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLASCL2 ( M, N, D, X, LDX ) */ | |||
| /* INTEGER M, N, LDX */ | |||
| /* DOUBLE PRECISION D( * ) */ | |||
| /* COMPLEX*16 X( LDX, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLASCL2 performs a diagonal scaling on a vector: */ | |||
| /* > x <-- D * x */ | |||
| /* > where the DOUBLE PRECISION diagonal matrix D is stored as a vector. */ | |||
| /* > */ | |||
| /* > Eventually to be replaced by BLAS_zge_diag_scale in the new BLAS */ | |||
| /* > standard. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of D and X. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of X. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] D */ | |||
| /* > \verbatim */ | |||
| /* > D is DOUBLE PRECISION array, length M */ | |||
| /* > Diagonal matrix D, stored as a vector of length M. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension (LDX,N) */ | |||
| /* > On entry, the vector X to be scaled by D. */ | |||
| /* > On exit, the scaled vector. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDX */ | |||
| /* > \verbatim */ | |||
| /* > LDX is INTEGER */ | |||
| /* > The leading dimension of the vector X. LDX >= M. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complex16OTHERcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlascl2_(integer *m, integer *n, doublereal *d__, | |||
| doublecomplex *x, integer *ldx) | |||
| { | |||
| /* System generated locals */ | |||
| integer x_dim1, x_offset, i__1, i__2, i__3, i__4, i__5; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --d__; | |||
| x_dim1 = *ldx; | |||
| x_offset = 1 + x_dim1 * 1; | |||
| x -= x_offset; | |||
| /* Function Body */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * x_dim1; | |||
| i__4 = i__ + j * x_dim1; | |||
| i__5 = i__; | |||
| z__1.r = d__[i__5] * x[i__4].r, z__1.i = d__[i__5] * x[i__4].i; | |||
| x[i__3].r = z__1.r, x[i__3].i = z__1.i; | |||
| } | |||
| } | |||
| return 0; | |||
| } /* zlascl2_ */ | |||
| @@ -0,0 +1,596 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given val | |||
| ues. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLASET + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaset. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaset. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaset. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLASET( UPLO, M, N, ALPHA, BETA, A, LDA ) */ | |||
| /* CHARACTER UPLO */ | |||
| /* INTEGER LDA, M, N */ | |||
| /* COMPLEX*16 ALPHA, BETA */ | |||
| /* COMPLEX*16 A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLASET initializes a 2-D array A to BETA on the diagonal and */ | |||
| /* > ALPHA on the offdiagonals. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > Specifies the part of the matrix A to be set. */ | |||
| /* > = 'U': Upper triangular part is set. The lower triangle */ | |||
| /* > is unchanged. */ | |||
| /* > = 'L': Lower triangular part is set. The upper triangle */ | |||
| /* > is unchanged. */ | |||
| /* > Otherwise: All of the matrix A is set. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > On entry, M specifies the number of rows of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > On entry, N specifies the number of columns of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ALPHA */ | |||
| /* > \verbatim */ | |||
| /* > ALPHA is COMPLEX*16 */ | |||
| /* > All the offdiagonal array elements are set to ALPHA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] BETA */ | |||
| /* > \verbatim */ | |||
| /* > BETA is COMPLEX*16 */ | |||
| /* > All the diagonal array elements are set to BETA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the m by n matrix A. */ | |||
| /* > On exit, A(i,j) = ALPHA, 1 <= i <= m, 1 <= j <= n, i.ne.j; */ | |||
| /* > A(i,i) = BETA , 1 <= i <= f2cmin(m,n) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaset_(char *uplo, integer *m, integer *n, | |||
| doublecomplex *alpha, doublecomplex *beta, doublecomplex *a, integer * | |||
| lda) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| /* Function Body */ | |||
| if (lsame_(uplo, "U")) { | |||
| /* Set the diagonal to BETA and the strictly upper triangular */ | |||
| /* part of the array to ALPHA. */ | |||
| i__1 = *n; | |||
| for (j = 2; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__3 = j - 1; | |||
| i__2 = f2cmin(i__3,*m); | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| a[i__3].r = alpha->r, a[i__3].i = alpha->i; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| i__1 = f2cmin(*n,*m); | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = beta->r, a[i__2].i = beta->i; | |||
| /* L30: */ | |||
| } | |||
| } else if (lsame_(uplo, "L")) { | |||
| /* Set the diagonal to BETA and the strictly lower triangular */ | |||
| /* part of the array to ALPHA. */ | |||
| i__1 = f2cmin(*m,*n); | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = j + 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| a[i__3].r = alpha->r, a[i__3].i = alpha->i; | |||
| /* L40: */ | |||
| } | |||
| /* L50: */ | |||
| } | |||
| i__1 = f2cmin(*n,*m); | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = beta->r, a[i__2].i = beta->i; | |||
| /* L60: */ | |||
| } | |||
| } else { | |||
| /* Set the array to BETA on the diagonal and ALPHA on the */ | |||
| /* offdiagonal. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| a[i__3].r = alpha->r, a[i__3].i = alpha->i; | |||
| /* L70: */ | |||
| } | |||
| /* L80: */ | |||
| } | |||
| i__1 = f2cmin(*m,*n); | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = beta->r, a[i__2].i = beta->i; | |||
| /* L90: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLASET */ | |||
| } /* zlaset_ */ | |||
| @@ -0,0 +1,560 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLASSQ updates a sum of squares represented in scaled form. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLASSQ + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlassq. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlassq. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlassq. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLASSQ( N, X, INCX, SCALE, SUMSQ ) */ | |||
| /* INTEGER INCX, N */ | |||
| /* DOUBLE PRECISION SCALE, SUMSQ */ | |||
| /* COMPLEX*16 X( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLASSQ returns the values scl and ssq such that */ | |||
| /* > */ | |||
| /* > ( scl**2 )*ssq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq, */ | |||
| /* > */ | |||
| /* > where x( i ) = abs( X( 1 + ( i - 1 )*INCX ) ). The value of sumsq is */ | |||
| /* > assumed to be at least unity and the value of ssq will then satisfy */ | |||
| /* > */ | |||
| /* > 1.0 <= ssq <= ( sumsq + 2*n ). */ | |||
| /* > */ | |||
| /* > scale is assumed to be non-negative and scl returns the value */ | |||
| /* > */ | |||
| /* > scl = f2cmax( scale, abs( real( x( i ) ) ), abs( aimag( x( i ) ) ) ), */ | |||
| /* > i */ | |||
| /* > */ | |||
| /* > scale and sumsq must be supplied in SCALE and SUMSQ respectively. */ | |||
| /* > SCALE and SUMSQ are overwritten by scl and ssq respectively. */ | |||
| /* > */ | |||
| /* > The routine makes only one pass through the vector X. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of elements to be used from the vector X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX*16 array, dimension (1+(N-1)*INCX) */ | |||
| /* > The vector x as described above. */ | |||
| /* > x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCX */ | |||
| /* > \verbatim */ | |||
| /* > INCX is INTEGER */ | |||
| /* > The increment between successive values of the vector X. */ | |||
| /* > INCX > 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] SCALE */ | |||
| /* > \verbatim */ | |||
| /* > SCALE is DOUBLE PRECISION */ | |||
| /* > On entry, the value scale in the equation above. */ | |||
| /* > On exit, SCALE is overwritten with the value scl . */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] SUMSQ */ | |||
| /* > \verbatim */ | |||
| /* > SUMSQ is DOUBLE PRECISION */ | |||
| /* > On entry, the value sumsq in the equation above. */ | |||
| /* > On exit, SUMSQ is overwritten with the value ssq . */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlassq_(integer *n, doublecomplex *x, integer *incx, | |||
| doublereal *scale, doublereal *sumsq) | |||
| { | |||
| /* System generated locals */ | |||
| integer i__1, i__2, i__3; | |||
| doublereal d__1; | |||
| /* Local variables */ | |||
| doublereal temp1; | |||
| integer ix; | |||
| extern logical disnan_(doublereal *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --x; | |||
| /* Function Body */ | |||
| if (*n > 0) { | |||
| i__1 = (*n - 1) * *incx + 1; | |||
| i__2 = *incx; | |||
| for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) { | |||
| i__3 = ix; | |||
| temp1 = (d__1 = x[i__3].r, abs(d__1)); | |||
| if (temp1 > 0. || disnan_(&temp1)) { | |||
| if (*scale < temp1) { | |||
| /* Computing 2nd power */ | |||
| d__1 = *scale / temp1; | |||
| *sumsq = *sumsq * (d__1 * d__1) + 1; | |||
| *scale = temp1; | |||
| } else { | |||
| /* Computing 2nd power */ | |||
| d__1 = temp1 / *scale; | |||
| *sumsq += d__1 * d__1; | |||
| } | |||
| } | |||
| temp1 = (d__1 = d_imag(&x[ix]), abs(d__1)); | |||
| if (temp1 > 0. || disnan_(&temp1)) { | |||
| if (*scale < temp1) { | |||
| /* Computing 2nd power */ | |||
| d__1 = *scale / temp1; | |||
| *sumsq = *sumsq * (d__1 * d__1) + 1; | |||
| *scale = temp1; | |||
| } else { | |||
| /* Computing 2nd power */ | |||
| d__1 = temp1 / *scale; | |||
| *sumsq += d__1 * d__1; | |||
| } | |||
| } | |||
| /* L10: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLASSQ */ | |||
| } /* zlassq_ */ | |||
| @@ -0,0 +1,671 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__0 = 0; | |||
| /* > \brief \b ZLASWLQ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLASWLQ( M, N, MB, NB, A, LDA, T, LDT, WORK, */ | |||
| /* LWORK, INFO) */ | |||
| /* INTEGER INFO, LDA, M, N, MB, NB, LDT, LWORK */ | |||
| /* COMPLEX*16 A( LDA, * ), T( LDT, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLASWLQ computes a blocked Tall-Skinny LQ factorization of */ | |||
| /* > a complexx M-by-N matrix A for M <= N: */ | |||
| /* > */ | |||
| /* > A = ( L 0 ) * Q, */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a n-by-N orthogonal matrix, stored on exit in an implicit */ | |||
| /* > form in the elements above the digonal of the array A and in */ | |||
| /* > the elemenst of the array T; */ | |||
| /* > L is an lower-triangular M-by-M matrix stored on exit in */ | |||
| /* > the elements on and below the diagonal of the array A. */ | |||
| /* > 0 is a M-by-(N-M) zero matrix, if M < N, and is not stored. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] MB */ | |||
| /* > \verbatim */ | |||
| /* > MB is INTEGER */ | |||
| /* > The row block size to be used in the blocked QR. */ | |||
| /* > M >= MB >= 1 */ | |||
| /* > \endverbatim */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The column block size to be used in the blocked QR. */ | |||
| /* > NB > M. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the elements on and below the diagonal */ | |||
| /* > of the array contain the N-by-N lower triangular matrix L; */ | |||
| /* > the elements above the diagonal represent Q by the rows */ | |||
| /* > of blocked V (see Further Details). */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX*16 array, */ | |||
| /* > dimension (LDT, N * Number_of_row_blocks) */ | |||
| /* > where Number_of_row_blocks = CEIL((N-M)/(NB-M)) */ | |||
| /* > The blocked upper triangular block reflectors stored in compact form */ | |||
| /* > as a sequence of upper triangular blocks. */ | |||
| /* > See Further Details below. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= MB. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > (workspace) COMPLEX*16 array, dimension (MAX(1,LWORK)) */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > The dimension of the array WORK. LWORK >= MB*M. */ | |||
| /* > If LWORK = -1, then a workspace query is assumed; the routine */ | |||
| /* > only calculates the optimal size of the WORK array, returns */ | |||
| /* > this value as the first entry of the WORK array, and no error */ | |||
| /* > message related to LWORK is issued by XERBLA. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > Short-Wide LQ (SWLQ) performs LQ by a sequence of orthogonal transformations, */ | |||
| /* > representing Q as a product of other orthogonal matrices */ | |||
| /* > Q = Q(1) * Q(2) * . . . * Q(k) */ | |||
| /* > where each Q(i) zeros out upper diagonal entries of a block of NB rows of A: */ | |||
| /* > Q(1) zeros out the upper diagonal entries of rows 1:NB of A */ | |||
| /* > Q(2) zeros out the bottom MB-N rows of rows [1:M,NB+1:2*NB-M] of A */ | |||
| /* > Q(3) zeros out the bottom MB-N rows of rows [1:M,2*NB-M+1:3*NB-2*M] of A */ | |||
| /* > . . . */ | |||
| /* > */ | |||
| /* > Q(1) is computed by GELQT, which represents Q(1) by Householder vectors */ | |||
| /* > stored under the diagonal of rows 1:MB of A, and by upper triangular */ | |||
| /* > block reflectors, stored in array T(1:LDT,1:N). */ | |||
| /* > For more information see Further Details in GELQT. */ | |||
| /* > */ | |||
| /* > Q(i) for i>1 is computed by TPLQT, which represents Q(i) by Householder vectors */ | |||
| /* > stored in columns [(i-1)*(NB-M)+M+1:i*(NB-M)+M] of A, and by upper triangular */ | |||
| /* > block reflectors, stored in array T(1:LDT,(i-1)*M+1:i*M). */ | |||
| /* > The last Q(k) may use fewer rows. */ | |||
| /* > For more information see Further Details in TPQRT. */ | |||
| /* > */ | |||
| /* > For more details of the overall algorithm, see the description of */ | |||
| /* > Sequential TSQR in Section 2.2 of [1]. */ | |||
| /* > */ | |||
| /* > [1] “Communication-Optimal Parallel and Sequential QR and LU Factorizations, */ | |||
| /* > J. Demmel, L. Grigori, M. Hoemmen, J. Langou, */ | |||
| /* > SIAM J. Sci. Comput, vol. 34, no. 1, 2012 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaswlq_(integer *m, integer *n, integer *mb, integer * | |||
| nb, doublecomplex *a, integer *lda, doublecomplex *t, integer *ldt, | |||
| doublecomplex *work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, i__1, i__2, i__3; | |||
| /* Local variables */ | |||
| integer i__, ii, kk; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), zgelqt_( | |||
| integer *, integer *, integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *); | |||
| logical lquery; | |||
| extern /* Subroutine */ int ztplqt_(integer *, integer *, integer *, | |||
| integer *, doublecomplex *, integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *); | |||
| integer ctr; | |||
| /* -- LAPACK computational routine (version 3.9.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd. -- */ | |||
| /* June 2017 */ | |||
| /* ===================================================================== */ | |||
| /* TEST THE INPUT ARGUMENTS */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0 || *n < *m) { | |||
| *info = -2; | |||
| } else if (*mb < 1 || *mb > *m && *m > 0) { | |||
| *info = -3; | |||
| } else if (*nb <= *m) { | |||
| *info = -4; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -5; | |||
| } else if (*ldt < *mb) { | |||
| *info = -8; | |||
| } else if (*lwork < *m * *mb && ! lquery) { | |||
| *info = -10; | |||
| } | |||
| if (*info == 0) { | |||
| i__1 = *mb * *m; | |||
| work[1].r = (doublereal) i__1, work[1].i = 0.; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("ZLASWLQ", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (f2cmin(*m,*n) == 0) { | |||
| return 0; | |||
| } | |||
| /* The LQ Decomposition */ | |||
| if (*m >= *n || *nb <= *m || *nb >= *n) { | |||
| zgelqt_(m, n, mb, &a[a_offset], lda, &t[t_offset], ldt, &work[1], | |||
| info); | |||
| return 0; | |||
| } | |||
| kk = (*n - *m) % (*nb - *m); | |||
| ii = *n - kk + 1; | |||
| /* Compute the LQ factorization of the first block A(1:M,1:NB) */ | |||
| zgelqt_(m, nb, mb, &a[a_dim1 + 1], lda, &t[t_offset], ldt, &work[1], info) | |||
| ; | |||
| ctr = 1; | |||
| i__1 = ii - *nb + *m; | |||
| i__2 = *nb - *m; | |||
| for (i__ = *nb + 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Compute the QR factorization of the current block A(1:M,I:I+NB-M) */ | |||
| i__3 = *nb - *m; | |||
| ztplqt_(m, &i__3, &c__0, mb, &a[a_dim1 + 1], lda, &a[i__ * a_dim1 + 1] | |||
| , lda, &t[(ctr * *m + 1) * t_dim1 + 1], ldt, &work[1], info); | |||
| ++ctr; | |||
| } | |||
| /* Compute the QR factorization of the last block A(1:M,II:N) */ | |||
| if (ii <= *n) { | |||
| ztplqt_(m, &kk, &c__0, mb, &a[a_dim1 + 1], lda, &a[ii * a_dim1 + 1], | |||
| lda, &t[(ctr * *m + 1) * t_dim1 + 1], ldt, &work[1], info); | |||
| } | |||
| i__2 = *m * *mb; | |||
| work[1].r = (doublereal) i__2, work[1].i = 0.; | |||
| return 0; | |||
| /* End of ZLASWLQ */ | |||
| } /* zlaswlq_ */ | |||
| @@ -0,0 +1,606 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLASWP performs a series of row interchanges on a general rectangular matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLASWP + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaswp. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaswp. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaswp. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLASWP( N, A, LDA, K1, K2, IPIV, INCX ) */ | |||
| /* INTEGER INCX, K1, K2, LDA, N */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLASWP performs a series of row interchanges on the matrix A. */ | |||
| /* > One row interchange is initiated for each of rows K1 through K2 of A. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the matrix of column dimension N to which the row */ | |||
| /* > interchanges will be applied. */ | |||
| /* > On exit, the permuted matrix. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K1 */ | |||
| /* > \verbatim */ | |||
| /* > K1 is INTEGER */ | |||
| /* > The first element of IPIV for which a row interchange will */ | |||
| /* > be done. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K2 */ | |||
| /* > \verbatim */ | |||
| /* > K2 is INTEGER */ | |||
| /* > (K2-K1+1) is the number of elements of IPIV for which a row */ | |||
| /* > interchange will be done. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (K1+(K2-K1)*abs(INCX)) */ | |||
| /* > The vector of pivot indices. Only the elements in positions */ | |||
| /* > K1 through K1+(K2-K1)*abs(INCX) of IPIV are accessed. */ | |||
| /* > IPIV(K1+(K-K1)*abs(INCX)) = L implies rows K and L are to be */ | |||
| /* > interchanged. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCX */ | |||
| /* > \verbatim */ | |||
| /* > INCX is INTEGER */ | |||
| /* > The increment between successive values of IPIV. If INCX */ | |||
| /* > is negative, the pivots are applied in reverse order. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2017 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > Modified by */ | |||
| /* > R. C. Whaley, Computer Science Dept., Univ. of Tenn., Knoxville, USA */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlaswp_(integer *n, doublecomplex *a, integer *lda, | |||
| integer *k1, integer *k2, integer *ipiv, integer *incx) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6; | |||
| /* Local variables */ | |||
| doublecomplex temp; | |||
| integer i__, j, k, i1, i2, n32, ip, ix, ix0, inc; | |||
| /* -- LAPACK auxiliary routine (version 3.7.1) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2017 */ | |||
| /* ===================================================================== */ | |||
| /* Interchange row I with row IPIV(K1+(I-K1)*abs(INCX)) for each of rows */ | |||
| /* K1 through K2. */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --ipiv; | |||
| /* Function Body */ | |||
| if (*incx > 0) { | |||
| ix0 = *k1; | |||
| i1 = *k1; | |||
| i2 = *k2; | |||
| inc = 1; | |||
| } else if (*incx < 0) { | |||
| ix0 = *k1 + (*k1 - *k2) * *incx; | |||
| i1 = *k2; | |||
| i2 = *k1; | |||
| inc = -1; | |||
| } else { | |||
| return 0; | |||
| } | |||
| n32 = *n / 32 << 5; | |||
| if (n32 != 0) { | |||
| i__1 = n32; | |||
| for (j = 1; j <= i__1; j += 32) { | |||
| ix = ix0; | |||
| i__2 = i2; | |||
| i__3 = inc; | |||
| for (i__ = i1; i__3 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__3) | |||
| { | |||
| ip = ipiv[ix]; | |||
| if (ip != i__) { | |||
| i__4 = j + 31; | |||
| for (k = j; k <= i__4; ++k) { | |||
| i__5 = i__ + k * a_dim1; | |||
| temp.r = a[i__5].r, temp.i = a[i__5].i; | |||
| i__5 = i__ + k * a_dim1; | |||
| i__6 = ip + k * a_dim1; | |||
| a[i__5].r = a[i__6].r, a[i__5].i = a[i__6].i; | |||
| i__5 = ip + k * a_dim1; | |||
| a[i__5].r = temp.r, a[i__5].i = temp.i; | |||
| /* L10: */ | |||
| } | |||
| } | |||
| ix += *incx; | |||
| /* L20: */ | |||
| } | |||
| /* L30: */ | |||
| } | |||
| } | |||
| if (n32 != *n) { | |||
| ++n32; | |||
| ix = ix0; | |||
| i__1 = i2; | |||
| i__3 = inc; | |||
| for (i__ = i1; i__3 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__3) { | |||
| ip = ipiv[ix]; | |||
| if (ip != i__) { | |||
| i__2 = *n; | |||
| for (k = n32; k <= i__2; ++k) { | |||
| i__4 = i__ + k * a_dim1; | |||
| temp.r = a[i__4].r, temp.i = a[i__4].i; | |||
| i__4 = i__ + k * a_dim1; | |||
| i__5 = ip + k * a_dim1; | |||
| a[i__4].r = a[i__5].r, a[i__4].i = a[i__5].i; | |||
| i__4 = ip + k * a_dim1; | |||
| a[i__4].r = temp.r, a[i__4].i = temp.i; | |||
| /* L40: */ | |||
| } | |||
| } | |||
| ix += *incx; | |||
| /* L50: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZLASWP */ | |||
| } /* zlaswp_ */ | |||
| @@ -0,0 +1,962 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b6 = {-1.,0.}; | |||
| static integer c__1 = 1; | |||
| static doublecomplex c_b8 = {1.,0.}; | |||
| static doublecomplex c_b19 = {0.,0.}; | |||
| /* > \brief \b ZLASYF_AA */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLASYF_AA + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlasyf_ | |||
| aa.f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlasyf_ | |||
| aa.f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlasyf_ | |||
| aa.f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLASYF_AA( UPLO, J1, M, NB, A, LDA, IPIV, */ | |||
| /* H, LDH, WORK ) */ | |||
| /* CHARACTER UPLO */ | |||
| /* INTEGER J1, M, NB, LDA, LDH */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ), H( LDH, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > DLATRF_AA factorizes a panel of a complex symmetric matrix A using */ | |||
| /* > the Aasen's algorithm. The panel consists of a set of NB rows of A */ | |||
| /* > when UPLO is U, or a set of NB columns when UPLO is L. */ | |||
| /* > */ | |||
| /* > In order to factorize the panel, the Aasen's algorithm requires the */ | |||
| /* > last row, or column, of the previous panel. The first row, or column, */ | |||
| /* > of A is set to be the first row, or column, of an identity matrix, */ | |||
| /* > which is used to factorize the first panel. */ | |||
| /* > */ | |||
| /* > The resulting J-th row of U, or J-th column of L, is stored in the */ | |||
| /* > (J-1)-th row, or column, of A (without the unit diagonals), while */ | |||
| /* > the diagonal and subdiagonal of A are overwritten by those of T. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > = 'U': Upper triangle of A is stored; */ | |||
| /* > = 'L': Lower triangle of A is stored. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] J1 */ | |||
| /* > \verbatim */ | |||
| /* > J1 is INTEGER */ | |||
| /* > The location of the first row, or column, of the panel */ | |||
| /* > within the submatrix of A, passed to this routine, e.g., */ | |||
| /* > when called by ZSYTRF_AA, for the first panel, J1 is 1, */ | |||
| /* > while for the remaining panels, J1 is 2. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The dimension of the submatrix. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The dimension of the panel to be facotorized. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,M) for */ | |||
| /* > the first panel, while dimension (LDA,M+1) for the */ | |||
| /* > remaining panels. */ | |||
| /* > */ | |||
| /* > On entry, A contains the last row, or column, of */ | |||
| /* > the previous panel, and the trailing submatrix of A */ | |||
| /* > to be factorized, except for the first panel, only */ | |||
| /* > the panel is passed. */ | |||
| /* > */ | |||
| /* > On exit, the leading panel is factorized. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (M) */ | |||
| /* > Details of the row and column interchanges, */ | |||
| /* > the row and column k were interchanged with the row and */ | |||
| /* > column IPIV(k). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] H */ | |||
| /* > \verbatim */ | |||
| /* > H is COMPLEX*16 workspace, dimension (LDH,NB). */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDH */ | |||
| /* > \verbatim */ | |||
| /* > LDH is INTEGER */ | |||
| /* > The leading dimension of the workspace H. LDH >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX*16 workspace, dimension (M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date November 2017 */ | |||
| /* > \ingroup complex16SYcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlasyf_aa_(char *uplo, integer *j1, integer *m, integer | |||
| *nb, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex * | |||
| h__, integer *ldh, doublecomplex *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, h_dim1, h_offset, i__1, i__2; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer j, k; | |||
| doublecomplex alpha; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int zscal_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *), zgemv_(char *, integer *, integer *, | |||
| doublecomplex *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *); | |||
| integer i1, k1, i2; | |||
| extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *), zswap_(integer *, doublecomplex *, | |||
| integer *, doublecomplex *, integer *), zaxpy_(integer *, | |||
| doublecomplex *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *); | |||
| integer mj; | |||
| extern integer izamax_(integer *, doublecomplex *, integer *); | |||
| extern /* Subroutine */ int zlaset_(char *, integer *, integer *, | |||
| doublecomplex *, doublecomplex *, doublecomplex *, integer *); | |||
| doublecomplex piv; | |||
| /* -- LAPACK computational routine (version 3.8.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* November 2017 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --ipiv; | |||
| h_dim1 = *ldh; | |||
| h_offset = 1 + h_dim1 * 1; | |||
| h__ -= h_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| j = 1; | |||
| /* K1 is the first column of the panel to be factorized */ | |||
| /* i.e., K1 is 2 for the first block column, and 1 for the rest of the blocks */ | |||
| k1 = 2 - *j1 + 1; | |||
| if (lsame_(uplo, "U")) { | |||
| /* ..................................................... */ | |||
| /* Factorize A as U**T*D*U using the upper triangle of A */ | |||
| /* ..................................................... */ | |||
| L10: | |||
| if (j > f2cmin(*m,*nb)) { | |||
| goto L20; | |||
| } | |||
| /* K is the column to be factorized */ | |||
| /* when being called from ZSYTRF_AA, */ | |||
| /* > for the first block column, J1 is 1, hence J1+J-1 is J, */ | |||
| /* > for the rest of the columns, J1 is 2, and J1+J-1 is J+1, */ | |||
| k = *j1 + j - 1; | |||
| if (j == *m) { | |||
| /* Only need to compute T(J, J) */ | |||
| mj = 1; | |||
| } else { | |||
| mj = *m - j + 1; | |||
| } | |||
| /* H(J:M, J) := A(J, J:M) - H(J:M, 1:(J-1)) * L(J1:(J-1), J), */ | |||
| /* where H(J:M, J) has been initialized to be A(J, J:M) */ | |||
| if (k > 2) { | |||
| /* K is the column to be factorized */ | |||
| /* > for the first block column, K is J, skipping the first two */ | |||
| /* columns */ | |||
| /* > for the rest of the columns, K is J+1, skipping only the */ | |||
| /* first column */ | |||
| i__1 = j - k1; | |||
| zgemv_("No transpose", &mj, &i__1, &c_b6, &h__[j + k1 * h_dim1], | |||
| ldh, &a[j * a_dim1 + 1], &c__1, &c_b8, &h__[j + j * | |||
| h_dim1], &c__1); | |||
| } | |||
| /* Copy H(i:M, i) into WORK */ | |||
| zcopy_(&mj, &h__[j + j * h_dim1], &c__1, &work[1], &c__1); | |||
| if (j > k1) { | |||
| /* Compute WORK := WORK - L(J-1, J:M) * T(J-1,J), */ | |||
| /* where A(J-1, J) stores T(J-1, J) and A(J-2, J:M) stores U(J-1, J:M) */ | |||
| i__1 = k - 1 + j * a_dim1; | |||
| z__1.r = -a[i__1].r, z__1.i = -a[i__1].i; | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| zaxpy_(&mj, &alpha, &a[k - 2 + j * a_dim1], lda, &work[1], &c__1); | |||
| } | |||
| /* Set A(J, J) = T(J, J) */ | |||
| i__1 = k + j * a_dim1; | |||
| a[i__1].r = work[1].r, a[i__1].i = work[1].i; | |||
| if (j < *m) { | |||
| /* Compute WORK(2:M) = T(J, J) L(J, (J+1):M) */ | |||
| /* where A(J, J) stores T(J, J) and A(J-1, (J+1):M) stores U(J, (J+1):M) */ | |||
| if (k > 1) { | |||
| i__1 = k + j * a_dim1; | |||
| z__1.r = -a[i__1].r, z__1.i = -a[i__1].i; | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| i__1 = *m - j; | |||
| zaxpy_(&i__1, &alpha, &a[k - 1 + (j + 1) * a_dim1], lda, & | |||
| work[2], &c__1); | |||
| } | |||
| /* Find f2cmax(|WORK(2:M)|) */ | |||
| i__1 = *m - j; | |||
| i2 = izamax_(&i__1, &work[2], &c__1) + 1; | |||
| i__1 = i2; | |||
| piv.r = work[i__1].r, piv.i = work[i__1].i; | |||
| /* Apply symmetric pivot */ | |||
| if (i2 != 2 && (piv.r != 0. || piv.i != 0.)) { | |||
| /* Swap WORK(I1) and WORK(I2) */ | |||
| i1 = 2; | |||
| i__1 = i2; | |||
| i__2 = i1; | |||
| work[i__1].r = work[i__2].r, work[i__1].i = work[i__2].i; | |||
| i__1 = i1; | |||
| work[i__1].r = piv.r, work[i__1].i = piv.i; | |||
| /* Swap A(I1, I1+1:M) with A(I1+1:M, I2) */ | |||
| i1 = i1 + j - 1; | |||
| i2 = i2 + j - 1; | |||
| i__1 = i2 - i1 - 1; | |||
| zswap_(&i__1, &a[*j1 + i1 - 1 + (i1 + 1) * a_dim1], lda, &a[* | |||
| j1 + i1 + i2 * a_dim1], &c__1); | |||
| /* Swap A(I1, I2+1:M) with A(I2, I2+1:M) */ | |||
| if (i2 < *m) { | |||
| i__1 = *m - i2; | |||
| zswap_(&i__1, &a[*j1 + i1 - 1 + (i2 + 1) * a_dim1], lda, & | |||
| a[*j1 + i2 - 1 + (i2 + 1) * a_dim1], lda); | |||
| } | |||
| /* Swap A(I1, I1) with A(I2,I2) */ | |||
| i__1 = i1 + *j1 - 1 + i1 * a_dim1; | |||
| piv.r = a[i__1].r, piv.i = a[i__1].i; | |||
| i__1 = *j1 + i1 - 1 + i1 * a_dim1; | |||
| i__2 = *j1 + i2 - 1 + i2 * a_dim1; | |||
| a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i; | |||
| i__1 = *j1 + i2 - 1 + i2 * a_dim1; | |||
| a[i__1].r = piv.r, a[i__1].i = piv.i; | |||
| /* Swap H(I1, 1:J1) with H(I2, 1:J1) */ | |||
| i__1 = i1 - 1; | |||
| zswap_(&i__1, &h__[i1 + h_dim1], ldh, &h__[i2 + h_dim1], ldh); | |||
| ipiv[i1] = i2; | |||
| if (i1 > k1 - 1) { | |||
| /* Swap L(1:I1-1, I1) with L(1:I1-1, I2), */ | |||
| /* skipping the first column */ | |||
| i__1 = i1 - k1 + 1; | |||
| zswap_(&i__1, &a[i1 * a_dim1 + 1], &c__1, &a[i2 * a_dim1 | |||
| + 1], &c__1); | |||
| } | |||
| } else { | |||
| ipiv[j + 1] = j + 1; | |||
| } | |||
| /* Set A(J, J+1) = T(J, J+1) */ | |||
| i__1 = k + (j + 1) * a_dim1; | |||
| a[i__1].r = work[2].r, a[i__1].i = work[2].i; | |||
| if (j < *nb) { | |||
| /* Copy A(J+1:M, J+1) into H(J:M, J), */ | |||
| i__1 = *m - j; | |||
| zcopy_(&i__1, &a[k + 1 + (j + 1) * a_dim1], lda, &h__[j + 1 + | |||
| (j + 1) * h_dim1], &c__1); | |||
| } | |||
| /* Compute L(J+2, J+1) = WORK( 3:M ) / T(J, J+1), */ | |||
| /* where A(J, J+1) = T(J, J+1) and A(J+2:M, J) = L(J+2:M, J+1) */ | |||
| if (j < *m - 1) { | |||
| i__1 = k + (j + 1) * a_dim1; | |||
| if (a[i__1].r != 0. || a[i__1].i != 0.) { | |||
| z_div(&z__1, &c_b8, &a[k + (j + 1) * a_dim1]); | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| i__1 = *m - j - 1; | |||
| zcopy_(&i__1, &work[3], &c__1, &a[k + (j + 2) * a_dim1], | |||
| lda); | |||
| i__1 = *m - j - 1; | |||
| zscal_(&i__1, &alpha, &a[k + (j + 2) * a_dim1], lda); | |||
| } else { | |||
| i__1 = *m - j - 1; | |||
| zlaset_("Full", &c__1, &i__1, &c_b19, &c_b19, &a[k + (j + | |||
| 2) * a_dim1], lda); | |||
| } | |||
| } | |||
| } | |||
| ++j; | |||
| goto L10; | |||
| L20: | |||
| ; | |||
| } else { | |||
| /* ..................................................... */ | |||
| /* Factorize A as L*D*L**T using the lower triangle of A */ | |||
| /* ..................................................... */ | |||
| L30: | |||
| if (j > f2cmin(*m,*nb)) { | |||
| goto L40; | |||
| } | |||
| /* K is the column to be factorized */ | |||
| /* when being called from ZSYTRF_AA, */ | |||
| /* > for the first block column, J1 is 1, hence J1+J-1 is J, */ | |||
| /* > for the rest of the columns, J1 is 2, and J1+J-1 is J+1, */ | |||
| k = *j1 + j - 1; | |||
| if (j == *m) { | |||
| /* Only need to compute T(J, J) */ | |||
| mj = 1; | |||
| } else { | |||
| mj = *m - j + 1; | |||
| } | |||
| /* H(J:M, J) := A(J:M, J) - H(J:M, 1:(J-1)) * L(J, J1:(J-1))^T, */ | |||
| /* where H(J:M, J) has been initialized to be A(J:M, J) */ | |||
| if (k > 2) { | |||
| /* K is the column to be factorized */ | |||
| /* > for the first block column, K is J, skipping the first two */ | |||
| /* columns */ | |||
| /* > for the rest of the columns, K is J+1, skipping only the */ | |||
| /* first column */ | |||
| i__1 = j - k1; | |||
| zgemv_("No transpose", &mj, &i__1, &c_b6, &h__[j + k1 * h_dim1], | |||
| ldh, &a[j + a_dim1], lda, &c_b8, &h__[j + j * h_dim1], & | |||
| c__1); | |||
| } | |||
| /* Copy H(J:M, J) into WORK */ | |||
| zcopy_(&mj, &h__[j + j * h_dim1], &c__1, &work[1], &c__1); | |||
| if (j > k1) { | |||
| /* Compute WORK := WORK - L(J:M, J-1) * T(J-1,J), */ | |||
| /* where A(J-1, J) = T(J-1, J) and A(J, J-2) = L(J, J-1) */ | |||
| i__1 = j + (k - 1) * a_dim1; | |||
| z__1.r = -a[i__1].r, z__1.i = -a[i__1].i; | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| zaxpy_(&mj, &alpha, &a[j + (k - 2) * a_dim1], &c__1, &work[1], & | |||
| c__1); | |||
| } | |||
| /* Set A(J, J) = T(J, J) */ | |||
| i__1 = j + k * a_dim1; | |||
| a[i__1].r = work[1].r, a[i__1].i = work[1].i; | |||
| if (j < *m) { | |||
| /* Compute WORK(2:M) = T(J, J) L((J+1):M, J) */ | |||
| /* where A(J, J) = T(J, J) and A((J+1):M, J-1) = L((J+1):M, J) */ | |||
| if (k > 1) { | |||
| i__1 = j + k * a_dim1; | |||
| z__1.r = -a[i__1].r, z__1.i = -a[i__1].i; | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| i__1 = *m - j; | |||
| zaxpy_(&i__1, &alpha, &a[j + 1 + (k - 1) * a_dim1], &c__1, & | |||
| work[2], &c__1); | |||
| } | |||
| /* Find f2cmax(|WORK(2:M)|) */ | |||
| i__1 = *m - j; | |||
| i2 = izamax_(&i__1, &work[2], &c__1) + 1; | |||
| i__1 = i2; | |||
| piv.r = work[i__1].r, piv.i = work[i__1].i; | |||
| /* Apply symmetric pivot */ | |||
| if (i2 != 2 && (piv.r != 0. || piv.i != 0.)) { | |||
| /* Swap WORK(I1) and WORK(I2) */ | |||
| i1 = 2; | |||
| i__1 = i2; | |||
| i__2 = i1; | |||
| work[i__1].r = work[i__2].r, work[i__1].i = work[i__2].i; | |||
| i__1 = i1; | |||
| work[i__1].r = piv.r, work[i__1].i = piv.i; | |||
| /* Swap A(I1+1:M, I1) with A(I2, I1+1:M) */ | |||
| i1 = i1 + j - 1; | |||
| i2 = i2 + j - 1; | |||
| i__1 = i2 - i1 - 1; | |||
| zswap_(&i__1, &a[i1 + 1 + (*j1 + i1 - 1) * a_dim1], &c__1, &a[ | |||
| i2 + (*j1 + i1) * a_dim1], lda); | |||
| /* Swap A(I2+1:M, I1) with A(I2+1:M, I2) */ | |||
| if (i2 < *m) { | |||
| i__1 = *m - i2; | |||
| zswap_(&i__1, &a[i2 + 1 + (*j1 + i1 - 1) * a_dim1], &c__1, | |||
| &a[i2 + 1 + (*j1 + i2 - 1) * a_dim1], &c__1); | |||
| } | |||
| /* Swap A(I1, I1) with A(I2, I2) */ | |||
| i__1 = i1 + (*j1 + i1 - 1) * a_dim1; | |||
| piv.r = a[i__1].r, piv.i = a[i__1].i; | |||
| i__1 = i1 + (*j1 + i1 - 1) * a_dim1; | |||
| i__2 = i2 + (*j1 + i2 - 1) * a_dim1; | |||
| a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i; | |||
| i__1 = i2 + (*j1 + i2 - 1) * a_dim1; | |||
| a[i__1].r = piv.r, a[i__1].i = piv.i; | |||
| /* Swap H(I1, I1:J1) with H(I2, I2:J1) */ | |||
| i__1 = i1 - 1; | |||
| zswap_(&i__1, &h__[i1 + h_dim1], ldh, &h__[i2 + h_dim1], ldh); | |||
| ipiv[i1] = i2; | |||
| if (i1 > k1 - 1) { | |||
| /* Swap L(1:I1-1, I1) with L(1:I1-1, I2), */ | |||
| /* skipping the first column */ | |||
| i__1 = i1 - k1 + 1; | |||
| zswap_(&i__1, &a[i1 + a_dim1], lda, &a[i2 + a_dim1], lda); | |||
| } | |||
| } else { | |||
| ipiv[j + 1] = j + 1; | |||
| } | |||
| /* Set A(J+1, J) = T(J+1, J) */ | |||
| i__1 = j + 1 + k * a_dim1; | |||
| a[i__1].r = work[2].r, a[i__1].i = work[2].i; | |||
| if (j < *nb) { | |||
| /* Copy A(J+1:M, J+1) into H(J+1:M, J), */ | |||
| i__1 = *m - j; | |||
| zcopy_(&i__1, &a[j + 1 + (k + 1) * a_dim1], &c__1, &h__[j + 1 | |||
| + (j + 1) * h_dim1], &c__1); | |||
| } | |||
| /* Compute L(J+2, J+1) = WORK( 3:M ) / T(J, J+1), */ | |||
| /* where A(J, J+1) = T(J, J+1) and A(J+2:M, J) = L(J+2:M, J+1) */ | |||
| if (j < *m - 1) { | |||
| i__1 = j + 1 + k * a_dim1; | |||
| if (a[i__1].r != 0. || a[i__1].i != 0.) { | |||
| z_div(&z__1, &c_b8, &a[j + 1 + k * a_dim1]); | |||
| alpha.r = z__1.r, alpha.i = z__1.i; | |||
| i__1 = *m - j - 1; | |||
| zcopy_(&i__1, &work[3], &c__1, &a[j + 2 + k * a_dim1], & | |||
| c__1); | |||
| i__1 = *m - j - 1; | |||
| zscal_(&i__1, &alpha, &a[j + 2 + k * a_dim1], &c__1); | |||
| } else { | |||
| i__1 = *m - j - 1; | |||
| zlaset_("Full", &i__1, &c__1, &c_b19, &c_b19, &a[j + 2 + | |||
| k * a_dim1], lda); | |||
| } | |||
| } | |||
| } | |||
| ++j; | |||
| goto L30; | |||
| L40: | |||
| ; | |||
| } | |||
| return 0; | |||
| /* End of ZLASYF_AA */ | |||
| } /* zlasyf_aa__ */ | |||
| @@ -0,0 +1,581 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ZLAT2C converts a double complex triangular matrix to a complex triangular matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAT2C + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlat2c. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlat2c. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlat2c. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAT2C( UPLO, N, A, LDA, SA, LDSA, INFO ) */ | |||
| /* CHARACTER UPLO */ | |||
| /* INTEGER INFO, LDA, LDSA, N */ | |||
| /* COMPLEX SA( LDSA, * ) */ | |||
| /* COMPLEX*16 A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLAT2C converts a COMPLEX*16 triangular matrix, SA, to a COMPLEX */ | |||
| /* > triangular matrix, A. */ | |||
| /* > */ | |||
| /* > RMAX is the overflow for the SINGLE PRECISION arithmetic */ | |||
| /* > ZLAT2C checks that all the entries of A are between -RMAX and */ | |||
| /* > RMAX. If not the conversion is aborted and a flag is raised. */ | |||
| /* > */ | |||
| /* > This is an auxiliary routine so there is no argument checking. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] UPLO */ | |||
| /* > \verbatim */ | |||
| /* > UPLO is CHARACTER*1 */ | |||
| /* > = 'U': A is upper triangular; */ | |||
| /* > = 'L': A is lower triangular. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of rows and columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the N-by-N triangular coefficient matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SA */ | |||
| /* > \verbatim */ | |||
| /* > SA is COMPLEX array, dimension (LDSA,N) */ | |||
| /* > Only the UPLO part of SA is referenced. On exit, if INFO=0, */ | |||
| /* > the N-by-N coefficient matrix SA; if INFO>0, the content of */ | |||
| /* > the UPLO part of SA is unspecified. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDSA */ | |||
| /* > \verbatim */ | |||
| /* > LDSA is INTEGER */ | |||
| /* > The leading dimension of the array SA. LDSA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit. */ | |||
| /* > = 1: an entry of the matrix A is greater than the SINGLE */ | |||
| /* > PRECISION overflow threshold, in this case, the content */ | |||
| /* > of the UPLO part of SA in exit is unspecified. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlat2c_(char *uplo, integer *n, doublecomplex *a, | |||
| integer *lda, complex *sa, integer *ldsa, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer sa_dim1, sa_offset, a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| /* Local variables */ | |||
| doublereal rmax; | |||
| integer i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| logical upper; | |||
| extern real slamch_(char *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| sa_dim1 = *ldsa; | |||
| sa_offset = 1 + sa_dim1 * 1; | |||
| sa -= sa_offset; | |||
| /* Function Body */ | |||
| rmax = slamch_("O"); | |||
| upper = lsame_(uplo, "U"); | |||
| if (upper) { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = j; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| if (a[i__3].r < -rmax || a[i__4].r > rmax || d_imag(&a[i__ + | |||
| j * a_dim1]) < -rmax || d_imag(&a[i__ + j * a_dim1]) | |||
| > rmax) { | |||
| *info = 1; | |||
| goto L50; | |||
| } | |||
| i__3 = i__ + j * sa_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| sa[i__3].r = a[i__4].r, sa[i__3].i = a[i__4].i; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = j; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * a_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| if (a[i__3].r < -rmax || a[i__4].r > rmax || d_imag(&a[i__ + | |||
| j * a_dim1]) < -rmax || d_imag(&a[i__ + j * a_dim1]) | |||
| > rmax) { | |||
| *info = 1; | |||
| goto L50; | |||
| } | |||
| i__3 = i__ + j * sa_dim1; | |||
| i__4 = i__ + j * a_dim1; | |||
| sa[i__3].r = a[i__4].r, sa[i__3].i = a[i__4].i; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| L50: | |||
| return 0; | |||
| /* End of ZLAT2C */ | |||
| } /* zlat2c_ */ | |||
| @@ -0,0 +1,794 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| 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; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {1.,0.}; | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static doublereal c_b24 = 1.; | |||
| /* > \brief \b ZLATDF uses the LU factorization of the n-by-n matrix computed by sgetc2 and computes a contrib | |||
| ution to the reciprocal Dif-estimate. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLATDF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlatdf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlatdf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlatdf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLATDF( IJOB, N, Z, LDZ, RHS, RDSUM, RDSCAL, IPIV, */ | |||
| /* JPIV ) */ | |||
| /* INTEGER IJOB, LDZ, N */ | |||
| /* DOUBLE PRECISION RDSCAL, RDSUM */ | |||
| /* INTEGER IPIV( * ), JPIV( * ) */ | |||
| /* COMPLEX*16 RHS( * ), Z( LDZ, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > ZLATDF computes the contribution to the reciprocal Dif-estimate */ | |||
| /* > by solving for x in Z * x = b, where b is chosen such that the norm */ | |||
| /* > of x is as large as possible. It is assumed that LU decomposition */ | |||
| /* > of Z has been computed by ZGETC2. On entry RHS = f holds the */ | |||
| /* > contribution from earlier solved sub-systems, and on return RHS = x. */ | |||
| /* > */ | |||
| /* > The factorization of Z returned by ZGETC2 has the form */ | |||
| /* > Z = P * L * U * Q, where P and Q are permutation matrices. L is lower */ | |||
| /* > triangular with unit diagonal elements and U is upper triangular. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] IJOB */ | |||
| /* > \verbatim */ | |||
| /* > IJOB is INTEGER */ | |||
| /* > IJOB = 2: First compute an approximative null-vector e */ | |||
| /* > of Z using ZGECON, e is normalized and solve for */ | |||
| /* > Zx = +-e - f with the sign giving the greater value of */ | |||
| /* > 2-norm(x). About 5 times as expensive as Default. */ | |||
| /* > IJOB .ne. 2: Local look ahead strategy where */ | |||
| /* > all entries of the r.h.s. b is chosen as either +1 or */ | |||
| /* > -1. Default. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix Z. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] Z */ | |||
| /* > \verbatim */ | |||
| /* > Z is COMPLEX*16 array, dimension (LDZ, N) */ | |||
| /* > On entry, the LU part of the factorization of the n-by-n */ | |||
| /* > matrix Z computed by ZGETC2: Z = P * L * U * Q */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDZ */ | |||
| /* > \verbatim */ | |||
| /* > LDZ is INTEGER */ | |||
| /* > The leading dimension of the array Z. LDA >= f2cmax(1, N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] RHS */ | |||
| /* > \verbatim */ | |||
| /* > RHS is COMPLEX*16 array, dimension (N). */ | |||
| /* > On entry, RHS contains contributions from other subsystems. */ | |||
| /* > On exit, RHS contains the solution of the subsystem with */ | |||
| /* > entries according to the value of IJOB (see above). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] RDSUM */ | |||
| /* > \verbatim */ | |||
| /* > RDSUM is DOUBLE PRECISION */ | |||
| /* > On entry, the sum of squares of computed contributions to */ | |||
| /* > the Dif-estimate under computation by ZTGSYL, where the */ | |||
| /* > scaling factor RDSCAL (see below) has been factored out. */ | |||
| /* > On exit, the corresponding sum of squares updated with the */ | |||
| /* > contributions from the current sub-system. */ | |||
| /* > If TRANS = 'T' RDSUM is not touched. */ | |||
| /* > NOTE: RDSUM only makes sense when ZTGSY2 is called by CTGSYL. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] RDSCAL */ | |||
| /* > \verbatim */ | |||
| /* > RDSCAL is DOUBLE PRECISION */ | |||
| /* > On entry, scaling factor used to prevent overflow in RDSUM. */ | |||
| /* > On exit, RDSCAL is updated w.r.t. the current contributions */ | |||
| /* > in RDSUM. */ | |||
| /* > If TRANS = 'T', RDSCAL is not touched. */ | |||
| /* > NOTE: RDSCAL only makes sense when ZTGSY2 is called by */ | |||
| /* > ZTGSYL. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (N). */ | |||
| /* > The pivot indices; for 1 <= i <= N, row i of the */ | |||
| /* > matrix has been interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] JPIV */ | |||
| /* > \verbatim */ | |||
| /* > JPIV is INTEGER array, dimension (N). */ | |||
| /* > The pivot indices; for 1 <= j <= N, column j of the */ | |||
| /* > matrix has been interchanged with column JPIV(j). */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > This routine is a further developed implementation of algorithm */ | |||
| /* > BSOLVE in [1] using complete pivoting in the LU factorization. */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > Bo Kagstrom and Peter Poromaa, Department of Computing Science, */ | |||
| /* > Umea University, S-901 87 Umea, Sweden. */ | |||
| /* > \par References: */ | |||
| /* ================ */ | |||
| /* > */ | |||
| /* > [1] Bo Kagstrom and Lars Westin, */ | |||
| /* > Generalized Schur Methods with Condition Estimators for */ | |||
| /* > Solving the Generalized Sylvester Equation, IEEE Transactions */ | |||
| /* > on Automatic Control, Vol. 34, No. 7, July 1989, pp 745-751. */ | |||
| /* >\n */ | |||
| /* > [2] Peter Poromaa, */ | |||
| /* > On Efficient and Robust Estimators for the Separation */ | |||
| /* > between two Regular Matrix Pairs with Applications in */ | |||
| /* > Condition Estimation. Report UMINF-95.05, Department of */ | |||
| /* > Computing Science, Umea University, S-901 87 Umea, Sweden, */ | |||
| /* > 1995. */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlatdf_(integer *ijob, integer *n, doublecomplex *z__, | |||
| integer *ldz, doublecomplex *rhs, doublereal *rdsum, doublereal * | |||
| rdscal, integer *ipiv, integer *jpiv) | |||
| { | |||
| /* System generated locals */ | |||
| integer z_dim1, z_offset, i__1, i__2, i__3, i__4, i__5; | |||
| doublecomplex z__1, z__2, z__3; | |||
| /* Local variables */ | |||
| integer info; | |||
| doublecomplex temp, work[8]; | |||
| integer i__, j, k; | |||
| doublereal scale; | |||
| extern /* Subroutine */ int zscal_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *); | |||
| doublecomplex pmone; | |||
| extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *); | |||
| doublereal rtemp, sminu, rwork[2]; | |||
| extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *); | |||
| doublereal splus; | |||
| extern /* Subroutine */ int zaxpy_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *), zgesc2_( | |||
| integer *, doublecomplex *, integer *, doublecomplex *, integer *, | |||
| integer *, doublereal *); | |||
| doublecomplex bm, bp, xm[2], xp[2]; | |||
| extern /* Subroutine */ int zgecon_(char *, integer *, doublecomplex *, | |||
| integer *, doublereal *, doublereal *, doublecomplex *, | |||
| doublereal *, integer *); | |||
| extern doublereal dzasum_(integer *, doublecomplex *, integer *); | |||
| extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *), zlaswp_(integer *, doublecomplex *, | |||
| integer *, integer *, integer *, integer *, integer *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| z_dim1 = *ldz; | |||
| z_offset = 1 + z_dim1 * 1; | |||
| z__ -= z_offset; | |||
| --rhs; | |||
| --ipiv; | |||
| --jpiv; | |||
| /* Function Body */ | |||
| if (*ijob != 2) { | |||
| /* Apply permutations IPIV to RHS */ | |||
| i__1 = *n - 1; | |||
| zlaswp_(&c__1, &rhs[1], ldz, &c__1, &i__1, &ipiv[1], &c__1); | |||
| /* Solve for L-part choosing RHS either to +1 or -1. */ | |||
| z__1.r = -1., z__1.i = 0.; | |||
| pmone.r = z__1.r, pmone.i = z__1.i; | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = j; | |||
| z__1.r = rhs[i__2].r + 1., z__1.i = rhs[i__2].i + 0.; | |||
| bp.r = z__1.r, bp.i = z__1.i; | |||
| i__2 = j; | |||
| z__1.r = rhs[i__2].r - 1., z__1.i = rhs[i__2].i + 0.; | |||
| bm.r = z__1.r, bm.i = z__1.i; | |||
| splus = 1.; | |||
| /* Lockahead for L- part RHS(1:N-1) = +-1 */ | |||
| /* SPLUS and SMIN computed more efficiently than in BSOLVE[1]. */ | |||
| i__2 = *n - j; | |||
| zdotc_(&z__1, &i__2, &z__[j + 1 + j * z_dim1], &c__1, &z__[j + 1 | |||
| + j * z_dim1], &c__1); | |||
| splus += z__1.r; | |||
| i__2 = *n - j; | |||
| zdotc_(&z__1, &i__2, &z__[j + 1 + j * z_dim1], &c__1, &rhs[j + 1], | |||
| &c__1); | |||
| sminu = z__1.r; | |||
| i__2 = j; | |||
| splus *= rhs[i__2].r; | |||
| if (splus > sminu) { | |||
| i__2 = j; | |||
| rhs[i__2].r = bp.r, rhs[i__2].i = bp.i; | |||
| } else if (sminu > splus) { | |||
| i__2 = j; | |||
| rhs[i__2].r = bm.r, rhs[i__2].i = bm.i; | |||
| } else { | |||
| /* In this case the updating sums are equal and we can */ | |||
| /* choose RHS(J) +1 or -1. The first time this happens we */ | |||
| /* choose -1, thereafter +1. This is a simple way to get */ | |||
| /* good estimates of matrices like Byers well-known example */ | |||
| /* (see [1]). (Not done in BSOLVE.) */ | |||
| i__2 = j; | |||
| i__3 = j; | |||
| z__1.r = rhs[i__3].r + pmone.r, z__1.i = rhs[i__3].i + | |||
| pmone.i; | |||
| rhs[i__2].r = z__1.r, rhs[i__2].i = z__1.i; | |||
| pmone.r = 1., pmone.i = 0.; | |||
| } | |||
| /* Compute the remaining r.h.s. */ | |||
| i__2 = j; | |||
| z__1.r = -rhs[i__2].r, z__1.i = -rhs[i__2].i; | |||
| temp.r = z__1.r, temp.i = z__1.i; | |||
| i__2 = *n - j; | |||
| zaxpy_(&i__2, &temp, &z__[j + 1 + j * z_dim1], &c__1, &rhs[j + 1], | |||
| &c__1); | |||
| /* L10: */ | |||
| } | |||
| /* Solve for U- part, lockahead for RHS(N) = +-1. This is not done */ | |||
| /* In BSOLVE and will hopefully give us a better estimate because */ | |||
| /* any ill-conditioning of the original matrix is transferred to U */ | |||
| /* and not to L. U(N, N) is an approximation to sigma_min(LU). */ | |||
| i__1 = *n - 1; | |||
| zcopy_(&i__1, &rhs[1], &c__1, work, &c__1); | |||
| i__1 = *n - 1; | |||
| i__2 = *n; | |||
| z__1.r = rhs[i__2].r + 1., z__1.i = rhs[i__2].i + 0.; | |||
| work[i__1].r = z__1.r, work[i__1].i = z__1.i; | |||
| i__1 = *n; | |||
| i__2 = *n; | |||
| z__1.r = rhs[i__2].r - 1., z__1.i = rhs[i__2].i + 0.; | |||
| rhs[i__1].r = z__1.r, rhs[i__1].i = z__1.i; | |||
| splus = 0.; | |||
| sminu = 0.; | |||
| for (i__ = *n; i__ >= 1; --i__) { | |||
| z_div(&z__1, &c_b1, &z__[i__ + i__ * z_dim1]); | |||
| temp.r = z__1.r, temp.i = z__1.i; | |||
| i__1 = i__ - 1; | |||
| i__2 = i__ - 1; | |||
| z__1.r = work[i__2].r * temp.r - work[i__2].i * temp.i, z__1.i = | |||
| work[i__2].r * temp.i + work[i__2].i * temp.r; | |||
| work[i__1].r = z__1.r, work[i__1].i = z__1.i; | |||
| i__1 = i__; | |||
| i__2 = i__; | |||
| z__1.r = rhs[i__2].r * temp.r - rhs[i__2].i * temp.i, z__1.i = | |||
| rhs[i__2].r * temp.i + rhs[i__2].i * temp.r; | |||
| rhs[i__1].r = z__1.r, rhs[i__1].i = z__1.i; | |||
| i__1 = *n; | |||
| for (k = i__ + 1; k <= i__1; ++k) { | |||
| i__2 = i__ - 1; | |||
| i__3 = i__ - 1; | |||
| i__4 = k - 1; | |||
| i__5 = i__ + k * z_dim1; | |||
| z__3.r = z__[i__5].r * temp.r - z__[i__5].i * temp.i, z__3.i = | |||
| z__[i__5].r * temp.i + z__[i__5].i * temp.r; | |||
| z__2.r = work[i__4].r * z__3.r - work[i__4].i * z__3.i, | |||
| z__2.i = work[i__4].r * z__3.i + work[i__4].i * | |||
| z__3.r; | |||
| z__1.r = work[i__3].r - z__2.r, z__1.i = work[i__3].i - | |||
| z__2.i; | |||
| work[i__2].r = z__1.r, work[i__2].i = z__1.i; | |||
| i__2 = i__; | |||
| i__3 = i__; | |||
| i__4 = k; | |||
| i__5 = i__ + k * z_dim1; | |||
| z__3.r = z__[i__5].r * temp.r - z__[i__5].i * temp.i, z__3.i = | |||
| z__[i__5].r * temp.i + z__[i__5].i * temp.r; | |||
| z__2.r = rhs[i__4].r * z__3.r - rhs[i__4].i * z__3.i, z__2.i = | |||
| rhs[i__4].r * z__3.i + rhs[i__4].i * z__3.r; | |||
| z__1.r = rhs[i__3].r - z__2.r, z__1.i = rhs[i__3].i - z__2.i; | |||
| rhs[i__2].r = z__1.r, rhs[i__2].i = z__1.i; | |||
| /* L20: */ | |||
| } | |||
| splus += z_abs(&work[i__ - 1]); | |||
| sminu += z_abs(&rhs[i__]); | |||
| /* L30: */ | |||
| } | |||
| if (splus > sminu) { | |||
| zcopy_(n, work, &c__1, &rhs[1], &c__1); | |||
| } | |||
| /* Apply the permutations JPIV to the computed solution (RHS) */ | |||
| i__1 = *n - 1; | |||
| zlaswp_(&c__1, &rhs[1], ldz, &c__1, &i__1, &jpiv[1], &c_n1); | |||
| /* Compute the sum of squares */ | |||
| zlassq_(n, &rhs[1], &c__1, rdscal, rdsum); | |||
| return 0; | |||
| } | |||
| /* ENTRY IJOB = 2 */ | |||
| /* Compute approximate nullvector XM of Z */ | |||
| zgecon_("I", n, &z__[z_offset], ldz, &c_b24, &rtemp, work, rwork, &info); | |||
| zcopy_(n, &work[*n], &c__1, xm, &c__1); | |||
| /* Compute RHS */ | |||
| i__1 = *n - 1; | |||
| zlaswp_(&c__1, xm, ldz, &c__1, &i__1, &ipiv[1], &c_n1); | |||
| zdotc_(&z__3, n, xm, &c__1, xm, &c__1); | |||
| z_sqrt(&z__2, &z__3); | |||
| z_div(&z__1, &c_b1, &z__2); | |||
| temp.r = z__1.r, temp.i = z__1.i; | |||
| zscal_(n, &temp, xm, &c__1); | |||
| zcopy_(n, xm, &c__1, xp, &c__1); | |||
| zaxpy_(n, &c_b1, &rhs[1], &c__1, xp, &c__1); | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zaxpy_(n, &z__1, xm, &c__1, &rhs[1], &c__1); | |||
| zgesc2_(n, &z__[z_offset], ldz, &rhs[1], &ipiv[1], &jpiv[1], &scale); | |||
| zgesc2_(n, &z__[z_offset], ldz, xp, &ipiv[1], &jpiv[1], &scale); | |||
| if (dzasum_(n, xp, &c__1) > dzasum_(n, &rhs[1], &c__1)) { | |||
| zcopy_(n, xp, &c__1, &rhs[1], &c__1); | |||
| } | |||
| /* Compute the sum of squares */ | |||
| zlassq_(n, &rhs[1], &c__1, rdscal, rdsum); | |||
| return 0; | |||
| /* End of ZLATDF */ | |||
| } /* zlatdf_ */ | |||