| @@ -0,0 +1,742 @@ | |||
| /* 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 CGBCON */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBCON + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbcon. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbcon. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbcon. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBCON( NORM, N, KL, KU, AB, LDAB, IPIV, ANORM, RCOND, */ | |||
| /* WORK, RWORK, INFO ) */ | |||
| /* CHARACTER NORM */ | |||
| /* INTEGER INFO, KL, KU, LDAB, N */ | |||
| /* REAL ANORM, RCOND */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX AB( LDAB, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBCON estimates the reciprocal of the condition number of a complex */ | |||
| /* > general band matrix A, in either the 1-norm or the infinity-norm, */ | |||
| /* > using the LU factorization computed by CGBTRF. */ | |||
| /* > */ | |||
| /* > An estimate is obtained for norm(inv(A)), and the reciprocal of the */ | |||
| /* > condition number is computed as */ | |||
| /* > RCOND = 1 / ( norm(A) * norm(inv(A)) ). */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies whether the 1-norm condition number or the */ | |||
| /* > infinity-norm condition number is required: */ | |||
| /* > = '1' or 'O': 1-norm; */ | |||
| /* > = 'I': Infinity-norm. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order 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] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX array, dimension (LDAB,N) */ | |||
| /* > Details of the LU factorization of the band matrix A, as */ | |||
| /* > computed by CGBTRF. U is stored as an upper triangular band */ | |||
| /* > matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */ | |||
| /* > the multipliers used during the factorization are stored in */ | |||
| /* > rows KL+KU+2 to 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (N) */ | |||
| /* > The pivot indices; for 1 <= i <= N, row i of the matrix was */ | |||
| /* > interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ANORM */ | |||
| /* > \verbatim */ | |||
| /* > ANORM is REAL */ | |||
| /* > If NORM = '1' or 'O', the 1-norm of the original matrix A. */ | |||
| /* > If NORM = 'I', the infinity-norm of the original matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RCOND */ | |||
| /* > \verbatim */ | |||
| /* > RCOND is REAL */ | |||
| /* > The reciprocal of the condition number of the matrix A, */ | |||
| /* > computed as RCOND = 1/(norm(A) * norm(inv(A))). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (N) */ | |||
| /* > \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 complexGBcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbcon_(char *norm, integer *n, integer *kl, integer *ku, | |||
| complex *ab, integer *ldab, integer *ipiv, real *anorm, real *rcond, | |||
| complex *work, real *rwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3; | |||
| real r__1, r__2; | |||
| complex q__1, q__2; | |||
| /* Local variables */ | |||
| integer kase, kase1, j; | |||
| complex t; | |||
| real scale; | |||
| extern /* Complex */ VOID cdotc_(complex *, integer *, complex *, integer | |||
| *, complex *, integer *); | |||
| extern logical lsame_(char *, char *); | |||
| integer isave[3]; | |||
| extern /* Subroutine */ int caxpy_(integer *, complex *, complex *, | |||
| integer *, complex *, integer *); | |||
| logical lnoti; | |||
| extern /* Subroutine */ int clacn2_(integer *, complex *, complex *, real | |||
| *, integer *, integer *); | |||
| integer kd, lm, jp, ix; | |||
| extern integer icamax_(integer *, complex *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int clatbs_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, integer *, complex *, real *, | |||
| real *, integer *), xerbla_(char * | |||
| , integer *, ftnlen); | |||
| real ainvnm; | |||
| extern /* Subroutine */ int csrscl_(integer *, real *, complex *, integer | |||
| *); | |||
| logical onenrm; | |||
| char normin[1]; | |||
| real smlnum; | |||
| /* -- 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 */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --ipiv; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O"); | |||
| if (! onenrm && ! lsame_(norm, "I")) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*kl < 0) { | |||
| *info = -3; | |||
| } else if (*ku < 0) { | |||
| *info = -4; | |||
| } else if (*ldab < (*kl << 1) + *ku + 1) { | |||
| *info = -6; | |||
| } else if (*anorm < 0.f) { | |||
| *info = -8; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBCON", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| *rcond = 0.f; | |||
| if (*n == 0) { | |||
| *rcond = 1.f; | |||
| return 0; | |||
| } else if (*anorm == 0.f) { | |||
| return 0; | |||
| } | |||
| smlnum = slamch_("Safe minimum"); | |||
| /* Estimate the norm of inv(A). */ | |||
| ainvnm = 0.f; | |||
| *(unsigned char *)normin = 'N'; | |||
| if (onenrm) { | |||
| kase1 = 1; | |||
| } else { | |||
| kase1 = 2; | |||
| } | |||
| kd = *kl + *ku + 1; | |||
| lnoti = *kl > 0; | |||
| kase = 0; | |||
| L10: | |||
| clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave); | |||
| if (kase != 0) { | |||
| if (kase == kase1) { | |||
| /* Multiply by inv(L). */ | |||
| if (lnoti) { | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__2 = *kl, i__3 = *n - j; | |||
| lm = f2cmin(i__2,i__3); | |||
| jp = ipiv[j]; | |||
| i__2 = jp; | |||
| t.r = work[i__2].r, t.i = work[i__2].i; | |||
| if (jp != j) { | |||
| i__2 = jp; | |||
| i__3 = j; | |||
| work[i__2].r = work[i__3].r, work[i__2].i = work[i__3] | |||
| .i; | |||
| i__2 = j; | |||
| work[i__2].r = t.r, work[i__2].i = t.i; | |||
| } | |||
| q__1.r = -t.r, q__1.i = -t.i; | |||
| caxpy_(&lm, &q__1, &ab[kd + 1 + j * ab_dim1], &c__1, & | |||
| work[j + 1], &c__1); | |||
| /* L20: */ | |||
| } | |||
| } | |||
| /* Multiply by inv(U). */ | |||
| i__1 = *kl + *ku; | |||
| clatbs_("Upper", "No transpose", "Non-unit", normin, n, &i__1, & | |||
| ab[ab_offset], ldab, &work[1], &scale, &rwork[1], info); | |||
| } else { | |||
| /* Multiply by inv(U**H). */ | |||
| i__1 = *kl + *ku; | |||
| clatbs_("Upper", "Conjugate transpose", "Non-unit", normin, n, & | |||
| i__1, &ab[ab_offset], ldab, &work[1], &scale, &rwork[1], | |||
| info); | |||
| /* Multiply by inv(L**H). */ | |||
| if (lnoti) { | |||
| for (j = *n - 1; j >= 1; --j) { | |||
| /* Computing MIN */ | |||
| i__1 = *kl, i__2 = *n - j; | |||
| lm = f2cmin(i__1,i__2); | |||
| i__1 = j; | |||
| i__2 = j; | |||
| cdotc_(&q__2, &lm, &ab[kd + 1 + j * ab_dim1], &c__1, & | |||
| work[j + 1], &c__1); | |||
| q__1.r = work[i__2].r - q__2.r, q__1.i = work[i__2].i - | |||
| q__2.i; | |||
| work[i__1].r = q__1.r, work[i__1].i = q__1.i; | |||
| jp = ipiv[j]; | |||
| if (jp != j) { | |||
| i__1 = jp; | |||
| t.r = work[i__1].r, t.i = work[i__1].i; | |||
| i__1 = jp; | |||
| i__2 = j; | |||
| work[i__1].r = work[i__2].r, work[i__1].i = work[i__2] | |||
| .i; | |||
| i__1 = j; | |||
| work[i__1].r = t.r, work[i__1].i = t.i; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| } | |||
| } | |||
| /* Divide X by 1/SCALE if doing so will not cause overflow. */ | |||
| *(unsigned char *)normin = 'Y'; | |||
| if (scale != 1.f) { | |||
| ix = icamax_(n, &work[1], &c__1); | |||
| i__1 = ix; | |||
| if (scale < ((r__1 = work[i__1].r, abs(r__1)) + (r__2 = r_imag(& | |||
| work[ix]), abs(r__2))) * smlnum || scale == 0.f) { | |||
| goto L40; | |||
| } | |||
| csrscl_(n, &scale, &work[1], &c__1); | |||
| } | |||
| goto L10; | |||
| } | |||
| /* Compute the estimate of the reciprocal condition number. */ | |||
| if (ainvnm != 0.f) { | |||
| *rcond = 1.f / ainvnm / *anorm; | |||
| } | |||
| L40: | |||
| return 0; | |||
| /* End of CGBCON */ | |||
| } /* cgbcon_ */ | |||
| @@ -0,0 +1,767 @@ | |||
| /* 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 CGBEQU */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBEQU + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbequ. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbequ. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbequ. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBEQU( M, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND, */ | |||
| /* AMAX, INFO ) */ | |||
| /* INTEGER INFO, KL, KU, LDAB, M, N */ | |||
| /* REAL AMAX, COLCND, ROWCND */ | |||
| /* REAL C( * ), R( * ) */ | |||
| /* COMPLEX AB( LDAB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBEQU computes row and column scalings intended to equilibrate an */ | |||
| /* > M-by-N band matrix A and reduce its condition number. R returns the */ | |||
| /* > row scale factors and C the column scale factors, chosen to try to */ | |||
| /* > make the largest element in each row and column of the matrix B with */ | |||
| /* > elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1. */ | |||
| /* > */ | |||
| /* > R(i) and C(j) are restricted to be between SMLNUM = smallest safe */ | |||
| /* > number and BIGNUM = largest safe number. Use of these scaling */ | |||
| /* > factors is not guaranteed to reduce the condition number of A but */ | |||
| /* > works well in practice. */ | |||
| /* > \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] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX 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(m,j+kl). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] R */ | |||
| /* > \verbatim */ | |||
| /* > R is REAL array, dimension (M) */ | |||
| /* > If INFO = 0, or INFO > M, R contains the row scale factors */ | |||
| /* > for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is REAL array, dimension (N) */ | |||
| /* > If INFO = 0, C contains the column scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ROWCND */ | |||
| /* > \verbatim */ | |||
| /* > ROWCND is REAL */ | |||
| /* > If INFO = 0 or INFO > M, ROWCND contains the ratio of the */ | |||
| /* > smallest R(i) to the largest R(i). If ROWCND >= 0.1 and */ | |||
| /* > AMAX is neither too large nor too small, it is not worth */ | |||
| /* > scaling by R. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] COLCND */ | |||
| /* > \verbatim */ | |||
| /* > COLCND is REAL */ | |||
| /* > If INFO = 0, COLCND contains the ratio of the smallest */ | |||
| /* > C(i) to the largest C(i). If COLCND >= 0.1, it is not */ | |||
| /* > worth scaling by C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is REAL */ | |||
| /* > Absolute value of largest matrix element. If AMAX is very */ | |||
| /* > close to overflow or very close to underflow, the matrix */ | |||
| /* > should be scaled. */ | |||
| /* > \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 = i, and i is */ | |||
| /* > <= M: the i-th row of A is exactly zero */ | |||
| /* > > M: the (i-M)-th column of A is exactly zero */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGBcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbequ_(integer *m, integer *n, integer *kl, integer *ku, | |||
| complex *ab, integer *ldab, real *r__, real *c__, real *rowcnd, real | |||
| *colcnd, real *amax, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4; | |||
| real r__1, r__2, r__3, r__4; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| real rcmin, rcmax; | |||
| integer kd; | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| real bignum, smlnum; | |||
| /* -- 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 */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --r__; | |||
| --c__; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*kl < 0) { | |||
| *info = -3; | |||
| } else if (*ku < 0) { | |||
| *info = -4; | |||
| } else if (*ldab < *kl + *ku + 1) { | |||
| *info = -6; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBEQU", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*m == 0 || *n == 0) { | |||
| *rowcnd = 1.f; | |||
| *colcnd = 1.f; | |||
| *amax = 0.f; | |||
| return 0; | |||
| } | |||
| /* Get machine constants. */ | |||
| smlnum = slamch_("S"); | |||
| bignum = 1.f / smlnum; | |||
| /* Compute row scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| r__[i__] = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* Find the maximum element in each row. */ | |||
| kd = *ku + 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__2 = j - *ku; | |||
| /* Computing MIN */ | |||
| i__4 = j + *kl; | |||
| i__3 = f2cmin(i__4,*m); | |||
| for (i__ = f2cmax(i__2,1); i__ <= i__3; ++i__) { | |||
| /* Computing MAX */ | |||
| i__2 = kd + i__ - j + j * ab_dim1; | |||
| r__3 = r__[i__], r__4 = (r__1 = ab[i__2].r, abs(r__1)) + (r__2 = | |||
| r_imag(&ab[kd + i__ - j + j * ab_dim1]), abs(r__2)); | |||
| r__[i__] = f2cmax(r__3,r__4); | |||
| /* L20: */ | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = r__[i__]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = r__[i__]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* L40: */ | |||
| } | |||
| *amax = rcmax; | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (r__[i__] == 0.f) { | |||
| *info = i__; | |||
| return 0; | |||
| } | |||
| /* L50: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = r__[i__]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| r__[i__] = 1.f / f2cmin(r__1,bignum); | |||
| /* L60: */ | |||
| } | |||
| /* Compute ROWCND = f2cmin(R(I)) / f2cmax(R(I)) */ | |||
| *rowcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| /* Compute column scale factors */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| c__[j] = 0.f; | |||
| /* L70: */ | |||
| } | |||
| /* Find the maximum element in each column, */ | |||
| /* assuming the row scaling computed above. */ | |||
| kd = *ku + 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__3 = j - *ku; | |||
| /* Computing MIN */ | |||
| i__4 = j + *kl; | |||
| i__2 = f2cmin(i__4,*m); | |||
| for (i__ = f2cmax(i__3,1); i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__3 = kd + i__ - j + j * ab_dim1; | |||
| r__3 = c__[j], r__4 = ((r__1 = ab[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&ab[kd + i__ - j + j * ab_dim1]), abs(r__2))) * | |||
| r__[i__]; | |||
| c__[j] = f2cmax(r__3,r__4); | |||
| /* L80: */ | |||
| } | |||
| /* L90: */ | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = c__[j]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = c__[j]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* L100: */ | |||
| } | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (c__[j] == 0.f) { | |||
| *info = *m + j; | |||
| return 0; | |||
| } | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = c__[j]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| c__[j] = 1.f / f2cmin(r__1,bignum); | |||
| /* L120: */ | |||
| } | |||
| /* Compute COLCND = f2cmin(C(J)) / f2cmax(C(J)) */ | |||
| *colcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| return 0; | |||
| /* End of CGBEQU */ | |||
| } /* cgbequ_ */ | |||
| @@ -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) | |||
| */ | |||
| /* > \brief \b CGBEQUB */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBEQUB + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbequb | |||
| .f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbequb | |||
| .f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbequb | |||
| .f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBEQUB( M, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND, */ | |||
| /* AMAX, INFO ) */ | |||
| /* INTEGER INFO, KL, KU, LDAB, M, N */ | |||
| /* REAL AMAX, COLCND, ROWCND */ | |||
| /* REAL C( * ), R( * ) */ | |||
| /* COMPLEX AB( LDAB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBEQUB computes row and column scalings intended to equilibrate an */ | |||
| /* > M-by-N matrix A and reduce its condition number. R returns the row */ | |||
| /* > scale factors and C the column scale factors, chosen to try to make */ | |||
| /* > the largest element in each row and column of the matrix B with */ | |||
| /* > elements B(i,j)=R(i)*A(i,j)*C(j) have an absolute value of at most */ | |||
| /* > the radix. */ | |||
| /* > */ | |||
| /* > R(i) and C(j) are restricted to be a power of the radix between */ | |||
| /* > SMLNUM = smallest safe number and BIGNUM = largest safe number. Use */ | |||
| /* > of these scaling factors is not guaranteed to reduce the condition */ | |||
| /* > number of A but works well in practice. */ | |||
| /* > */ | |||
| /* > This routine differs from CGEEQU by restricting the scaling factors */ | |||
| /* > to a power of the radix. Barring over- and underflow, scaling by */ | |||
| /* > these factors introduces no additional rounding errors. However, the */ | |||
| /* > scaled entries' magnitudes are no longer approximately 1 but lie */ | |||
| /* > between sqrt(radix) and 1/sqrt(radix). */ | |||
| /* > \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] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX 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(N,j+kl) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array A. LDAB >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] R */ | |||
| /* > \verbatim */ | |||
| /* > R is REAL array, dimension (M) */ | |||
| /* > If INFO = 0 or INFO > M, R contains the row scale factors */ | |||
| /* > for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is REAL array, dimension (N) */ | |||
| /* > If INFO = 0, C contains the column scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ROWCND */ | |||
| /* > \verbatim */ | |||
| /* > ROWCND is REAL */ | |||
| /* > If INFO = 0 or INFO > M, ROWCND contains the ratio of the */ | |||
| /* > smallest R(i) to the largest R(i). If ROWCND >= 0.1 and */ | |||
| /* > AMAX is neither too large nor too small, it is not worth */ | |||
| /* > scaling by R. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] COLCND */ | |||
| /* > \verbatim */ | |||
| /* > COLCND is REAL */ | |||
| /* > If INFO = 0, COLCND contains the ratio of the smallest */ | |||
| /* > C(i) to the largest C(i). If COLCND >= 0.1, it is not */ | |||
| /* > worth scaling by C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is REAL */ | |||
| /* > Absolute value of largest matrix element. If AMAX is very */ | |||
| /* > close to overflow or very close to underflow, the matrix */ | |||
| /* > should be scaled. */ | |||
| /* > \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 = i, and i is */ | |||
| /* > <= M: the i-th row of A is exactly zero */ | |||
| /* > > M: the (i-M)-th column of A is exactly zero */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complexGBcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbequb_(integer *m, integer *n, integer *kl, integer * | |||
| ku, complex *ab, integer *ldab, real *r__, real *c__, real *rowcnd, | |||
| real *colcnd, real *amax, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4; | |||
| real r__1, r__2, r__3, r__4; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| real radix, rcmin, rcmax; | |||
| integer kd; | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| real bignum, logrdx, smlnum; | |||
| /* -- 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 */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --r__; | |||
| --c__; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*kl < 0) { | |||
| *info = -3; | |||
| } else if (*ku < 0) { | |||
| *info = -4; | |||
| } else if (*ldab < *kl + *ku + 1) { | |||
| *info = -6; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBEQUB", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible. */ | |||
| if (*m == 0 || *n == 0) { | |||
| *rowcnd = 1.f; | |||
| *colcnd = 1.f; | |||
| *amax = 0.f; | |||
| return 0; | |||
| } | |||
| /* Get machine constants. Assume SMLNUM is a power of the radix. */ | |||
| smlnum = slamch_("S"); | |||
| bignum = 1.f / smlnum; | |||
| radix = slamch_("B"); | |||
| logrdx = log(radix); | |||
| /* Compute row scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| r__[i__] = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* Find the maximum element in each row. */ | |||
| kd = *ku + 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__2 = j - *ku; | |||
| /* Computing MIN */ | |||
| i__4 = j + *kl; | |||
| i__3 = f2cmin(i__4,*m); | |||
| for (i__ = f2cmax(i__2,1); i__ <= i__3; ++i__) { | |||
| /* Computing MAX */ | |||
| i__2 = kd + i__ - j + j * ab_dim1; | |||
| r__3 = r__[i__], r__4 = (r__1 = ab[i__2].r, abs(r__1)) + (r__2 = | |||
| r_imag(&ab[kd + i__ - j + j * ab_dim1]), abs(r__2)); | |||
| r__[i__] = f2cmax(r__3,r__4); | |||
| /* L20: */ | |||
| } | |||
| /* L30: */ | |||
| } | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (r__[i__] > 0.f) { | |||
| i__3 = (integer) (log(r__[i__]) / logrdx); | |||
| r__[i__] = pow_ri(&radix, &i__3); | |||
| } | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = r__[i__]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = r__[i__]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* L40: */ | |||
| } | |||
| *amax = rcmax; | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (r__[i__] == 0.f) { | |||
| *info = i__; | |||
| return 0; | |||
| } | |||
| /* L50: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = r__[i__]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| r__[i__] = 1.f / f2cmin(r__1,bignum); | |||
| /* L60: */ | |||
| } | |||
| /* Compute ROWCND = f2cmin(R(I)) / f2cmax(R(I)). */ | |||
| *rowcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| /* Compute column scale factors. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| c__[j] = 0.f; | |||
| /* L70: */ | |||
| } | |||
| /* Find the maximum element in each column, */ | |||
| /* assuming the row scaling computed above. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__3 = j - *ku; | |||
| /* Computing MIN */ | |||
| i__4 = j + *kl; | |||
| i__2 = f2cmin(i__4,*m); | |||
| for (i__ = f2cmax(i__3,1); i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__3 = kd + i__ - j + j * ab_dim1; | |||
| r__3 = c__[j], r__4 = ((r__1 = ab[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&ab[kd + i__ - j + j * ab_dim1]), abs(r__2))) * | |||
| r__[i__]; | |||
| c__[j] = f2cmax(r__3,r__4); | |||
| /* L80: */ | |||
| } | |||
| if (c__[j] > 0.f) { | |||
| i__2 = (integer) (log(c__[j]) / logrdx); | |||
| c__[j] = pow_ri(&radix, &i__2); | |||
| } | |||
| /* L90: */ | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = c__[j]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = c__[j]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* L100: */ | |||
| } | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (c__[j] == 0.f) { | |||
| *info = *m + j; | |||
| return 0; | |||
| } | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = c__[j]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| c__[j] = 1.f / f2cmin(r__1,bignum); | |||
| /* L120: */ | |||
| } | |||
| /* Compute COLCND = f2cmin(C(J)) / f2cmax(C(J)). */ | |||
| *colcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| return 0; | |||
| /* End of CGBEQUB */ | |||
| } /* cgbequb_ */ | |||
| @@ -0,0 +1,950 @@ | |||
| /* 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 complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGBRFS */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBRFS + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbrfs. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbrfs. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbrfs. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBRFS( TRANS, N, KL, KU, NRHS, AB, LDAB, AFB, LDAFB, */ | |||
| /* IPIV, B, LDB, X, LDX, FERR, BERR, WORK, RWORK, */ | |||
| /* INFO ) */ | |||
| /* CHARACTER TRANS */ | |||
| /* INTEGER INFO, KL, KU, LDAB, LDAFB, LDB, LDX, N, NRHS */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* REAL BERR( * ), FERR( * ), RWORK( * ) */ | |||
| /* COMPLEX AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ), */ | |||
| /* $ WORK( * ), X( LDX, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBRFS improves the computed solution to a system of linear */ | |||
| /* > equations when the coefficient matrix is banded, and provides */ | |||
| /* > error bounds and backward error estimates for the solution. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > Specifies the form of the system of equations: */ | |||
| /* > = 'N': A * X = B (No transpose) */ | |||
| /* > = 'T': A**T * X = B (Transpose) */ | |||
| /* > = 'C': A**H * X = B (Conjugate transpose) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order 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] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of columns */ | |||
| /* > of the matrices B and X. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX array, dimension (LDAB,N) */ | |||
| /* > The original 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[in] AFB */ | |||
| /* > \verbatim */ | |||
| /* > AFB is COMPLEX array, dimension (LDAFB,N) */ | |||
| /* > Details of the LU factorization of the band matrix A, as */ | |||
| /* > computed by CGBTRF. U is stored as an upper triangular band */ | |||
| /* > matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */ | |||
| /* > the multipliers used during the factorization are stored in */ | |||
| /* > rows KL+KU+2 to 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAFB */ | |||
| /* > \verbatim */ | |||
| /* > LDAFB is INTEGER */ | |||
| /* > The leading dimension of the array AFB. LDAFB >= 2*KL*KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (N) */ | |||
| /* > The pivot indices from CGBTRF; for 1<=i<=N, row i of the */ | |||
| /* > matrix was interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > The right hand side matrix B. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX array, dimension (LDX,NRHS) */ | |||
| /* > On entry, the solution matrix X, as computed by CGBTRS. */ | |||
| /* > On exit, the improved solution matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDX */ | |||
| /* > \verbatim */ | |||
| /* > LDX is INTEGER */ | |||
| /* > The leading dimension of the array X. LDX >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] FERR */ | |||
| /* > \verbatim */ | |||
| /* > FERR is REAL array, dimension (NRHS) */ | |||
| /* > The estimated forward error bound for each solution vector */ | |||
| /* > X(j) (the j-th column of the solution matrix X). */ | |||
| /* > If XTRUE is the true solution corresponding to X(j), FERR(j) */ | |||
| /* > is an estimated upper bound for the magnitude of the largest */ | |||
| /* > element in (X(j) - XTRUE) divided by the magnitude of the */ | |||
| /* > largest element in X(j). The estimate is as reliable as */ | |||
| /* > the estimate for RCOND, and is almost always a slight */ | |||
| /* > overestimate of the true error. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] BERR */ | |||
| /* > \verbatim */ | |||
| /* > BERR is REAL array, dimension (NRHS) */ | |||
| /* > The componentwise relative backward error of each solution */ | |||
| /* > vector X(j) (i.e., the smallest relative change in */ | |||
| /* > any element of A or B that makes X(j) an exact solution). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > ITMAX is the maximum number of steps of iterative refinement. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGBcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbrfs_(char *trans, integer *n, integer *kl, integer * | |||
| ku, integer *nrhs, complex *ab, integer *ldab, complex *afb, integer * | |||
| ldafb, integer *ipiv, complex *b, integer *ldb, complex *x, integer * | |||
| ldx, real *ferr, real *berr, complex *work, real *rwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset, | |||
| x_dim1, x_offset, i__1, i__2, i__3, i__4, i__5, i__6, i__7; | |||
| real r__1, r__2, r__3, r__4; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer kase; | |||
| real safe1, safe2; | |||
| integer i__, j, k; | |||
| real s; | |||
| extern /* Subroutine */ int cgbmv_(char *, integer *, integer *, integer * | |||
| , integer *, complex *, complex *, integer *, complex *, integer * | |||
| , complex *, complex *, integer *); | |||
| extern logical lsame_(char *, char *); | |||
| integer isave[3]; | |||
| extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, | |||
| complex *, integer *), caxpy_(integer *, complex *, complex *, | |||
| integer *, complex *, integer *); | |||
| integer count; | |||
| extern /* Subroutine */ int clacn2_(integer *, complex *, complex *, real | |||
| *, integer *, integer *); | |||
| integer kk; | |||
| real xk; | |||
| extern real slamch_(char *); | |||
| integer nz; | |||
| real safmin; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), cgbtrs_( | |||
| char *, integer *, integer *, integer *, integer *, complex *, | |||
| integer *, integer *, complex *, integer *, integer *); | |||
| logical notran; | |||
| char transn[1], transt[1]; | |||
| real lstres, eps; | |||
| /* -- 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 */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| afb_dim1 = *ldafb; | |||
| afb_offset = 1 + afb_dim1 * 1; | |||
| afb -= afb_offset; | |||
| --ipiv; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| x_dim1 = *ldx; | |||
| x_offset = 1 + x_dim1 * 1; | |||
| x -= x_offset; | |||
| --ferr; | |||
| --berr; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| notran = lsame_(trans, "N"); | |||
| if (! notran && ! lsame_(trans, "T") && ! lsame_( | |||
| trans, "C")) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*kl < 0) { | |||
| *info = -3; | |||
| } else if (*ku < 0) { | |||
| *info = -4; | |||
| } else if (*nrhs < 0) { | |||
| *info = -5; | |||
| } else if (*ldab < *kl + *ku + 1) { | |||
| *info = -7; | |||
| } else if (*ldafb < (*kl << 1) + *ku + 1) { | |||
| *info = -9; | |||
| } else if (*ldb < f2cmax(1,*n)) { | |||
| *info = -12; | |||
| } else if (*ldx < f2cmax(1,*n)) { | |||
| *info = -14; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBRFS", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0 || *nrhs == 0) { | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| ferr[j] = 0.f; | |||
| berr[j] = 0.f; | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| } | |||
| if (notran) { | |||
| *(unsigned char *)transn = 'N'; | |||
| *(unsigned char *)transt = 'C'; | |||
| } else { | |||
| *(unsigned char *)transn = 'C'; | |||
| *(unsigned char *)transt = 'N'; | |||
| } | |||
| /* NZ = maximum number of nonzero elements in each row of A, plus 1 */ | |||
| /* Computing MIN */ | |||
| i__1 = *kl + *ku + 2, i__2 = *n + 1; | |||
| nz = f2cmin(i__1,i__2); | |||
| eps = slamch_("Epsilon"); | |||
| safmin = slamch_("Safe minimum"); | |||
| safe1 = nz * safmin; | |||
| safe2 = safe1 / eps; | |||
| /* Do for each right hand side */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| count = 1; | |||
| lstres = 3.f; | |||
| L20: | |||
| /* Loop until stopping criterion is satisfied. */ | |||
| /* Compute residual R = B - op(A) * X, */ | |||
| /* where op(A) = A, A**T, or A**H, depending on TRANS. */ | |||
| ccopy_(n, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1); | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgbmv_(trans, n, n, kl, ku, &q__1, &ab[ab_offset], ldab, &x[j * | |||
| x_dim1 + 1], &c__1, &c_b1, &work[1], &c__1); | |||
| /* Compute componentwise relative backward error from formula */ | |||
| /* f2cmax(i) ( abs(R(i)) / ( abs(op(A))*abs(X) + abs(B) )(i) ) */ | |||
| /* where abs(Z) is the componentwise absolute value of the matrix */ | |||
| /* or vector Z. If the i-th component of the denominator is less */ | |||
| /* than SAFE2, then SAFE1 is added to the i-th components of the */ | |||
| /* numerator and denominator before dividing. */ | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| rwork[i__] = (r__1 = b[i__3].r, abs(r__1)) + (r__2 = r_imag(&b[ | |||
| i__ + j * b_dim1]), abs(r__2)); | |||
| /* L30: */ | |||
| } | |||
| /* Compute abs(op(A))*abs(X) + abs(B). */ | |||
| if (notran) { | |||
| i__2 = *n; | |||
| for (k = 1; k <= i__2; ++k) { | |||
| kk = *ku + 1 - k; | |||
| i__3 = k + j * x_dim1; | |||
| xk = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[k + j * | |||
| x_dim1]), abs(r__2)); | |||
| /* Computing MAX */ | |||
| i__3 = 1, i__4 = k - *ku; | |||
| /* Computing MIN */ | |||
| i__6 = *n, i__7 = k + *kl; | |||
| i__5 = f2cmin(i__6,i__7); | |||
| for (i__ = f2cmax(i__3,i__4); i__ <= i__5; ++i__) { | |||
| i__3 = kk + i__ + k * ab_dim1; | |||
| rwork[i__] += ((r__1 = ab[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&ab[kk + i__ + k * ab_dim1]), abs(r__2))) * | |||
| xk; | |||
| /* L40: */ | |||
| } | |||
| /* L50: */ | |||
| } | |||
| } else { | |||
| i__2 = *n; | |||
| for (k = 1; k <= i__2; ++k) { | |||
| s = 0.f; | |||
| kk = *ku + 1 - k; | |||
| /* Computing MAX */ | |||
| i__5 = 1, i__3 = k - *ku; | |||
| /* Computing MIN */ | |||
| i__6 = *n, i__7 = k + *kl; | |||
| i__4 = f2cmin(i__6,i__7); | |||
| for (i__ = f2cmax(i__5,i__3); i__ <= i__4; ++i__) { | |||
| i__5 = kk + i__ + k * ab_dim1; | |||
| i__3 = i__ + j * x_dim1; | |||
| s += ((r__1 = ab[i__5].r, abs(r__1)) + (r__2 = r_imag(&ab[ | |||
| kk + i__ + k * ab_dim1]), abs(r__2))) * ((r__3 = | |||
| x[i__3].r, abs(r__3)) + (r__4 = r_imag(&x[i__ + j | |||
| * x_dim1]), abs(r__4))); | |||
| /* L60: */ | |||
| } | |||
| rwork[k] += s; | |||
| /* L70: */ | |||
| } | |||
| } | |||
| s = 0.f; | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| if (rwork[i__] > safe2) { | |||
| /* Computing MAX */ | |||
| i__4 = i__; | |||
| r__3 = s, r__4 = ((r__1 = work[i__4].r, abs(r__1)) + (r__2 = | |||
| r_imag(&work[i__]), abs(r__2))) / rwork[i__]; | |||
| s = f2cmax(r__3,r__4); | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__4 = i__; | |||
| r__3 = s, r__4 = ((r__1 = work[i__4].r, abs(r__1)) + (r__2 = | |||
| r_imag(&work[i__]), abs(r__2)) + safe1) / (rwork[i__] | |||
| + safe1); | |||
| s = f2cmax(r__3,r__4); | |||
| } | |||
| /* L80: */ | |||
| } | |||
| berr[j] = s; | |||
| /* Test stopping criterion. Continue iterating if */ | |||
| /* 1) The residual BERR(J) is larger than machine epsilon, and */ | |||
| /* 2) BERR(J) decreased by at least a factor of 2 during the */ | |||
| /* last iteration, and */ | |||
| /* 3) At most ITMAX iterations tried. */ | |||
| if (berr[j] > eps && berr[j] * 2.f <= lstres && count <= 5) { | |||
| /* Update solution and try again. */ | |||
| cgbtrs_(trans, n, kl, ku, &c__1, &afb[afb_offset], ldafb, &ipiv[1] | |||
| , &work[1], n, info); | |||
| caxpy_(n, &c_b1, &work[1], &c__1, &x[j * x_dim1 + 1], &c__1); | |||
| lstres = berr[j]; | |||
| ++count; | |||
| goto L20; | |||
| } | |||
| /* Bound error from formula */ | |||
| /* norm(X - XTRUE) / norm(X) .le. FERR = */ | |||
| /* norm( abs(inv(op(A)))* */ | |||
| /* ( abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) / norm(X) */ | |||
| /* where */ | |||
| /* norm(Z) is the magnitude of the largest component of Z */ | |||
| /* inv(op(A)) is the inverse of op(A) */ | |||
| /* abs(Z) is the componentwise absolute value of the matrix or */ | |||
| /* vector Z */ | |||
| /* NZ is the maximum number of nonzeros in any row of A, plus 1 */ | |||
| /* EPS is machine epsilon */ | |||
| /* The i-th component of abs(R)+NZ*EPS*(abs(op(A))*abs(X)+abs(B)) */ | |||
| /* is incremented by SAFE1 if the i-th component of */ | |||
| /* abs(op(A))*abs(X) + abs(B) is less than SAFE2. */ | |||
| /* Use CLACN2 to estimate the infinity-norm of the matrix */ | |||
| /* inv(op(A)) * diag(W), */ | |||
| /* where W = abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) */ | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| if (rwork[i__] > safe2) { | |||
| i__4 = i__; | |||
| rwork[i__] = (r__1 = work[i__4].r, abs(r__1)) + (r__2 = | |||
| r_imag(&work[i__]), abs(r__2)) + nz * eps * rwork[i__] | |||
| ; | |||
| } else { | |||
| i__4 = i__; | |||
| rwork[i__] = (r__1 = work[i__4].r, abs(r__1)) + (r__2 = | |||
| r_imag(&work[i__]), abs(r__2)) + nz * eps * rwork[i__] | |||
| + safe1; | |||
| } | |||
| /* L90: */ | |||
| } | |||
| kase = 0; | |||
| L100: | |||
| clacn2_(n, &work[*n + 1], &work[1], &ferr[j], &kase, isave); | |||
| if (kase != 0) { | |||
| if (kase == 1) { | |||
| /* Multiply by diag(W)*inv(op(A)**H). */ | |||
| cgbtrs_(transt, n, kl, ku, &c__1, &afb[afb_offset], ldafb, & | |||
| ipiv[1], &work[1], n, info); | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__4 = i__; | |||
| i__5 = i__; | |||
| i__3 = i__; | |||
| q__1.r = rwork[i__5] * work[i__3].r, q__1.i = rwork[i__5] | |||
| * work[i__3].i; | |||
| work[i__4].r = q__1.r, work[i__4].i = q__1.i; | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| /* Multiply by inv(op(A))*diag(W). */ | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__4 = i__; | |||
| i__5 = i__; | |||
| i__3 = i__; | |||
| q__1.r = rwork[i__5] * work[i__3].r, q__1.i = rwork[i__5] | |||
| * work[i__3].i; | |||
| work[i__4].r = q__1.r, work[i__4].i = q__1.i; | |||
| /* L120: */ | |||
| } | |||
| cgbtrs_(transn, n, kl, ku, &c__1, &afb[afb_offset], ldafb, & | |||
| ipiv[1], &work[1], n, info); | |||
| } | |||
| goto L100; | |||
| } | |||
| /* Normalize error. */ | |||
| lstres = 0.f; | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__4 = i__ + j * x_dim1; | |||
| r__3 = lstres, r__4 = (r__1 = x[i__4].r, abs(r__1)) + (r__2 = | |||
| r_imag(&x[i__ + j * x_dim1]), abs(r__2)); | |||
| lstres = f2cmax(r__3,r__4); | |||
| /* L130: */ | |||
| } | |||
| if (lstres != 0.f) { | |||
| ferr[j] /= lstres; | |||
| } | |||
| /* L140: */ | |||
| } | |||
| return 0; | |||
| /* End of CGBRFS */ | |||
| } /* cgbrfs_ */ | |||
| @@ -0,0 +1,381 @@ | |||
| /* 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 | |||
| @@ -0,0 +1,622 @@ | |||
| /* 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> CGBSV computes the solution to system of linear equations A * X = B for GB matrices</b> (simpl | |||
| e driver) */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBSV + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbsv.f | |||
| "> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbsv.f | |||
| "> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbsv.f | |||
| "> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBSV( N, KL, KU, NRHS, AB, LDAB, IPIV, B, LDB, INFO ) */ | |||
| /* INTEGER INFO, KL, KU, LDAB, LDB, N, NRHS */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX AB( LDAB, * ), B( LDB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBSV computes the solution to a complex system of linear equations */ | |||
| /* > A * X = B, where A is a band matrix of order N with KL subdiagonals */ | |||
| /* > and KU superdiagonals, and X and B are N-by-NRHS matrices. */ | |||
| /* > */ | |||
| /* > The LU decomposition with partial pivoting and row interchanges is */ | |||
| /* > used to factor A as A = L * U, where L is a product of permutation */ | |||
| /* > and unit lower triangular matrices with KL subdiagonals, and U is */ | |||
| /* > upper triangular with KL+KU superdiagonals. The factored form of A */ | |||
| /* > is then used to solve the system of equations A * X = B. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of linear equations, i.e., the order 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] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of columns */ | |||
| /* > of the matrix B. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX array, dimension (LDAB,N) */ | |||
| /* > On entry, the matrix A in band storage, in rows KL+1 to */ | |||
| /* > 2*KL+KU+1; rows 1 to KL of the array need not be set. */ | |||
| /* > The j-th column of A is stored in the j-th column of the */ | |||
| /* > array AB as follows: */ | |||
| /* > AB(KL+KU+1+i-j,j) = A(i,j) for f2cmax(1,j-KU)<=i<=f2cmin(N,j+KL) */ | |||
| /* > On exit, details of the factorization: U is stored as an */ | |||
| /* > upper triangular band matrix with KL+KU superdiagonals in */ | |||
| /* > rows 1 to KL+KU+1, and the multipliers used during the */ | |||
| /* > factorization are stored in rows KL+KU+2 to 2*KL+KU+1. */ | |||
| /* > See below for further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (N) */ | |||
| /* > The pivot indices that define the permutation matrix P; */ | |||
| /* > row i of the matrix was interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the N-by-NRHS right hand side matrix B. */ | |||
| /* > On exit, if INFO = 0, the N-by-NRHS solution matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= 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: if INFO = i, U(i,i) is exactly zero. The factorization */ | |||
| /* > has been completed, but the factor U is exactly */ | |||
| /* > singular, and the solution has not been computed. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGBsolve */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The band storage scheme is illustrated by the following example, when */ | |||
| /* > M = N = 6, KL = 2, KU = 1: */ | |||
| /* > */ | |||
| /* > On entry: On exit: */ | |||
| /* > */ | |||
| /* > * * * + + + * * * u14 u25 u36 */ | |||
| /* > * * + + + + * * u13 u24 u35 u46 */ | |||
| /* > * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56 */ | |||
| /* > a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66 */ | |||
| /* > a21 a32 a43 a54 a65 * m21 m32 m43 m54 m65 * */ | |||
| /* > a31 a42 a53 a64 * * m31 m42 m53 m64 * * */ | |||
| /* > */ | |||
| /* > Array elements marked * are not used by the routine; elements marked */ | |||
| /* > + need not be set on entry, but are required by the routine to store */ | |||
| /* > elements of U because of fill-in resulting from the row interchanges. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbsv_(integer *n, integer *kl, integer *ku, integer * | |||
| nrhs, complex *ab, integer *ldab, integer *ipiv, complex *b, integer * | |||
| ldb, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, b_dim1, b_offset, i__1; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int cgbtrf_(integer *, integer *, integer *, | |||
| integer *, complex *, integer *, integer *, integer *), xerbla_( | |||
| char *, integer *, ftnlen), cgbtrs_(char *, integer *, integer *, | |||
| integer *, integer *, complex *, integer *, integer *, complex *, | |||
| integer *, integer *); | |||
| /* -- LAPACK driver 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 */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --ipiv; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*n < 0) { | |||
| *info = -1; | |||
| } else if (*kl < 0) { | |||
| *info = -2; | |||
| } else if (*ku < 0) { | |||
| *info = -3; | |||
| } else if (*nrhs < 0) { | |||
| *info = -4; | |||
| } else if (*ldab < (*kl << 1) + *ku + 1) { | |||
| *info = -6; | |||
| } else if (*ldb < f2cmax(*n,1)) { | |||
| *info = -9; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBSV ", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Compute the LU factorization of the band matrix A. */ | |||
| cgbtrf_(n, n, kl, ku, &ab[ab_offset], ldab, &ipiv[1], info); | |||
| if (*info == 0) { | |||
| /* Solve the system A*X = B, overwriting B with X. */ | |||
| cgbtrs_("No transpose", n, kl, ku, nrhs, &ab[ab_offset], ldab, &ipiv[ | |||
| 1], &b[b_offset], ldb, info); | |||
| } | |||
| return 0; | |||
| /* End of CGBSV */ | |||
| } /* cgbsv_ */ | |||
| @@ -0,0 +1,699 @@ | |||
| /* 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 complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGBTF2 computes the LU factorization of a general band matrix using the unblocked version of th | |||
| e algorithm. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBTF2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbtf2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbtf2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbtf2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBTF2( M, N, KL, KU, AB, LDAB, IPIV, INFO ) */ | |||
| /* INTEGER INFO, KL, KU, LDAB, M, N */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX AB( LDAB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBTF2 computes an LU factorization of a complex m-by-n band matrix */ | |||
| /* > A using partial pivoting with row interchanges. */ | |||
| /* > */ | |||
| /* > This is the unblocked version of the algorithm, calling Level 2 BLAS. */ | |||
| /* > \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 array, dimension (LDAB,N) */ | |||
| /* > On entry, the matrix A in band storage, in rows KL+1 to */ | |||
| /* > 2*KL+KU+1; rows 1 to KL of the array need not be set. */ | |||
| /* > The j-th column of A is stored in the j-th column of the */ | |||
| /* > array AB as follows: */ | |||
| /* > AB(kl+ku+1+i-j,j) = A(i,j) for f2cmax(1,j-ku)<=i<=f2cmin(m,j+kl) */ | |||
| /* > */ | |||
| /* > On exit, details of the factorization: U is stored as an */ | |||
| /* > upper triangular band matrix with KL+KU superdiagonals in */ | |||
| /* > rows 1 to KL+KU+1, and the multipliers used during the */ | |||
| /* > factorization are stored in rows KL+KU+2 to 2*KL+KU+1. */ | |||
| /* > See below for further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (f2cmin(M,N)) */ | |||
| /* > The pivot indices; for 1 <= i <= f2cmin(M,N), row i of the */ | |||
| /* > matrix was interchanged with row IPIV(i). */ | |||
| /* > \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 = +i, U(i,i) is exactly zero. The factorization */ | |||
| /* > has been completed, but the factor U is exactly */ | |||
| /* > singular, and division by zero will occur if it is used */ | |||
| /* > to solve a system of equations. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGBcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The band storage scheme is illustrated by the following example, when */ | |||
| /* > M = N = 6, KL = 2, KU = 1: */ | |||
| /* > */ | |||
| /* > On entry: On exit: */ | |||
| /* > */ | |||
| /* > * * * + + + * * * u14 u25 u36 */ | |||
| /* > * * + + + + * * u13 u24 u35 u46 */ | |||
| /* > * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56 */ | |||
| /* > a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66 */ | |||
| /* > a21 a32 a43 a54 a65 * m21 m32 m43 m54 m65 * */ | |||
| /* > a31 a42 a53 a64 * * m31 m42 m53 m64 * * */ | |||
| /* > */ | |||
| /* > Array elements marked * are not used by the routine; elements marked */ | |||
| /* > + need not be set on entry, but are required by the routine to store */ | |||
| /* > elements of U, because of fill-in resulting from the row */ | |||
| /* > interchanges. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbtf2_(integer *m, integer *n, integer *kl, integer *ku, | |||
| complex *ab, integer *ldab, integer *ipiv, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cscal_(integer *, complex *, complex *, | |||
| integer *), cgeru_(integer *, integer *, complex *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *), cswap_( | |||
| integer *, complex *, integer *, complex *, integer *); | |||
| integer km, jp, ju, kv; | |||
| extern integer icamax_(integer *, complex *, integer *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| /* -- 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 */ | |||
| /* ===================================================================== */ | |||
| /* KV is the number of superdiagonals in the factor U, allowing for */ | |||
| /* fill-in. */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --ipiv; | |||
| /* Function Body */ | |||
| kv = *ku + *kl; | |||
| /* Test the input parameters. */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*kl < 0) { | |||
| *info = -3; | |||
| } else if (*ku < 0) { | |||
| *info = -4; | |||
| } else if (*ldab < *kl + kv + 1) { | |||
| *info = -6; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBTF2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*m == 0 || *n == 0) { | |||
| return 0; | |||
| } | |||
| /* Gaussian elimination with partial pivoting */ | |||
| /* Set fill-in elements in columns KU+2 to KV to zero. */ | |||
| i__1 = f2cmin(kv,*n); | |||
| for (j = *ku + 2; j <= i__1; ++j) { | |||
| i__2 = *kl; | |||
| for (i__ = kv - j + 2; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * ab_dim1; | |||
| ab[i__3].r = 0.f, ab[i__3].i = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| /* JU is the index of the last column affected by the current stage */ | |||
| /* of the factorization. */ | |||
| ju = 1; | |||
| i__1 = f2cmin(*m,*n); | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Set fill-in elements in column J+KV to zero. */ | |||
| if (j + kv <= *n) { | |||
| i__2 = *kl; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + (j + kv) * ab_dim1; | |||
| ab[i__3].r = 0.f, ab[i__3].i = 0.f; | |||
| /* L30: */ | |||
| } | |||
| } | |||
| /* Find pivot and test for singularity. KM is the number of */ | |||
| /* subdiagonal elements in the current column. */ | |||
| /* Computing MIN */ | |||
| i__2 = *kl, i__3 = *m - j; | |||
| km = f2cmin(i__2,i__3); | |||
| i__2 = km + 1; | |||
| jp = icamax_(&i__2, &ab[kv + 1 + j * ab_dim1], &c__1); | |||
| ipiv[j] = jp + j - 1; | |||
| i__2 = kv + jp + j * ab_dim1; | |||
| if (ab[i__2].r != 0.f || ab[i__2].i != 0.f) { | |||
| /* Computing MAX */ | |||
| /* Computing MIN */ | |||
| i__4 = j + *ku + jp - 1; | |||
| i__2 = ju, i__3 = f2cmin(i__4,*n); | |||
| ju = f2cmax(i__2,i__3); | |||
| /* Apply interchange to columns J to JU. */ | |||
| if (jp != 1) { | |||
| i__2 = ju - j + 1; | |||
| i__3 = *ldab - 1; | |||
| i__4 = *ldab - 1; | |||
| cswap_(&i__2, &ab[kv + jp + j * ab_dim1], &i__3, &ab[kv + 1 + | |||
| j * ab_dim1], &i__4); | |||
| } | |||
| if (km > 0) { | |||
| /* Compute multipliers. */ | |||
| c_div(&q__1, &c_b1, &ab[kv + 1 + j * ab_dim1]); | |||
| cscal_(&km, &q__1, &ab[kv + 2 + j * ab_dim1], &c__1); | |||
| /* Update trailing submatrix within the band. */ | |||
| if (ju > j) { | |||
| i__2 = ju - j; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| i__3 = *ldab - 1; | |||
| i__4 = *ldab - 1; | |||
| cgeru_(&km, &i__2, &q__1, &ab[kv + 2 + j * ab_dim1], & | |||
| c__1, &ab[kv + (j + 1) * ab_dim1], &i__3, &ab[kv | |||
| + 1 + (j + 1) * ab_dim1], &i__4); | |||
| } | |||
| } | |||
| } else { | |||
| /* If pivot is zero, set INFO to the index of the pivot */ | |||
| /* unless a zero pivot has already been found. */ | |||
| if (*info == 0) { | |||
| *info = j; | |||
| } | |||
| } | |||
| /* L40: */ | |||
| } | |||
| return 0; | |||
| /* End of CGBTF2 */ | |||
| } /* cgbtf2_ */ | |||
| @@ -0,0 +1,723 @@ | |||
| /* 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 complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGBTRS */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBTRS + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbtrs. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbtrs. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbtrs. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBTRS( TRANS, N, KL, KU, NRHS, AB, LDAB, IPIV, B, LDB, */ | |||
| /* INFO ) */ | |||
| /* CHARACTER TRANS */ | |||
| /* INTEGER INFO, KL, KU, LDAB, LDB, N, NRHS */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX AB( LDAB, * ), B( LDB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBTRS solves a system of linear equations */ | |||
| /* > A * X = B, A**T * X = B, or A**H * X = B */ | |||
| /* > with a general band matrix A using the LU factorization computed */ | |||
| /* > by CGBTRF. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > Specifies the form of the system of equations. */ | |||
| /* > = 'N': A * X = B (No transpose) */ | |||
| /* > = 'T': A**T * X = B (Transpose) */ | |||
| /* > = 'C': A**H * X = B (Conjugate transpose) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order 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] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of columns */ | |||
| /* > of the matrix B. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX array, dimension (LDAB,N) */ | |||
| /* > Details of the LU factorization of the band matrix A, as */ | |||
| /* > computed by CGBTRF. U is stored as an upper triangular band */ | |||
| /* > matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */ | |||
| /* > the multipliers used during the factorization are stored in */ | |||
| /* > rows KL+KU+2 to 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (N) */ | |||
| /* > The pivot indices; for 1 <= i <= N, row i of the matrix was */ | |||
| /* > interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the right hand side matrix B. */ | |||
| /* > On exit, the solution matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= 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 */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGBcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbtrs_(char *trans, integer *n, integer *kl, integer * | |||
| ku, integer *nrhs, complex *ab, integer *ldab, integer *ipiv, complex | |||
| *b, integer *ldb, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, b_dim1, b_offset, i__1, i__2, i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j, l; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int cgemv_(char *, integer *, integer *, complex * | |||
| , complex *, integer *, complex *, integer *, complex *, complex * | |||
| , integer *), cgeru_(integer *, integer *, complex *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *), | |||
| cswap_(integer *, complex *, integer *, complex *, integer *), | |||
| ctbsv_(char *, char *, char *, integer *, integer *, complex *, | |||
| integer *, complex *, integer *); | |||
| logical lnoti; | |||
| integer kd, lm; | |||
| extern /* Subroutine */ int clacgv_(integer *, complex *, integer *), | |||
| xerbla_(char *, integer *, ftnlen); | |||
| logical notran; | |||
| /* -- 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 */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --ipiv; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| notran = lsame_(trans, "N"); | |||
| if (! notran && ! lsame_(trans, "T") && ! lsame_( | |||
| trans, "C")) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*kl < 0) { | |||
| *info = -3; | |||
| } else if (*ku < 0) { | |||
| *info = -4; | |||
| } else if (*nrhs < 0) { | |||
| *info = -5; | |||
| } else if (*ldab < (*kl << 1) + *ku + 1) { | |||
| *info = -7; | |||
| } else if (*ldb < f2cmax(1,*n)) { | |||
| *info = -10; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBTRS", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0 || *nrhs == 0) { | |||
| return 0; | |||
| } | |||
| kd = *ku + *kl + 1; | |||
| lnoti = *kl > 0; | |||
| if (notran) { | |||
| /* Solve A*X = B. */ | |||
| /* Solve L*X = B, overwriting B with X. */ | |||
| /* L is represented as a product of permutations and unit lower */ | |||
| /* triangular matrices L = P(1) * L(1) * ... * P(n-1) * L(n-1), */ | |||
| /* where each transformation L(i) is a rank-one modification of */ | |||
| /* the identity matrix. */ | |||
| if (lnoti) { | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__2 = *kl, i__3 = *n - j; | |||
| lm = f2cmin(i__2,i__3); | |||
| l = ipiv[j]; | |||
| if (l != j) { | |||
| cswap_(nrhs, &b[l + b_dim1], ldb, &b[j + b_dim1], ldb); | |||
| } | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgeru_(&lm, nrhs, &q__1, &ab[kd + 1 + j * ab_dim1], &c__1, &b[ | |||
| j + b_dim1], ldb, &b[j + 1 + b_dim1], ldb); | |||
| /* L10: */ | |||
| } | |||
| } | |||
| i__1 = *nrhs; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Solve U*X = B, overwriting B with X. */ | |||
| i__2 = *kl + *ku; | |||
| ctbsv_("Upper", "No transpose", "Non-unit", n, &i__2, &ab[ | |||
| ab_offset], ldab, &b[i__ * b_dim1 + 1], &c__1); | |||
| /* L20: */ | |||
| } | |||
| } else if (lsame_(trans, "T")) { | |||
| /* Solve A**T * X = B. */ | |||
| i__1 = *nrhs; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Solve U**T * X = B, overwriting B with X. */ | |||
| i__2 = *kl + *ku; | |||
| ctbsv_("Upper", "Transpose", "Non-unit", n, &i__2, &ab[ab_offset], | |||
| ldab, &b[i__ * b_dim1 + 1], &c__1); | |||
| /* L30: */ | |||
| } | |||
| /* Solve L**T * X = B, overwriting B with X. */ | |||
| if (lnoti) { | |||
| for (j = *n - 1; j >= 1; --j) { | |||
| /* Computing MIN */ | |||
| i__1 = *kl, i__2 = *n - j; | |||
| lm = f2cmin(i__1,i__2); | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemv_("Transpose", &lm, nrhs, &q__1, &b[j + 1 + b_dim1], ldb, | |||
| &ab[kd + 1 + j * ab_dim1], &c__1, &c_b1, &b[j + | |||
| b_dim1], ldb); | |||
| l = ipiv[j]; | |||
| if (l != j) { | |||
| cswap_(nrhs, &b[l + b_dim1], ldb, &b[j + b_dim1], ldb); | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| } else { | |||
| /* Solve A**H * X = B. */ | |||
| i__1 = *nrhs; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Solve U**H * X = B, overwriting B with X. */ | |||
| i__2 = *kl + *ku; | |||
| ctbsv_("Upper", "Conjugate transpose", "Non-unit", n, &i__2, &ab[ | |||
| ab_offset], ldab, &b[i__ * b_dim1 + 1], &c__1); | |||
| /* L50: */ | |||
| } | |||
| /* Solve L**H * X = B, overwriting B with X. */ | |||
| if (lnoti) { | |||
| for (j = *n - 1; j >= 1; --j) { | |||
| /* Computing MIN */ | |||
| i__1 = *kl, i__2 = *n - j; | |||
| lm = f2cmin(i__1,i__2); | |||
| clacgv_(nrhs, &b[j + b_dim1], ldb); | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemv_("Conjugate transpose", &lm, nrhs, &q__1, &b[j + 1 + | |||
| b_dim1], ldb, &ab[kd + 1 + j * ab_dim1], &c__1, &c_b1, | |||
| &b[j + b_dim1], ldb); | |||
| clacgv_(nrhs, &b[j + b_dim1], ldb); | |||
| l = ipiv[j]; | |||
| if (l != j) { | |||
| cswap_(nrhs, &b[l + b_dim1], ldb, &b[j + b_dim1], ldb); | |||
| } | |||
| /* L60: */ | |||
| } | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGBTRS */ | |||
| } /* cgbtrs_ */ | |||
| @@ -0,0 +1,675 @@ | |||
| /* 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 CGEBAK */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEBAK + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgebak. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgebak. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgebak. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEBAK( JOB, SIDE, N, ILO, IHI, SCALE, M, V, LDV, */ | |||
| /* INFO ) */ | |||
| /* CHARACTER JOB, SIDE */ | |||
| /* INTEGER IHI, ILO, INFO, LDV, M, N */ | |||
| /* REAL SCALE( * ) */ | |||
| /* COMPLEX V( LDV, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEBAK forms the right or left eigenvectors of a complex general */ | |||
| /* > matrix by backward transformation on the computed eigenvectors of the */ | |||
| /* > balanced matrix output by CGEBAL. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOB */ | |||
| /* > \verbatim */ | |||
| /* > JOB is CHARACTER*1 */ | |||
| /* > Specifies the type of backward transformation required: */ | |||
| /* > = 'N': do nothing, return immediately; */ | |||
| /* > = 'P': do backward transformation for permutation only; */ | |||
| /* > = 'S': do backward transformation for scaling only; */ | |||
| /* > = 'B': do backward transformations for both permutation and */ | |||
| /* > scaling. */ | |||
| /* > JOB must be the same as the argument JOB supplied to CGEBAL. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'R': V contains right eigenvectors; */ | |||
| /* > = 'L': V contains left eigenvectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of rows of the matrix V. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ILO */ | |||
| /* > \verbatim */ | |||
| /* > ILO is INTEGER */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IHI */ | |||
| /* > \verbatim */ | |||
| /* > IHI is INTEGER */ | |||
| /* > The integers ILO and IHI determined by CGEBAL. */ | |||
| /* > 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SCALE */ | |||
| /* > \verbatim */ | |||
| /* > SCALE is REAL array, dimension (N) */ | |||
| /* > Details of the permutation and scaling factors, as returned */ | |||
| /* > by CGEBAL. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of columns of the matrix V. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX array, dimension (LDV,M) */ | |||
| /* > On entry, the matrix of right or left eigenvectors to be */ | |||
| /* > transformed, as returned by CHSEIN or CTREVC. */ | |||
| /* > On exit, V is overwritten by the transformed eigenvectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the array V. LDV >= 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. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgebak_(char *job, char *side, integer *n, integer *ilo, | |||
| integer *ihi, real *scale, integer *m, complex *v, integer *ldv, | |||
| integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer v_dim1, v_offset, i__1; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| real s; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int cswap_(integer *, complex *, integer *, | |||
| complex *, integer *); | |||
| logical leftv; | |||
| integer ii; | |||
| extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer | |||
| *), xerbla_(char *, integer *, ftnlen); | |||
| logical rightv; | |||
| /* -- 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 */ | |||
| /* ===================================================================== */ | |||
| /* Decode and Test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| --scale; | |||
| v_dim1 = *ldv; | |||
| v_offset = 1 + v_dim1 * 1; | |||
| v -= v_offset; | |||
| /* Function Body */ | |||
| rightv = lsame_(side, "R"); | |||
| leftv = lsame_(side, "L"); | |||
| *info = 0; | |||
| if (! lsame_(job, "N") && ! lsame_(job, "P") && ! lsame_(job, "S") | |||
| && ! lsame_(job, "B")) { | |||
| *info = -1; | |||
| } else if (! rightv && ! leftv) { | |||
| *info = -2; | |||
| } else if (*n < 0) { | |||
| *info = -3; | |||
| } else if (*ilo < 1 || *ilo > f2cmax(1,*n)) { | |||
| *info = -4; | |||
| } else if (*ihi < f2cmin(*ilo,*n) || *ihi > *n) { | |||
| *info = -5; | |||
| } else if (*m < 0) { | |||
| *info = -7; | |||
| } else if (*ldv < f2cmax(1,*n)) { | |||
| *info = -9; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEBAK", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0) { | |||
| return 0; | |||
| } | |||
| if (*m == 0) { | |||
| return 0; | |||
| } | |||
| if (lsame_(job, "N")) { | |||
| return 0; | |||
| } | |||
| if (*ilo == *ihi) { | |||
| goto L30; | |||
| } | |||
| /* Backward balance */ | |||
| if (lsame_(job, "S") || lsame_(job, "B")) { | |||
| if (rightv) { | |||
| i__1 = *ihi; | |||
| for (i__ = *ilo; i__ <= i__1; ++i__) { | |||
| s = scale[i__]; | |||
| csscal_(m, &s, &v[i__ + v_dim1], ldv); | |||
| /* L10: */ | |||
| } | |||
| } | |||
| if (leftv) { | |||
| i__1 = *ihi; | |||
| for (i__ = *ilo; i__ <= i__1; ++i__) { | |||
| s = 1.f / scale[i__]; | |||
| csscal_(m, &s, &v[i__ + v_dim1], ldv); | |||
| /* L20: */ | |||
| } | |||
| } | |||
| } | |||
| /* Backward permutation */ | |||
| /* For I = ILO-1 step -1 until 1, */ | |||
| /* IHI+1 step 1 until N do -- */ | |||
| L30: | |||
| if (lsame_(job, "P") || lsame_(job, "B")) { | |||
| if (rightv) { | |||
| i__1 = *n; | |||
| for (ii = 1; ii <= i__1; ++ii) { | |||
| i__ = ii; | |||
| if (i__ >= *ilo && i__ <= *ihi) { | |||
| goto L40; | |||
| } | |||
| if (i__ < *ilo) { | |||
| i__ = *ilo - ii; | |||
| } | |||
| k = scale[i__]; | |||
| if (k == i__) { | |||
| goto L40; | |||
| } | |||
| cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); | |||
| L40: | |||
| ; | |||
| } | |||
| } | |||
| if (leftv) { | |||
| i__1 = *n; | |||
| for (ii = 1; ii <= i__1; ++ii) { | |||
| i__ = ii; | |||
| if (i__ >= *ilo && i__ <= *ihi) { | |||
| goto L50; | |||
| } | |||
| if (i__ < *ilo) { | |||
| i__ = *ilo - ii; | |||
| } | |||
| k = scale[i__]; | |||
| if (k == i__) { | |||
| goto L50; | |||
| } | |||
| cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); | |||
| L50: | |||
| ; | |||
| } | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGEBAK */ | |||
| } /* cgebak_ */ | |||
| @@ -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__1 = 1; | |||
| /* > \brief \b CGEBAL */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEBAL + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgebal. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgebal. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgebal. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEBAL( JOB, N, A, LDA, ILO, IHI, SCALE, INFO ) */ | |||
| /* CHARACTER JOB */ | |||
| /* INTEGER IHI, ILO, INFO, LDA, N */ | |||
| /* REAL SCALE( * ) */ | |||
| /* COMPLEX A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEBAL balances a general complex matrix A. This involves, first, */ | |||
| /* > permuting A by a similarity transformation to isolate eigenvalues */ | |||
| /* > in the first 1 to ILO-1 and last IHI+1 to N elements on the */ | |||
| /* > diagonal; and second, applying a diagonal similarity transformation */ | |||
| /* > to rows and columns ILO to IHI to make the rows and columns as */ | |||
| /* > close in norm as possible. Both steps are optional. */ | |||
| /* > */ | |||
| /* > Balancing may reduce the 1-norm of the matrix, and improve the */ | |||
| /* > accuracy of the computed eigenvalues and/or eigenvectors. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOB */ | |||
| /* > \verbatim */ | |||
| /* > JOB is CHARACTER*1 */ | |||
| /* > Specifies the operations to be performed on A: */ | |||
| /* > = 'N': none: simply set ILO = 1, IHI = N, SCALE(I) = 1.0 */ | |||
| /* > for i = 1,...,N; */ | |||
| /* > = 'P': permute only; */ | |||
| /* > = 'S': scale only; */ | |||
| /* > = 'B': both permute and scale. */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the input matrix A. */ | |||
| /* > On exit, A is overwritten by the balanced matrix. */ | |||
| /* > If JOB = 'N', A is not referenced. */ | |||
| /* > 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] ILO */ | |||
| /* > \verbatim */ | |||
| /* > ILO is INTEGER */ | |||
| /* > \endverbatim */ | |||
| /* > \param[out] IHI */ | |||
| /* > \verbatim */ | |||
| /* > IHI is INTEGER */ | |||
| /* > ILO and IHI are set to integers such that on exit */ | |||
| /* > A(i,j) = 0 if i > j and j = 1,...,ILO-1 or I = IHI+1,...,N. */ | |||
| /* > If JOB = 'N' or 'S', ILO = 1 and IHI = N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SCALE */ | |||
| /* > \verbatim */ | |||
| /* > SCALE is REAL array, dimension (N) */ | |||
| /* > Details of the permutations and scaling factors applied to */ | |||
| /* > A. If P(j) is the index of the row and column interchanged */ | |||
| /* > with row and column j and D(j) is the scaling factor */ | |||
| /* > applied to row and column j, then */ | |||
| /* > SCALE(j) = P(j) for j = 1,...,ILO-1 */ | |||
| /* > = D(j) for j = ILO,...,IHI */ | |||
| /* > = P(j) for j = IHI+1,...,N. */ | |||
| /* > The order in which the interchanges are made is N to IHI+1, */ | |||
| /* > then 1 to ILO-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 December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The permutations consist of row and column interchanges which put */ | |||
| /* > the matrix in the form */ | |||
| /* > */ | |||
| /* > ( T1 X Y ) */ | |||
| /* > P A P = ( 0 B Z ) */ | |||
| /* > ( 0 0 T2 ) */ | |||
| /* > */ | |||
| /* > where T1 and T2 are upper triangular matrices whose eigenvalues lie */ | |||
| /* > along the diagonal. The column indices ILO and IHI mark the starting */ | |||
| /* > and ending columns of the submatrix B. Balancing consists of applying */ | |||
| /* > a diagonal similarity transformation inv(D) * B * D to make the */ | |||
| /* > 1-norms of each row of B and its corresponding column nearly equal. */ | |||
| /* > The output matrix is */ | |||
| /* > */ | |||
| /* > ( T1 X*D Y ) */ | |||
| /* > ( 0 inv(D)*B*D inv(D)*Z ). */ | |||
| /* > ( 0 0 T2 ) */ | |||
| /* > */ | |||
| /* > Information about the permutations P and the diagonal matrix D is */ | |||
| /* > returned in the vector SCALE. */ | |||
| /* > */ | |||
| /* > This subroutine is based on the EISPACK routine CBAL. */ | |||
| /* > */ | |||
| /* > Modified by Tzu-Yi Chen, Computer Science Division, University of */ | |||
| /* > California at Berkeley, USA */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgebal_(char *job, integer *n, complex *a, integer *lda, | |||
| integer *ilo, integer *ihi, real *scale, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| real r__1, r__2; | |||
| /* Local variables */ | |||
| integer iexc; | |||
| real c__, f, g; | |||
| integer i__, j, k, l, m; | |||
| real r__, s; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int cswap_(integer *, complex *, integer *, | |||
| complex *, integer *); | |||
| real sfmin1, sfmin2, sfmax1, sfmax2, ca; | |||
| extern real scnrm2_(integer *, complex *, integer *); | |||
| real ra; | |||
| extern integer icamax_(integer *, complex *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer | |||
| *), xerbla_(char *, integer *, ftnlen); | |||
| extern logical sisnan_(real *); | |||
| logical noconv; | |||
| integer ica, ira; | |||
| /* -- 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 */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --scale; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (! lsame_(job, "N") && ! lsame_(job, "P") && ! lsame_(job, "S") | |||
| && ! lsame_(job, "B")) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEBAL", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| k = 1; | |||
| l = *n; | |||
| if (*n == 0) { | |||
| goto L210; | |||
| } | |||
| if (lsame_(job, "N")) { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| scale[i__] = 1.f; | |||
| /* L10: */ | |||
| } | |||
| goto L210; | |||
| } | |||
| if (lsame_(job, "S")) { | |||
| goto L120; | |||
| } | |||
| /* Permutation to isolate eigenvalues if possible */ | |||
| goto L50; | |||
| /* Row and column exchange. */ | |||
| L20: | |||
| scale[m] = (real) j; | |||
| if (j == m) { | |||
| goto L30; | |||
| } | |||
| cswap_(&l, &a[j * a_dim1 + 1], &c__1, &a[m * a_dim1 + 1], &c__1); | |||
| i__1 = *n - k + 1; | |||
| cswap_(&i__1, &a[j + k * a_dim1], lda, &a[m + k * a_dim1], lda); | |||
| L30: | |||
| switch (iexc) { | |||
| case 1: goto L40; | |||
| case 2: goto L80; | |||
| } | |||
| /* Search for rows isolating an eigenvalue and push them down. */ | |||
| L40: | |||
| if (l == 1) { | |||
| goto L210; | |||
| } | |||
| --l; | |||
| L50: | |||
| for (j = l; j >= 1; --j) { | |||
| i__1 = l; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (i__ == j) { | |||
| goto L60; | |||
| } | |||
| i__2 = j + i__ * a_dim1; | |||
| if (a[i__2].r != 0.f || r_imag(&a[j + i__ * a_dim1]) != 0.f) { | |||
| goto L70; | |||
| } | |||
| L60: | |||
| ; | |||
| } | |||
| m = l; | |||
| iexc = 1; | |||
| goto L20; | |||
| L70: | |||
| ; | |||
| } | |||
| goto L90; | |||
| /* Search for columns isolating an eigenvalue and push them left. */ | |||
| L80: | |||
| ++k; | |||
| L90: | |||
| i__1 = l; | |||
| for (j = k; j <= i__1; ++j) { | |||
| i__2 = l; | |||
| for (i__ = k; i__ <= i__2; ++i__) { | |||
| if (i__ == j) { | |||
| goto L100; | |||
| } | |||
| i__3 = i__ + j * a_dim1; | |||
| if (a[i__3].r != 0.f || r_imag(&a[i__ + j * a_dim1]) != 0.f) { | |||
| goto L110; | |||
| } | |||
| L100: | |||
| ; | |||
| } | |||
| m = k; | |||
| iexc = 2; | |||
| goto L20; | |||
| L110: | |||
| ; | |||
| } | |||
| L120: | |||
| i__1 = l; | |||
| for (i__ = k; i__ <= i__1; ++i__) { | |||
| scale[i__] = 1.f; | |||
| /* L130: */ | |||
| } | |||
| if (lsame_(job, "P")) { | |||
| goto L210; | |||
| } | |||
| /* Balance the submatrix in rows K to L. */ | |||
| /* Iterative loop for norm reduction */ | |||
| sfmin1 = slamch_("S") / slamch_("P"); | |||
| sfmax1 = 1.f / sfmin1; | |||
| sfmin2 = sfmin1 * 2.f; | |||
| sfmax2 = 1.f / sfmin2; | |||
| L140: | |||
| noconv = FALSE_; | |||
| i__1 = l; | |||
| for (i__ = k; i__ <= i__1; ++i__) { | |||
| i__2 = l - k + 1; | |||
| c__ = scnrm2_(&i__2, &a[k + i__ * a_dim1], &c__1); | |||
| i__2 = l - k + 1; | |||
| r__ = scnrm2_(&i__2, &a[i__ + k * a_dim1], lda); | |||
| ica = icamax_(&l, &a[i__ * a_dim1 + 1], &c__1); | |||
| ca = c_abs(&a[ica + i__ * a_dim1]); | |||
| i__2 = *n - k + 1; | |||
| ira = icamax_(&i__2, &a[i__ + k * a_dim1], lda); | |||
| ra = c_abs(&a[i__ + (ira + k - 1) * a_dim1]); | |||
| /* Guard against zero C or R due to underflow. */ | |||
| if (c__ == 0.f || r__ == 0.f) { | |||
| goto L200; | |||
| } | |||
| g = r__ / 2.f; | |||
| f = 1.f; | |||
| s = c__ + r__; | |||
| L160: | |||
| /* Computing MAX */ | |||
| r__1 = f2cmax(f,c__); | |||
| /* Computing MIN */ | |||
| r__2 = f2cmin(r__,g); | |||
| if (c__ >= g || f2cmax(r__1,ca) >= sfmax2 || f2cmin(r__2,ra) <= sfmin2) { | |||
| goto L170; | |||
| } | |||
| r__1 = c__ + f + ca + r__ + g + ra; | |||
| if (sisnan_(&r__1)) { | |||
| /* Exit if NaN to avoid infinite loop */ | |||
| *info = -3; | |||
| i__2 = -(*info); | |||
| xerbla_("CGEBAL", &i__2, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| f *= 2.f; | |||
| c__ *= 2.f; | |||
| ca *= 2.f; | |||
| r__ /= 2.f; | |||
| g /= 2.f; | |||
| ra /= 2.f; | |||
| goto L160; | |||
| L170: | |||
| g = c__ / 2.f; | |||
| L180: | |||
| /* Computing MIN */ | |||
| r__1 = f2cmin(f,c__), r__1 = f2cmin(r__1,g); | |||
| if (g < r__ || f2cmax(r__,ra) >= sfmax2 || f2cmin(r__1,ca) <= sfmin2) { | |||
| goto L190; | |||
| } | |||
| f /= 2.f; | |||
| c__ /= 2.f; | |||
| g /= 2.f; | |||
| ca /= 2.f; | |||
| r__ *= 2.f; | |||
| ra *= 2.f; | |||
| goto L180; | |||
| /* Now balance. */ | |||
| L190: | |||
| if (c__ + r__ >= s * .95f) { | |||
| goto L200; | |||
| } | |||
| if (f < 1.f && scale[i__] < 1.f) { | |||
| if (f * scale[i__] <= sfmin1) { | |||
| goto L200; | |||
| } | |||
| } | |||
| if (f > 1.f && scale[i__] > 1.f) { | |||
| if (scale[i__] >= sfmax1 / f) { | |||
| goto L200; | |||
| } | |||
| } | |||
| g = 1.f / f; | |||
| scale[i__] *= f; | |||
| noconv = TRUE_; | |||
| i__2 = *n - k + 1; | |||
| csscal_(&i__2, &g, &a[i__ + k * a_dim1], lda); | |||
| csscal_(&l, &f, &a[i__ * a_dim1 + 1], &c__1); | |||
| L200: | |||
| ; | |||
| } | |||
| if (noconv) { | |||
| goto L140; | |||
| } | |||
| L210: | |||
| *ilo = k; | |||
| *ihi = l; | |||
| return 0; | |||
| /* End of CGEBAL */ | |||
| } /* cgebal_ */ | |||
| @@ -0,0 +1,784 @@ | |||
| /* 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 CGEBD2 reduces a general matrix to bidiagonal form using an unblocked algorithm. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEBD2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgebd2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgebd2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgebd2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEBD2( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* REAL D( * ), E( * ) */ | |||
| /* COMPLEX A( LDA, * ), TAUP( * ), TAUQ( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEBD2 reduces a complex general m by n matrix A to upper or lower */ | |||
| /* > real bidiagonal form B by a unitary transformation: Q**H * A * P = B. */ | |||
| /* > */ | |||
| /* > If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows in the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns in the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the m by n general matrix to be reduced. */ | |||
| /* > On exit, */ | |||
| /* > if m >= n, the diagonal and the first superdiagonal are */ | |||
| /* > overwritten with the upper bidiagonal matrix B; the */ | |||
| /* > elements below the diagonal, with the array TAUQ, represent */ | |||
| /* > the unitary matrix Q as a product of elementary */ | |||
| /* > reflectors, and the elements above the first superdiagonal, */ | |||
| /* > with the array TAUP, represent the unitary matrix P as */ | |||
| /* > a product of elementary reflectors; */ | |||
| /* > if m < n, the diagonal and the first subdiagonal are */ | |||
| /* > overwritten with the lower bidiagonal matrix B; the */ | |||
| /* > elements below the first subdiagonal, with the array TAUQ, */ | |||
| /* > represent the unitary matrix Q as a product of */ | |||
| /* > elementary reflectors, and the elements above the diagonal, */ | |||
| /* > with the array TAUP, represent the unitary matrix P as */ | |||
| /* > a product of elementary reflectors. */ | |||
| /* > 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] D */ | |||
| /* > \verbatim */ | |||
| /* > D is REAL array, dimension (f2cmin(M,N)) */ | |||
| /* > The diagonal elements of the bidiagonal matrix B: */ | |||
| /* > D(i) = A(i,i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] E */ | |||
| /* > \verbatim */ | |||
| /* > E is REAL array, dimension (f2cmin(M,N)-1) */ | |||
| /* > The off-diagonal elements of the bidiagonal matrix B: */ | |||
| /* > if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1; */ | |||
| /* > if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAUQ */ | |||
| /* > \verbatim */ | |||
| /* > TAUQ is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors which */ | |||
| /* > represent the unitary matrix Q. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAUP */ | |||
| /* > \verbatim */ | |||
| /* > TAUP is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors which */ | |||
| /* > represent the unitary matrix P. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (f2cmax(M,N)) */ | |||
| /* > \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 2017 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* @precisions normal c -> s d z */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrices Q and P are represented as products of elementary */ | |||
| /* > reflectors: */ | |||
| /* > */ | |||
| /* > If m >= n, */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1) */ | |||
| /* > */ | |||
| /* > Each H(i) and G(i) has the form: */ | |||
| /* > */ | |||
| /* > H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H */ | |||
| /* > */ | |||
| /* > where tauq and taup are complex scalars, and v and u are complex */ | |||
| /* > vectors; v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in */ | |||
| /* > A(i+1:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in */ | |||
| /* > A(i,i+2:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */ | |||
| /* > */ | |||
| /* > If m < n, */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m) */ | |||
| /* > */ | |||
| /* > Each H(i) and G(i) has the form: */ | |||
| /* > */ | |||
| /* > H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H */ | |||
| /* > */ | |||
| /* > where tauq and taup are complex scalars, v and u are complex vectors; */ | |||
| /* > v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i); */ | |||
| /* > u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n); */ | |||
| /* > tauq is stored in TAUQ(i) and taup in TAUP(i). */ | |||
| /* > */ | |||
| /* > The contents of A on exit are illustrated by the following examples: */ | |||
| /* > */ | |||
| /* > m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n): */ | |||
| /* > */ | |||
| /* > ( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 ) */ | |||
| /* > ( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 ) */ | |||
| /* > ( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 ) */ | |||
| /* > ( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 ) */ | |||
| /* > ( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 ) */ | |||
| /* > ( v1 v2 v3 v4 v5 ) */ | |||
| /* > */ | |||
| /* > where d and e denote diagonal and off-diagonal elements of B, vi */ | |||
| /* > denotes an element of the vector defining H(i), and ui an element of */ | |||
| /* > the vector defining G(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgebd2_(integer *m, integer *n, complex *a, integer *lda, | |||
| real *d__, real *e, complex *tauq, complex *taup, complex *work, | |||
| integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__; | |||
| complex alpha; | |||
| extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex * | |||
| , integer *, complex *, complex *, integer *, complex *), | |||
| clarfg_(integer *, complex *, complex *, integer *, complex *), | |||
| clacgv_(integer *, complex *, integer *), xerbla_(char *, integer | |||
| *, ftnlen); | |||
| /* -- 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 parameters */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --d__; | |||
| --e; | |||
| --tauq; | |||
| --taup; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info < 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEBD2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| if (*m >= *n) { | |||
| /* Reduce to upper bidiagonal form */ | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Generate elementary reflector H(i) to annihilate A(i+1:m,i) */ | |||
| i__2 = i__ + i__ * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = *m - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 1; | |||
| clarfg_(&i__2, &alpha, &a[f2cmin(i__3,*m) + i__ * a_dim1], &c__1, & | |||
| tauq[i__]); | |||
| i__2 = i__; | |||
| d__[i__2] = alpha.r; | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| /* Apply H(i)**H to A(i:m,i+1:n) from the left */ | |||
| if (i__ < *n) { | |||
| i__2 = *m - i__ + 1; | |||
| i__3 = *n - i__; | |||
| r_cnjg(&q__1, &tauq[i__]); | |||
| clarf_("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, & | |||
| q__1, &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]); | |||
| } | |||
| i__2 = i__ + i__ * a_dim1; | |||
| i__3 = i__; | |||
| a[i__2].r = d__[i__3], a[i__2].i = 0.f; | |||
| if (i__ < *n) { | |||
| /* Generate elementary reflector G(i) to annihilate */ | |||
| /* A(i,i+2:n) */ | |||
| i__2 = *n - i__; | |||
| clacgv_(&i__2, &a[i__ + (i__ + 1) * a_dim1], lda); | |||
| i__2 = i__ + (i__ + 1) * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = *n - i__; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 2; | |||
| clarfg_(&i__2, &alpha, &a[i__ + f2cmin(i__3,*n) * a_dim1], lda, & | |||
| taup[i__]); | |||
| i__2 = i__; | |||
| e[i__2] = alpha.r; | |||
| i__2 = i__ + (i__ + 1) * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| /* Apply G(i) to A(i+1:m,i+1:n) from the right */ | |||
| i__2 = *m - i__; | |||
| i__3 = *n - i__; | |||
| clarf_("Right", &i__2, &i__3, &a[i__ + (i__ + 1) * a_dim1], | |||
| lda, &taup[i__], &a[i__ + 1 + (i__ + 1) * a_dim1], | |||
| lda, &work[1]); | |||
| i__2 = *n - i__; | |||
| clacgv_(&i__2, &a[i__ + (i__ + 1) * a_dim1], lda); | |||
| i__2 = i__ + (i__ + 1) * a_dim1; | |||
| i__3 = i__; | |||
| a[i__2].r = e[i__3], a[i__2].i = 0.f; | |||
| } else { | |||
| i__2 = i__; | |||
| taup[i__2].r = 0.f, taup[i__2].i = 0.f; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| } else { | |||
| /* Reduce to lower bidiagonal form */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Generate elementary reflector G(i) to annihilate A(i,i+1:n) */ | |||
| i__2 = *n - i__ + 1; | |||
| clacgv_(&i__2, &a[i__ + i__ * a_dim1], lda); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = *n - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 1; | |||
| clarfg_(&i__2, &alpha, &a[i__ + f2cmin(i__3,*n) * a_dim1], lda, & | |||
| taup[i__]); | |||
| i__2 = i__; | |||
| d__[i__2] = alpha.r; | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| /* Apply G(i) to A(i+1:m,i:n) from the right */ | |||
| if (i__ < *m) { | |||
| i__2 = *m - i__; | |||
| i__3 = *n - i__ + 1; | |||
| clarf_("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, & | |||
| taup[i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]); | |||
| } | |||
| i__2 = *n - i__ + 1; | |||
| clacgv_(&i__2, &a[i__ + i__ * a_dim1], lda); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| i__3 = i__; | |||
| a[i__2].r = d__[i__3], a[i__2].i = 0.f; | |||
| if (i__ < *m) { | |||
| /* Generate elementary reflector H(i) to annihilate */ | |||
| /* A(i+2:m,i) */ | |||
| i__2 = i__ + 1 + i__ * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = *m - i__; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 2; | |||
| clarfg_(&i__2, &alpha, &a[f2cmin(i__3,*m) + i__ * a_dim1], &c__1, | |||
| &tauq[i__]); | |||
| i__2 = i__; | |||
| e[i__2] = alpha.r; | |||
| i__2 = i__ + 1 + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| /* Apply H(i)**H to A(i+1:m,i+1:n) from the left */ | |||
| i__2 = *m - i__; | |||
| i__3 = *n - i__; | |||
| r_cnjg(&q__1, &tauq[i__]); | |||
| clarf_("Left", &i__2, &i__3, &a[i__ + 1 + i__ * a_dim1], & | |||
| c__1, &q__1, &a[i__ + 1 + (i__ + 1) * a_dim1], lda, & | |||
| work[1]); | |||
| i__2 = i__ + 1 + i__ * a_dim1; | |||
| i__3 = i__; | |||
| a[i__2].r = e[i__3], a[i__2].i = 0.f; | |||
| } else { | |||
| i__2 = i__; | |||
| tauq[i__2].r = 0.f, tauq[i__2].i = 0.f; | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGEBD2 */ | |||
| } /* cgebd2_ */ | |||
| @@ -0,0 +1,798 @@ | |||
| /* 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 complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__3 = 3; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGEBRD */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEBRD + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgebrd. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgebrd. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgebrd. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEBRD( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK, */ | |||
| /* INFO ) */ | |||
| /* INTEGER INFO, LDA, LWORK, M, N */ | |||
| /* REAL D( * ), E( * ) */ | |||
| /* COMPLEX A( LDA, * ), TAUP( * ), TAUQ( * ), */ | |||
| /* $ WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEBRD reduces a general complex M-by-N matrix A to upper or lower */ | |||
| /* > bidiagonal form B by a unitary transformation: Q**H * A * P = B. */ | |||
| /* > */ | |||
| /* > If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows in the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns in the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N general matrix to be reduced. */ | |||
| /* > On exit, */ | |||
| /* > if m >= n, the diagonal and the first superdiagonal are */ | |||
| /* > overwritten with the upper bidiagonal matrix B; the */ | |||
| /* > elements below the diagonal, with the array TAUQ, represent */ | |||
| /* > the unitary matrix Q as a product of elementary */ | |||
| /* > reflectors, and the elements above the first superdiagonal, */ | |||
| /* > with the array TAUP, represent the unitary matrix P as */ | |||
| /* > a product of elementary reflectors; */ | |||
| /* > if m < n, the diagonal and the first subdiagonal are */ | |||
| /* > overwritten with the lower bidiagonal matrix B; the */ | |||
| /* > elements below the first subdiagonal, with the array TAUQ, */ | |||
| /* > represent the unitary matrix Q as a product of */ | |||
| /* > elementary reflectors, and the elements above the diagonal, */ | |||
| /* > with the array TAUP, represent the unitary matrix P as */ | |||
| /* > a product of elementary reflectors. */ | |||
| /* > 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] D */ | |||
| /* > \verbatim */ | |||
| /* > D is REAL array, dimension (f2cmin(M,N)) */ | |||
| /* > The diagonal elements of the bidiagonal matrix B: */ | |||
| /* > D(i) = A(i,i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] E */ | |||
| /* > \verbatim */ | |||
| /* > E is REAL array, dimension (f2cmin(M,N)-1) */ | |||
| /* > The off-diagonal elements of the bidiagonal matrix B: */ | |||
| /* > if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1; */ | |||
| /* > if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAUQ */ | |||
| /* > \verbatim */ | |||
| /* > TAUQ is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors which */ | |||
| /* > represent the unitary matrix Q. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAUP */ | |||
| /* > \verbatim */ | |||
| /* > TAUP is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors which */ | |||
| /* > represent the unitary matrix P. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The length of the array WORK. LWORK >= f2cmax(1,M,N). */ | |||
| /* > For optimum performance LWORK >= (M+N)*NB, where NB */ | |||
| /* > is the optimal blocksize. */ | |||
| /* > */ | |||
| /* > 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. */ | |||
| /* > \date November 2017 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrices Q and P are represented as products of elementary */ | |||
| /* > reflectors: */ | |||
| /* > */ | |||
| /* > If m >= n, */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1) */ | |||
| /* > */ | |||
| /* > Each H(i) and G(i) has the form: */ | |||
| /* > */ | |||
| /* > H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H */ | |||
| /* > */ | |||
| /* > where tauq and taup are complex scalars, and v and u are complex */ | |||
| /* > vectors; v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in */ | |||
| /* > A(i+1:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in */ | |||
| /* > A(i,i+2:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */ | |||
| /* > */ | |||
| /* > If m < n, */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m) */ | |||
| /* > */ | |||
| /* > Each H(i) and G(i) has the form: */ | |||
| /* > */ | |||
| /* > H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H */ | |||
| /* > */ | |||
| /* > where tauq and taup are complex scalars, and v and u are complex */ | |||
| /* > vectors; v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in */ | |||
| /* > A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in */ | |||
| /* > A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */ | |||
| /* > */ | |||
| /* > The contents of A on exit are illustrated by the following examples: */ | |||
| /* > */ | |||
| /* > m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n): */ | |||
| /* > */ | |||
| /* > ( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 ) */ | |||
| /* > ( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 ) */ | |||
| /* > ( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 ) */ | |||
| /* > ( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 ) */ | |||
| /* > ( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 ) */ | |||
| /* > ( v1 v2 v3 v4 v5 ) */ | |||
| /* > */ | |||
| /* > where d and e denote diagonal and off-diagonal elements of B, vi */ | |||
| /* > denotes an element of the vector defining H(i), and ui an element of */ | |||
| /* > the vector defining G(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgebrd_(integer *m, integer *n, complex *a, integer *lda, | |||
| real *d__, real *e, complex *tauq, complex *taup, complex *work, | |||
| integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5; | |||
| real r__1; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, | |||
| integer *, complex *, complex *, integer *, complex *, integer *, | |||
| complex *, complex *, integer *); | |||
| integer nbmin, iinfo, minmn; | |||
| extern /* Subroutine */ int cgebd2_(integer *, integer *, complex *, | |||
| integer *, real *, real *, complex *, complex *, complex *, | |||
| integer *); | |||
| integer nb; | |||
| extern /* Subroutine */ int clabrd_(integer *, integer *, integer *, | |||
| complex *, integer *, real *, real *, complex *, complex *, | |||
| complex *, integer *, complex *, integer *); | |||
| integer nx, ws; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| integer ldwrkx, ldwrky, lwkopt; | |||
| logical lquery; | |||
| /* -- 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 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --d__; | |||
| --e; | |||
| --tauq; | |||
| --taup; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = ilaenv_(&c__1, "CGEBRD", " ", m, n, &c_n1, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nb = f2cmax(i__1,i__2); | |||
| lwkopt = (*m + *n) * nb; | |||
| r__1 = (real) lwkopt; | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(1,*m); | |||
| if (*lwork < f2cmax(i__1,*n) && ! lquery) { | |||
| *info = -10; | |||
| } | |||
| } | |||
| if (*info < 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEBRD", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| minmn = f2cmin(*m,*n); | |||
| if (minmn == 0) { | |||
| work[1].r = 1.f, work[1].i = 0.f; | |||
| return 0; | |||
| } | |||
| ws = f2cmax(*m,*n); | |||
| ldwrkx = *m; | |||
| ldwrky = *n; | |||
| if (nb > 1 && nb < minmn) { | |||
| /* Set the crossover point NX. */ | |||
| /* Computing MAX */ | |||
| i__1 = nb, i__2 = ilaenv_(&c__3, "CGEBRD", " ", m, n, &c_n1, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nx = f2cmax(i__1,i__2); | |||
| /* Determine when to switch from blocked to unblocked code. */ | |||
| if (nx < minmn) { | |||
| ws = (*m + *n) * nb; | |||
| if (*lwork < ws) { | |||
| /* Not enough work space for the optimal NB, consider using */ | |||
| /* a smaller block size. */ | |||
| nbmin = ilaenv_(&c__2, "CGEBRD", " ", m, n, &c_n1, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| if (*lwork >= (*m + *n) * nbmin) { | |||
| nb = *lwork / (*m + *n); | |||
| } else { | |||
| nb = 1; | |||
| nx = minmn; | |||
| } | |||
| } | |||
| } | |||
| } else { | |||
| nx = minmn; | |||
| } | |||
| i__1 = minmn - nx; | |||
| i__2 = nb; | |||
| for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Reduce rows and columns i:i+ib-1 to bidiagonal form and return */ | |||
| /* the matrices X and Y which are needed to update the unreduced */ | |||
| /* part of the matrix */ | |||
| i__3 = *m - i__ + 1; | |||
| i__4 = *n - i__ + 1; | |||
| clabrd_(&i__3, &i__4, &nb, &a[i__ + i__ * a_dim1], lda, &d__[i__], &e[ | |||
| i__], &tauq[i__], &taup[i__], &work[1], &ldwrkx, &work[ldwrkx | |||
| * nb + 1], &ldwrky); | |||
| /* Update the trailing submatrix A(i+ib:m,i+ib:n), using */ | |||
| /* an update of the form A := A - V*Y**H - X*U**H */ | |||
| i__3 = *m - i__ - nb + 1; | |||
| i__4 = *n - i__ - nb + 1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemm_("No transpose", "Conjugate transpose", &i__3, &i__4, &nb, & | |||
| q__1, &a[i__ + nb + i__ * a_dim1], lda, &work[ldwrkx * nb + | |||
| nb + 1], &ldwrky, &c_b1, &a[i__ + nb + (i__ + nb) * a_dim1], | |||
| lda); | |||
| i__3 = *m - i__ - nb + 1; | |||
| i__4 = *n - i__ - nb + 1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemm_("No transpose", "No transpose", &i__3, &i__4, &nb, &q__1, & | |||
| work[nb + 1], &ldwrkx, &a[i__ + (i__ + nb) * a_dim1], lda, & | |||
| c_b1, &a[i__ + nb + (i__ + nb) * a_dim1], lda); | |||
| /* Copy diagonal and off-diagonal elements of B back into A */ | |||
| if (*m >= *n) { | |||
| i__3 = i__ + nb - 1; | |||
| for (j = i__; j <= i__3; ++j) { | |||
| i__4 = j + j * a_dim1; | |||
| i__5 = j; | |||
| a[i__4].r = d__[i__5], a[i__4].i = 0.f; | |||
| i__4 = j + (j + 1) * a_dim1; | |||
| i__5 = j; | |||
| a[i__4].r = e[i__5], a[i__4].i = 0.f; | |||
| /* L10: */ | |||
| } | |||
| } else { | |||
| i__3 = i__ + nb - 1; | |||
| for (j = i__; j <= i__3; ++j) { | |||
| i__4 = j + j * a_dim1; | |||
| i__5 = j; | |||
| a[i__4].r = d__[i__5], a[i__4].i = 0.f; | |||
| i__4 = j + 1 + j * a_dim1; | |||
| i__5 = j; | |||
| a[i__4].r = e[i__5], a[i__4].i = 0.f; | |||
| /* L20: */ | |||
| } | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* Use unblocked code to reduce the remainder of the matrix */ | |||
| i__2 = *m - i__ + 1; | |||
| i__1 = *n - i__ + 1; | |||
| cgebd2_(&i__2, &i__1, &a[i__ + i__ * a_dim1], lda, &d__[i__], &e[i__], & | |||
| tauq[i__], &taup[i__], &work[1], &iinfo); | |||
| work[1].r = (real) ws, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEBRD */ | |||
| } /* cgebrd_ */ | |||
| @@ -0,0 +1,658 @@ | |||
| /* 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 CGECON */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGECON + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgecon. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgecon. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgecon. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGECON( NORM, N, A, LDA, ANORM, RCOND, WORK, RWORK, */ | |||
| /* INFO ) */ | |||
| /* CHARACTER NORM */ | |||
| /* INTEGER INFO, LDA, N */ | |||
| /* REAL ANORM, RCOND */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGECON estimates the reciprocal of the condition number of a general */ | |||
| /* > complex matrix A, in either the 1-norm or the infinity-norm, using */ | |||
| /* > the LU factorization computed by CGETRF. */ | |||
| /* > */ | |||
| /* > An estimate is obtained for norm(inv(A)), and the reciprocal of the */ | |||
| /* > condition number is computed as */ | |||
| /* > RCOND = 1 / ( norm(A) * norm(inv(A)) ). */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies whether the 1-norm condition number or the */ | |||
| /* > infinity-norm condition number is required: */ | |||
| /* > = '1' or 'O': 1-norm; */ | |||
| /* > = 'I': Infinity-norm. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > The factors L and U from the factorization A = P*L*U */ | |||
| /* > as computed by CGETRF. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ANORM */ | |||
| /* > \verbatim */ | |||
| /* > ANORM is REAL */ | |||
| /* > If NORM = '1' or 'O', the 1-norm of the original matrix A. */ | |||
| /* > If NORM = 'I', the infinity-norm of the original matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RCOND */ | |||
| /* > \verbatim */ | |||
| /* > RCOND is REAL */ | |||
| /* > The reciprocal of the condition number of the matrix A, */ | |||
| /* > computed as RCOND = 1/(norm(A) * norm(inv(A))). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (2*N) */ | |||
| /* > \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 complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgecon_(char *norm, integer *n, complex *a, integer *lda, | |||
| real *anorm, real *rcond, complex *work, real *rwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1; | |||
| real r__1, r__2; | |||
| /* Local variables */ | |||
| integer kase, kase1; | |||
| real scale; | |||
| extern logical lsame_(char *, char *); | |||
| integer isave[3]; | |||
| extern /* Subroutine */ int clacn2_(integer *, complex *, complex *, real | |||
| *, integer *, integer *); | |||
| real sl; | |||
| integer ix; | |||
| extern integer icamax_(integer *, complex *, integer *); | |||
| extern real slamch_(char *); | |||
| real su; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| real ainvnm; | |||
| extern /* Subroutine */ int clatrs_(char *, char *, char *, char *, | |||
| integer *, complex *, integer *, complex *, real *, real *, | |||
| integer *), csrscl_(integer *, | |||
| real *, complex *, integer *); | |||
| logical onenrm; | |||
| char normin[1]; | |||
| real smlnum; | |||
| /* -- 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 */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O"); | |||
| if (! onenrm && ! lsame_(norm, "I")) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -4; | |||
| } else if (*anorm < 0.f) { | |||
| *info = -5; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGECON", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| *rcond = 0.f; | |||
| if (*n == 0) { | |||
| *rcond = 1.f; | |||
| return 0; | |||
| } else if (*anorm == 0.f) { | |||
| return 0; | |||
| } | |||
| smlnum = slamch_("Safe minimum"); | |||
| /* Estimate the norm of inv(A). */ | |||
| ainvnm = 0.f; | |||
| *(unsigned char *)normin = 'N'; | |||
| if (onenrm) { | |||
| kase1 = 1; | |||
| } else { | |||
| kase1 = 2; | |||
| } | |||
| kase = 0; | |||
| L10: | |||
| clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave); | |||
| if (kase != 0) { | |||
| if (kase == kase1) { | |||
| /* Multiply by inv(L). */ | |||
| clatrs_("Lower", "No transpose", "Unit", normin, n, &a[a_offset], | |||
| lda, &work[1], &sl, &rwork[1], info); | |||
| /* Multiply by inv(U). */ | |||
| clatrs_("Upper", "No transpose", "Non-unit", normin, n, &a[ | |||
| a_offset], lda, &work[1], &su, &rwork[*n + 1], info); | |||
| } else { | |||
| /* Multiply by inv(U**H). */ | |||
| clatrs_("Upper", "Conjugate transpose", "Non-unit", normin, n, &a[ | |||
| a_offset], lda, &work[1], &su, &rwork[*n + 1], info); | |||
| /* Multiply by inv(L**H). */ | |||
| clatrs_("Lower", "Conjugate transpose", "Unit", normin, n, &a[ | |||
| a_offset], lda, &work[1], &sl, &rwork[1], info); | |||
| } | |||
| /* Divide X by 1/(SL*SU) if doing so will not cause overflow. */ | |||
| scale = sl * su; | |||
| *(unsigned char *)normin = 'Y'; | |||
| if (scale != 1.f) { | |||
| ix = icamax_(n, &work[1], &c__1); | |||
| i__1 = ix; | |||
| if (scale < ((r__1 = work[i__1].r, abs(r__1)) + (r__2 = r_imag(& | |||
| work[ix]), abs(r__2))) * smlnum || scale == 0.f) { | |||
| goto L20; | |||
| } | |||
| csrscl_(n, &scale, &work[1], &c__1); | |||
| } | |||
| goto L10; | |||
| } | |||
| /* Compute the estimate of the reciprocal condition number. */ | |||
| if (ainvnm != 0.f) { | |||
| *rcond = 1.f / ainvnm / *anorm; | |||
| } | |||
| L20: | |||
| return 0; | |||
| /* End of CGECON */ | |||
| } /* cgecon_ */ | |||
| @@ -0,0 +1,737 @@ | |||
| /* 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 CGEEQU */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEEQU + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeequ. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeequ. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeequ. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEEQU( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX, */ | |||
| /* INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* REAL AMAX, COLCND, ROWCND */ | |||
| /* REAL C( * ), R( * ) */ | |||
| /* COMPLEX A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEEQU computes row and column scalings intended to equilibrate an */ | |||
| /* > M-by-N matrix A and reduce its condition number. R returns the row */ | |||
| /* > scale factors and C the column scale factors, chosen to try to make */ | |||
| /* > the largest element in each row and column of the matrix B with */ | |||
| /* > elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1. */ | |||
| /* > */ | |||
| /* > R(i) and C(j) are restricted to be between SMLNUM = smallest safe */ | |||
| /* > number and BIGNUM = largest safe number. Use of these scaling */ | |||
| /* > factors is not guaranteed to reduce the condition number of A but */ | |||
| /* > works well in practice. */ | |||
| /* > \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] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > The M-by-N matrix whose equilibration factors are */ | |||
| /* > to be computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] R */ | |||
| /* > \verbatim */ | |||
| /* > R is REAL array, dimension (M) */ | |||
| /* > If INFO = 0 or INFO > M, R contains the row scale factors */ | |||
| /* > for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is REAL array, dimension (N) */ | |||
| /* > If INFO = 0, C contains the column scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ROWCND */ | |||
| /* > \verbatim */ | |||
| /* > ROWCND is REAL */ | |||
| /* > If INFO = 0 or INFO > M, ROWCND contains the ratio of the */ | |||
| /* > smallest R(i) to the largest R(i). If ROWCND >= 0.1 and */ | |||
| /* > AMAX is neither too large nor too small, it is not worth */ | |||
| /* > scaling by R. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] COLCND */ | |||
| /* > \verbatim */ | |||
| /* > COLCND is REAL */ | |||
| /* > If INFO = 0, COLCND contains the ratio of the smallest */ | |||
| /* > C(i) to the largest C(i). If COLCND >= 0.1, it is not */ | |||
| /* > worth scaling by C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is REAL */ | |||
| /* > Absolute value of largest matrix element. If AMAX is very */ | |||
| /* > close to overflow or very close to underflow, the matrix */ | |||
| /* > should be scaled. */ | |||
| /* > \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 = i, and i is */ | |||
| /* > <= M: the i-th row of A is exactly zero */ | |||
| /* > > M: the (i-M)-th column of A is exactly zero */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeequ_(integer *m, integer *n, complex *a, integer *lda, | |||
| real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, | |||
| integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| real r__1, r__2, r__3, r__4; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| real rcmin, rcmax; | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| real bignum, smlnum; | |||
| /* -- 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 */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --r__; | |||
| --c__; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEEQU", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*m == 0 || *n == 0) { | |||
| *rowcnd = 1.f; | |||
| *colcnd = 1.f; | |||
| *amax = 0.f; | |||
| return 0; | |||
| } | |||
| /* Get machine constants. */ | |||
| smlnum = slamch_("S"); | |||
| bignum = 1.f / smlnum; | |||
| /* Compute row scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| r__[i__] = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* Find the maximum element in each row. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__3 = i__ + j * a_dim1; | |||
| r__3 = r__[i__], r__4 = (r__1 = a[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&a[i__ + j * a_dim1]), abs(r__2)); | |||
| r__[i__] = f2cmax(r__3,r__4); | |||
| /* L20: */ | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = r__[i__]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = r__[i__]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* L40: */ | |||
| } | |||
| *amax = rcmax; | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (r__[i__] == 0.f) { | |||
| *info = i__; | |||
| return 0; | |||
| } | |||
| /* L50: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = r__[i__]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| r__[i__] = 1.f / f2cmin(r__1,bignum); | |||
| /* L60: */ | |||
| } | |||
| /* Compute ROWCND = f2cmin(R(I)) / f2cmax(R(I)) */ | |||
| *rowcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| /* Compute column scale factors */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| c__[j] = 0.f; | |||
| /* L70: */ | |||
| } | |||
| /* Find the maximum element in each column, */ | |||
| /* assuming the row scaling computed above. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__3 = i__ + j * a_dim1; | |||
| r__3 = c__[j], r__4 = ((r__1 = a[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&a[i__ + j * a_dim1]), abs(r__2))) * r__[i__]; | |||
| c__[j] = f2cmax(r__3,r__4); | |||
| /* L80: */ | |||
| } | |||
| /* L90: */ | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = c__[j]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = c__[j]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* L100: */ | |||
| } | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (c__[j] == 0.f) { | |||
| *info = *m + j; | |||
| return 0; | |||
| } | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = c__[j]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| c__[j] = 1.f / f2cmin(r__1,bignum); | |||
| /* L120: */ | |||
| } | |||
| /* Compute COLCND = f2cmin(C(J)) / f2cmax(C(J)) */ | |||
| *colcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| return 0; | |||
| /* End of CGEEQU */ | |||
| } /* cgeequ_ */ | |||
| @@ -0,0 +1,757 @@ | |||
| /* 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 CGEEQUB */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEEQUB + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeequb | |||
| .f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeequb | |||
| .f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeequb | |||
| .f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEEQUB( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX, */ | |||
| /* INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* REAL AMAX, COLCND, ROWCND */ | |||
| /* REAL C( * ), R( * ) */ | |||
| /* COMPLEX A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEEQUB computes row and column scalings intended to equilibrate an */ | |||
| /* > M-by-N matrix A and reduce its condition number. R returns the row */ | |||
| /* > scale factors and C the column scale factors, chosen to try to make */ | |||
| /* > the largest element in each row and column of the matrix B with */ | |||
| /* > elements B(i,j)=R(i)*A(i,j)*C(j) have an absolute value of at most */ | |||
| /* > the radix. */ | |||
| /* > */ | |||
| /* > R(i) and C(j) are restricted to be a power of the radix between */ | |||
| /* > SMLNUM = smallest safe number and BIGNUM = largest safe number. Use */ | |||
| /* > of these scaling factors is not guaranteed to reduce the condition */ | |||
| /* > number of A but works well in practice. */ | |||
| /* > */ | |||
| /* > This routine differs from CGEEQU by restricting the scaling factors */ | |||
| /* > to a power of the radix. Barring over- and underflow, scaling by */ | |||
| /* > these factors introduces no additional rounding errors. However, the */ | |||
| /* > scaled entries' magnitudes are no longer approximately 1 but lie */ | |||
| /* > between sqrt(radix) and 1/sqrt(radix). */ | |||
| /* > \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] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > The M-by-N matrix whose equilibration factors are */ | |||
| /* > to be computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] R */ | |||
| /* > \verbatim */ | |||
| /* > R is REAL array, dimension (M) */ | |||
| /* > If INFO = 0 or INFO > M, R contains the row scale factors */ | |||
| /* > for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is REAL array, dimension (N) */ | |||
| /* > If INFO = 0, C contains the column scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ROWCND */ | |||
| /* > \verbatim */ | |||
| /* > ROWCND is REAL */ | |||
| /* > If INFO = 0 or INFO > M, ROWCND contains the ratio of the */ | |||
| /* > smallest R(i) to the largest R(i). If ROWCND >= 0.1 and */ | |||
| /* > AMAX is neither too large nor too small, it is not worth */ | |||
| /* > scaling by R. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] COLCND */ | |||
| /* > \verbatim */ | |||
| /* > COLCND is REAL */ | |||
| /* > If INFO = 0, COLCND contains the ratio of the smallest */ | |||
| /* > C(i) to the largest C(i). If COLCND >= 0.1, it is not */ | |||
| /* > worth scaling by C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is REAL */ | |||
| /* > Absolute value of largest matrix element. If AMAX is very */ | |||
| /* > close to overflow or very close to underflow, the matrix */ | |||
| /* > should be scaled. */ | |||
| /* > \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 = i, and i is */ | |||
| /* > <= M: the i-th row of A is exactly zero */ | |||
| /* > > M: the (i-M)-th column of A is exactly zero */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeequb_(integer *m, integer *n, complex *a, integer * | |||
| lda, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, | |||
| integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| real r__1, r__2, r__3, r__4; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| real radix, rcmin, rcmax; | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| real bignum, logrdx, smlnum; | |||
| /* -- 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 */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --r__; | |||
| --c__; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEEQUB", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible. */ | |||
| if (*m == 0 || *n == 0) { | |||
| *rowcnd = 1.f; | |||
| *colcnd = 1.f; | |||
| *amax = 0.f; | |||
| return 0; | |||
| } | |||
| /* Get machine constants. Assume SMLNUM is a power of the radix. */ | |||
| smlnum = slamch_("S"); | |||
| bignum = 1.f / smlnum; | |||
| radix = slamch_("B"); | |||
| logrdx = log(radix); | |||
| /* Compute row scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| r__[i__] = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* Find the maximum element in each row. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__3 = i__ + j * a_dim1; | |||
| r__3 = r__[i__], r__4 = (r__1 = a[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&a[i__ + j * a_dim1]), abs(r__2)); | |||
| r__[i__] = f2cmax(r__3,r__4); | |||
| /* L20: */ | |||
| } | |||
| /* L30: */ | |||
| } | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (r__[i__] > 0.f) { | |||
| i__2 = (integer) (log(r__[i__]) / logrdx); | |||
| r__[i__] = pow_ri(&radix, &i__2); | |||
| } | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = r__[i__]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = r__[i__]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* L40: */ | |||
| } | |||
| *amax = rcmax; | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (r__[i__] == 0.f) { | |||
| *info = i__; | |||
| return 0; | |||
| } | |||
| /* L50: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = r__[i__]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| r__[i__] = 1.f / f2cmin(r__1,bignum); | |||
| /* L60: */ | |||
| } | |||
| /* Compute ROWCND = f2cmin(R(I)) / f2cmax(R(I)). */ | |||
| *rowcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| /* Compute column scale factors. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| c__[j] = 0.f; | |||
| /* L70: */ | |||
| } | |||
| /* Find the maximum element in each column, */ | |||
| /* assuming the row scaling computed above. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__3 = i__ + j * a_dim1; | |||
| r__3 = c__[j], r__4 = ((r__1 = a[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&a[i__ + j * a_dim1]), abs(r__2))) * r__[i__]; | |||
| c__[j] = f2cmax(r__3,r__4); | |||
| /* L80: */ | |||
| } | |||
| if (c__[j] > 0.f) { | |||
| i__2 = (integer) (log(c__[j]) / logrdx); | |||
| c__[j] = pow_ri(&radix, &i__2); | |||
| } | |||
| /* L90: */ | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = c__[j]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = c__[j]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* L100: */ | |||
| } | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (c__[j] == 0.f) { | |||
| *info = *m + j; | |||
| return 0; | |||
| } | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = c__[j]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| c__[j] = 1.f / f2cmin(r__1,bignum); | |||
| /* L120: */ | |||
| } | |||
| /* Compute COLCND = f2cmin(C(J)) / f2cmax(C(J)). */ | |||
| *colcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| return 0; | |||
| /* End of CGEEQUB */ | |||
| } /* cgeequb_ */ | |||
| @@ -0,0 +1,855 @@ | |||
| /* 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; | |||
| static integer c__0 = 0; | |||
| static integer c_n1 = -1; | |||
| /* > \brief <b> CGEES computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors f | |||
| or GE matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEES + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgees.f | |||
| "> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgees.f | |||
| "> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgees.f | |||
| "> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEES( JOBVS, SORT, SELECT, N, A, LDA, SDIM, W, VS, */ | |||
| /* LDVS, WORK, LWORK, RWORK, BWORK, INFO ) */ | |||
| /* CHARACTER JOBVS, SORT */ | |||
| /* INTEGER INFO, LDA, LDVS, LWORK, N, SDIM */ | |||
| /* LOGICAL BWORK( * ) */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), VS( LDVS, * ), W( * ), WORK( * ) */ | |||
| /* LOGICAL SELECT */ | |||
| /* EXTERNAL SELECT */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEES computes for an N-by-N complex nonsymmetric matrix A, the */ | |||
| /* > eigenvalues, the Schur form T, and, optionally, the matrix of Schur */ | |||
| /* > vectors Z. This gives the Schur factorization A = Z*T*(Z**H). */ | |||
| /* > */ | |||
| /* > Optionally, it also orders the eigenvalues on the diagonal of the */ | |||
| /* > Schur form so that selected eigenvalues are at the top left. */ | |||
| /* > The leading columns of Z then form an orthonormal basis for the */ | |||
| /* > invariant subspace corresponding to the selected eigenvalues. */ | |||
| /* > */ | |||
| /* > A complex matrix is in Schur form if it is upper triangular. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOBVS */ | |||
| /* > \verbatim */ | |||
| /* > JOBVS is CHARACTER*1 */ | |||
| /* > = 'N': Schur vectors are not computed; */ | |||
| /* > = 'V': Schur vectors are computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SORT */ | |||
| /* > \verbatim */ | |||
| /* > SORT is CHARACTER*1 */ | |||
| /* > Specifies whether or not to order the eigenvalues on the */ | |||
| /* > diagonal of the Schur form. */ | |||
| /* > = 'N': Eigenvalues are not ordered: */ | |||
| /* > = 'S': Eigenvalues are ordered (see SELECT). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SELECT */ | |||
| /* > \verbatim */ | |||
| /* > SELECT is a LOGICAL FUNCTION of one COMPLEX argument */ | |||
| /* > SELECT must be declared EXTERNAL in the calling subroutine. */ | |||
| /* > If SORT = 'S', SELECT is used to select eigenvalues to order */ | |||
| /* > to the top left of the Schur form. */ | |||
| /* > IF SORT = 'N', SELECT is not referenced. */ | |||
| /* > The eigenvalue W(j) is selected if SELECT(W(j)) is true. */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the N-by-N matrix A. */ | |||
| /* > On exit, A has been overwritten by its Schur form T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SDIM */ | |||
| /* > \verbatim */ | |||
| /* > SDIM is INTEGER */ | |||
| /* > If SORT = 'N', SDIM = 0. */ | |||
| /* > If SORT = 'S', SDIM = number of eigenvalues for which */ | |||
| /* > SELECT is true. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] W */ | |||
| /* > \verbatim */ | |||
| /* > W is COMPLEX array, dimension (N) */ | |||
| /* > W contains the computed eigenvalues, in the same order that */ | |||
| /* > they appear on the diagonal of the output Schur form T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] VS */ | |||
| /* > \verbatim */ | |||
| /* > VS is COMPLEX array, dimension (LDVS,N) */ | |||
| /* > If JOBVS = 'V', VS contains the unitary matrix Z of Schur */ | |||
| /* > vectors. */ | |||
| /* > If JOBVS = 'N', VS is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDVS */ | |||
| /* > \verbatim */ | |||
| /* > LDVS is INTEGER */ | |||
| /* > The leading dimension of the array VS. LDVS >= 1; if */ | |||
| /* > JOBVS = 'V', LDVS >= N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= f2cmax(1,2*N). */ | |||
| /* > For good performance, LWORK must generally be larger. */ | |||
| /* > */ | |||
| /* > 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] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] BWORK */ | |||
| /* > \verbatim */ | |||
| /* > BWORK is LOGICAL array, dimension (N) */ | |||
| /* > Not referenced if SORT = '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: if INFO = i, and i is */ | |||
| /* > <= N: the QR algorithm failed to compute all the */ | |||
| /* > eigenvalues; elements 1:ILO-1 and i+1:N of W */ | |||
| /* > contain those eigenvalues which have converged; */ | |||
| /* > if JOBVS = 'V', VS contains the matrix which */ | |||
| /* > reduces A to its partially converged Schur form. */ | |||
| /* > = N+1: the eigenvalues could not be reordered because */ | |||
| /* > some eigenvalues were too close to separate (the */ | |||
| /* > problem is very ill-conditioned); */ | |||
| /* > = N+2: after reordering, roundoff changed values of */ | |||
| /* > some complex eigenvalues so that leading */ | |||
| /* > eigenvalues in the Schur form no longer satisfy */ | |||
| /* > SELECT = .TRUE.. This could also be caused by */ | |||
| /* > underflow due to scaling. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEeigen */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgees_(char *jobvs, char *sort, L_fp select, integer *n, | |||
| complex *a, integer *lda, integer *sdim, complex *w, complex *vs, | |||
| integer *ldvs, complex *work, integer *lwork, real *rwork, logical * | |||
| bwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, vs_dim1, vs_offset, i__1, i__2; | |||
| /* Local variables */ | |||
| integer ibal; | |||
| real anrm; | |||
| integer ierr, itau, iwrk, i__; | |||
| real s; | |||
| integer icond, ieval; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, | |||
| complex *, integer *), cgebak_(char *, char *, integer *, integer | |||
| *, integer *, real *, integer *, complex *, integer *, integer *), cgebal_(char *, integer *, complex *, integer *, | |||
| integer *, integer *, real *, integer *), slabad_(real *, | |||
| real *); | |||
| logical scalea; | |||
| extern real clange_(char *, integer *, integer *, complex *, integer *, | |||
| real *); | |||
| real cscale; | |||
| extern /* Subroutine */ int cgehrd_(integer *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *, integer *), | |||
| clascl_(char *, integer *, integer *, real *, real *, integer *, | |||
| integer *, complex *, integer *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex | |||
| *, integer *, complex *, integer *), xerbla_(char *, | |||
| integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| real bignum; | |||
| extern /* Subroutine */ int chseqr_(char *, char *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, complex *, integer *, | |||
| complex *, integer *, integer *), cunghr_(integer | |||
| *, integer *, integer *, complex *, integer *, complex *, complex | |||
| *, integer *, integer *), ctrsen_(char *, char *, logical *, | |||
| integer *, complex *, integer *, complex *, integer *, complex *, | |||
| integer *, real *, real *, complex *, integer *, integer *); | |||
| integer minwrk, maxwrk; | |||
| real smlnum; | |||
| integer hswork; | |||
| logical wantst, lquery, wantvs; | |||
| integer ihi, ilo; | |||
| real dum[1], eps, sep; | |||
| /* -- LAPACK driver 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 arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --w; | |||
| vs_dim1 = *ldvs; | |||
| vs_offset = 1 + vs_dim1 * 1; | |||
| vs -= vs_offset; | |||
| --work; | |||
| --rwork; | |||
| --bwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *lwork == -1; | |||
| wantvs = lsame_(jobvs, "V"); | |||
| wantst = lsame_(sort, "S"); | |||
| if (! wantvs && ! lsame_(jobvs, "N")) { | |||
| *info = -1; | |||
| } else if (! wantst && ! lsame_(sort, "N")) { | |||
| *info = -2; | |||
| } else if (*n < 0) { | |||
| *info = -4; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -6; | |||
| } else if (*ldvs < 1 || wantvs && *ldvs < *n) { | |||
| *info = -10; | |||
| } | |||
| /* Compute workspace */ | |||
| /* (Note: Comments in the code beginning "Workspace:" describe the */ | |||
| /* minimal amount of workspace needed at that point in the code, */ | |||
| /* as well as the preferred amount for good performance. */ | |||
| /* CWorkspace refers to complex workspace, and RWorkspace to real */ | |||
| /* workspace. NB refers to the optimal block size for the */ | |||
| /* immediately following subroutine, as returned by ILAENV. */ | |||
| /* HSWORK refers to the workspace preferred by CHSEQR, as */ | |||
| /* calculated below. HSWORK is computed assuming ILO=1 and IHI=N, */ | |||
| /* the worst case.) */ | |||
| if (*info == 0) { | |||
| if (*n == 0) { | |||
| minwrk = 1; | |||
| maxwrk = 1; | |||
| } else { | |||
| maxwrk = *n + *n * ilaenv_(&c__1, "CGEHRD", " ", n, &c__1, n, & | |||
| c__0, (ftnlen)6, (ftnlen)1); | |||
| minwrk = *n << 1; | |||
| chseqr_("S", jobvs, n, &c__1, n, &a[a_offset], lda, &w[1], &vs[ | |||
| vs_offset], ldvs, &work[1], &c_n1, &ieval); | |||
| hswork = work[1].r; | |||
| if (! wantvs) { | |||
| maxwrk = f2cmax(maxwrk,hswork); | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__1 = maxwrk, i__2 = *n + (*n - 1) * ilaenv_(&c__1, "CUNGHR", | |||
| " ", n, &c__1, n, &c_n1, (ftnlen)6, (ftnlen)1); | |||
| maxwrk = f2cmax(i__1,i__2); | |||
| maxwrk = f2cmax(maxwrk,hswork); | |||
| } | |||
| } | |||
| work[1].r = (real) maxwrk, work[1].i = 0.f; | |||
| if (*lwork < minwrk && ! lquery) { | |||
| *info = -12; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEES ", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0) { | |||
| *sdim = 0; | |||
| return 0; | |||
| } | |||
| /* Get machine constants */ | |||
| eps = slamch_("P"); | |||
| smlnum = slamch_("S"); | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| smlnum = sqrt(smlnum) / eps; | |||
| bignum = 1.f / smlnum; | |||
| /* Scale A if f2cmax element outside range [SMLNUM,BIGNUM] */ | |||
| anrm = clange_("M", n, n, &a[a_offset], lda, dum); | |||
| scalea = FALSE_; | |||
| if (anrm > 0.f && anrm < smlnum) { | |||
| scalea = TRUE_; | |||
| cscale = smlnum; | |||
| } else if (anrm > bignum) { | |||
| scalea = TRUE_; | |||
| cscale = bignum; | |||
| } | |||
| if (scalea) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &cscale, n, n, &a[a_offset], lda, & | |||
| ierr); | |||
| } | |||
| /* Permute the matrix to make it more nearly triangular */ | |||
| /* (CWorkspace: none) */ | |||
| /* (RWorkspace: need N) */ | |||
| ibal = 1; | |||
| cgebal_("P", n, &a[a_offset], lda, &ilo, &ihi, &rwork[ibal], &ierr); | |||
| /* Reduce to upper Hessenberg form */ | |||
| /* (CWorkspace: need 2*N, prefer N+N*NB) */ | |||
| /* (RWorkspace: none) */ | |||
| itau = 1; | |||
| iwrk = *n + itau; | |||
| i__1 = *lwork - iwrk + 1; | |||
| cgehrd_(n, &ilo, &ihi, &a[a_offset], lda, &work[itau], &work[iwrk], &i__1, | |||
| &ierr); | |||
| if (wantvs) { | |||
| /* Copy Householder vectors to VS */ | |||
| clacpy_("L", n, n, &a[a_offset], lda, &vs[vs_offset], ldvs) | |||
| ; | |||
| /* Generate unitary matrix in VS */ | |||
| /* (CWorkspace: need 2*N-1, prefer N+(N-1)*NB) */ | |||
| /* (RWorkspace: none) */ | |||
| i__1 = *lwork - iwrk + 1; | |||
| cunghr_(n, &ilo, &ihi, &vs[vs_offset], ldvs, &work[itau], &work[iwrk], | |||
| &i__1, &ierr); | |||
| } | |||
| *sdim = 0; | |||
| /* Perform QR iteration, accumulating Schur vectors in VS if desired */ | |||
| /* (CWorkspace: need 1, prefer HSWORK (see comments) ) */ | |||
| /* (RWorkspace: none) */ | |||
| iwrk = itau; | |||
| i__1 = *lwork - iwrk + 1; | |||
| chseqr_("S", jobvs, n, &ilo, &ihi, &a[a_offset], lda, &w[1], &vs[ | |||
| vs_offset], ldvs, &work[iwrk], &i__1, &ieval); | |||
| if (ieval > 0) { | |||
| *info = ieval; | |||
| } | |||
| /* Sort eigenvalues if desired */ | |||
| if (wantst && *info == 0) { | |||
| if (scalea) { | |||
| clascl_("G", &c__0, &c__0, &cscale, &anrm, n, &c__1, &w[1], n, & | |||
| ierr); | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| bwork[i__] = (*select)(&w[i__]); | |||
| /* L10: */ | |||
| } | |||
| /* Reorder eigenvalues and transform Schur vectors */ | |||
| /* (CWorkspace: none) */ | |||
| /* (RWorkspace: none) */ | |||
| i__1 = *lwork - iwrk + 1; | |||
| ctrsen_("N", jobvs, &bwork[1], n, &a[a_offset], lda, &vs[vs_offset], | |||
| ldvs, &w[1], sdim, &s, &sep, &work[iwrk], &i__1, &icond); | |||
| } | |||
| if (wantvs) { | |||
| /* Undo balancing */ | |||
| /* (CWorkspace: none) */ | |||
| /* (RWorkspace: need N) */ | |||
| cgebak_("P", "R", n, &ilo, &ihi, &rwork[ibal], n, &vs[vs_offset], | |||
| ldvs, &ierr); | |||
| } | |||
| if (scalea) { | |||
| /* Undo scaling for the Schur form of A */ | |||
| clascl_("U", &c__0, &c__0, &cscale, &anrm, n, n, &a[a_offset], lda, & | |||
| ierr); | |||
| i__1 = *lda + 1; | |||
| ccopy_(n, &a[a_offset], &i__1, &w[1], &c__1); | |||
| } | |||
| work[1].r = (real) maxwrk, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEES */ | |||
| } /* cgees_ */ | |||
| @@ -0,0 +1,937 @@ | |||
| /* 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; | |||
| static integer c__0 = 0; | |||
| static integer c_n1 = -1; | |||
| /* > \brief <b> CGEESX computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors | |||
| for GE matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEESX + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeesx. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeesx. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeesx. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEESX( JOBVS, SORT, SELECT, SENSE, N, A, LDA, SDIM, W, */ | |||
| /* VS, LDVS, RCONDE, RCONDV, WORK, LWORK, RWORK, */ | |||
| /* BWORK, INFO ) */ | |||
| /* CHARACTER JOBVS, SENSE, SORT */ | |||
| /* INTEGER INFO, LDA, LDVS, LWORK, N, SDIM */ | |||
| /* REAL RCONDE, RCONDV */ | |||
| /* LOGICAL BWORK( * ) */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), VS( LDVS, * ), W( * ), WORK( * ) */ | |||
| /* LOGICAL SELECT */ | |||
| /* EXTERNAL SELECT */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEESX computes for an N-by-N complex nonsymmetric matrix A, the */ | |||
| /* > eigenvalues, the Schur form T, and, optionally, the matrix of Schur */ | |||
| /* > vectors Z. This gives the Schur factorization A = Z*T*(Z**H). */ | |||
| /* > */ | |||
| /* > Optionally, it also orders the eigenvalues on the diagonal of the */ | |||
| /* > Schur form so that selected eigenvalues are at the top left; */ | |||
| /* > computes a reciprocal condition number for the average of the */ | |||
| /* > selected eigenvalues (RCONDE); and computes a reciprocal condition */ | |||
| /* > number for the right invariant subspace corresponding to the */ | |||
| /* > selected eigenvalues (RCONDV). The leading columns of Z form an */ | |||
| /* > orthonormal basis for this invariant subspace. */ | |||
| /* > */ | |||
| /* > For further explanation of the reciprocal condition numbers RCONDE */ | |||
| /* > and RCONDV, see Section 4.10 of the LAPACK Users' Guide (where */ | |||
| /* > these quantities are called s and sep respectively). */ | |||
| /* > */ | |||
| /* > A complex matrix is in Schur form if it is upper triangular. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOBVS */ | |||
| /* > \verbatim */ | |||
| /* > JOBVS is CHARACTER*1 */ | |||
| /* > = 'N': Schur vectors are not computed; */ | |||
| /* > = 'V': Schur vectors are computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SORT */ | |||
| /* > \verbatim */ | |||
| /* > SORT is CHARACTER*1 */ | |||
| /* > Specifies whether or not to order the eigenvalues on the */ | |||
| /* > diagonal of the Schur form. */ | |||
| /* > = 'N': Eigenvalues are not ordered; */ | |||
| /* > = 'S': Eigenvalues are ordered (see SELECT). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SELECT */ | |||
| /* > \verbatim */ | |||
| /* > SELECT is a LOGICAL FUNCTION of one COMPLEX argument */ | |||
| /* > SELECT must be declared EXTERNAL in the calling subroutine. */ | |||
| /* > If SORT = 'S', SELECT is used to select eigenvalues to order */ | |||
| /* > to the top left of the Schur form. */ | |||
| /* > If SORT = 'N', SELECT is not referenced. */ | |||
| /* > An eigenvalue W(j) is selected if SELECT(W(j)) is true. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SENSE */ | |||
| /* > \verbatim */ | |||
| /* > SENSE is CHARACTER*1 */ | |||
| /* > Determines which reciprocal condition numbers are computed. */ | |||
| /* > = 'N': None are computed; */ | |||
| /* > = 'E': Computed for average of selected eigenvalues only; */ | |||
| /* > = 'V': Computed for selected right invariant subspace only; */ | |||
| /* > = 'B': Computed for both. */ | |||
| /* > If SENSE = 'E', 'V' or 'B', SORT must equal 'S'. */ | |||
| /* > \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 array, dimension (LDA, N) */ | |||
| /* > On entry, the N-by-N matrix A. */ | |||
| /* > On exit, A is overwritten by its Schur form T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SDIM */ | |||
| /* > \verbatim */ | |||
| /* > SDIM is INTEGER */ | |||
| /* > If SORT = 'N', SDIM = 0. */ | |||
| /* > If SORT = 'S', SDIM = number of eigenvalues for which */ | |||
| /* > SELECT is true. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] W */ | |||
| /* > \verbatim */ | |||
| /* > W is COMPLEX array, dimension (N) */ | |||
| /* > W contains the computed eigenvalues, in the same order */ | |||
| /* > that they appear on the diagonal of the output Schur form T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] VS */ | |||
| /* > \verbatim */ | |||
| /* > VS is COMPLEX array, dimension (LDVS,N) */ | |||
| /* > If JOBVS = 'V', VS contains the unitary matrix Z of Schur */ | |||
| /* > vectors. */ | |||
| /* > If JOBVS = 'N', VS is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDVS */ | |||
| /* > \verbatim */ | |||
| /* > LDVS is INTEGER */ | |||
| /* > The leading dimension of the array VS. LDVS >= 1, and if */ | |||
| /* > JOBVS = 'V', LDVS >= N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RCONDE */ | |||
| /* > \verbatim */ | |||
| /* > RCONDE is REAL */ | |||
| /* > If SENSE = 'E' or 'B', RCONDE contains the reciprocal */ | |||
| /* > condition number for the average of the selected eigenvalues. */ | |||
| /* > Not referenced if SENSE = 'N' or 'V'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RCONDV */ | |||
| /* > \verbatim */ | |||
| /* > RCONDV is REAL */ | |||
| /* > If SENSE = 'V' or 'B', RCONDV contains the reciprocal */ | |||
| /* > condition number for the selected right invariant subspace. */ | |||
| /* > Not referenced if SENSE = 'N' or 'E'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= f2cmax(1,2*N). */ | |||
| /* > Also, if SENSE = 'E' or 'V' or 'B', LWORK >= 2*SDIM*(N-SDIM), */ | |||
| /* > where SDIM is the number of selected eigenvalues computed by */ | |||
| /* > this routine. Note that 2*SDIM*(N-SDIM) <= N*N/2. Note also */ | |||
| /* > that an error is only returned if LWORK < f2cmax(1,2*N), but if */ | |||
| /* > SENSE = 'E' or 'V' or 'B' this may not be large enough. */ | |||
| /* > For good performance, LWORK must generally be larger. */ | |||
| /* > */ | |||
| /* > If LWORK = -1, then a workspace query is assumed; the routine */ | |||
| /* > only calculates upper bound on the optimal size of the */ | |||
| /* > array WORK, 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] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] BWORK */ | |||
| /* > \verbatim */ | |||
| /* > BWORK is LOGICAL array, dimension (N) */ | |||
| /* > Not referenced if SORT = '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: if INFO = i, and i is */ | |||
| /* > <= N: the QR algorithm failed to compute all the */ | |||
| /* > eigenvalues; elements 1:ILO-1 and i+1:N of W */ | |||
| /* > contain those eigenvalues which have converged; if */ | |||
| /* > JOBVS = 'V', VS contains the transformation which */ | |||
| /* > reduces A to its partially converged Schur form. */ | |||
| /* > = N+1: the eigenvalues could not be reordered because some */ | |||
| /* > eigenvalues were too close to separate (the problem */ | |||
| /* > is very ill-conditioned); */ | |||
| /* > = N+2: after reordering, roundoff changed values of some */ | |||
| /* > complex eigenvalues so that leading eigenvalues in */ | |||
| /* > the Schur form no longer satisfy SELECT=.TRUE. This */ | |||
| /* > could also be caused by underflow due to scaling. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complexGEeigen */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeesx_(char *jobvs, char *sort, L_fp select, char * | |||
| sense, integer *n, complex *a, integer *lda, integer *sdim, complex * | |||
| w, complex *vs, integer *ldvs, real *rconde, real *rcondv, complex * | |||
| work, integer *lwork, real *rwork, logical *bwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, vs_dim1, vs_offset, i__1, i__2; | |||
| /* Local variables */ | |||
| integer ibal; | |||
| real anrm; | |||
| integer ierr, itau, iwrk, lwrk, i__, icond, ieval; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, | |||
| complex *, integer *), cgebak_(char *, char *, integer *, integer | |||
| *, integer *, real *, integer *, complex *, integer *, integer *), cgebal_(char *, integer *, complex *, integer *, | |||
| integer *, integer *, real *, integer *), slabad_(real *, | |||
| real *); | |||
| logical scalea; | |||
| extern real clange_(char *, integer *, integer *, complex *, integer *, | |||
| real *); | |||
| real cscale; | |||
| extern /* Subroutine */ int cgehrd_(integer *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *, integer *), | |||
| clascl_(char *, integer *, integer *, real *, real *, integer *, | |||
| integer *, complex *, integer *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex | |||
| *, integer *, complex *, integer *), xerbla_(char *, | |||
| integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| real bignum; | |||
| extern /* Subroutine */ int slascl_(char *, integer *, integer *, real *, | |||
| real *, integer *, integer *, real *, integer *, integer *), chseqr_(char *, char *, integer *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *, integer *), cunghr_(integer *, integer | |||
| *, integer *, complex *, integer *, complex *, complex *, integer | |||
| *, integer *); | |||
| logical wantsb; | |||
| extern /* Subroutine */ int ctrsen_(char *, char *, logical *, integer *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *, | |||
| real *, real *, complex *, integer *, integer *); | |||
| logical wantse; | |||
| integer minwrk, maxwrk; | |||
| logical wantsn; | |||
| real smlnum; | |||
| integer hswork; | |||
| logical wantst, lquery, wantsv, wantvs; | |||
| integer ihi, ilo; | |||
| real dum[1], eps; | |||
| /* -- LAPACK driver 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; | |||
| --w; | |||
| vs_dim1 = *ldvs; | |||
| vs_offset = 1 + vs_dim1 * 1; | |||
| vs -= vs_offset; | |||
| --work; | |||
| --rwork; | |||
| --bwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| wantvs = lsame_(jobvs, "V"); | |||
| wantst = lsame_(sort, "S"); | |||
| wantsn = lsame_(sense, "N"); | |||
| wantse = lsame_(sense, "E"); | |||
| wantsv = lsame_(sense, "V"); | |||
| wantsb = lsame_(sense, "B"); | |||
| lquery = *lwork == -1; | |||
| if (! wantvs && ! lsame_(jobvs, "N")) { | |||
| *info = -1; | |||
| } else if (! wantst && ! lsame_(sort, "N")) { | |||
| *info = -2; | |||
| } else if (! (wantsn || wantse || wantsv || wantsb) || ! wantst && ! | |||
| wantsn) { | |||
| *info = -4; | |||
| } else if (*n < 0) { | |||
| *info = -5; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -7; | |||
| } else if (*ldvs < 1 || wantvs && *ldvs < *n) { | |||
| *info = -11; | |||
| } | |||
| /* Compute workspace */ | |||
| /* (Note: Comments in the code beginning "Workspace:" describe the */ | |||
| /* minimal amount of real workspace needed at that point in the */ | |||
| /* code, as well as the preferred amount for good performance. */ | |||
| /* CWorkspace refers to complex workspace, and RWorkspace to real */ | |||
| /* workspace. NB refers to the optimal block size for the */ | |||
| /* immediately following subroutine, as returned by ILAENV. */ | |||
| /* HSWORK refers to the workspace preferred by CHSEQR, as */ | |||
| /* calculated below. HSWORK is computed assuming ILO=1 and IHI=N, */ | |||
| /* the worst case. */ | |||
| /* If SENSE = 'E', 'V' or 'B', then the amount of workspace needed */ | |||
| /* depends on SDIM, which is computed by the routine CTRSEN later */ | |||
| /* in the code.) */ | |||
| if (*info == 0) { | |||
| if (*n == 0) { | |||
| minwrk = 1; | |||
| lwrk = 1; | |||
| } else { | |||
| maxwrk = *n + *n * ilaenv_(&c__1, "CGEHRD", " ", n, &c__1, n, & | |||
| c__0, (ftnlen)6, (ftnlen)1); | |||
| minwrk = *n << 1; | |||
| chseqr_("S", jobvs, n, &c__1, n, &a[a_offset], lda, &w[1], &vs[ | |||
| vs_offset], ldvs, &work[1], &c_n1, &ieval); | |||
| hswork = work[1].r; | |||
| if (! wantvs) { | |||
| maxwrk = f2cmax(maxwrk,hswork); | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__1 = maxwrk, i__2 = *n + (*n - 1) * ilaenv_(&c__1, "CUNGHR", | |||
| " ", n, &c__1, n, &c_n1, (ftnlen)6, (ftnlen)1); | |||
| maxwrk = f2cmax(i__1,i__2); | |||
| maxwrk = f2cmax(maxwrk,hswork); | |||
| } | |||
| lwrk = maxwrk; | |||
| if (! wantsn) { | |||
| /* Computing MAX */ | |||
| i__1 = lwrk, i__2 = *n * *n / 2; | |||
| lwrk = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| work[1].r = (real) lwrk, work[1].i = 0.f; | |||
| if (*lwork < minwrk && ! lquery) { | |||
| *info = -15; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEESX", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0) { | |||
| *sdim = 0; | |||
| return 0; | |||
| } | |||
| /* Get machine constants */ | |||
| eps = slamch_("P"); | |||
| smlnum = slamch_("S"); | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| smlnum = sqrt(smlnum) / eps; | |||
| bignum = 1.f / smlnum; | |||
| /* Scale A if f2cmax element outside range [SMLNUM,BIGNUM] */ | |||
| anrm = clange_("M", n, n, &a[a_offset], lda, dum); | |||
| scalea = FALSE_; | |||
| if (anrm > 0.f && anrm < smlnum) { | |||
| scalea = TRUE_; | |||
| cscale = smlnum; | |||
| } else if (anrm > bignum) { | |||
| scalea = TRUE_; | |||
| cscale = bignum; | |||
| } | |||
| if (scalea) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &cscale, n, n, &a[a_offset], lda, & | |||
| ierr); | |||
| } | |||
| /* Permute the matrix to make it more nearly triangular */ | |||
| /* (CWorkspace: none) */ | |||
| /* (RWorkspace: need N) */ | |||
| ibal = 1; | |||
| cgebal_("P", n, &a[a_offset], lda, &ilo, &ihi, &rwork[ibal], &ierr); | |||
| /* Reduce to upper Hessenberg form */ | |||
| /* (CWorkspace: need 2*N, prefer N+N*NB) */ | |||
| /* (RWorkspace: none) */ | |||
| itau = 1; | |||
| iwrk = *n + itau; | |||
| i__1 = *lwork - iwrk + 1; | |||
| cgehrd_(n, &ilo, &ihi, &a[a_offset], lda, &work[itau], &work[iwrk], &i__1, | |||
| &ierr); | |||
| if (wantvs) { | |||
| /* Copy Householder vectors to VS */ | |||
| clacpy_("L", n, n, &a[a_offset], lda, &vs[vs_offset], ldvs) | |||
| ; | |||
| /* Generate unitary matrix in VS */ | |||
| /* (CWorkspace: need 2*N-1, prefer N+(N-1)*NB) */ | |||
| /* (RWorkspace: none) */ | |||
| i__1 = *lwork - iwrk + 1; | |||
| cunghr_(n, &ilo, &ihi, &vs[vs_offset], ldvs, &work[itau], &work[iwrk], | |||
| &i__1, &ierr); | |||
| } | |||
| *sdim = 0; | |||
| /* Perform QR iteration, accumulating Schur vectors in VS if desired */ | |||
| /* (CWorkspace: need 1, prefer HSWORK (see comments) ) */ | |||
| /* (RWorkspace: none) */ | |||
| iwrk = itau; | |||
| i__1 = *lwork - iwrk + 1; | |||
| chseqr_("S", jobvs, n, &ilo, &ihi, &a[a_offset], lda, &w[1], &vs[ | |||
| vs_offset], ldvs, &work[iwrk], &i__1, &ieval); | |||
| if (ieval > 0) { | |||
| *info = ieval; | |||
| } | |||
| /* Sort eigenvalues if desired */ | |||
| if (wantst && *info == 0) { | |||
| if (scalea) { | |||
| clascl_("G", &c__0, &c__0, &cscale, &anrm, n, &c__1, &w[1], n, & | |||
| ierr); | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| bwork[i__] = (*select)(&w[i__]); | |||
| /* L10: */ | |||
| } | |||
| /* Reorder eigenvalues, transform Schur vectors, and compute */ | |||
| /* reciprocal condition numbers */ | |||
| /* (CWorkspace: if SENSE is not 'N', need 2*SDIM*(N-SDIM) */ | |||
| /* otherwise, need none ) */ | |||
| /* (RWorkspace: none) */ | |||
| i__1 = *lwork - iwrk + 1; | |||
| ctrsen_(sense, jobvs, &bwork[1], n, &a[a_offset], lda, &vs[vs_offset], | |||
| ldvs, &w[1], sdim, rconde, rcondv, &work[iwrk], &i__1, & | |||
| icond); | |||
| if (! wantsn) { | |||
| /* Computing MAX */ | |||
| i__1 = maxwrk, i__2 = (*sdim << 1) * (*n - *sdim); | |||
| maxwrk = f2cmax(i__1,i__2); | |||
| } | |||
| if (icond == -14) { | |||
| /* Not enough complex workspace */ | |||
| *info = -15; | |||
| } | |||
| } | |||
| if (wantvs) { | |||
| /* Undo balancing */ | |||
| /* (CWorkspace: none) */ | |||
| /* (RWorkspace: need N) */ | |||
| cgebak_("P", "R", n, &ilo, &ihi, &rwork[ibal], n, &vs[vs_offset], | |||
| ldvs, &ierr); | |||
| } | |||
| if (scalea) { | |||
| /* Undo scaling for the Schur form of A */ | |||
| clascl_("U", &c__0, &c__0, &cscale, &anrm, n, n, &a[a_offset], lda, & | |||
| ierr); | |||
| i__1 = *lda + 1; | |||
| ccopy_(n, &a[a_offset], &i__1, &w[1], &c__1); | |||
| if ((wantsv || wantsb) && *info == 0) { | |||
| dum[0] = *rcondv; | |||
| slascl_("G", &c__0, &c__0, &cscale, &anrm, &c__1, &c__1, dum, & | |||
| c__1, &ierr); | |||
| *rcondv = dum[0]; | |||
| } | |||
| } | |||
| work[1].r = (real) maxwrk, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEESX */ | |||
| } /* cgeesx_ */ | |||
| @@ -0,0 +1,994 @@ | |||
| /* 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; | |||
| static integer c__0 = 0; | |||
| static integer c_n1 = -1; | |||
| /* > \brief <b> CGEEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matr | |||
| ices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEEV + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeev.f | |||
| "> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeev.f | |||
| "> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeev.f | |||
| "> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEEV( JOBVL, JOBVR, N, A, LDA, W, VL, LDVL, VR, LDVR, */ | |||
| /* WORK, LWORK, RWORK, INFO ) */ | |||
| /* CHARACTER JOBVL, JOBVR */ | |||
| /* INTEGER INFO, LDA, LDVL, LDVR, LWORK, N */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), VL( LDVL, * ), VR( LDVR, * ), */ | |||
| /* $ W( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEEV computes for an N-by-N complex nonsymmetric matrix A, the */ | |||
| /* > eigenvalues and, optionally, the left and/or right eigenvectors. */ | |||
| /* > */ | |||
| /* > The right eigenvector v(j) of A satisfies */ | |||
| /* > A * v(j) = lambda(j) * v(j) */ | |||
| /* > where lambda(j) is its eigenvalue. */ | |||
| /* > The left eigenvector u(j) of A satisfies */ | |||
| /* > u(j)**H * A = lambda(j) * u(j)**H */ | |||
| /* > where u(j)**H denotes the conjugate transpose of u(j). */ | |||
| /* > */ | |||
| /* > The computed eigenvectors are normalized to have Euclidean norm */ | |||
| /* > equal to 1 and largest component real. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOBVL */ | |||
| /* > \verbatim */ | |||
| /* > JOBVL is CHARACTER*1 */ | |||
| /* > = 'N': left eigenvectors of A are not computed; */ | |||
| /* > = 'V': left eigenvectors of are computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] JOBVR */ | |||
| /* > \verbatim */ | |||
| /* > JOBVR is CHARACTER*1 */ | |||
| /* > = 'N': right eigenvectors of A are not computed; */ | |||
| /* > = 'V': right eigenvectors of A are computed. */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the N-by-N matrix A. */ | |||
| /* > On exit, A has been overwritten. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] W */ | |||
| /* > \verbatim */ | |||
| /* > W is COMPLEX array, dimension (N) */ | |||
| /* > W contains the computed eigenvalues. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] VL */ | |||
| /* > \verbatim */ | |||
| /* > VL is COMPLEX array, dimension (LDVL,N) */ | |||
| /* > If JOBVL = 'V', the left eigenvectors u(j) are stored one */ | |||
| /* > after another in the columns of VL, in the same order */ | |||
| /* > as their eigenvalues. */ | |||
| /* > If JOBVL = 'N', VL is not referenced. */ | |||
| /* > u(j) = VL(:,j), the j-th column of VL. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDVL */ | |||
| /* > \verbatim */ | |||
| /* > LDVL is INTEGER */ | |||
| /* > The leading dimension of the array VL. LDVL >= 1; if */ | |||
| /* > JOBVL = 'V', LDVL >= N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] VR */ | |||
| /* > \verbatim */ | |||
| /* > VR is COMPLEX array, dimension (LDVR,N) */ | |||
| /* > If JOBVR = 'V', the right eigenvectors v(j) are stored one */ | |||
| /* > after another in the columns of VR, in the same order */ | |||
| /* > as their eigenvalues. */ | |||
| /* > If JOBVR = 'N', VR is not referenced. */ | |||
| /* > v(j) = VR(:,j), the j-th column of VR. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDVR */ | |||
| /* > \verbatim */ | |||
| /* > LDVR is INTEGER */ | |||
| /* > The leading dimension of the array VR. LDVR >= 1; if */ | |||
| /* > JOBVR = 'V', LDVR >= N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= f2cmax(1,2*N). */ | |||
| /* > For good performance, LWORK must generally be larger. */ | |||
| /* > */ | |||
| /* > 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] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (2*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: if INFO = i, the QR algorithm failed to compute all the */ | |||
| /* > eigenvalues, and no eigenvectors have been computed; */ | |||
| /* > elements i+1:N of W contain eigenvalues which have */ | |||
| /* > converged. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* @generated from zgeev.f, fortran z -> c, Tue Apr 19 01:47:44 2016 */ | |||
| /* > \ingroup complexGEeigen */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeev_(char *jobvl, char *jobvr, integer *n, complex *a, | |||
| integer *lda, complex *w, complex *vl, integer *ldvl, complex *vr, | |||
| integer *ldvr, complex *work, integer *lwork, real *rwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, vl_dim1, vl_offset, vr_dim1, vr_offset, i__1, | |||
| i__2, i__3; | |||
| real r__1, r__2; | |||
| complex q__1, q__2; | |||
| /* Local variables */ | |||
| integer ibal; | |||
| char side[1]; | |||
| real anrm; | |||
| integer ierr, itau, iwrk, nout, i__, k; | |||
| extern /* Subroutine */ int cscal_(integer *, complex *, complex *, | |||
| integer *); | |||
| extern logical lsame_(char *, char *); | |||
| extern real scnrm2_(integer *, complex *, integer *); | |||
| extern /* Subroutine */ int cgebak_(char *, char *, integer *, integer *, | |||
| integer *, real *, integer *, complex *, integer *, integer *), cgebal_(char *, integer *, complex *, integer *, | |||
| integer *, integer *, real *, integer *), slabad_(real *, | |||
| real *); | |||
| logical scalea; | |||
| extern real clange_(char *, integer *, integer *, complex *, integer *, | |||
| real *); | |||
| real cscale; | |||
| extern /* Subroutine */ int cgehrd_(integer *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *, integer *), | |||
| clascl_(char *, integer *, integer *, real *, real *, integer *, | |||
| integer *, complex *, integer *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer | |||
| *), clacpy_(char *, integer *, integer *, complex *, integer *, | |||
| complex *, integer *), xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| logical select[1]; | |||
| real bignum; | |||
| extern integer isamax_(integer *, real *, integer *); | |||
| extern /* Subroutine */ int chseqr_(char *, char *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, complex *, integer *, | |||
| complex *, integer *, integer *), cunghr_(integer | |||
| *, integer *, integer *, complex *, integer *, complex *, complex | |||
| *, integer *, integer *); | |||
| integer minwrk, maxwrk; | |||
| logical wantvl; | |||
| real smlnum; | |||
| integer hswork, irwork; | |||
| logical lquery, wantvr; | |||
| extern /* Subroutine */ int ctrevc3_(char *, char *, logical *, integer *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *, | |||
| integer *, integer *, complex *, integer *, real *, integer *, | |||
| integer *); | |||
| integer ihi; | |||
| real scl; | |||
| integer ilo; | |||
| real dum[1], eps; | |||
| complex tmp; | |||
| integer lwork_trevc__; | |||
| /* -- LAPACK driver 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; | |||
| --w; | |||
| vl_dim1 = *ldvl; | |||
| vl_offset = 1 + vl_dim1 * 1; | |||
| vl -= vl_offset; | |||
| vr_dim1 = *ldvr; | |||
| vr_offset = 1 + vr_dim1 * 1; | |||
| vr -= vr_offset; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *lwork == -1; | |||
| wantvl = lsame_(jobvl, "V"); | |||
| wantvr = lsame_(jobvr, "V"); | |||
| if (! wantvl && ! lsame_(jobvl, "N")) { | |||
| *info = -1; | |||
| } else if (! wantvr && ! lsame_(jobvr, "N")) { | |||
| *info = -2; | |||
| } else if (*n < 0) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -5; | |||
| } else if (*ldvl < 1 || wantvl && *ldvl < *n) { | |||
| *info = -8; | |||
| } else if (*ldvr < 1 || wantvr && *ldvr < *n) { | |||
| *info = -10; | |||
| } | |||
| /* Compute workspace */ | |||
| /* (Note: Comments in the code beginning "Workspace:" describe the */ | |||
| /* minimal amount of workspace needed at that point in the code, */ | |||
| /* as well as the preferred amount for good performance. */ | |||
| /* CWorkspace refers to complex workspace, and RWorkspace to real */ | |||
| /* workspace. NB refers to the optimal block size for the */ | |||
| /* immediately following subroutine, as returned by ILAENV. */ | |||
| /* HSWORK refers to the workspace preferred by CHSEQR, as */ | |||
| /* calculated below. HSWORK is computed assuming ILO=1 and IHI=N, */ | |||
| /* the worst case.) */ | |||
| if (*info == 0) { | |||
| if (*n == 0) { | |||
| minwrk = 1; | |||
| maxwrk = 1; | |||
| } else { | |||
| maxwrk = *n + *n * ilaenv_(&c__1, "CGEHRD", " ", n, &c__1, n, & | |||
| c__0, (ftnlen)6, (ftnlen)1); | |||
| minwrk = *n << 1; | |||
| if (wantvl) { | |||
| /* Computing MAX */ | |||
| i__1 = maxwrk, i__2 = *n + (*n - 1) * ilaenv_(&c__1, "CUNGHR", | |||
| " ", n, &c__1, n, &c_n1, (ftnlen)6, (ftnlen)1); | |||
| maxwrk = f2cmax(i__1,i__2); | |||
| ctrevc3_("L", "B", select, n, &a[a_offset], lda, &vl[ | |||
| vl_offset], ldvl, &vr[vr_offset], ldvr, n, &nout, & | |||
| work[1], &c_n1, &rwork[1], &c_n1, &ierr); | |||
| lwork_trevc__ = (integer) work[1].r; | |||
| /* Computing MAX */ | |||
| i__1 = maxwrk, i__2 = *n + lwork_trevc__; | |||
| maxwrk = f2cmax(i__1,i__2); | |||
| chseqr_("S", "V", n, &c__1, n, &a[a_offset], lda, &w[1], &vl[ | |||
| vl_offset], ldvl, &work[1], &c_n1, info); | |||
| } else if (wantvr) { | |||
| /* Computing MAX */ | |||
| i__1 = maxwrk, i__2 = *n + (*n - 1) * ilaenv_(&c__1, "CUNGHR", | |||
| " ", n, &c__1, n, &c_n1, (ftnlen)6, (ftnlen)1); | |||
| maxwrk = f2cmax(i__1,i__2); | |||
| ctrevc3_("R", "B", select, n, &a[a_offset], lda, &vl[ | |||
| vl_offset], ldvl, &vr[vr_offset], ldvr, n, &nout, & | |||
| work[1], &c_n1, &rwork[1], &c_n1, &ierr); | |||
| lwork_trevc__ = (integer) work[1].r; | |||
| /* Computing MAX */ | |||
| i__1 = maxwrk, i__2 = *n + lwork_trevc__; | |||
| maxwrk = f2cmax(i__1,i__2); | |||
| chseqr_("S", "V", n, &c__1, n, &a[a_offset], lda, &w[1], &vr[ | |||
| vr_offset], ldvr, &work[1], &c_n1, info); | |||
| } else { | |||
| chseqr_("E", "N", n, &c__1, n, &a[a_offset], lda, &w[1], &vr[ | |||
| vr_offset], ldvr, &work[1], &c_n1, info); | |||
| } | |||
| hswork = (integer) work[1].r; | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(maxwrk,hswork); | |||
| maxwrk = f2cmax(i__1,minwrk); | |||
| } | |||
| work[1].r = (real) maxwrk, work[1].i = 0.f; | |||
| if (*lwork < minwrk && ! lquery) { | |||
| *info = -12; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEEV ", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0) { | |||
| return 0; | |||
| } | |||
| /* Get machine constants */ | |||
| eps = slamch_("P"); | |||
| smlnum = slamch_("S"); | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| smlnum = sqrt(smlnum) / eps; | |||
| bignum = 1.f / smlnum; | |||
| /* Scale A if f2cmax element outside range [SMLNUM,BIGNUM] */ | |||
| anrm = clange_("M", n, n, &a[a_offset], lda, dum); | |||
| scalea = FALSE_; | |||
| if (anrm > 0.f && anrm < smlnum) { | |||
| scalea = TRUE_; | |||
| cscale = smlnum; | |||
| } else if (anrm > bignum) { | |||
| scalea = TRUE_; | |||
| cscale = bignum; | |||
| } | |||
| if (scalea) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &cscale, n, n, &a[a_offset], lda, & | |||
| ierr); | |||
| } | |||
| /* Balance the matrix */ | |||
| /* (CWorkspace: none) */ | |||
| /* (RWorkspace: need N) */ | |||
| ibal = 1; | |||
| cgebal_("B", n, &a[a_offset], lda, &ilo, &ihi, &rwork[ibal], &ierr); | |||
| /* Reduce to upper Hessenberg form */ | |||
| /* (CWorkspace: need 2*N, prefer N+N*NB) */ | |||
| /* (RWorkspace: none) */ | |||
| itau = 1; | |||
| iwrk = itau + *n; | |||
| i__1 = *lwork - iwrk + 1; | |||
| cgehrd_(n, &ilo, &ihi, &a[a_offset], lda, &work[itau], &work[iwrk], &i__1, | |||
| &ierr); | |||
| if (wantvl) { | |||
| /* Want left eigenvectors */ | |||
| /* Copy Householder vectors to VL */ | |||
| *(unsigned char *)side = 'L'; | |||
| clacpy_("L", n, n, &a[a_offset], lda, &vl[vl_offset], ldvl) | |||
| ; | |||
| /* Generate unitary matrix in VL */ | |||
| /* (CWorkspace: need 2*N-1, prefer N+(N-1)*NB) */ | |||
| /* (RWorkspace: none) */ | |||
| i__1 = *lwork - iwrk + 1; | |||
| cunghr_(n, &ilo, &ihi, &vl[vl_offset], ldvl, &work[itau], &work[iwrk], | |||
| &i__1, &ierr); | |||
| /* Perform QR iteration, accumulating Schur vectors in VL */ | |||
| /* (CWorkspace: need 1, prefer HSWORK (see comments) ) */ | |||
| /* (RWorkspace: none) */ | |||
| iwrk = itau; | |||
| i__1 = *lwork - iwrk + 1; | |||
| chseqr_("S", "V", n, &ilo, &ihi, &a[a_offset], lda, &w[1], &vl[ | |||
| vl_offset], ldvl, &work[iwrk], &i__1, info); | |||
| if (wantvr) { | |||
| /* Want left and right eigenvectors */ | |||
| /* Copy Schur vectors to VR */ | |||
| *(unsigned char *)side = 'B'; | |||
| clacpy_("F", n, n, &vl[vl_offset], ldvl, &vr[vr_offset], ldvr); | |||
| } | |||
| } else if (wantvr) { | |||
| /* Want right eigenvectors */ | |||
| /* Copy Householder vectors to VR */ | |||
| *(unsigned char *)side = 'R'; | |||
| clacpy_("L", n, n, &a[a_offset], lda, &vr[vr_offset], ldvr) | |||
| ; | |||
| /* Generate unitary matrix in VR */ | |||
| /* (CWorkspace: need 2*N-1, prefer N+(N-1)*NB) */ | |||
| /* (RWorkspace: none) */ | |||
| i__1 = *lwork - iwrk + 1; | |||
| cunghr_(n, &ilo, &ihi, &vr[vr_offset], ldvr, &work[itau], &work[iwrk], | |||
| &i__1, &ierr); | |||
| /* Perform QR iteration, accumulating Schur vectors in VR */ | |||
| /* (CWorkspace: need 1, prefer HSWORK (see comments) ) */ | |||
| /* (RWorkspace: none) */ | |||
| iwrk = itau; | |||
| i__1 = *lwork - iwrk + 1; | |||
| chseqr_("S", "V", n, &ilo, &ihi, &a[a_offset], lda, &w[1], &vr[ | |||
| vr_offset], ldvr, &work[iwrk], &i__1, info); | |||
| } else { | |||
| /* Compute eigenvalues only */ | |||
| /* (CWorkspace: need 1, prefer HSWORK (see comments) ) */ | |||
| /* (RWorkspace: none) */ | |||
| iwrk = itau; | |||
| i__1 = *lwork - iwrk + 1; | |||
| chseqr_("E", "N", n, &ilo, &ihi, &a[a_offset], lda, &w[1], &vr[ | |||
| vr_offset], ldvr, &work[iwrk], &i__1, info); | |||
| } | |||
| /* If INFO .NE. 0 from CHSEQR, then quit */ | |||
| if (*info != 0) { | |||
| goto L50; | |||
| } | |||
| if (wantvl || wantvr) { | |||
| /* Compute left and/or right eigenvectors */ | |||
| /* (CWorkspace: need 2*N, prefer N + 2*N*NB) */ | |||
| /* (RWorkspace: need 2*N) */ | |||
| irwork = ibal + *n; | |||
| i__1 = *lwork - iwrk + 1; | |||
| ctrevc3_(side, "B", select, n, &a[a_offset], lda, &vl[vl_offset], | |||
| ldvl, &vr[vr_offset], ldvr, n, &nout, &work[iwrk], &i__1, & | |||
| rwork[irwork], n, &ierr); | |||
| } | |||
| if (wantvl) { | |||
| /* Undo balancing of left eigenvectors */ | |||
| /* (CWorkspace: none) */ | |||
| /* (RWorkspace: need N) */ | |||
| cgebak_("B", "L", n, &ilo, &ihi, &rwork[ibal], n, &vl[vl_offset], | |||
| ldvl, &ierr); | |||
| /* Normalize left eigenvectors and make largest component real */ | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| scl = 1.f / scnrm2_(n, &vl[i__ * vl_dim1 + 1], &c__1); | |||
| csscal_(n, &scl, &vl[i__ * vl_dim1 + 1], &c__1); | |||
| i__2 = *n; | |||
| for (k = 1; k <= i__2; ++k) { | |||
| i__3 = k + i__ * vl_dim1; | |||
| /* Computing 2nd power */ | |||
| r__1 = vl[i__3].r; | |||
| /* Computing 2nd power */ | |||
| r__2 = r_imag(&vl[k + i__ * vl_dim1]); | |||
| rwork[irwork + k - 1] = r__1 * r__1 + r__2 * r__2; | |||
| /* L10: */ | |||
| } | |||
| k = isamax_(n, &rwork[irwork], &c__1); | |||
| r_cnjg(&q__2, &vl[k + i__ * vl_dim1]); | |||
| r__1 = sqrt(rwork[irwork + k - 1]); | |||
| q__1.r = q__2.r / r__1, q__1.i = q__2.i / r__1; | |||
| tmp.r = q__1.r, tmp.i = q__1.i; | |||
| cscal_(n, &tmp, &vl[i__ * vl_dim1 + 1], &c__1); | |||
| i__2 = k + i__ * vl_dim1; | |||
| i__3 = k + i__ * vl_dim1; | |||
| r__1 = vl[i__3].r; | |||
| q__1.r = r__1, q__1.i = 0.f; | |||
| vl[i__2].r = q__1.r, vl[i__2].i = q__1.i; | |||
| /* L20: */ | |||
| } | |||
| } | |||
| if (wantvr) { | |||
| /* Undo balancing of right eigenvectors */ | |||
| /* (CWorkspace: none) */ | |||
| /* (RWorkspace: need N) */ | |||
| cgebak_("B", "R", n, &ilo, &ihi, &rwork[ibal], n, &vr[vr_offset], | |||
| ldvr, &ierr); | |||
| /* Normalize right eigenvectors and make largest component real */ | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| scl = 1.f / scnrm2_(n, &vr[i__ * vr_dim1 + 1], &c__1); | |||
| csscal_(n, &scl, &vr[i__ * vr_dim1 + 1], &c__1); | |||
| i__2 = *n; | |||
| for (k = 1; k <= i__2; ++k) { | |||
| i__3 = k + i__ * vr_dim1; | |||
| /* Computing 2nd power */ | |||
| r__1 = vr[i__3].r; | |||
| /* Computing 2nd power */ | |||
| r__2 = r_imag(&vr[k + i__ * vr_dim1]); | |||
| rwork[irwork + k - 1] = r__1 * r__1 + r__2 * r__2; | |||
| /* L30: */ | |||
| } | |||
| k = isamax_(n, &rwork[irwork], &c__1); | |||
| r_cnjg(&q__2, &vr[k + i__ * vr_dim1]); | |||
| r__1 = sqrt(rwork[irwork + k - 1]); | |||
| q__1.r = q__2.r / r__1, q__1.i = q__2.i / r__1; | |||
| tmp.r = q__1.r, tmp.i = q__1.i; | |||
| cscal_(n, &tmp, &vr[i__ * vr_dim1 + 1], &c__1); | |||
| i__2 = k + i__ * vr_dim1; | |||
| i__3 = k + i__ * vr_dim1; | |||
| r__1 = vr[i__3].r; | |||
| q__1.r = r__1, q__1.i = 0.f; | |||
| vr[i__2].r = q__1.r, vr[i__2].i = q__1.i; | |||
| /* L40: */ | |||
| } | |||
| } | |||
| /* Undo scaling if necessary */ | |||
| L50: | |||
| if (scalea) { | |||
| i__1 = *n - *info; | |||
| /* Computing MAX */ | |||
| i__3 = *n - *info; | |||
| i__2 = f2cmax(i__3,1); | |||
| clascl_("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &w[*info + 1] | |||
| , &i__2, &ierr); | |||
| if (*info > 0) { | |||
| i__1 = ilo - 1; | |||
| clascl_("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &w[1], n, | |||
| &ierr); | |||
| } | |||
| } | |||
| work[1].r = (real) maxwrk, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEEV */ | |||
| } /* cgeev_ */ | |||
| @@ -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) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGEHD2 reduces a general square matrix to upper Hessenberg form using an unblocked algorithm. | |||
| */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEHD2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgehd2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgehd2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgehd2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEHD2( N, ILO, IHI, A, LDA, TAU, WORK, INFO ) */ | |||
| /* INTEGER IHI, ILO, INFO, LDA, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEHD2 reduces a complex general matrix A to upper Hessenberg form H */ | |||
| /* > by a unitary similarity transformation: Q**H * A * Q = H . */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ILO */ | |||
| /* > \verbatim */ | |||
| /* > ILO is INTEGER */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IHI */ | |||
| /* > \verbatim */ | |||
| /* > IHI is INTEGER */ | |||
| /* > */ | |||
| /* > It is assumed that A is already upper triangular in rows */ | |||
| /* > and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally */ | |||
| /* > set by a previous call to CGEBAL; otherwise they should be */ | |||
| /* > set to 1 and N respectively. See Further Details. */ | |||
| /* > 1 <= ILO <= IHI <= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the n by n general matrix to be reduced. */ | |||
| /* > On exit, the upper triangle and the first subdiagonal of A */ | |||
| /* > are overwritten with the upper Hessenberg matrix H, and the */ | |||
| /* > elements below the first subdiagonal, with the array TAU, */ | |||
| /* > represent the unitary matrix Q as a product of elementary */ | |||
| /* > reflectors. 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 array, dimension (N-1) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (N) */ | |||
| /* > \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 complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of (ihi-ilo) elementary */ | |||
| /* > reflectors */ | |||
| /* > */ | |||
| /* > Q = H(ilo) H(ilo+1) . . . H(ihi-1). */ | |||
| /* > */ | |||
| /* > 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) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on */ | |||
| /* > exit in A(i+2:ihi,i), and tau in TAU(i). */ | |||
| /* > */ | |||
| /* > The contents of A are illustrated by the following example, with */ | |||
| /* > n = 7, ilo = 2 and ihi = 6: */ | |||
| /* > */ | |||
| /* > on entry, on exit, */ | |||
| /* > */ | |||
| /* > ( a a a a a a a ) ( a a h h h h a ) */ | |||
| /* > ( a a a a a a ) ( a h h h h a ) */ | |||
| /* > ( a a a a a a ) ( h h h h h h ) */ | |||
| /* > ( a a a a a a ) ( v2 h h h h h ) */ | |||
| /* > ( a a a a a a ) ( v2 v3 h h h h ) */ | |||
| /* > ( a a a a a a ) ( v2 v3 v4 h h h ) */ | |||
| /* > ( 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). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgehd2_(integer *n, integer *ilo, integer *ihi, complex * | |||
| a, integer *lda, complex *tau, complex *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__; | |||
| complex alpha; | |||
| extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex * | |||
| , integer *, complex *, complex *, integer *, complex *), | |||
| clarfg_(integer *, complex *, complex *, integer *, complex *), | |||
| xerbla_(char *, integer *, ftnlen); | |||
| /* -- 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 */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*n < 0) { | |||
| *info = -1; | |||
| } else if (*ilo < 1 || *ilo > f2cmax(1,*n)) { | |||
| *info = -2; | |||
| } else if (*ihi < f2cmin(*ilo,*n) || *ihi > *n) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -5; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEHD2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| i__1 = *ihi - 1; | |||
| for (i__ = *ilo; i__ <= i__1; ++i__) { | |||
| /* Compute elementary reflector H(i) to annihilate A(i+2:ihi,i) */ | |||
| i__2 = i__ + 1 + i__ * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = *ihi - i__; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 2; | |||
| clarfg_(&i__2, &alpha, &a[f2cmin(i__3,*n) + i__ * a_dim1], &c__1, &tau[ | |||
| i__]); | |||
| i__2 = i__ + 1 + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| /* Apply H(i) to A(1:ihi,i+1:ihi) from the right */ | |||
| i__2 = *ihi - i__; | |||
| clarf_("Right", ihi, &i__2, &a[i__ + 1 + i__ * a_dim1], &c__1, &tau[ | |||
| i__], &a[(i__ + 1) * a_dim1 + 1], lda, &work[1]); | |||
| /* Apply H(i)**H to A(i+1:ihi,i+1:n) from the left */ | |||
| i__2 = *ihi - i__; | |||
| i__3 = *n - i__; | |||
| r_cnjg(&q__1, &tau[i__]); | |||
| clarf_("Left", &i__2, &i__3, &a[i__ + 1 + i__ * a_dim1], &c__1, &q__1, | |||
| &a[i__ + 1 + (i__ + 1) * a_dim1], lda, &work[1]); | |||
| i__2 = i__ + 1 + i__ * a_dim1; | |||
| a[i__2].r = alpha.r, a[i__2].i = alpha.i; | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* End of CGEHD2 */ | |||
| } /* cgehd2_ */ | |||
| @@ -0,0 +1,796 @@ | |||
| /* 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 complex c_b2 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__3 = 3; | |||
| static integer c__2 = 2; | |||
| static integer c__65 = 65; | |||
| /* > \brief \b CGEHRD */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEHRD + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgehrd. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgehrd. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgehrd. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEHRD( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO ) */ | |||
| /* INTEGER IHI, ILO, INFO, LDA, LWORK, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEHRD reduces a complex general matrix A to upper Hessenberg form H by */ | |||
| /* > an unitary similarity transformation: Q**H * A * Q = H . */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ILO */ | |||
| /* > \verbatim */ | |||
| /* > ILO is INTEGER */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IHI */ | |||
| /* > \verbatim */ | |||
| /* > IHI is INTEGER */ | |||
| /* > */ | |||
| /* > It is assumed that A is already upper triangular in rows */ | |||
| /* > and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally */ | |||
| /* > set by a previous call to CGEBAL; otherwise they should be */ | |||
| /* > set to 1 and N respectively. See Further Details. */ | |||
| /* > 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the N-by-N general matrix to be reduced. */ | |||
| /* > On exit, the upper triangle and the first subdiagonal of A */ | |||
| /* > are overwritten with the upper Hessenberg matrix H, and the */ | |||
| /* > elements below the first subdiagonal, with the array TAU, */ | |||
| /* > represent the unitary matrix Q as a product of elementary */ | |||
| /* > reflectors. 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 array, dimension (N-1) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). Elements 1:ILO-1 and IHI:N-1 of TAU are set to */ | |||
| /* > zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (LWORK) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The length of the array WORK. LWORK >= f2cmax(1,N). */ | |||
| /* > For good performance, LWORK should generally be larger. */ | |||
| /* > */ | |||
| /* > 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. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of (ihi-ilo) elementary */ | |||
| /* > reflectors */ | |||
| /* > */ | |||
| /* > Q = H(ilo) H(ilo+1) . . . H(ihi-1). */ | |||
| /* > */ | |||
| /* > 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) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on */ | |||
| /* > exit in A(i+2:ihi,i), and tau in TAU(i). */ | |||
| /* > */ | |||
| /* > The contents of A are illustrated by the following example, with */ | |||
| /* > n = 7, ilo = 2 and ihi = 6: */ | |||
| /* > */ | |||
| /* > on entry, on exit, */ | |||
| /* > */ | |||
| /* > ( a a a a a a a ) ( a a h h h h a ) */ | |||
| /* > ( a a a a a a ) ( a h h h h a ) */ | |||
| /* > ( a a a a a a ) ( h h h h h h ) */ | |||
| /* > ( a a a a a a ) ( v2 h h h h h ) */ | |||
| /* > ( a a a a a a ) ( v2 v3 h h h h ) */ | |||
| /* > ( a a a a a a ) ( v2 v3 v4 h h h ) */ | |||
| /* > ( 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 file is a slight modification of LAPACK-3.0's DGEHRD */ | |||
| /* > subroutine incorporating improvements proposed by Quintana-Orti and */ | |||
| /* > Van de Geijn (2006). (See DLAHR2.) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgehrd_(integer *n, integer *ilo, integer *ihi, complex * | |||
| a, integer *lda, complex *tau, complex *work, integer *lwork, integer | |||
| *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, | |||
| integer *, complex *, complex *, integer *, complex *, integer *, | |||
| complex *, complex *, integer *); | |||
| integer nbmin, iinfo; | |||
| extern /* Subroutine */ int ctrmm_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *), caxpy_(integer *, | |||
| complex *, complex *, integer *, complex *, integer *), cgehd2_( | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| complex *, integer *), clahr2_(integer *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *); | |||
| integer ib; | |||
| complex ei; | |||
| integer nb, nh; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *); | |||
| integer nx; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| integer ldwork, lwkopt; | |||
| logical lquery; | |||
| integer iwt; | |||
| /* -- 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 */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *lwork == -1; | |||
| if (*n < 0) { | |||
| *info = -1; | |||
| } else if (*ilo < 1 || *ilo > f2cmax(1,*n)) { | |||
| *info = -2; | |||
| } else if (*ihi < f2cmin(*ilo,*n) || *ihi > *n) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -5; | |||
| } else if (*lwork < f2cmax(1,*n) && ! lquery) { | |||
| *info = -8; | |||
| } | |||
| if (*info == 0) { | |||
| /* Compute the workspace requirements */ | |||
| /* Computing MIN */ | |||
| i__1 = 64, i__2 = ilaenv_(&c__1, "CGEHRD", " ", n, ilo, ihi, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nb = f2cmin(i__1,i__2); | |||
| lwkopt = *n * nb + 4160; | |||
| work[1].r = (real) lwkopt, work[1].i = 0.f; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEHRD", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Set elements 1:ILO-1 and IHI:N-1 of TAU to zero */ | |||
| i__1 = *ilo - 1; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| tau[i__2].r = 0.f, tau[i__2].i = 0.f; | |||
| /* L10: */ | |||
| } | |||
| i__1 = *n - 1; | |||
| for (i__ = f2cmax(1,*ihi); i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| tau[i__2].r = 0.f, tau[i__2].i = 0.f; | |||
| /* L20: */ | |||
| } | |||
| /* Quick return if possible */ | |||
| nh = *ihi - *ilo + 1; | |||
| if (nh <= 1) { | |||
| work[1].r = 1.f, work[1].i = 0.f; | |||
| return 0; | |||
| } | |||
| /* Determine the block size */ | |||
| /* Computing MIN */ | |||
| i__1 = 64, i__2 = ilaenv_(&c__1, "CGEHRD", " ", n, ilo, ihi, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nb = f2cmin(i__1,i__2); | |||
| nbmin = 2; | |||
| if (nb > 1 && nb < nh) { | |||
| /* Determine when to cross over from blocked to unblocked code */ | |||
| /* (last block is always handled by unblocked code) */ | |||
| /* Computing MAX */ | |||
| i__1 = nb, i__2 = ilaenv_(&c__3, "CGEHRD", " ", n, ilo, ihi, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nx = f2cmax(i__1,i__2); | |||
| if (nx < nh) { | |||
| /* Determine if workspace is large enough for blocked code */ | |||
| if (*lwork < *n * nb + 4160) { | |||
| /* Not enough workspace to use optimal NB: determine the */ | |||
| /* minimum value of NB, and reduce NB or force use of */ | |||
| /* unblocked code */ | |||
| /* Computing MAX */ | |||
| i__1 = 2, i__2 = ilaenv_(&c__2, "CGEHRD", " ", n, ilo, ihi, & | |||
| c_n1, (ftnlen)6, (ftnlen)1); | |||
| nbmin = f2cmax(i__1,i__2); | |||
| if (*lwork >= *n * nbmin + 4160) { | |||
| nb = (*lwork - 4160) / *n; | |||
| } else { | |||
| nb = 1; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| ldwork = *n; | |||
| if (nb < nbmin || nb >= nh) { | |||
| /* Use unblocked code below */ | |||
| i__ = *ilo; | |||
| } else { | |||
| /* Use blocked code */ | |||
| iwt = *n * nb + 1; | |||
| i__1 = *ihi - 1 - nx; | |||
| i__2 = nb; | |||
| for (i__ = *ilo; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = nb, i__4 = *ihi - i__; | |||
| ib = f2cmin(i__3,i__4); | |||
| /* Reduce columns i:i+ib-1 to Hessenberg form, returning the */ | |||
| /* matrices V and T of the block reflector H = I - V*T*V**H */ | |||
| /* which performs the reduction, and also the matrix Y = A*V*T */ | |||
| clahr2_(ihi, &i__, &ib, &a[i__ * a_dim1 + 1], lda, &tau[i__], & | |||
| work[iwt], &c__65, &work[1], &ldwork); | |||
| /* Apply the block reflector H to A(1:ihi,i+ib:ihi) from the */ | |||
| /* right, computing A := A - Y * V**H. V(i+ib,ib-1) must be set */ | |||
| /* to 1 */ | |||
| i__3 = i__ + ib + (i__ + ib - 1) * a_dim1; | |||
| ei.r = a[i__3].r, ei.i = a[i__3].i; | |||
| i__3 = i__ + ib + (i__ + ib - 1) * a_dim1; | |||
| a[i__3].r = 1.f, a[i__3].i = 0.f; | |||
| i__3 = *ihi - i__ - ib + 1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemm_("No transpose", "Conjugate transpose", ihi, &i__3, &ib, & | |||
| q__1, &work[1], &ldwork, &a[i__ + ib + i__ * a_dim1], lda, | |||
| &c_b2, &a[(i__ + ib) * a_dim1 + 1], lda); | |||
| i__3 = i__ + ib + (i__ + ib - 1) * a_dim1; | |||
| a[i__3].r = ei.r, a[i__3].i = ei.i; | |||
| /* Apply the block reflector H to A(1:i,i+1:i+ib-1) from the */ | |||
| /* right */ | |||
| i__3 = ib - 1; | |||
| ctrmm_("Right", "Lower", "Conjugate transpose", "Unit", &i__, & | |||
| i__3, &c_b2, &a[i__ + 1 + i__ * a_dim1], lda, &work[1], & | |||
| ldwork); | |||
| i__3 = ib - 2; | |||
| for (j = 0; j <= i__3; ++j) { | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| caxpy_(&i__, &q__1, &work[ldwork * j + 1], &c__1, &a[(i__ + j | |||
| + 1) * a_dim1 + 1], &c__1); | |||
| /* L30: */ | |||
| } | |||
| /* Apply the block reflector H to A(i+1:ihi,i+ib:n) from the */ | |||
| /* left */ | |||
| i__3 = *ihi - i__; | |||
| i__4 = *n - i__ - ib + 1; | |||
| clarfb_("Left", "Conjugate transpose", "Forward", "Columnwise", & | |||
| i__3, &i__4, &ib, &a[i__ + 1 + i__ * a_dim1], lda, &work[ | |||
| iwt], &c__65, &a[i__ + 1 + (i__ + ib) * a_dim1], lda, & | |||
| work[1], &ldwork); | |||
| /* L40: */ | |||
| } | |||
| } | |||
| /* Use unblocked code to reduce the rest of the matrix */ | |||
| cgehd2_(n, &i__, ihi, &a[a_offset], lda, &tau[1], &work[1], &iinfo); | |||
| work[1].r = (real) lwkopt, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEHRD */ | |||
| } /* cgehrd_ */ | |||
| @@ -0,0 +1,745 @@ | |||
| /* 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; | |||
| static integer c_n1 = -1; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGELQ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELQ( M, N, A, LDA, T, TSIZE, WORK, LWORK, */ | |||
| /* INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N, TSIZE, LWORK */ | |||
| /* COMPLEX A( LDA, * ), T( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELQ computes an LQ factorization of a complex M-by-N matrix A: */ | |||
| /* > */ | |||
| /* > A = ( L 0 ) * Q */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a N-by-N orthogonal matrix; */ | |||
| /* > L is a lower-triangular M-by-M matrix; */ | |||
| /* > 0 is a M-by-(N-M) zero matrix, if M < N. */ | |||
| /* > */ | |||
| /* > \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 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 M-by-f2cmin(M,N) lower trapezoidal matrix L */ | |||
| /* > (L is lower triangular if M <= N); */ | |||
| /* > the elements above the diagonal are used to store part of the */ | |||
| /* > data structure to represent Q. */ | |||
| /* > \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 array, dimension (MAX(5,TSIZE)) */ | |||
| /* > On exit, if INFO = 0, T(1) returns optimal (or either minimal */ | |||
| /* > or optimal, if query is assumed) TSIZE. See TSIZE for details. */ | |||
| /* > Remaining T contains part of the data structure used to represent Q. */ | |||
| /* > If one wants to apply or construct Q, then one needs to keep T */ | |||
| /* > (in addition to A) and pass it to further subroutines. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TSIZE */ | |||
| /* > \verbatim */ | |||
| /* > TSIZE is INTEGER */ | |||
| /* > If TSIZE >= 5, the dimension of the array T. */ | |||
| /* > If TSIZE = -1 or -2, then a workspace query is assumed. The routine */ | |||
| /* > only calculates the sizes of the T and WORK arrays, returns these */ | |||
| /* > values as the first entries of the T and WORK arrays, and no error */ | |||
| /* > message related to T or WORK is issued by XERBLA. */ | |||
| /* > If TSIZE = -1, the routine calculates optimal size of T for the */ | |||
| /* > optimum performance and returns this value in T(1). */ | |||
| /* > If TSIZE = -2, the routine calculates minimal size of T and */ | |||
| /* > returns this value in T(1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > (workspace) COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) contains optimal (or either minimal */ | |||
| /* > or optimal, if query was assumed) LWORK. */ | |||
| /* > See LWORK for details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > If LWORK = -1 or -2, then a workspace query is assumed. The routine */ | |||
| /* > only calculates the sizes of the T and WORK arrays, returns these */ | |||
| /* > values as the first entries of the T and WORK arrays, and no error */ | |||
| /* > message related to T or WORK is issued by XERBLA. */ | |||
| /* > If LWORK = -1, the routine calculates optimal size of WORK for the */ | |||
| /* > optimal performance and returns this value in WORK(1). */ | |||
| /* > If LWORK = -2, the routine calculates minimal size of WORK and */ | |||
| /* > returns this value in WORK(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. */ | |||
| /* > \par Further Details */ | |||
| /* ==================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The goal of the interface is to give maximum freedom to the developers for */ | |||
| /* > creating any LQ factorization algorithm they wish. The triangular */ | |||
| /* > (trapezoidal) L has to be stored in the lower part of A. The lower part of A */ | |||
| /* > and the array T can be used to store any relevant information for applying or */ | |||
| /* > constructing the Q factor. The WORK array can safely be discarded after exit. */ | |||
| /* > */ | |||
| /* > Caution: One should not expect the sizes of T and WORK to be the same from one */ | |||
| /* > LAPACK implementation to the other, or even from one execution to the other. */ | |||
| /* > A workspace query (for T and WORK) is needed at each execution. However, */ | |||
| /* > for a given execution, the size of T and WORK are fixed and will not change */ | |||
| /* > from one query to the next. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \par Further Details particular to this LAPACK implementation: */ | |||
| /* ============================================================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > These details are particular for this LAPACK implementation. Users should not */ | |||
| /* > take them for granted. These details may change in the future, and are not likely */ | |||
| /* > true for another LAPACK implementation. These details are relevant if one wants */ | |||
| /* > to try to understand the code. They are not part of the interface. */ | |||
| /* > */ | |||
| /* > In this version, */ | |||
| /* > */ | |||
| /* > T(2): row block size (MB) */ | |||
| /* > T(3): column block size (NB) */ | |||
| /* > T(6:TSIZE): data structure needed for Q, computed by */ | |||
| /* > CLASWLQ or CGELQT */ | |||
| /* > */ | |||
| /* > Depending on the matrix dimensions M and N, and row and column */ | |||
| /* > block sizes MB and NB returned by ILAENV, CGELQ will use either */ | |||
| /* > CLASWLQ (if the matrix is short-and-wide) or CGELQT to compute */ | |||
| /* > the LQ factorization. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgelq_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *t, integer *tsize, complex *work, integer *lwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2; | |||
| /* Local variables */ | |||
| logical mint, minw; | |||
| integer lwmin, lwreq, lwopt, mb, nb, nblcks; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| extern /* Subroutine */ int cgelqt_(integer *, integer *, integer *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *); | |||
| logical lminws, lquery; | |||
| integer mintsz; | |||
| extern /* Subroutine */ int claswlq_(integer *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, integer *, complex *, | |||
| integer *, integer *); | |||
| /* -- 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. -- */ | |||
| /* November 2019 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --t; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *tsize == -1 || *tsize == -2 || *lwork == -1 || *lwork == -2; | |||
| mint = FALSE_; | |||
| minw = FALSE_; | |||
| if (*tsize == -2 || *lwork == -2) { | |||
| if (*tsize != -1) { | |||
| mint = TRUE_; | |||
| } | |||
| if (*lwork != -1) { | |||
| minw = TRUE_; | |||
| } | |||
| } | |||
| /* Determine the block size */ | |||
| if (f2cmin(*m,*n) > 0) { | |||
| mb = ilaenv_(&c__1, "CGELQ ", " ", m, n, &c__1, &c_n1, (ftnlen)6, ( | |||
| ftnlen)1); | |||
| nb = ilaenv_(&c__1, "CGELQ ", " ", m, n, &c__2, &c_n1, (ftnlen)6, ( | |||
| ftnlen)1); | |||
| } else { | |||
| mb = 1; | |||
| nb = *n; | |||
| } | |||
| if (mb > f2cmin(*m,*n) || mb < 1) { | |||
| mb = 1; | |||
| } | |||
| if (nb > *n || nb <= *m) { | |||
| nb = *n; | |||
| } | |||
| mintsz = *m + 5; | |||
| if (nb > *m && *n > *m) { | |||
| if ((*n - *m) % (nb - *m) == 0) { | |||
| nblcks = (*n - *m) / (nb - *m); | |||
| } else { | |||
| nblcks = (*n - *m) / (nb - *m) + 1; | |||
| } | |||
| } else { | |||
| nblcks = 1; | |||
| } | |||
| /* Determine if the workspace size satisfies minimal size */ | |||
| if (*n <= *m || nb <= *m || nb >= *n) { | |||
| lwmin = f2cmax(1,*n); | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *n; | |||
| lwopt = f2cmax(i__1,i__2); | |||
| } else { | |||
| lwmin = f2cmax(1,*m); | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *m; | |||
| lwopt = f2cmax(i__1,i__2); | |||
| } | |||
| lminws = FALSE_; | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *m * nblcks + 5; | |||
| if ((*tsize < f2cmax(i__1,i__2) || *lwork < lwopt) && *lwork >= lwmin && * | |||
| tsize >= mintsz && ! lquery) { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *m * nblcks + 5; | |||
| if (*tsize < f2cmax(i__1,i__2)) { | |||
| lminws = TRUE_; | |||
| mb = 1; | |||
| nb = *n; | |||
| } | |||
| if (*lwork < lwopt) { | |||
| lminws = TRUE_; | |||
| mb = 1; | |||
| } | |||
| } | |||
| if (*n <= *m || nb <= *m || nb >= *n) { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *n; | |||
| lwreq = f2cmax(i__1,i__2); | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *m; | |||
| lwreq = f2cmax(i__1,i__2); | |||
| } | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *m * nblcks + 5; | |||
| if (*tsize < f2cmax(i__1,i__2) && ! lquery && ! lminws) { | |||
| *info = -6; | |||
| } else if (*lwork < lwreq && ! lquery && ! lminws) { | |||
| *info = -8; | |||
| } | |||
| } | |||
| if (*info == 0) { | |||
| if (mint) { | |||
| t[1].r = (real) mintsz, t[1].i = 0.f; | |||
| } else { | |||
| i__1 = mb * *m * nblcks + 5; | |||
| t[1].r = (real) i__1, t[1].i = 0.f; | |||
| } | |||
| t[2].r = (real) mb, t[2].i = 0.f; | |||
| t[3].r = (real) nb, t[3].i = 0.f; | |||
| if (minw) { | |||
| work[1].r = (real) lwmin, work[1].i = 0.f; | |||
| } else { | |||
| work[1].r = (real) lwreq, work[1].i = 0.f; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELQ", &i__1, (ftnlen)5); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (f2cmin(*m,*n) == 0) { | |||
| return 0; | |||
| } | |||
| /* The LQ Decomposition */ | |||
| if (*n <= *m || nb <= *m || nb >= *n) { | |||
| cgelqt_(m, n, &mb, &a[a_offset], lda, &t[6], &mb, &work[1], info); | |||
| } else { | |||
| claswlq_(m, n, &mb, &nb, &a[a_offset], lda, &t[6], &mb, &work[1], | |||
| lwork, info); | |||
| } | |||
| work[1].r = (real) lwreq, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGELQ */ | |||
| } /* cgelq_ */ | |||
| @@ -0,0 +1,605 @@ | |||
| /* 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 CGELQ2 computes the LQ factorization of a general rectangular matrix using an unblocked algorit | |||
| hm. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGELQ2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgelq2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgelq2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgelq2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELQ2( M, N, A, LDA, TAU, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELQ2 computes an LQ factorization of a complex m-by-n matrix A: */ | |||
| /* > */ | |||
| /* > A = ( L 0 ) * Q */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a n-by-n orthogonal matrix; */ | |||
| /* > L is an lower-triangular m-by-m matrix; */ | |||
| /* > 0 is a m-by-(n-m) zero matrix, if m < n. */ | |||
| /* > */ | |||
| /* > \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 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 m by f2cmin(m,n) lower trapezoidal matrix L (L is */ | |||
| /* > lower triangular if m <= n); the elements above the diagonal, */ | |||
| /* > with the array TAU, represent the unitary matrix Q as a */ | |||
| /* > product of elementary reflectors (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] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (M) */ | |||
| /* > \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 November 2019 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(k)**H . . . H(2)**H H(1)**H, where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > 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-1) = 0 and v(i) = 1; conjg(v(i+1:n)) is stored on exit in */ | |||
| /* > A(i,i+1:n), and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgelq2_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, complex *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| complex alpha; | |||
| extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex * | |||
| , integer *, complex *, complex *, integer *, complex *), | |||
| clarfg_(integer *, complex *, complex *, integer *, complex *), | |||
| clacgv_(integer *, complex *, integer *), xerbla_(char *, integer | |||
| *, ftnlen); | |||
| /* -- 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..-- */ | |||
| /* November 2019 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELQ2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| k = f2cmin(*m,*n); | |||
| i__1 = k; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Generate elementary reflector H(i) to annihilate A(i,i+1:n) */ | |||
| i__2 = *n - i__ + 1; | |||
| clacgv_(&i__2, &a[i__ + i__ * a_dim1], lda); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = *n - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 1; | |||
| clarfg_(&i__2, &alpha, &a[i__ + f2cmin(i__3,*n) * a_dim1], lda, &tau[i__] | |||
| ); | |||
| if (i__ < *m) { | |||
| /* Apply H(i) to A(i+1:m,i:n) from the right */ | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| i__2 = *m - i__; | |||
| i__3 = *n - i__ + 1; | |||
| clarf_("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, &tau[ | |||
| i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]); | |||
| } | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = alpha.r, a[i__2].i = alpha.i; | |||
| i__2 = *n - i__ + 1; | |||
| clacgv_(&i__2, &a[i__ + i__ * a_dim1], lda); | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* End of CGELQ2 */ | |||
| } /* cgelq2_ */ | |||
| @@ -0,0 +1,699 @@ | |||
| /* 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; | |||
| static integer c_n1 = -1; | |||
| static integer c__3 = 3; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGELQF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGELQF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgelqf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgelqf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgelqf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELQF( M, N, A, LDA, TAU, WORK, LWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LWORK, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELQF computes an LQ factorization of a complex M-by-N matrix A: */ | |||
| /* > */ | |||
| /* > A = ( L 0 ) * Q */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a N-by-N orthogonal matrix; */ | |||
| /* > L is an lower-triangular M-by-M matrix; */ | |||
| /* > 0 is a M-by-(N-M) zero matrix, if M < N. */ | |||
| /* > */ | |||
| /* > \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 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 m-by-f2cmin(m,n) lower trapezoidal matrix L (L is */ | |||
| /* > lower triangular if m <= n); the elements above the diagonal, */ | |||
| /* > with the array TAU, represent the unitary matrix Q as a */ | |||
| /* > product of elementary reflectors (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] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= f2cmax(1,M). */ | |||
| /* > For optimum performance LWORK >= M*NB, where NB is the */ | |||
| /* > optimal blocksize. */ | |||
| /* > */ | |||
| /* > 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. */ | |||
| /* > \date November 2019 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(k)**H . . . H(2)**H H(1)**H, where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > 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-1) = 0 and v(i) = 1; conjg(v(i+1:n)) is stored on exit in */ | |||
| /* > A(i,i+1:n), and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgelqf_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, complex *work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| /* Local variables */ | |||
| integer i__, k, nbmin, iinfo; | |||
| extern /* Subroutine */ int cgelq2_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *); | |||
| integer ib, nb; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *); | |||
| integer nx; | |||
| extern /* Subroutine */ int clarft_(char *, char *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *), xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| integer ldwork, lwkopt; | |||
| logical lquery; | |||
| integer iws; | |||
| /* -- 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..-- */ | |||
| /* November 2019 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| nb = ilaenv_(&c__1, "CGELQF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, (ftnlen) | |||
| 1); | |||
| lwkopt = *m * nb; | |||
| work[1].r = (real) lwkopt, work[1].i = 0.f; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else if (*lwork < f2cmax(1,*m) && ! lquery) { | |||
| *info = -7; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELQF", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| k = f2cmin(*m,*n); | |||
| if (k == 0) { | |||
| work[1].r = 1.f, work[1].i = 0.f; | |||
| return 0; | |||
| } | |||
| nbmin = 2; | |||
| nx = 0; | |||
| iws = *m; | |||
| if (nb > 1 && nb < k) { | |||
| /* Determine when to cross over from blocked to unblocked code. */ | |||
| /* Computing MAX */ | |||
| i__1 = 0, i__2 = ilaenv_(&c__3, "CGELQF", " ", m, n, &c_n1, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nx = f2cmax(i__1,i__2); | |||
| if (nx < k) { | |||
| /* Determine if workspace is large enough for blocked code. */ | |||
| ldwork = *m; | |||
| iws = ldwork * nb; | |||
| if (*lwork < iws) { | |||
| /* Not enough workspace to use optimal NB: reduce NB and */ | |||
| /* determine the minimum value of NB. */ | |||
| nb = *lwork / ldwork; | |||
| /* Computing MAX */ | |||
| i__1 = 2, i__2 = ilaenv_(&c__2, "CGELQF", " ", m, n, &c_n1, & | |||
| c_n1, (ftnlen)6, (ftnlen)1); | |||
| nbmin = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| } | |||
| if (nb >= nbmin && nb < k && nx < k) { | |||
| /* Use blocked code initially */ | |||
| i__1 = k - nx; | |||
| i__2 = nb; | |||
| for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = k - i__ + 1; | |||
| ib = f2cmin(i__3,nb); | |||
| /* Compute the LQ factorization of the current block */ | |||
| /* A(i:i+ib-1,i:n) */ | |||
| i__3 = *n - i__ + 1; | |||
| cgelq2_(&ib, &i__3, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[ | |||
| 1], &iinfo); | |||
| if (i__ + ib <= *m) { | |||
| /* Form the triangular factor of the block reflector */ | |||
| /* H = H(i) H(i+1) . . . H(i+ib-1) */ | |||
| i__3 = *n - i__ + 1; | |||
| clarft_("Forward", "Rowwise", &i__3, &ib, &a[i__ + i__ * | |||
| a_dim1], lda, &tau[i__], &work[1], &ldwork); | |||
| /* Apply H to A(i+ib:m,i:n) from the right */ | |||
| i__3 = *m - i__ - ib + 1; | |||
| i__4 = *n - i__ + 1; | |||
| clarfb_("Right", "No transpose", "Forward", "Rowwise", &i__3, | |||
| &i__4, &ib, &a[i__ + i__ * a_dim1], lda, &work[1], & | |||
| ldwork, &a[i__ + ib + i__ * a_dim1], lda, &work[ib + | |||
| 1], &ldwork); | |||
| } | |||
| /* L10: */ | |||
| } | |||
| } else { | |||
| i__ = 1; | |||
| } | |||
| /* Use unblocked code to factor the last or only block. */ | |||
| if (i__ <= k) { | |||
| i__2 = *m - i__ + 1; | |||
| i__1 = *n - i__ + 1; | |||
| cgelq2_(&i__2, &i__1, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[1] | |||
| , &iinfo); | |||
| } | |||
| work[1].r = (real) iws, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGELQF */ | |||
| } /* cgelqf_ */ | |||
| @@ -0,0 +1,601 @@ | |||
| /* 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 CGELQT */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELQT( M, N, MB, A, LDA, T, LDT, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LDT, M, N, MB */ | |||
| /* COMPLEX A( LDA, * ), T( LDT, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELQT computes a blocked LQ factorization of a complex M-by-N matrix A */ | |||
| /* > using the compact WY representation of Q. */ | |||
| /* > \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] MB */ | |||
| /* > \verbatim */ | |||
| /* > MB is INTEGER */ | |||
| /* > The block size to be used in the blocked QR. MIN(M,N) >= MB >= 1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX 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 M-by-MIN(M,N) lower trapezoidal matrix L (L is */ | |||
| /* > lower triangular if M <= N); the elements above the diagonal */ | |||
| /* > are the rows of V. */ | |||
| /* > \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 array, dimension (LDT,MIN(M,N)) */ | |||
| /* > The 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[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MB*N) */ | |||
| /* > \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 2017 */ | |||
| /* > \ingroup doubleGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix V stores the elementary reflectors H(i) in the i-th row */ | |||
| /* > above the diagonal. For example, if M=5 and N=3, the matrix V is */ | |||
| /* > */ | |||
| /* > V = ( 1 v1 v1 v1 v1 ) */ | |||
| /* > ( 1 v2 v2 v2 ) */ | |||
| /* > ( 1 v3 v3 ) */ | |||
| /* > */ | |||
| /* > */ | |||
| /* > where the vi's represent the vectors which define H(i), which are returned */ | |||
| /* > in the matrix A. The 1's along the diagonal of V are not stored in A. */ | |||
| /* > Let K=MIN(M,N). The number of blocks is B = ceiling(K/MB), where each */ | |||
| /* > block is of order MB except for the last block, which is of order */ | |||
| /* > IB = K - (B-1)*MB. For each of the B blocks, a upper triangular block */ | |||
| /* > reflector factor is computed: T1, T2, ..., TB. The MB-by-MB (and IB-by-IB */ | |||
| /* > for the last block) T's are stored in the MB-by-K matrix T as */ | |||
| /* > */ | |||
| /* > T = (T1 T2 ... TB). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgelqt_(integer *m, integer *n, integer *mb, complex *a, | |||
| integer *lda, complex *t, integer *ldt, complex *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, i__1, i__2, i__3, i__4, i__5; | |||
| /* Local variables */ | |||
| integer i__, k, iinfo, ib; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *), xerbla_(char *, integer *, ftnlen), | |||
| cgelqt3_(integer *, integer *, complex *, integer *, complex *, | |||
| integer *, 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; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*mb < 1 || *mb > f2cmin(*m,*n) && f2cmin(*m,*n) > 0) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -5; | |||
| } else if (*ldt < *mb) { | |||
| *info = -7; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELQT", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| k = f2cmin(*m,*n); | |||
| if (k == 0) { | |||
| return 0; | |||
| } | |||
| /* Blocked loop of length K */ | |||
| i__1 = k; | |||
| i__2 = *mb; | |||
| for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = k - i__ + 1; | |||
| ib = f2cmin(i__3,*mb); | |||
| /* Compute the LQ factorization of the current block A(I:M,I:I+IB-1) */ | |||
| i__3 = *n - i__ + 1; | |||
| cgelqt3_(&ib, &i__3, &a[i__ + i__ * a_dim1], lda, &t[i__ * t_dim1 + 1] | |||
| , ldt, &iinfo); | |||
| if (i__ + ib <= *m) { | |||
| /* Update by applying H**T to A(I:M,I+IB:N) from the right */ | |||
| i__3 = *m - i__ - ib + 1; | |||
| i__4 = *n - i__ + 1; | |||
| i__5 = *m - i__ - ib + 1; | |||
| clarfb_("R", "N", "F", "R", &i__3, &i__4, &ib, &a[i__ + i__ * | |||
| a_dim1], lda, &t[i__ * t_dim1 + 1], ldt, &a[i__ + ib + | |||
| i__ * a_dim1], lda, &work[1], &i__5); | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGELQT */ | |||
| } /* cgelqt_ */ | |||
| @@ -0,0 +1,676 @@ | |||
| /* 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 complex c_b1 = {1.f,0.f}; | |||
| /* > \brief \b CGELQT3 */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELQT3( M, N, A, LDA, T, LDT, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N, LDT */ | |||
| /* COMPLEX A( LDA, * ), T( LDT, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELQT3 recursively computes a LQ factorization of a complex M-by-N */ | |||
| /* > matrix A, using the compact WY representation of Q. */ | |||
| /* > */ | |||
| /* > Based on the algorithm of Elmroth and Gustavson, */ | |||
| /* > IBM J. Res. Develop. Vol 44 No. 4 July 2000. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M =< N. */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the real M-by-N matrix A. On exit, the elements on and */ | |||
| /* > below the diagonal contain the N-by-N lower triangular matrix L; the */ | |||
| /* > elements above the diagonal are the rows of V. See below for */ | |||
| /* > 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 array, dimension (LDT,N) */ | |||
| /* > The N-by-N upper triangular factor of the block reflector. */ | |||
| /* > The elements on and above the diagonal contain the block */ | |||
| /* > reflector T; the elements below the diagonal are not used. */ | |||
| /* > See below for further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= 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 */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date November 2017 */ | |||
| /* > \ingroup doubleGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix V stores the elementary reflectors H(i) in the i-th row */ | |||
| /* > above the diagonal. For example, if M=5 and N=3, the matrix V is */ | |||
| /* > */ | |||
| /* > V = ( 1 v1 v1 v1 v1 ) */ | |||
| /* > ( 1 v2 v2 v2 ) */ | |||
| /* > ( 1 v3 v3 v3 ) */ | |||
| /* > */ | |||
| /* > */ | |||
| /* > where the vi's represent the vectors which define H(i), which are returned */ | |||
| /* > in the matrix A. The 1's along the diagonal of V are not stored in A. The */ | |||
| /* > block reflector H is then given by */ | |||
| /* > */ | |||
| /* > H = I - V * T * V**T */ | |||
| /* > */ | |||
| /* > where V**T is the transpose of V. */ | |||
| /* > */ | |||
| /* > For details of the algorithm, see Elmroth and Gustavson (cited above). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgelqt3_(integer *m, integer *n, complex *a, integer * | |||
| lda, complex *t, integer *ldt, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, i__1, i__2, i__3, i__4, i__5; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, | |||
| integer *, complex *, complex *, integer *, complex *, integer *, | |||
| complex *, complex *, integer *); | |||
| integer iinfo; | |||
| extern /* Subroutine */ int ctrmm_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *); | |||
| integer i1, j1, m1, m2; | |||
| extern /* Subroutine */ int clarfg_(integer *, complex *, complex *, | |||
| integer *, complex *), xerbla_(char *, integer *, ftnlen); | |||
| /* -- 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; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < *m) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else if (*ldt < f2cmax(1,*m)) { | |||
| *info = -6; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELQT3", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| if (*m == 1) { | |||
| /* Compute Householder transform when N=1 */ | |||
| clarfg_(n, &a[a_offset], &a[f2cmin(2,*n) * a_dim1 + 1], lda, &t[t_offset] | |||
| ); | |||
| i__1 = t_dim1 + 1; | |||
| r_cnjg(&q__1, &t[t_dim1 + 1]); | |||
| t[i__1].r = q__1.r, t[i__1].i = q__1.i; | |||
| } else { | |||
| /* Otherwise, split A into blocks... */ | |||
| m1 = *m / 2; | |||
| m2 = *m - m1; | |||
| /* Computing MIN */ | |||
| i__1 = m1 + 1; | |||
| i1 = f2cmin(i__1,*m); | |||
| /* Computing MIN */ | |||
| i__1 = *m + 1; | |||
| j1 = f2cmin(i__1,*n); | |||
| /* Compute A(1:M1,1:N) <- (Y1,R1,T1), where Q1 = I - Y1 T1 Y1^H */ | |||
| cgelqt3_(&m1, n, &a[a_offset], lda, &t[t_offset], ldt, &iinfo); | |||
| /* Compute A(J1:M,1:N) = A(J1:M,1:N) Q1^H [workspace: T(1:N1,J1:N)] */ | |||
| i__1 = m2; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = m1; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| i__3 = i__ + m1 + j * t_dim1; | |||
| i__4 = i__ + m1 + j * a_dim1; | |||
| t[i__3].r = a[i__4].r, t[i__3].i = a[i__4].i; | |||
| } | |||
| } | |||
| ctrmm_("R", "U", "C", "U", &m2, &m1, &c_b1, &a[a_offset], lda, &t[i1 | |||
| + t_dim1], ldt); | |||
| i__1 = *n - m1; | |||
| cgemm_("N", "C", &m2, &m1, &i__1, &c_b1, &a[i1 + i1 * a_dim1], lda, & | |||
| a[i1 * a_dim1 + 1], lda, &c_b1, &t[i1 + t_dim1], ldt); | |||
| ctrmm_("R", "U", "N", "N", &m2, &m1, &c_b1, &t[t_offset], ldt, &t[i1 | |||
| + t_dim1], ldt); | |||
| i__1 = *n - m1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemm_("N", "N", &m2, &i__1, &m1, &q__1, &t[i1 + t_dim1], ldt, &a[i1 * | |||
| a_dim1 + 1], lda, &c_b1, &a[i1 + i1 * a_dim1], lda); | |||
| ctrmm_("R", "U", "N", "U", &m2, &m1, &c_b1, &a[a_offset], lda, &t[i1 | |||
| + t_dim1], ldt); | |||
| i__1 = m2; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = m1; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| i__3 = i__ + m1 + j * a_dim1; | |||
| i__4 = i__ + m1 + j * a_dim1; | |||
| i__5 = i__ + m1 + j * t_dim1; | |||
| q__1.r = a[i__4].r - t[i__5].r, q__1.i = a[i__4].i - t[i__5] | |||
| .i; | |||
| a[i__3].r = q__1.r, a[i__3].i = q__1.i; | |||
| i__3 = i__ + m1 + j * t_dim1; | |||
| t[i__3].r = 0.f, t[i__3].i = 0.f; | |||
| } | |||
| } | |||
| /* Compute A(J1:M,J1:N) <- (Y2,R2,T2) where Q2 = I - Y2 T2 Y2^H */ | |||
| i__1 = *n - m1; | |||
| cgelqt3_(&m2, &i__1, &a[i1 + i1 * a_dim1], lda, &t[i1 + i1 * t_dim1], | |||
| ldt, &iinfo); | |||
| /* Compute T3 = T(J1:N1,1:N) = -T1 Y1^H Y2 T2 */ | |||
| i__1 = m2; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = m1; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| i__3 = j + (i__ + m1) * t_dim1; | |||
| i__4 = j + (i__ + m1) * a_dim1; | |||
| t[i__3].r = a[i__4].r, t[i__3].i = a[i__4].i; | |||
| } | |||
| } | |||
| ctrmm_("R", "U", "C", "U", &m1, &m2, &c_b1, &a[i1 + i1 * a_dim1], lda, | |||
| &t[i1 * t_dim1 + 1], ldt); | |||
| i__1 = *n - *m; | |||
| cgemm_("N", "C", &m1, &m2, &i__1, &c_b1, &a[j1 * a_dim1 + 1], lda, &a[ | |||
| i1 + j1 * a_dim1], lda, &c_b1, &t[i1 * t_dim1 + 1], ldt); | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| ctrmm_("L", "U", "N", "N", &m1, &m2, &q__1, &t[t_offset], ldt, &t[i1 * | |||
| t_dim1 + 1], ldt) | |||
| ; | |||
| ctrmm_("R", "U", "N", "N", &m1, &m2, &c_b1, &t[i1 + i1 * t_dim1], ldt, | |||
| &t[i1 * t_dim1 + 1], ldt); | |||
| /* Y = (Y1,Y2); L = [ L1 0 ]; T = [T1 T3] */ | |||
| /* [ A(1:N1,J1:N) L2 ] [ 0 T2] */ | |||
| } | |||
| return 0; | |||
| /* End of CGELQT3 */ | |||
| } /* cgelqt3_ */ | |||
| @@ -0,0 +1,961 @@ | |||
| /* 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 complex c_b1 = {0.f,0.f}; | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__0 = 0; | |||
| /* > \brief <b> CGELS solves overdetermined or underdetermined systems for GE matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGELS + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgels.f | |||
| "> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgels.f | |||
| "> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgels.f | |||
| "> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELS( TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK, */ | |||
| /* INFO ) */ | |||
| /* CHARACTER TRANS */ | |||
| /* INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS */ | |||
| /* COMPLEX A( LDA, * ), B( LDB, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELS solves overdetermined or underdetermined complex linear systems */ | |||
| /* > involving an M-by-N matrix A, or its conjugate-transpose, using a QR */ | |||
| /* > or LQ factorization of A. It is assumed that A has full rank. */ | |||
| /* > */ | |||
| /* > The following options are provided: */ | |||
| /* > */ | |||
| /* > 1. If TRANS = 'N' and m >= n: find the least squares solution of */ | |||
| /* > an overdetermined system, i.e., solve the least squares problem */ | |||
| /* > minimize || B - A*X ||. */ | |||
| /* > */ | |||
| /* > 2. If TRANS = 'N' and m < n: find the minimum norm solution of */ | |||
| /* > an underdetermined system A * X = B. */ | |||
| /* > */ | |||
| /* > 3. If TRANS = 'C' and m >= n: find the minimum norm solution of */ | |||
| /* > an underdetermined system A**H * X = B. */ | |||
| /* > */ | |||
| /* > 4. If TRANS = 'C' and m < n: find the least squares solution of */ | |||
| /* > an overdetermined system, i.e., solve the least squares problem */ | |||
| /* > minimize || B - A**H * X ||. */ | |||
| /* > */ | |||
| /* > Several right hand side vectors b and solution vectors x can be */ | |||
| /* > handled in a single call; they are stored as the columns of the */ | |||
| /* > M-by-NRHS right hand side matrix B and the N-by-NRHS solution */ | |||
| /* > matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > = 'N': the linear system involves A; */ | |||
| /* > = 'C': the linear system involves A**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 A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of */ | |||
| /* > columns of the matrices B and X. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > if M >= N, A is overwritten by details of its QR */ | |||
| /* > factorization as returned by CGEQRF; */ | |||
| /* > if M < N, A is overwritten by details of its LQ */ | |||
| /* > factorization as returned by CGELQF. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the matrix B of right hand side vectors, stored */ | |||
| /* > columnwise; B is M-by-NRHS if TRANS = 'N', or N-by-NRHS */ | |||
| /* > if TRANS = 'C'. */ | |||
| /* > On exit, if INFO = 0, B is overwritten by the solution */ | |||
| /* > vectors, stored columnwise: */ | |||
| /* > if TRANS = 'N' and m >= n, rows 1 to n of B contain the least */ | |||
| /* > squares solution vectors; the residual sum of squares for the */ | |||
| /* > solution in each column is given by the sum of squares of the */ | |||
| /* > modulus of elements N+1 to M in that column; */ | |||
| /* > if TRANS = 'N' and m < n, rows 1 to N of B contain the */ | |||
| /* > minimum norm solution vectors; */ | |||
| /* > if TRANS = 'C' and m >= n, rows 1 to M of B contain the */ | |||
| /* > minimum norm solution vectors; */ | |||
| /* > if TRANS = 'C' and m < n, rows 1 to M of B contain the */ | |||
| /* > least squares solution vectors; the residual sum of squares */ | |||
| /* > for the solution in each column is given by the sum of */ | |||
| /* > squares of the modulus of elements M+1 to N in that column. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= MAX(1,M,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > LWORK >= f2cmax( 1, MN + f2cmax( MN, NRHS ) ). */ | |||
| /* > For optimal performance, */ | |||
| /* > LWORK >= f2cmax( 1, MN + f2cmax( MN, NRHS )*NB ). */ | |||
| /* > where MN = f2cmin(M,N) and NB is the optimum block size. */ | |||
| /* > */ | |||
| /* > 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 */ | |||
| /* > > 0: if INFO = i, the i-th diagonal element of the */ | |||
| /* > triangular factor of A is zero, so that A does not have */ | |||
| /* > full rank; the least squares solution could not be */ | |||
| /* > computed. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEsolve */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgels_(char *trans, integer *m, integer *n, integer * | |||
| nrhs, complex *a, integer *lda, complex *b, integer *ldb, complex * | |||
| work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3; | |||
| real r__1; | |||
| /* Local variables */ | |||
| real anrm, bnrm; | |||
| integer brow; | |||
| logical tpsd; | |||
| integer i__, j, iascl, ibscl; | |||
| extern logical lsame_(char *, char *); | |||
| integer wsize; | |||
| real rwork[1]; | |||
| integer nb; | |||
| extern /* Subroutine */ int slabad_(real *, real *); | |||
| extern real clange_(char *, integer *, integer *, complex *, integer *, | |||
| real *); | |||
| integer mn; | |||
| extern /* Subroutine */ int cgelqf_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *, integer *), clascl_( | |||
| char *, integer *, integer *, real *, real *, integer *, integer * | |||
| , complex *, integer *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int cgeqrf_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *, integer *), claset_( | |||
| char *, integer *, integer *, complex *, complex *, complex *, | |||
| integer *), xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| integer scllen; | |||
| real bignum; | |||
| extern /* Subroutine */ int cunmlq_(char *, char *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, complex *, integer *, | |||
| complex *, integer *, integer *), cunmqr_(char *, | |||
| char *, integer *, integer *, integer *, complex *, integer *, | |||
| complex *, complex *, integer *, complex *, integer *, integer *); | |||
| real smlnum; | |||
| logical lquery; | |||
| extern /* Subroutine */ int ctrtrs_(char *, char *, char *, integer *, | |||
| integer *, complex *, integer *, complex *, integer *, integer *); | |||
| /* -- LAPACK driver 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 arguments. */ | |||
| /* 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; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| mn = f2cmin(*m,*n); | |||
| lquery = *lwork == -1; | |||
| if (! (lsame_(trans, "N") || lsame_(trans, "C"))) { | |||
| *info = -1; | |||
| } else if (*m < 0) { | |||
| *info = -2; | |||
| } else if (*n < 0) { | |||
| *info = -3; | |||
| } else if (*nrhs < 0) { | |||
| *info = -4; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -6; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(1,*m); | |||
| if (*ldb < f2cmax(i__1,*n)) { | |||
| *info = -8; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mn + f2cmax(mn,*nrhs); | |||
| if (*lwork < f2cmax(i__1,i__2) && ! lquery) { | |||
| *info = -10; | |||
| } | |||
| } | |||
| } | |||
| /* Figure out optimal block size */ | |||
| if (*info == 0 || *info == -10) { | |||
| tpsd = TRUE_; | |||
| if (lsame_(trans, "N")) { | |||
| tpsd = FALSE_; | |||
| } | |||
| if (*m >= *n) { | |||
| nb = ilaenv_(&c__1, "CGEQRF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, | |||
| (ftnlen)1); | |||
| if (tpsd) { | |||
| /* Computing MAX */ | |||
| i__1 = nb, i__2 = ilaenv_(&c__1, "CUNMQR", "LN", m, nrhs, n, & | |||
| c_n1, (ftnlen)6, (ftnlen)2); | |||
| nb = f2cmax(i__1,i__2); | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__1 = nb, i__2 = ilaenv_(&c__1, "CUNMQR", "LC", m, nrhs, n, & | |||
| c_n1, (ftnlen)6, (ftnlen)2); | |||
| nb = f2cmax(i__1,i__2); | |||
| } | |||
| } else { | |||
| nb = ilaenv_(&c__1, "CGELQF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, | |||
| (ftnlen)1); | |||
| if (tpsd) { | |||
| /* Computing MAX */ | |||
| i__1 = nb, i__2 = ilaenv_(&c__1, "CUNMLQ", "LC", n, nrhs, m, & | |||
| c_n1, (ftnlen)6, (ftnlen)2); | |||
| nb = f2cmax(i__1,i__2); | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__1 = nb, i__2 = ilaenv_(&c__1, "CUNMLQ", "LN", n, nrhs, m, & | |||
| c_n1, (ftnlen)6, (ftnlen)2); | |||
| nb = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mn + f2cmax(mn,*nrhs) * nb; | |||
| wsize = f2cmax(i__1,i__2); | |||
| r__1 = (real) wsize; | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELS ", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| /* Computing MIN */ | |||
| i__1 = f2cmin(*m,*n); | |||
| if (f2cmin(i__1,*nrhs) == 0) { | |||
| i__1 = f2cmax(*m,*n); | |||
| claset_("Full", &i__1, nrhs, &c_b1, &c_b1, &b[b_offset], ldb); | |||
| return 0; | |||
| } | |||
| /* Get machine parameters */ | |||
| smlnum = slamch_("S") / slamch_("P"); | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| /* Scale A, B if f2cmax element outside range [SMLNUM,BIGNUM] */ | |||
| anrm = clange_("M", m, n, &a[a_offset], lda, rwork); | |||
| iascl = 0; | |||
| if (anrm > 0.f && anrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| clascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 1; | |||
| } else if (anrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| clascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 2; | |||
| } else if (anrm == 0.f) { | |||
| /* Matrix all zero. Return zero solution. */ | |||
| i__1 = f2cmax(*m,*n); | |||
| claset_("F", &i__1, nrhs, &c_b1, &c_b1, &b[b_offset], ldb); | |||
| goto L50; | |||
| } | |||
| brow = *m; | |||
| if (tpsd) { | |||
| brow = *n; | |||
| } | |||
| bnrm = clange_("M", &brow, nrhs, &b[b_offset], ldb, rwork); | |||
| ibscl = 0; | |||
| if (bnrm > 0.f && bnrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| clascl_("G", &c__0, &c__0, &bnrm, &smlnum, &brow, nrhs, &b[b_offset], | |||
| ldb, info); | |||
| ibscl = 1; | |||
| } else if (bnrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| clascl_("G", &c__0, &c__0, &bnrm, &bignum, &brow, nrhs, &b[b_offset], | |||
| ldb, info); | |||
| ibscl = 2; | |||
| } | |||
| if (*m >= *n) { | |||
| /* compute QR factorization of A */ | |||
| i__1 = *lwork - mn; | |||
| cgeqrf_(m, n, &a[a_offset], lda, &work[1], &work[mn + 1], &i__1, info) | |||
| ; | |||
| /* workspace at least N, optimally N*NB */ | |||
| if (! tpsd) { | |||
| /* Least-Squares Problem f2cmin || A * X - B || */ | |||
| /* B(1:M,1:NRHS) := Q**H * B(1:M,1:NRHS) */ | |||
| i__1 = *lwork - mn; | |||
| cunmqr_("Left", "Conjugate transpose", m, nrhs, n, &a[a_offset], | |||
| lda, &work[1], &b[b_offset], ldb, &work[mn + 1], &i__1, | |||
| info); | |||
| /* workspace at least NRHS, optimally NRHS*NB */ | |||
| /* B(1:N,1:NRHS) := inv(R) * B(1:N,1:NRHS) */ | |||
| ctrtrs_("Upper", "No transpose", "Non-unit", n, nrhs, &a[a_offset] | |||
| , lda, &b[b_offset], ldb, info); | |||
| if (*info > 0) { | |||
| return 0; | |||
| } | |||
| scllen = *n; | |||
| } else { | |||
| /* Underdetermined system of equations A**T * X = B */ | |||
| /* B(1:N,1:NRHS) := inv(R**H) * B(1:N,1:NRHS) */ | |||
| ctrtrs_("Upper", "Conjugate transpose", "Non-unit", n, nrhs, &a[ | |||
| a_offset], lda, &b[b_offset], ldb, info); | |||
| if (*info > 0) { | |||
| return 0; | |||
| } | |||
| /* B(N+1:M,1:NRHS) = ZERO */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = *n + 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| b[i__3].r = 0.f, b[i__3].i = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| /* B(1:M,1:NRHS) := Q(1:N,:) * B(1:N,1:NRHS) */ | |||
| i__1 = *lwork - mn; | |||
| cunmqr_("Left", "No transpose", m, nrhs, n, &a[a_offset], lda, & | |||
| work[1], &b[b_offset], ldb, &work[mn + 1], &i__1, info); | |||
| /* workspace at least NRHS, optimally NRHS*NB */ | |||
| scllen = *m; | |||
| } | |||
| } else { | |||
| /* Compute LQ factorization of A */ | |||
| i__1 = *lwork - mn; | |||
| cgelqf_(m, n, &a[a_offset], lda, &work[1], &work[mn + 1], &i__1, info) | |||
| ; | |||
| /* workspace at least M, optimally M*NB. */ | |||
| if (! tpsd) { | |||
| /* underdetermined system of equations A * X = B */ | |||
| /* B(1:M,1:NRHS) := inv(L) * B(1:M,1:NRHS) */ | |||
| ctrtrs_("Lower", "No transpose", "Non-unit", m, nrhs, &a[a_offset] | |||
| , lda, &b[b_offset], ldb, info); | |||
| if (*info > 0) { | |||
| return 0; | |||
| } | |||
| /* B(M+1:N,1:NRHS) = 0 */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = *m + 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| b[i__3].r = 0.f, b[i__3].i = 0.f; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| /* B(1:N,1:NRHS) := Q(1:N,:)**H * B(1:M,1:NRHS) */ | |||
| i__1 = *lwork - mn; | |||
| cunmlq_("Left", "Conjugate transpose", n, nrhs, m, &a[a_offset], | |||
| lda, &work[1], &b[b_offset], ldb, &work[mn + 1], &i__1, | |||
| info); | |||
| /* workspace at least NRHS, optimally NRHS*NB */ | |||
| scllen = *n; | |||
| } else { | |||
| /* overdetermined system f2cmin || A**H * X - B || */ | |||
| /* B(1:N,1:NRHS) := Q * B(1:N,1:NRHS) */ | |||
| i__1 = *lwork - mn; | |||
| cunmlq_("Left", "No transpose", n, nrhs, m, &a[a_offset], lda, & | |||
| work[1], &b[b_offset], ldb, &work[mn + 1], &i__1, info); | |||
| /* workspace at least NRHS, optimally NRHS*NB */ | |||
| /* B(1:M,1:NRHS) := inv(L**H) * B(1:M,1:NRHS) */ | |||
| ctrtrs_("Lower", "Conjugate transpose", "Non-unit", m, nrhs, &a[ | |||
| a_offset], lda, &b[b_offset], ldb, info); | |||
| if (*info > 0) { | |||
| return 0; | |||
| } | |||
| scllen = *m; | |||
| } | |||
| } | |||
| /* Undo scaling */ | |||
| if (iascl == 1) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &smlnum, &scllen, nrhs, &b[b_offset] | |||
| , ldb, info); | |||
| } else if (iascl == 2) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &bignum, &scllen, nrhs, &b[b_offset] | |||
| , ldb, info); | |||
| } | |||
| if (ibscl == 1) { | |||
| clascl_("G", &c__0, &c__0, &smlnum, &bnrm, &scllen, nrhs, &b[b_offset] | |||
| , ldb, info); | |||
| } else if (ibscl == 2) { | |||
| clascl_("G", &c__0, &c__0, &bignum, &bnrm, &scllen, nrhs, &b[b_offset] | |||
| , ldb, info); | |||
| } | |||
| L50: | |||
| r__1 = (real) wsize; | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGELS */ | |||
| } /* cgels_ */ | |||
| @@ -0,0 +1,966 @@ | |||
| /* 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 complex c_b1 = {0.f,0.f}; | |||
| static complex c_b2 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__0 = 0; | |||
| static integer c__2 = 2; | |||
| /* > \brief <b> CGELSY solves overdetermined or underdetermined systems for GE matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGELSY + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgelsy. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgelsy. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgelsy. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELSY( M, N, NRHS, A, LDA, B, LDB, JPVT, RCOND, RANK, */ | |||
| /* WORK, LWORK, RWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS, RANK */ | |||
| /* REAL RCOND */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), B( LDB, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELSY computes the minimum-norm solution to a complex linear least */ | |||
| /* > squares problem: */ | |||
| /* > minimize || A * X - B || */ | |||
| /* > using a complete orthogonal factorization of A. A is an M-by-N */ | |||
| /* > matrix which may be rank-deficient. */ | |||
| /* > */ | |||
| /* > Several right hand side vectors b and solution vectors x can be */ | |||
| /* > handled in a single call; they are stored as the columns of the */ | |||
| /* > M-by-NRHS right hand side matrix B and the N-by-NRHS solution */ | |||
| /* > matrix X. */ | |||
| /* > */ | |||
| /* > The routine first computes a QR factorization with column pivoting: */ | |||
| /* > A * P = Q * [ R11 R12 ] */ | |||
| /* > [ 0 R22 ] */ | |||
| /* > with R11 defined as the largest leading submatrix whose estimated */ | |||
| /* > condition number is less than 1/RCOND. The order of R11, RANK, */ | |||
| /* > is the effective rank of A. */ | |||
| /* > */ | |||
| /* > Then, R22 is considered to be negligible, and R12 is annihilated */ | |||
| /* > by unitary transformations from the right, arriving at the */ | |||
| /* > complete orthogonal factorization: */ | |||
| /* > A * P = Q * [ T11 0 ] * Z */ | |||
| /* > [ 0 0 ] */ | |||
| /* > The minimum-norm solution is then */ | |||
| /* > X = P * Z**H [ inv(T11)*Q1**H*B ] */ | |||
| /* > [ 0 ] */ | |||
| /* > where Q1 consists of the first RANK columns of Q. */ | |||
| /* > */ | |||
| /* > This routine is basically identical to the original xGELSX except */ | |||
| /* > three differences: */ | |||
| /* > o The permutation of matrix B (the right hand side) is faster and */ | |||
| /* > more simple. */ | |||
| /* > o The call to the subroutine xGEQPF has been substituted by the */ | |||
| /* > the call to the subroutine xGEQP3. This subroutine is a Blas-3 */ | |||
| /* > version of the QR factorization with column pivoting. */ | |||
| /* > o Matrix B (the right hand side) is updated with Blas-3. */ | |||
| /* > \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] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of */ | |||
| /* > columns of matrices B and X. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, A has been overwritten by details of its */ | |||
| /* > complete orthogonal factorization. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the M-by-NRHS right hand side matrix B. */ | |||
| /* > On exit, the N-by-NRHS solution matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,M,N). */ | |||
| /* > \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 AP, otherwise column i 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[in] RCOND */ | |||
| /* > \verbatim */ | |||
| /* > RCOND is REAL */ | |||
| /* > RCOND is used to determine the effective rank of A, which */ | |||
| /* > is defined as the order of the largest leading triangular */ | |||
| /* > submatrix R11 in the QR factorization with pivoting of A, */ | |||
| /* > whose estimated condition number < 1/RCOND. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RANK */ | |||
| /* > \verbatim */ | |||
| /* > RANK is INTEGER */ | |||
| /* > The effective rank of A, i.e., the order of the submatrix */ | |||
| /* > R11. This is the same as the order of the submatrix T11 */ | |||
| /* > in the complete orthogonal factorization of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > The unblocked strategy requires that: */ | |||
| /* > LWORK >= MN + MAX( 2*MN, N+1, MN+NRHS ) */ | |||
| /* > where MN = f2cmin(M,N). */ | |||
| /* > The block algorithm requires that: */ | |||
| /* > LWORK >= MN + MAX( 2*MN, NB*(N+1), MN+MN*NB, MN+NB*NRHS ) */ | |||
| /* > where NB is an upper bound on the blocksize returned */ | |||
| /* > by ILAENV for the routines CGEQP3, CTZRZF, CTZRQF, CUNMQR, */ | |||
| /* > and CUNMRZ. */ | |||
| /* > */ | |||
| /* > 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] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (2*N) */ | |||
| /* > \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 complexGEsolve */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA \n */ | |||
| /* > E. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain \n */ | |||
| /* > G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain \n */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgelsy_(integer *m, integer *n, integer *nrhs, complex * | |||
| a, integer *lda, complex *b, integer *ldb, integer *jpvt, real *rcond, | |||
| integer *rank, complex *work, integer *lwork, real *rwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3, i__4; | |||
| real r__1, r__2; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| real anrm, bnrm, smin, smax; | |||
| integer i__, j, iascl, ibscl; | |||
| extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, | |||
| complex *, integer *); | |||
| integer ismin, ismax; | |||
| complex c1, c2; | |||
| extern /* Subroutine */ int ctrsm_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *), claic1_(integer *, | |||
| integer *, complex *, real *, complex *, complex *, real *, | |||
| complex *, complex *); | |||
| real wsize; | |||
| complex s1, s2; | |||
| extern /* Subroutine */ int cgeqp3_(integer *, integer *, complex *, | |||
| integer *, integer *, complex *, complex *, integer *, real *, | |||
| integer *); | |||
| integer nb; | |||
| extern /* Subroutine */ int slabad_(real *, real *); | |||
| extern real clange_(char *, integer *, integer *, complex *, integer *, | |||
| real *); | |||
| integer mn; | |||
| extern /* Subroutine */ int clascl_(char *, integer *, integer *, real *, | |||
| real *, integer *, integer *, complex *, integer *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int claset_(char *, integer *, integer *, complex | |||
| *, complex *, complex *, integer *), xerbla_(char *, | |||
| integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| real bignum; | |||
| integer nb1, nb2, nb3, nb4; | |||
| extern /* Subroutine */ int cunmqr_(char *, char *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, complex *, integer *, | |||
| complex *, integer *, integer *); | |||
| real sminpr, smaxpr, smlnum; | |||
| extern /* Subroutine */ int cunmrz_(char *, char *, integer *, integer *, | |||
| integer *, integer *, complex *, integer *, complex *, complex *, | |||
| integer *, complex *, integer *, integer *); | |||
| integer lwkopt; | |||
| logical lquery; | |||
| extern /* Subroutine */ int ctzrzf_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *, integer *); | |||
| /* -- LAPACK driver 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; | |||
| --jpvt; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| mn = f2cmin(*m,*n); | |||
| ismin = mn + 1; | |||
| ismax = (mn << 1) + 1; | |||
| /* Test the input arguments. */ | |||
| *info = 0; | |||
| nb1 = ilaenv_(&c__1, "CGEQRF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, ( | |||
| ftnlen)1); | |||
| nb2 = ilaenv_(&c__1, "CGERQF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, ( | |||
| ftnlen)1); | |||
| nb3 = ilaenv_(&c__1, "CUNMQR", " ", m, n, nrhs, &c_n1, (ftnlen)6, (ftnlen) | |||
| 1); | |||
| nb4 = ilaenv_(&c__1, "CUNMRQ", " ", m, n, nrhs, &c_n1, (ftnlen)6, (ftnlen) | |||
| 1); | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(nb1,nb2), i__1 = f2cmax(i__1,nb3); | |||
| nb = f2cmax(i__1,nb4); | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mn + (*n << 1) + nb * (*n + 1), i__1 = f2cmax(i__1,i__2), | |||
| i__2 = (mn << 1) + nb * *nrhs; | |||
| lwkopt = f2cmax(i__1,i__2); | |||
| q__1.r = (real) lwkopt, q__1.i = 0.f; | |||
| work[1].r = q__1.r, work[1].i = q__1.i; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*nrhs < 0) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -5; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(1,*m); | |||
| if (*ldb < f2cmax(i__1,*n)) { | |||
| *info = -7; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = mn << 1, i__2 = *n + 1, i__1 = f2cmax(i__1,i__2), i__2 = mn + | |||
| *nrhs; | |||
| if (*lwork < mn + f2cmax(i__1,i__2) && ! lquery) { | |||
| *info = -12; | |||
| } | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELSY", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| /* Computing MIN */ | |||
| i__1 = f2cmin(*m,*n); | |||
| if (f2cmin(i__1,*nrhs) == 0) { | |||
| *rank = 0; | |||
| return 0; | |||
| } | |||
| /* Get machine parameters */ | |||
| smlnum = slamch_("S") / slamch_("P"); | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| /* Scale A, B if f2cmax entries outside range [SMLNUM,BIGNUM] */ | |||
| anrm = clange_("M", m, n, &a[a_offset], lda, &rwork[1]); | |||
| iascl = 0; | |||
| if (anrm > 0.f && anrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| clascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 1; | |||
| } else if (anrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| clascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 2; | |||
| } else if (anrm == 0.f) { | |||
| /* Matrix all zero. Return zero solution. */ | |||
| i__1 = f2cmax(*m,*n); | |||
| claset_("F", &i__1, nrhs, &c_b1, &c_b1, &b[b_offset], ldb); | |||
| *rank = 0; | |||
| goto L70; | |||
| } | |||
| bnrm = clange_("M", m, nrhs, &b[b_offset], ldb, &rwork[1]); | |||
| ibscl = 0; | |||
| if (bnrm > 0.f && bnrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| clascl_("G", &c__0, &c__0, &bnrm, &smlnum, m, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| ibscl = 1; | |||
| } else if (bnrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| clascl_("G", &c__0, &c__0, &bnrm, &bignum, m, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| ibscl = 2; | |||
| } | |||
| /* Compute QR factorization with column pivoting of A: */ | |||
| /* A * P = Q * R */ | |||
| i__1 = *lwork - mn; | |||
| cgeqp3_(m, n, &a[a_offset], lda, &jpvt[1], &work[1], &work[mn + 1], &i__1, | |||
| &rwork[1], info); | |||
| i__1 = mn + 1; | |||
| wsize = mn + work[i__1].r; | |||
| /* complex workspace: MN+NB*(N+1). real workspace 2*N. */ | |||
| /* Details of Householder rotations stored in WORK(1:MN). */ | |||
| /* Determine RANK using incremental condition estimation */ | |||
| i__1 = ismin; | |||
| work[i__1].r = 1.f, work[i__1].i = 0.f; | |||
| i__1 = ismax; | |||
| work[i__1].r = 1.f, work[i__1].i = 0.f; | |||
| smax = c_abs(&a[a_dim1 + 1]); | |||
| smin = smax; | |||
| if (c_abs(&a[a_dim1 + 1]) == 0.f) { | |||
| *rank = 0; | |||
| i__1 = f2cmax(*m,*n); | |||
| claset_("F", &i__1, nrhs, &c_b1, &c_b1, &b[b_offset], ldb); | |||
| goto L70; | |||
| } else { | |||
| *rank = 1; | |||
| } | |||
| L10: | |||
| if (*rank < mn) { | |||
| i__ = *rank + 1; | |||
| claic1_(&c__2, rank, &work[ismin], &smin, &a[i__ * a_dim1 + 1], &a[ | |||
| i__ + i__ * a_dim1], &sminpr, &s1, &c1); | |||
| claic1_(&c__1, rank, &work[ismax], &smax, &a[i__ * a_dim1 + 1], &a[ | |||
| i__ + i__ * a_dim1], &smaxpr, &s2, &c2); | |||
| if (smaxpr * *rcond <= sminpr) { | |||
| i__1 = *rank; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = ismin + i__ - 1; | |||
| i__3 = ismin + i__ - 1; | |||
| q__1.r = s1.r * work[i__3].r - s1.i * work[i__3].i, q__1.i = | |||
| s1.r * work[i__3].i + s1.i * work[i__3].r; | |||
| work[i__2].r = q__1.r, work[i__2].i = q__1.i; | |||
| i__2 = ismax + i__ - 1; | |||
| i__3 = ismax + i__ - 1; | |||
| q__1.r = s2.r * work[i__3].r - s2.i * work[i__3].i, q__1.i = | |||
| s2.r * work[i__3].i + s2.i * work[i__3].r; | |||
| work[i__2].r = q__1.r, work[i__2].i = q__1.i; | |||
| /* L20: */ | |||
| } | |||
| i__1 = ismin + *rank; | |||
| work[i__1].r = c1.r, work[i__1].i = c1.i; | |||
| i__1 = ismax + *rank; | |||
| work[i__1].r = c2.r, work[i__1].i = c2.i; | |||
| smin = sminpr; | |||
| smax = smaxpr; | |||
| ++(*rank); | |||
| goto L10; | |||
| } | |||
| } | |||
| /* complex workspace: 3*MN. */ | |||
| /* Logically partition R = [ R11 R12 ] */ | |||
| /* [ 0 R22 ] */ | |||
| /* where R11 = R(1:RANK,1:RANK) */ | |||
| /* [R11,R12] = [ T11, 0 ] * Y */ | |||
| if (*rank < *n) { | |||
| i__1 = *lwork - (mn << 1); | |||
| ctzrzf_(rank, n, &a[a_offset], lda, &work[mn + 1], &work[(mn << 1) + | |||
| 1], &i__1, info); | |||
| } | |||
| /* complex workspace: 2*MN. */ | |||
| /* Details of Householder rotations stored in WORK(MN+1:2*MN) */ | |||
| /* B(1:M,1:NRHS) := Q**H * B(1:M,1:NRHS) */ | |||
| i__1 = *lwork - (mn << 1); | |||
| cunmqr_("Left", "Conjugate transpose", m, nrhs, &mn, &a[a_offset], lda, & | |||
| work[1], &b[b_offset], ldb, &work[(mn << 1) + 1], &i__1, info); | |||
| /* Computing MAX */ | |||
| i__1 = (mn << 1) + 1; | |||
| r__1 = wsize, r__2 = (mn << 1) + work[i__1].r; | |||
| wsize = f2cmax(r__1,r__2); | |||
| /* complex workspace: 2*MN+NB*NRHS. */ | |||
| /* B(1:RANK,1:NRHS) := inv(T11) * B(1:RANK,1:NRHS) */ | |||
| ctrsm_("Left", "Upper", "No transpose", "Non-unit", rank, nrhs, &c_b2, &a[ | |||
| a_offset], lda, &b[b_offset], ldb); | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = *rank + 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| b[i__3].r = 0.f, b[i__3].i = 0.f; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| /* B(1:N,1:NRHS) := Y**H * B(1:N,1:NRHS) */ | |||
| if (*rank < *n) { | |||
| i__1 = *n - *rank; | |||
| i__2 = *lwork - (mn << 1); | |||
| cunmrz_("Left", "Conjugate transpose", n, nrhs, rank, &i__1, &a[ | |||
| a_offset], lda, &work[mn + 1], &b[b_offset], ldb, &work[(mn << | |||
| 1) + 1], &i__2, info); | |||
| } | |||
| /* complex workspace: 2*MN+NRHS. */ | |||
| /* B(1:N,1:NRHS) := P * B(1:N,1:NRHS) */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = jpvt[i__]; | |||
| i__4 = i__ + j * b_dim1; | |||
| work[i__3].r = b[i__4].r, work[i__3].i = b[i__4].i; | |||
| /* L50: */ | |||
| } | |||
| ccopy_(n, &work[1], &c__1, &b[j * b_dim1 + 1], &c__1); | |||
| /* L60: */ | |||
| } | |||
| /* complex workspace: N. */ | |||
| /* Undo scaling */ | |||
| if (iascl == 1) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &smlnum, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| clascl_("U", &c__0, &c__0, &smlnum, &anrm, rank, rank, &a[a_offset], | |||
| lda, info); | |||
| } else if (iascl == 2) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &bignum, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| clascl_("U", &c__0, &c__0, &bignum, &anrm, rank, rank, &a[a_offset], | |||
| lda, info); | |||
| } | |||
| if (ibscl == 1) { | |||
| clascl_("G", &c__0, &c__0, &smlnum, &bnrm, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| } else if (ibscl == 2) { | |||
| clascl_("G", &c__0, &c__0, &bignum, &bnrm, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| } | |||
| L70: | |||
| q__1.r = (real) lwkopt, q__1.i = 0.f; | |||
| work[1].r = q__1.r, work[1].i = q__1.i; | |||
| return 0; | |||
| /* End of CGELSY */ | |||
| } /* cgelsy_ */ | |||
| @@ -0,0 +1,686 @@ | |||
| /* 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 CGEMLQ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEMLQ( SIDE, TRANS, M, N, K, A, LDA, T, */ | |||
| /* $ TSIZE, C, LDC, WORK, LWORK, INFO ) */ | |||
| /* CHARACTER SIDE, TRANS */ | |||
| /* INTEGER INFO, LDA, M, N, K, LDT, TSIZE, LWORK, LDC */ | |||
| /* COMPLEX A( LDA, * ), T( * ), C(LDC, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEMLQ 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 complex unitary matrix defined as the product */ | |||
| /* > of blocked elementary reflectors computed by short wide */ | |||
| /* > LQ factorization (CGELQ) */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': apply Q or Q**T from the Left; */ | |||
| /* > = 'R': apply Q or Q**T from the Right. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > = 'N': No transpose, apply Q; */ | |||
| /* > = 'T': Transpose, apply Q**T. */ | |||
| /* > \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. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The number of elementary reflectors whose product defines */ | |||
| /* > the matrix Q. */ | |||
| /* > If SIDE = 'L', M >= K >= 0; */ | |||
| /* > if SIDE = 'R', N >= K >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension */ | |||
| /* > (LDA,M) if SIDE = 'L', */ | |||
| /* > (LDA,N) if SIDE = 'R' */ | |||
| /* > Part of the data structure to represent Q as returned by CGELQ. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,K). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX array, dimension (MAX(5,TSIZE)). */ | |||
| /* > Part of the data structure to represent Q as returned by CGELQ. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TSIZE */ | |||
| /* > \verbatim */ | |||
| /* > TSIZE is INTEGER */ | |||
| /* > The dimension of the array T. TSIZE >= 5. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX array, dimension (LDC,N) */ | |||
| /* > On entry, the M-by-N matrix C. */ | |||
| /* > On exit, C is overwritten by Q*C or Q**T*C or C*Q**T 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 array, dimension (MAX(1,LWORK)) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > If LWORK = -1, then a workspace query is assumed. The routine */ | |||
| /* > only calculates the size of the WORK array, returns this */ | |||
| /* > value as WORK(1), and no error message related to WORK */ | |||
| /* > 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 */ | |||
| /* > */ | |||
| /* > These details are particular for this LAPACK implementation. Users should not */ | |||
| /* > take them for granted. These details may change in the future, and are not likely */ | |||
| /* > true for another LAPACK implementation. These details are relevant if one wants */ | |||
| /* > to try to understand the code. They are not part of the interface. */ | |||
| /* > */ | |||
| /* > In this version, */ | |||
| /* > */ | |||
| /* > T(2): row block size (MB) */ | |||
| /* > T(3): column block size (NB) */ | |||
| /* > T(6:TSIZE): data structure needed for Q, computed by */ | |||
| /* > CLASWQR or CGELQT */ | |||
| /* > */ | |||
| /* > Depending on the matrix dimensions M and N, and row and column */ | |||
| /* > block sizes MB and NB returned by ILAENV, CGELQ will use either */ | |||
| /* > CLASWLQ (if the matrix is wide-and-short) or CGELQT to compute */ | |||
| /* > the LQ factorization. */ | |||
| /* > This version of CGEMLQ will use either CLAMSWLQ or CGEMLQT to */ | |||
| /* > multiply matrix Q by another matrix. */ | |||
| /* > Further Details in CLAMSWLQ or CGEMLQT. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgemlq_(char *side, char *trans, integer *m, integer *n, | |||
| integer *k, complex *a, integer *lda, complex *t, integer *tsize, | |||
| complex *c__, integer *ldc, complex *work, integer *lwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, c_dim1, c_offset, i__1; | |||
| real r__1; | |||
| /* Local variables */ | |||
| logical left, tran; | |||
| extern /* Subroutine */ int clamswlq_(char *, char *, integer *, integer * | |||
| , integer *, integer *, integer *, complex *, integer *, complex * | |||
| , integer *, complex *, integer *, complex *, integer *, integer * | |||
| ); | |||
| extern logical lsame_(char *, char *); | |||
| logical right; | |||
| integer mb, nb, mn, lw, nblcks; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| logical notran, lquery; | |||
| extern /* Subroutine */ int cgemlqt_(char *, char *, integer *, integer *, | |||
| integer *, integer *, complex *, integer *, complex *, integer *, | |||
| complex *, integer *, complex *, 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 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --t; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| lquery = *lwork == -1; | |||
| notran = lsame_(trans, "N"); | |||
| tran = lsame_(trans, "C"); | |||
| left = lsame_(side, "L"); | |||
| right = lsame_(side, "R"); | |||
| mb = (integer) t[2].r; | |||
| nb = (integer) t[3].r; | |||
| if (left) { | |||
| lw = *n * mb; | |||
| mn = *m; | |||
| } else { | |||
| lw = *m * mb; | |||
| mn = *n; | |||
| } | |||
| if (nb > *k && mn > *k) { | |||
| if ((mn - *k) % (nb - *k) == 0) { | |||
| nblcks = (mn - *k) / (nb - *k); | |||
| } else { | |||
| nblcks = (mn - *k) / (nb - *k) + 1; | |||
| } | |||
| } else { | |||
| nblcks = 1; | |||
| } | |||
| *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 || *k > mn) { | |||
| *info = -5; | |||
| } else if (*lda < f2cmax(1,*k)) { | |||
| *info = -7; | |||
| } else if (*tsize < 5) { | |||
| *info = -9; | |||
| } else if (*ldc < f2cmax(1,*m)) { | |||
| *info = -11; | |||
| } else if (*lwork < f2cmax(1,lw) && ! lquery) { | |||
| *info = -13; | |||
| } | |||
| if (*info == 0) { | |||
| r__1 = (real) lw; | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEMLQ", &i__1, (ftnlen)6); | |||
| 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 (left && *m <= *k || right && *n <= *k || nb <= *k || nb >= f2cmax(i__1,* | |||
| k)) { | |||
| cgemlqt_(side, trans, m, n, k, &mb, &a[a_offset], lda, &t[6], &mb, & | |||
| c__[c_offset], ldc, &work[1], info); | |||
| } else { | |||
| clamswlq_(side, trans, m, n, k, &mb, &nb, &a[a_offset], lda, &t[6], & | |||
| mb, &c__[c_offset], ldc, &work[1], lwork, info); | |||
| } | |||
| r__1 = (real) lw; | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEMLQ */ | |||
| } /* cgemlq_ */ | |||
| @@ -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) | |||
| */ | |||
| /* > \brief \b CGEMLQT */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEMLQT( SIDE, TRANS, M, N, K, MB, V, LDV, T, LDT, */ | |||
| /* C, LDC, WORK, INFO ) */ | |||
| /* CHARACTER SIDE, TRANS */ | |||
| /* INTEGER INFO, K, LDV, LDC, M, N, MB, LDT */ | |||
| /* COMPLEX V( LDV, * ), C( LDC, * ), T( LDT, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEMLQT 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 complex orthogonal matrix defined as the product of K */ | |||
| /* > elementary reflectors: */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(K) = I - V T V**H */ | |||
| /* > */ | |||
| /* > generated using the compact WY representation as returned by CGELQT. */ | |||
| /* > */ | |||
| /* > Q is of order M if SIDE = 'L' and of order N if SIDE = 'R'. */ | |||
| /* > \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': 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 >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The number of elementary reflectors whose product defines */ | |||
| /* > the matrix Q. */ | |||
| /* > If SIDE = 'L', M >= K >= 0; */ | |||
| /* > if SIDE = 'R', N >= K >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] MB */ | |||
| /* > \verbatim */ | |||
| /* > MB is INTEGER */ | |||
| /* > The block size used for the storage of T. K >= MB >= 1. */ | |||
| /* > This must be the same value of MB used to generate T */ | |||
| /* > in DGELQT. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX array, dimension */ | |||
| /* > (LDV,M) if SIDE = 'L', */ | |||
| /* > (LDV,N) if SIDE = 'R' */ | |||
| /* > The i-th row must contain the vector which defines the */ | |||
| /* > elementary reflector H(i), for i = 1,2,...,k, as returned by */ | |||
| /* > DGELQT in the first K rows of its array argument A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the array V. LDV >= f2cmax(1,K). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX array, dimension (LDT,K) */ | |||
| /* > The upper triangular factors of the block reflectors */ | |||
| /* > as returned by DGELQT, stored as a MB-by-K matrix. */ | |||
| /* > \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 array, dimension (LDC,N) */ | |||
| /* > On entry, the M-by-N matrix C. */ | |||
| /* > On exit, C is overwritten by Q C, Q**H C, 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 */ | |||
| /* > WORK is COMPLEX array. The dimension of */ | |||
| /* > WORK is N*MB if SIDE = 'L', or M*MB if SIDE = 'R'. */ | |||
| /* > \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 November 2017 */ | |||
| /* > \ingroup doubleGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgemlqt_(char *side, char *trans, integer *m, integer *n, | |||
| integer *k, integer *mb, complex *v, integer *ldv, complex *t, | |||
| integer *ldt, complex *c__, integer *ldc, complex *work, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer v_dim1, v_offset, c_dim1, c_offset, t_dim1, t_offset, i__1, i__2, | |||
| i__3, i__4; | |||
| /* Local variables */ | |||
| logical left, tran; | |||
| integer i__; | |||
| extern logical lsame_(char *, char *); | |||
| logical right; | |||
| integer ib, kf; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *), xerbla_(char *, integer *, ftnlen); | |||
| logical notran; | |||
| integer ldwork; | |||
| /* -- 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 */ | |||
| 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; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| left = lsame_(side, "L"); | |||
| right = lsame_(side, "R"); | |||
| tran = lsame_(trans, "C"); | |||
| notran = lsame_(trans, "N"); | |||
| if (left) { | |||
| ldwork = f2cmax(1,*n); | |||
| } else if (right) { | |||
| ldwork = f2cmax(1,*m); | |||
| } | |||
| 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 (*mb < 1 || *mb > *k && *k > 0) { | |||
| *info = -6; | |||
| } else if (*ldv < f2cmax(1,*k)) { | |||
| *info = -8; | |||
| } else if (*ldt < *mb) { | |||
| *info = -10; | |||
| } else if (*ldc < f2cmax(1,*m)) { | |||
| *info = -12; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEMLQT", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| if (*m == 0 || *n == 0 || *k == 0) { | |||
| return 0; | |||
| } | |||
| if (left && notran) { | |||
| i__1 = *k; | |||
| i__2 = *mb; | |||
| for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = *mb, i__4 = *k - i__ + 1; | |||
| ib = f2cmin(i__3,i__4); | |||
| i__3 = *m - i__ + 1; | |||
| clarfb_("L", "C", "F", "R", &i__3, n, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ + c_dim1], ldc, | |||
| &work[1], &ldwork); | |||
| } | |||
| } else if (right && tran) { | |||
| i__2 = *k; | |||
| i__1 = *mb; | |||
| for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) { | |||
| /* Computing MIN */ | |||
| i__3 = *mb, i__4 = *k - i__ + 1; | |||
| ib = f2cmin(i__3,i__4); | |||
| i__3 = *n - i__ + 1; | |||
| clarfb_("R", "N", "F", "R", m, &i__3, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ * c_dim1 + 1], | |||
| ldc, &work[1], &ldwork); | |||
| } | |||
| } else if (left && tran) { | |||
| kf = (*k - 1) / *mb * *mb + 1; | |||
| i__1 = -(*mb); | |||
| for (i__ = kf; i__1 < 0 ? i__ >= 1 : i__ <= 1; i__ += i__1) { | |||
| /* Computing MIN */ | |||
| i__2 = *mb, i__3 = *k - i__ + 1; | |||
| ib = f2cmin(i__2,i__3); | |||
| i__2 = *m - i__ + 1; | |||
| clarfb_("L", "N", "F", "R", &i__2, n, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ + c_dim1], ldc, | |||
| &work[1], &ldwork); | |||
| } | |||
| } else if (right && notran) { | |||
| kf = (*k - 1) / *mb * *mb + 1; | |||
| i__1 = -(*mb); | |||
| for (i__ = kf; i__1 < 0 ? i__ >= 1 : i__ <= 1; i__ += i__1) { | |||
| /* Computing MIN */ | |||
| i__2 = *mb, i__3 = *k - i__ + 1; | |||
| ib = f2cmin(i__2,i__3); | |||
| i__2 = *n - i__ + 1; | |||
| clarfb_("R", "C", "F", "R", m, &i__2, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ * c_dim1 + 1], | |||
| ldc, &work[1], &ldwork); | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGEMLQT */ | |||
| } /* cgemlqt_ */ | |||
| @@ -0,0 +1,685 @@ | |||
| /* 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 CGEMQR */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEMQR( SIDE, TRANS, M, N, K, A, LDA, T, */ | |||
| /* $ TSIZE, C, LDC, WORK, LWORK, INFO ) */ | |||
| /* CHARACTER SIDE, TRANS */ | |||
| /* INTEGER INFO, LDA, M, N, K, LDT, TSIZE, LWORK, LDC */ | |||
| /* COMPLEX A( LDA, * ), T( * ), C( LDC, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEMQR overwrites the general real M-by-N matrix C with */ | |||
| /* > */ | |||
| /* > SIDE = 'L' SIDE = 'R' */ | |||
| /* > TRANS = 'N': Q * C C * Q */ | |||
| /* > TRANS = 'T': Q**H * C C * Q**H */ | |||
| /* > */ | |||
| /* > where Q is a complex unitary matrix defined as the product */ | |||
| /* > of blocked elementary reflectors computed by tall skinny */ | |||
| /* > QR factorization (CGEQR) */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': apply Q or Q**T from the Left; */ | |||
| /* > = 'R': apply Q or Q**T from the Right. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > = 'N': No transpose, apply Q; */ | |||
| /* > = 'T': Transpose, apply Q**T. */ | |||
| /* > \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. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The number of elementary reflectors whose product defines */ | |||
| /* > the matrix Q. */ | |||
| /* > If SIDE = 'L', M >= K >= 0; */ | |||
| /* > if SIDE = 'R', N >= K >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,K) */ | |||
| /* > Part of the data structure to represent Q as returned by CGEQR. */ | |||
| /* > \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 array, dimension (MAX(5,TSIZE)). */ | |||
| /* > Part of the data structure to represent Q as returned by CGEQR. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TSIZE */ | |||
| /* > \verbatim */ | |||
| /* > TSIZE is INTEGER */ | |||
| /* > The dimension of the array T. TSIZE >= 5. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX array, dimension (LDC,N) */ | |||
| /* > On entry, the M-by-N matrix C. */ | |||
| /* > On exit, C is overwritten by Q*C or Q**T*C or C*Q**T 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 array, dimension (MAX(1,LWORK)) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > If LWORK = -1, then a workspace query is assumed. The routine */ | |||
| /* > only calculates the size of the WORK array, returns this */ | |||
| /* > value as WORK(1), and no error message related to WORK */ | |||
| /* > 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 */ | |||
| /* > */ | |||
| /* > These details are particular for this LAPACK implementation. Users should not */ | |||
| /* > take them for granted. These details may change in the future, and are not likely */ | |||
| /* > true for another LAPACK implementation. These details are relevant if one wants */ | |||
| /* > to try to understand the code. They are not part of the interface. */ | |||
| /* > */ | |||
| /* > In this version, */ | |||
| /* > */ | |||
| /* > T(2): row block size (MB) */ | |||
| /* > T(3): column block size (NB) */ | |||
| /* > T(6:TSIZE): data structure needed for Q, computed by */ | |||
| /* > CLATSQR or CGEQRT */ | |||
| /* > */ | |||
| /* > Depending on the matrix dimensions M and N, and row and column */ | |||
| /* > block sizes MB and NB returned by ILAENV, CGEQR will use either */ | |||
| /* > CLATSQR (if the matrix is tall-and-skinny) or CGEQRT to compute */ | |||
| /* > the QR factorization. */ | |||
| /* > This version of CGEMQR will use either CLAMTSQR or CGEMQRT to */ | |||
| /* > multiply matrix Q by another matrix. */ | |||
| /* > Further Details in CLAMTSQR or CGEMQRT. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgemqr_(char *side, char *trans, integer *m, integer *n, | |||
| integer *k, complex *a, integer *lda, complex *t, integer *tsize, | |||
| complex *c__, integer *ldc, complex *work, integer *lwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, c_dim1, c_offset, i__1; | |||
| /* Local variables */ | |||
| logical left, tran; | |||
| extern /* Subroutine */ int clamtsqr_(char *, char *, integer *, integer * | |||
| , integer *, integer *, integer *, complex *, integer *, complex * | |||
| , integer *, complex *, integer *, complex *, integer *, integer * | |||
| ); | |||
| extern logical lsame_(char *, char *); | |||
| logical right; | |||
| integer mb, nb, mn, lw, nblcks; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| logical notran, lquery; | |||
| extern /* Subroutine */ int cgemqrt_(char *, char *, integer *, integer *, | |||
| integer *, integer *, complex *, integer *, complex *, integer *, | |||
| complex *, integer *, complex *, 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 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --t; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| lquery = *lwork == -1; | |||
| notran = lsame_(trans, "N"); | |||
| tran = lsame_(trans, "C"); | |||
| left = lsame_(side, "L"); | |||
| right = lsame_(side, "R"); | |||
| mb = (integer) t[2].r; | |||
| nb = (integer) t[3].r; | |||
| if (left) { | |||
| lw = *n * nb; | |||
| mn = *m; | |||
| } else { | |||
| lw = mb * nb; | |||
| mn = *n; | |||
| } | |||
| if (mb > *k && mn > *k) { | |||
| if ((mn - *k) % (mb - *k) == 0) { | |||
| nblcks = (mn - *k) / (mb - *k); | |||
| } else { | |||
| nblcks = (mn - *k) / (mb - *k) + 1; | |||
| } | |||
| } else { | |||
| nblcks = 1; | |||
| } | |||
| *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 || *k > mn) { | |||
| *info = -5; | |||
| } else if (*lda < f2cmax(1,mn)) { | |||
| *info = -7; | |||
| } else if (*tsize < 5) { | |||
| *info = -9; | |||
| } else if (*ldc < f2cmax(1,*m)) { | |||
| *info = -11; | |||
| } else if (*lwork < f2cmax(1,lw) && ! lquery) { | |||
| *info = -13; | |||
| } | |||
| if (*info == 0) { | |||
| work[1].r = (real) lw, work[1].i = 0.f; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEMQR", &i__1, (ftnlen)6); | |||
| 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 (left && *m <= *k || right && *n <= *k || mb <= *k || mb >= f2cmax(i__1,* | |||
| k)) { | |||
| cgemqrt_(side, trans, m, n, k, &nb, &a[a_offset], lda, &t[6], &nb, & | |||
| c__[c_offset], ldc, &work[1], info); | |||
| } else { | |||
| clamtsqr_(side, trans, m, n, k, &mb, &nb, &a[a_offset], lda, &t[6], & | |||
| nb, &c__[c_offset], ldc, &work[1], lwork, info); | |||
| } | |||
| work[1].r = (real) lw, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEMQR */ | |||
| } /* cgemqr_ */ | |||
| @@ -0,0 +1,707 @@ | |||
| /* 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 CGEMQRT */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEMQRT + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgemqrt | |||
| .f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgemqrt | |||
| .f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgemqrt | |||
| .f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEMQRT( SIDE, TRANS, M, N, K, NB, V, LDV, T, LDT, */ | |||
| /* C, LDC, WORK, INFO ) */ | |||
| /* CHARACTER SIDE, TRANS */ | |||
| /* INTEGER INFO, K, LDV, LDC, M, N, NB, LDT */ | |||
| /* COMPLEX V( LDV, * ), C( LDC, * ), T( LDT, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEMQRT 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 complex orthogonal matrix defined as the product of K */ | |||
| /* > elementary reflectors: */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(K) = I - V T V**H */ | |||
| /* > */ | |||
| /* > generated using the compact WY representation as returned by CGEQRT. */ | |||
| /* > */ | |||
| /* > Q is of order M if SIDE = 'L' and of order N if SIDE = 'R'. */ | |||
| /* > \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': 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 >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The number of elementary reflectors whose product defines */ | |||
| /* > the matrix Q. */ | |||
| /* > If SIDE = 'L', M >= K >= 0; */ | |||
| /* > if SIDE = 'R', N >= K >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The block size used for the storage of T. K >= NB >= 1. */ | |||
| /* > This must be the same value of NB used to generate T */ | |||
| /* > in CGEQRT. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX array, dimension (LDV,K) */ | |||
| /* > The i-th column must contain the vector which defines the */ | |||
| /* > elementary reflector H(i), for i = 1,2,...,k, as returned by */ | |||
| /* > CGEQRT in the first K columns of its array argument A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the array V. */ | |||
| /* > If SIDE = 'L', LDA >= f2cmax(1,M); */ | |||
| /* > if SIDE = 'R', LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX array, dimension (LDT,K) */ | |||
| /* > The upper triangular factors of the block reflectors */ | |||
| /* > as returned by CGEQRT, stored as a NB-by-N matrix. */ | |||
| /* > \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 array, dimension (LDC,N) */ | |||
| /* > On entry, the M-by-N matrix C. */ | |||
| /* > On exit, C is overwritten by Q C, Q**H C, 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 */ | |||
| /* > WORK is COMPLEX array. The dimension of WORK is */ | |||
| /* > N*NB if SIDE = 'L', or M*NB if SIDE = 'R'. */ | |||
| /* > \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 complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgemqrt_(char *side, char *trans, integer *m, integer *n, | |||
| integer *k, integer *nb, complex *v, integer *ldv, complex *t, | |||
| integer *ldt, complex *c__, integer *ldc, complex *work, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer v_dim1, v_offset, c_dim1, c_offset, t_dim1, t_offset, i__1, i__2, | |||
| i__3, i__4; | |||
| /* Local variables */ | |||
| logical left, tran; | |||
| integer i__, q; | |||
| extern logical lsame_(char *, char *); | |||
| logical right; | |||
| integer ib, kf; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *), xerbla_(char *, integer *, ftnlen); | |||
| logical notran; | |||
| integer ldwork; | |||
| /* -- 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_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; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| left = lsame_(side, "L"); | |||
| right = lsame_(side, "R"); | |||
| tran = lsame_(trans, "C"); | |||
| notran = lsame_(trans, "N"); | |||
| if (left) { | |||
| ldwork = f2cmax(1,*n); | |||
| q = *m; | |||
| } else if (right) { | |||
| ldwork = f2cmax(1,*m); | |||
| q = *n; | |||
| } | |||
| 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 || *k > q) { | |||
| *info = -5; | |||
| } else if (*nb < 1 || *nb > *k && *k > 0) { | |||
| *info = -6; | |||
| } else if (*ldv < f2cmax(1,q)) { | |||
| *info = -8; | |||
| } else if (*ldt < *nb) { | |||
| *info = -10; | |||
| } else if (*ldc < f2cmax(1,*m)) { | |||
| *info = -12; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEMQRT", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| if (*m == 0 || *n == 0 || *k == 0) { | |||
| return 0; | |||
| } | |||
| if (left && tran) { | |||
| i__1 = *k; | |||
| i__2 = *nb; | |||
| for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = *nb, i__4 = *k - i__ + 1; | |||
| ib = f2cmin(i__3,i__4); | |||
| i__3 = *m - i__ + 1; | |||
| clarfb_("L", "C", "F", "C", &i__3, n, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ + c_dim1], ldc, | |||
| &work[1], &ldwork); | |||
| } | |||
| } else if (right && notran) { | |||
| i__2 = *k; | |||
| i__1 = *nb; | |||
| for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) { | |||
| /* Computing MIN */ | |||
| i__3 = *nb, i__4 = *k - i__ + 1; | |||
| ib = f2cmin(i__3,i__4); | |||
| i__3 = *n - i__ + 1; | |||
| clarfb_("R", "N", "F", "C", m, &i__3, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ * c_dim1 + 1], | |||
| ldc, &work[1], &ldwork); | |||
| } | |||
| } else if (left && notran) { | |||
| kf = (*k - 1) / *nb * *nb + 1; | |||
| i__1 = -(*nb); | |||
| for (i__ = kf; i__1 < 0 ? i__ >= 1 : i__ <= 1; i__ += i__1) { | |||
| /* Computing MIN */ | |||
| i__2 = *nb, i__3 = *k - i__ + 1; | |||
| ib = f2cmin(i__2,i__3); | |||
| i__2 = *m - i__ + 1; | |||
| clarfb_("L", "N", "F", "C", &i__2, n, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ + c_dim1], ldc, | |||
| &work[1], &ldwork); | |||
| } | |||
| } else if (right && tran) { | |||
| kf = (*k - 1) / *nb * *nb + 1; | |||
| i__1 = -(*nb); | |||
| for (i__ = kf; i__1 < 0 ? i__ >= 1 : i__ <= 1; i__ += i__1) { | |||
| /* Computing MIN */ | |||
| i__2 = *nb, i__3 = *k - i__ + 1; | |||
| ib = f2cmin(i__2,i__3); | |||
| i__2 = *n - i__ + 1; | |||
| clarfb_("R", "C", "F", "C", m, &i__2, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ * c_dim1 + 1], | |||
| ldc, &work[1], &ldwork); | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGEMQRT */ | |||
| } /* cgemqrt_ */ | |||
| @@ -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) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGEQL2 computes the QL factorization of a general rectangular matrix using an unblocked algorit | |||
| hm. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQL2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeql2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeql2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeql2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQL2( M, N, A, LDA, TAU, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQL2 computes a QL factorization of a complex m by n matrix A: */ | |||
| /* > A = Q * L. */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the m by n matrix A. */ | |||
| /* > On exit, if m >= n, the lower triangle of the subarray */ | |||
| /* > A(m-n+1:m,1:n) contains the n by n lower triangular matrix L; */ | |||
| /* > if m <= n, the elements on and below the (n-m)-th */ | |||
| /* > superdiagonal contain the m by n lower trapezoidal matrix L; */ | |||
| /* > the remaining elements, with the array TAU, represent the */ | |||
| /* > unitary matrix Q as a product of elementary reflectors */ | |||
| /* > (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] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (N) */ | |||
| /* > \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 complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(k) . . . H(2) H(1), where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > 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(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in */ | |||
| /* > A(1:m-k+i-1,n-k+i), and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeql2_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, complex *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| complex alpha; | |||
| extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex * | |||
| , integer *, complex *, complex *, integer *, complex *), | |||
| clarfg_(integer *, complex *, complex *, integer *, complex *), | |||
| xerbla_(char *, integer *, ftnlen); | |||
| /* -- 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 arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQL2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| k = f2cmin(*m,*n); | |||
| for (i__ = k; i__ >= 1; --i__) { | |||
| /* Generate elementary reflector H(i) to annihilate */ | |||
| /* A(1:m-k+i-1,n-k+i) */ | |||
| i__1 = *m - k + i__ + (*n - k + i__) * a_dim1; | |||
| alpha.r = a[i__1].r, alpha.i = a[i__1].i; | |||
| i__1 = *m - k + i__; | |||
| clarfg_(&i__1, &alpha, &a[(*n - k + i__) * a_dim1 + 1], &c__1, &tau[ | |||
| i__]); | |||
| /* Apply H(i)**H to A(1:m-k+i,1:n-k+i-1) from the left */ | |||
| i__1 = *m - k + i__ + (*n - k + i__) * a_dim1; | |||
| a[i__1].r = 1.f, a[i__1].i = 0.f; | |||
| i__1 = *m - k + i__; | |||
| i__2 = *n - k + i__ - 1; | |||
| r_cnjg(&q__1, &tau[i__]); | |||
| clarf_("Left", &i__1, &i__2, &a[(*n - k + i__) * a_dim1 + 1], &c__1, & | |||
| q__1, &a[a_offset], lda, &work[1]); | |||
| i__1 = *m - k + i__ + (*n - k + i__) * a_dim1; | |||
| a[i__1].r = alpha.r, a[i__1].i = alpha.i; | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* End of CGEQL2 */ | |||
| } /* cgeql2_ */ | |||
| @@ -0,0 +1,710 @@ | |||
| /* 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; | |||
| static integer c_n1 = -1; | |||
| static integer c__3 = 3; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGEQLF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQLF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqlf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqlf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqlf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQLF( M, N, A, LDA, TAU, WORK, LWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LWORK, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQLF computes a QL factorization of a complex M-by-N matrix A: */ | |||
| /* > A = Q * L. */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, */ | |||
| /* > if m >= n, the lower triangle of the subarray */ | |||
| /* > A(m-n+1:m,1:n) contains the N-by-N lower triangular matrix L; */ | |||
| /* > if m <= n, the elements on and below the (n-m)-th */ | |||
| /* > superdiagonal contain the M-by-N lower trapezoidal matrix L; */ | |||
| /* > the remaining elements, with the array TAU, represent the */ | |||
| /* > unitary matrix Q as a product of elementary reflectors */ | |||
| /* > (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] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= f2cmax(1,N). */ | |||
| /* > For optimum performance LWORK >= N*NB, where NB is */ | |||
| /* > the optimal blocksize. */ | |||
| /* > */ | |||
| /* > 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. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(k) . . . H(2) H(1), where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > 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(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in */ | |||
| /* > A(1:m-k+i-1,n-k+i), and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqlf_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, complex *work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| /* Local variables */ | |||
| integer i__, k, nbmin, iinfo; | |||
| extern /* Subroutine */ int cgeql2_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *); | |||
| integer ib, nb, ki, kk; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *); | |||
| integer mu, nu, nx; | |||
| extern /* Subroutine */ int clarft_(char *, char *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *), xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| integer ldwork, lwkopt; | |||
| logical lquery; | |||
| integer iws; | |||
| /* -- 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 arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info == 0) { | |||
| k = f2cmin(*m,*n); | |||
| if (k == 0) { | |||
| lwkopt = 1; | |||
| } else { | |||
| nb = ilaenv_(&c__1, "CGEQLF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, | |||
| (ftnlen)1); | |||
| lwkopt = *n * nb; | |||
| } | |||
| work[1].r = (real) lwkopt, work[1].i = 0.f; | |||
| if (*lwork < f2cmax(1,*n) && ! lquery) { | |||
| *info = -7; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQLF", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (k == 0) { | |||
| return 0; | |||
| } | |||
| nbmin = 2; | |||
| nx = 1; | |||
| iws = *n; | |||
| if (nb > 1 && nb < k) { | |||
| /* Determine when to cross over from blocked to unblocked code. */ | |||
| /* Computing MAX */ | |||
| i__1 = 0, i__2 = ilaenv_(&c__3, "CGEQLF", " ", m, n, &c_n1, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nx = f2cmax(i__1,i__2); | |||
| if (nx < k) { | |||
| /* Determine if workspace is large enough for blocked code. */ | |||
| ldwork = *n; | |||
| iws = ldwork * nb; | |||
| if (*lwork < iws) { | |||
| /* Not enough workspace to use optimal NB: reduce NB and */ | |||
| /* determine the minimum value of NB. */ | |||
| nb = *lwork / ldwork; | |||
| /* Computing MAX */ | |||
| i__1 = 2, i__2 = ilaenv_(&c__2, "CGEQLF", " ", m, n, &c_n1, & | |||
| c_n1, (ftnlen)6, (ftnlen)1); | |||
| nbmin = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| } | |||
| if (nb >= nbmin && nb < k && nx < k) { | |||
| /* Use blocked code initially. */ | |||
| /* The last kk columns are handled by the block method. */ | |||
| ki = (k - nx - 1) / nb * nb; | |||
| /* Computing MIN */ | |||
| i__1 = k, i__2 = ki + nb; | |||
| kk = f2cmin(i__1,i__2); | |||
| i__1 = k - kk + 1; | |||
| i__2 = -nb; | |||
| for (i__ = k - kk + ki + 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ | |||
| += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = k - i__ + 1; | |||
| ib = f2cmin(i__3,nb); | |||
| /* Compute the QL factorization of the current block */ | |||
| /* A(1:m-k+i+ib-1,n-k+i:n-k+i+ib-1) */ | |||
| i__3 = *m - k + i__ + ib - 1; | |||
| cgeql2_(&i__3, &ib, &a[(*n - k + i__) * a_dim1 + 1], lda, &tau[ | |||
| i__], &work[1], &iinfo); | |||
| if (*n - k + i__ > 1) { | |||
| /* Form the triangular factor of the block reflector */ | |||
| /* H = H(i+ib-1) . . . H(i+1) H(i) */ | |||
| i__3 = *m - k + i__ + ib - 1; | |||
| clarft_("Backward", "Columnwise", &i__3, &ib, &a[(*n - k + | |||
| i__) * a_dim1 + 1], lda, &tau[i__], &work[1], &ldwork); | |||
| /* Apply H**H to A(1:m-k+i+ib-1,1:n-k+i-1) from the left */ | |||
| i__3 = *m - k + i__ + ib - 1; | |||
| i__4 = *n - k + i__ - 1; | |||
| clarfb_("Left", "Conjugate transpose", "Backward", "Columnwi" | |||
| "se", &i__3, &i__4, &ib, &a[(*n - k + i__) * a_dim1 + | |||
| 1], lda, &work[1], &ldwork, &a[a_offset], lda, &work[ | |||
| ib + 1], &ldwork); | |||
| } | |||
| /* L10: */ | |||
| } | |||
| mu = *m - k + i__ + nb - 1; | |||
| nu = *n - k + i__ + nb - 1; | |||
| } else { | |||
| mu = *m; | |||
| nu = *n; | |||
| } | |||
| /* Use unblocked code to factor the last or only block */ | |||
| if (mu > 0 && nu > 0) { | |||
| cgeql2_(&mu, &nu, &a[a_offset], lda, &tau[1], &work[1], &iinfo); | |||
| } | |||
| work[1].r = (real) iws, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEQLF */ | |||
| } /* cgeqlf_ */ | |||
| @@ -0,0 +1,805 @@ | |||
| /* 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; | |||
| static integer c_n1 = -1; | |||
| static integer c__3 = 3; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGEQP3 */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQP3 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqp3. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqp3. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqp3. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQP3( M, N, A, LDA, JPVT, TAU, WORK, LWORK, RWORK, */ | |||
| /* INFO ) */ | |||
| /* INTEGER INFO, LDA, LWORK, M, N */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQP3 computes a QR factorization with column pivoting of a */ | |||
| /* > matrix A: A*P = Q*R using Level 3 BLAS. */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the upper triangle of the array contains the */ | |||
| /* > f2cmin(M,N)-by-N upper trapezoidal matrix R; the elements below */ | |||
| /* > the diagonal, together with the array TAU, represent the */ | |||
| /* > unitary matrix Q as a product of f2cmin(M,N) elementary */ | |||
| /* > reflectors. */ | |||
| /* > \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(J).ne.0, the J-th column of A is permuted */ | |||
| /* > to the front of A*P (a leading column); if JPVT(J)=0, */ | |||
| /* > the J-th column of A is a free column. */ | |||
| /* > On exit, if JPVT(J)=K, then the J-th column of A*P was the */ | |||
| /* > the K-th column of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO=0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= N+1. */ | |||
| /* > For optimal performance LWORK >= ( N+1 )*NB, where NB */ | |||
| /* > is the optimal blocksize. */ | |||
| /* > */ | |||
| /* > 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] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (2*N) */ | |||
| /* > \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 complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(k), where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a real/complex vector */ | |||
| /* > with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in */ | |||
| /* > A(i+1:m,i), and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain */ | |||
| /* > X. Sun, Computer Science Dept., Duke University, USA */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqp3_(integer *m, integer *n, complex *a, integer *lda, | |||
| integer *jpvt, complex *tau, complex *work, integer *lwork, real * | |||
| rwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer nfxd, j, nbmin; | |||
| extern /* Subroutine */ int cswap_(integer *, complex *, integer *, | |||
| complex *, integer *); | |||
| integer minmn, minws; | |||
| extern /* Subroutine */ int claqp2_(integer *, integer *, integer *, | |||
| complex *, integer *, integer *, complex *, real *, real *, | |||
| complex *); | |||
| extern real scnrm2_(integer *, complex *, integer *); | |||
| integer jb, na, nb, sm, sn, nx; | |||
| extern /* Subroutine */ int cgeqrf_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *, integer *), xerbla_( | |||
| char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| extern /* Subroutine */ int claqps_(integer *, integer *, integer *, | |||
| integer *, integer *, complex *, integer *, integer *, complex *, | |||
| real *, real *, complex *, complex *, integer *); | |||
| integer topbmn, sminmn; | |||
| extern /* Subroutine */ int cunmqr_(char *, char *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, complex *, integer *, | |||
| complex *, integer *, integer *); | |||
| integer lwkopt; | |||
| logical lquery; | |||
| integer fjb, iws; | |||
| /* -- 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 input arguments */ | |||
| /* ==================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --jpvt; | |||
| --tau; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info == 0) { | |||
| minmn = f2cmin(*m,*n); | |||
| if (minmn == 0) { | |||
| iws = 1; | |||
| lwkopt = 1; | |||
| } else { | |||
| iws = *n + 1; | |||
| nb = ilaenv_(&c__1, "CGEQRF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, | |||
| (ftnlen)1); | |||
| lwkopt = (*n + 1) * nb; | |||
| } | |||
| q__1.r = (real) lwkopt, q__1.i = 0.f; | |||
| work[1].r = q__1.r, work[1].i = q__1.i; | |||
| if (*lwork < iws && ! lquery) { | |||
| *info = -8; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQP3", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Move initial columns up front. */ | |||
| nfxd = 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (jpvt[j] != 0) { | |||
| if (j != nfxd) { | |||
| cswap_(m, &a[j * a_dim1 + 1], &c__1, &a[nfxd * a_dim1 + 1], & | |||
| c__1); | |||
| jpvt[j] = jpvt[nfxd]; | |||
| jpvt[nfxd] = j; | |||
| } else { | |||
| jpvt[j] = j; | |||
| } | |||
| ++nfxd; | |||
| } else { | |||
| jpvt[j] = j; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| --nfxd; | |||
| /* Factorize fixed columns */ | |||
| /* ======================= */ | |||
| /* Compute the QR factorization of fixed columns and update */ | |||
| /* remaining columns. */ | |||
| if (nfxd > 0) { | |||
| na = f2cmin(*m,nfxd); | |||
| /* CC CALL CGEQR2( M, NA, A, LDA, TAU, WORK, INFO ) */ | |||
| cgeqrf_(m, &na, &a[a_offset], lda, &tau[1], &work[1], lwork, info); | |||
| /* Computing MAX */ | |||
| i__1 = iws, i__2 = (integer) work[1].r; | |||
| iws = f2cmax(i__1,i__2); | |||
| if (na < *n) { | |||
| /* CC CALL CUNM2R( 'Left', 'Conjugate Transpose', M, N-NA, */ | |||
| /* CC $ NA, A, LDA, TAU, A( 1, NA+1 ), LDA, WORK, */ | |||
| /* CC $ INFO ) */ | |||
| i__1 = *n - na; | |||
| cunmqr_("Left", "Conjugate Transpose", m, &i__1, &na, &a[a_offset] | |||
| , lda, &tau[1], &a[(na + 1) * a_dim1 + 1], lda, &work[1], | |||
| lwork, info); | |||
| /* Computing MAX */ | |||
| i__1 = iws, i__2 = (integer) work[1].r; | |||
| iws = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| /* Factorize free columns */ | |||
| /* ====================== */ | |||
| if (nfxd < minmn) { | |||
| sm = *m - nfxd; | |||
| sn = *n - nfxd; | |||
| sminmn = minmn - nfxd; | |||
| /* Determine the block size. */ | |||
| nb = ilaenv_(&c__1, "CGEQRF", " ", &sm, &sn, &c_n1, &c_n1, (ftnlen)6, | |||
| (ftnlen)1); | |||
| nbmin = 2; | |||
| nx = 0; | |||
| if (nb > 1 && nb < sminmn) { | |||
| /* Determine when to cross over from blocked to unblocked code. */ | |||
| /* Computing MAX */ | |||
| i__1 = 0, i__2 = ilaenv_(&c__3, "CGEQRF", " ", &sm, &sn, &c_n1, & | |||
| c_n1, (ftnlen)6, (ftnlen)1); | |||
| nx = f2cmax(i__1,i__2); | |||
| if (nx < sminmn) { | |||
| /* Determine if workspace is large enough for blocked code. */ | |||
| minws = (sn + 1) * nb; | |||
| iws = f2cmax(iws,minws); | |||
| if (*lwork < minws) { | |||
| /* Not enough workspace to use optimal NB: Reduce NB and */ | |||
| /* determine the minimum value of NB. */ | |||
| nb = *lwork / (sn + 1); | |||
| /* Computing MAX */ | |||
| i__1 = 2, i__2 = ilaenv_(&c__2, "CGEQRF", " ", &sm, &sn, & | |||
| c_n1, &c_n1, (ftnlen)6, (ftnlen)1); | |||
| nbmin = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| } | |||
| /* Initialize partial column norms. The first N elements of work */ | |||
| /* store the exact column norms. */ | |||
| i__1 = *n; | |||
| for (j = nfxd + 1; j <= i__1; ++j) { | |||
| rwork[j] = scnrm2_(&sm, &a[nfxd + 1 + j * a_dim1], &c__1); | |||
| rwork[*n + j] = rwork[j]; | |||
| /* L20: */ | |||
| } | |||
| if (nb >= nbmin && nb < sminmn && nx < sminmn) { | |||
| /* Use blocked code initially. */ | |||
| j = nfxd + 1; | |||
| /* Compute factorization: while loop. */ | |||
| topbmn = minmn - nx; | |||
| L30: | |||
| if (j <= topbmn) { | |||
| /* Computing MIN */ | |||
| i__1 = nb, i__2 = topbmn - j + 1; | |||
| jb = f2cmin(i__1,i__2); | |||
| /* Factorize JB columns among columns J:N. */ | |||
| i__1 = *n - j + 1; | |||
| i__2 = j - 1; | |||
| i__3 = *n - j + 1; | |||
| claqps_(m, &i__1, &i__2, &jb, &fjb, &a[j * a_dim1 + 1], lda, & | |||
| jpvt[j], &tau[j], &rwork[j], &rwork[*n + j], &work[1], | |||
| &work[jb + 1], &i__3); | |||
| j += fjb; | |||
| goto L30; | |||
| } | |||
| } else { | |||
| j = nfxd + 1; | |||
| } | |||
| /* Use unblocked code to factor the last or only block. */ | |||
| if (j <= minmn) { | |||
| i__1 = *n - j + 1; | |||
| i__2 = j - 1; | |||
| claqp2_(m, &i__1, &i__2, &a[j * a_dim1 + 1], lda, &jpvt[j], &tau[ | |||
| j], &rwork[j], &rwork[*n + j], &work[1]); | |||
| } | |||
| } | |||
| q__1.r = (real) lwkopt, q__1.i = 0.f; | |||
| work[1].r = q__1.r, work[1].i = q__1.i; | |||
| return 0; | |||
| /* End of CGEQP3 */ | |||
| } /* cgeqp3_ */ | |||
| @@ -0,0 +1,738 @@ | |||
| /* 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; | |||
| static integer c_n1 = -1; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGEQR */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQR( M, N, A, LDA, T, TSIZE, WORK, LWORK, */ | |||
| /* INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N, TSIZE, LWORK */ | |||
| /* COMPLEX A( LDA, * ), T( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQR computes a QR factorization of a complex M-by-N matrix A: */ | |||
| /* > */ | |||
| /* > A = Q * ( R ), */ | |||
| /* > ( 0 ) */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a M-by-M orthogonal matrix; */ | |||
| /* > R is an upper-triangular N-by-N matrix; */ | |||
| /* > 0 is a (M-N)-by-N zero matrix, if M > N. */ | |||
| /* > */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the elements on and above the diagonal of the array */ | |||
| /* > contain the f2cmin(M,N)-by-N upper trapezoidal matrix R */ | |||
| /* > (R is upper triangular if M >= N); */ | |||
| /* > the elements below the diagonal are used to store part of the */ | |||
| /* > data structure to represent Q. */ | |||
| /* > \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 array, dimension (MAX(5,TSIZE)) */ | |||
| /* > On exit, if INFO = 0, T(1) returns optimal (or either minimal */ | |||
| /* > or optimal, if query is assumed) TSIZE. See TSIZE for details. */ | |||
| /* > Remaining T contains part of the data structure used to represent Q. */ | |||
| /* > If one wants to apply or construct Q, then one needs to keep T */ | |||
| /* > (in addition to A) and pass it to further subroutines. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TSIZE */ | |||
| /* > \verbatim */ | |||
| /* > TSIZE is INTEGER */ | |||
| /* > If TSIZE >= 5, the dimension of the array T. */ | |||
| /* > If TSIZE = -1 or -2, then a workspace query is assumed. The routine */ | |||
| /* > only calculates the sizes of the T and WORK arrays, returns these */ | |||
| /* > values as the first entries of the T and WORK arrays, and no error */ | |||
| /* > message related to T or WORK is issued by XERBLA. */ | |||
| /* > If TSIZE = -1, the routine calculates optimal size of T for the */ | |||
| /* > optimum performance and returns this value in T(1). */ | |||
| /* > If TSIZE = -2, the routine calculates minimal size of T and */ | |||
| /* > returns this value in T(1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > (workspace) COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) contains optimal (or either minimal */ | |||
| /* > or optimal, if query was assumed) LWORK. */ | |||
| /* > See LWORK for details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > If LWORK = -1 or -2, then a workspace query is assumed. The routine */ | |||
| /* > only calculates the sizes of the T and WORK arrays, returns these */ | |||
| /* > values as the first entries of the T and WORK arrays, and no error */ | |||
| /* > message related to T or WORK is issued by XERBLA. */ | |||
| /* > If LWORK = -1, the routine calculates optimal size of WORK for the */ | |||
| /* > optimal performance and returns this value in WORK(1). */ | |||
| /* > If LWORK = -2, the routine calculates minimal size of WORK and */ | |||
| /* > returns this value in WORK(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. */ | |||
| /* > \par Further Details */ | |||
| /* ==================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The goal of the interface is to give maximum freedom to the developers for */ | |||
| /* > creating any QR factorization algorithm they wish. The triangular */ | |||
| /* > (trapezoidal) R has to be stored in the upper part of A. The lower part of A */ | |||
| /* > and the array T can be used to store any relevant information for applying or */ | |||
| /* > constructing the Q factor. The WORK array can safely be discarded after exit. */ | |||
| /* > */ | |||
| /* > Caution: One should not expect the sizes of T and WORK to be the same from one */ | |||
| /* > LAPACK implementation to the other, or even from one execution to the other. */ | |||
| /* > A workspace query (for T and WORK) is needed at each execution. However, */ | |||
| /* > for a given execution, the size of T and WORK are fixed and will not change */ | |||
| /* > from one query to the next. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \par Further Details particular to this LAPACK implementation: */ | |||
| /* ============================================================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > These details are particular for this LAPACK implementation. Users should not */ | |||
| /* > take them for granted. These details may change in the future, and are not likely */ | |||
| /* > true for another LAPACK implementation. These details are relevant if one wants */ | |||
| /* > to try to understand the code. They are not part of the interface. */ | |||
| /* > */ | |||
| /* > In this version, */ | |||
| /* > */ | |||
| /* > T(2): row block size (MB) */ | |||
| /* > T(3): column block size (NB) */ | |||
| /* > T(6:TSIZE): data structure needed for Q, computed by */ | |||
| /* > CLATSQR or CGEQRT */ | |||
| /* > */ | |||
| /* > Depending on the matrix dimensions M and N, and row and column */ | |||
| /* > block sizes MB and NB returned by ILAENV, CGEQR will use either */ | |||
| /* > CLATSQR (if the matrix is tall-and-skinny) or CGEQRT to compute */ | |||
| /* > the QR factorization. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqr_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *t, integer *tsize, complex *work, integer *lwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| /* Local variables */ | |||
| logical mint, minw; | |||
| integer mb, nb, nblcks; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| extern /* Subroutine */ int cgeqrt_(integer *, integer *, integer *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *); | |||
| logical lminws, lquery; | |||
| integer mintsz; | |||
| extern /* Subroutine */ int clatsqr_(integer *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, integer *, complex *, | |||
| integer *, integer *); | |||
| /* -- 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. -- */ | |||
| /* November 2019 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --t; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *tsize == -1 || *tsize == -2 || *lwork == -1 || *lwork == -2; | |||
| mint = FALSE_; | |||
| minw = FALSE_; | |||
| if (*tsize == -2 || *lwork == -2) { | |||
| if (*tsize != -1) { | |||
| mint = TRUE_; | |||
| } | |||
| if (*lwork != -1) { | |||
| minw = TRUE_; | |||
| } | |||
| } | |||
| /* Determine the block size */ | |||
| if (f2cmin(*m,*n) > 0) { | |||
| mb = ilaenv_(&c__1, "CGEQR ", " ", m, n, &c__1, &c_n1, (ftnlen)6, ( | |||
| ftnlen)1); | |||
| nb = ilaenv_(&c__1, "CGEQR ", " ", m, n, &c__2, &c_n1, (ftnlen)6, ( | |||
| ftnlen)1); | |||
| } else { | |||
| mb = *m; | |||
| nb = 1; | |||
| } | |||
| if (mb > *m || mb <= *n) { | |||
| mb = *m; | |||
| } | |||
| if (nb > f2cmin(*m,*n) || nb < 1) { | |||
| nb = 1; | |||
| } | |||
| mintsz = *n + 5; | |||
| if (mb > *n && *m > *n) { | |||
| if ((*m - *n) % (mb - *n) == 0) { | |||
| nblcks = (*m - *n) / (mb - *n); | |||
| } else { | |||
| nblcks = (*m - *n) / (mb - *n) + 1; | |||
| } | |||
| } else { | |||
| nblcks = 1; | |||
| } | |||
| /* Determine if the workspace size satisfies minimal size */ | |||
| lminws = FALSE_; | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = nb * *n * nblcks + 5; | |||
| if ((*tsize < f2cmax(i__1,i__2) || *lwork < nb * *n) && *lwork >= *n && * | |||
| tsize >= mintsz && ! lquery) { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = nb * *n * nblcks + 5; | |||
| if (*tsize < f2cmax(i__1,i__2)) { | |||
| lminws = TRUE_; | |||
| nb = 1; | |||
| mb = *m; | |||
| } | |||
| if (*lwork < nb * *n) { | |||
| lminws = TRUE_; | |||
| nb = 1; | |||
| } | |||
| } | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = nb * *n * nblcks + 5; | |||
| if (*tsize < f2cmax(i__1,i__2) && ! lquery && ! lminws) { | |||
| *info = -6; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = *n * nb; | |||
| if (*lwork < f2cmax(i__1,i__2) && ! lquery && ! lminws) { | |||
| *info = -8; | |||
| } | |||
| } | |||
| } | |||
| if (*info == 0) { | |||
| if (mint) { | |||
| t[1].r = (real) mintsz, t[1].i = 0.f; | |||
| } else { | |||
| i__1 = nb * *n * nblcks + 5; | |||
| t[1].r = (real) i__1, t[1].i = 0.f; | |||
| } | |||
| t[2].r = (real) mb, t[2].i = 0.f; | |||
| t[3].r = (real) nb, t[3].i = 0.f; | |||
| if (minw) { | |||
| i__1 = f2cmax(1,*n); | |||
| work[1].r = (real) i__1, work[1].i = 0.f; | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__2 = 1, i__3 = nb * *n; | |||
| i__1 = f2cmax(i__2,i__3); | |||
| work[1].r = (real) i__1, work[1].i = 0.f; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQR", &i__1, (ftnlen)5); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (f2cmin(*m,*n) == 0) { | |||
| return 0; | |||
| } | |||
| /* The QR Decomposition */ | |||
| if (*m <= *n || mb <= *n || mb >= *m) { | |||
| cgeqrt_(m, n, &nb, &a[a_offset], lda, &t[6], &nb, &work[1], info); | |||
| } else { | |||
| clatsqr_(m, n, &mb, &nb, &a[a_offset], lda, &t[6], &nb, &work[1], | |||
| lwork, info); | |||
| } | |||
| /* Computing MAX */ | |||
| i__2 = 1, i__3 = nb * *n; | |||
| i__1 = f2cmax(i__2,i__3); | |||
| work[1].r = (real) i__1, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEQR */ | |||
| } /* cgeqr_ */ | |||
| @@ -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) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGEQR2 computes the QR factorization of a general rectangular matrix using an unblocked algorit | |||
| hm. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQR2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqr2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqr2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqr2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQR2( M, N, A, LDA, TAU, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQR2 computes a QR factorization of a complex m-by-n matrix A: */ | |||
| /* > */ | |||
| /* > A = Q * ( R ), */ | |||
| /* > ( 0 ) */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a m-by-m orthogonal matrix; */ | |||
| /* > R is an upper-triangular n-by-n matrix; */ | |||
| /* > 0 is a (m-n)-by-n zero matrix, if m > n. */ | |||
| /* > */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the m by n matrix A. */ | |||
| /* > On exit, the elements on and above the diagonal of the array */ | |||
| /* > contain the f2cmin(m,n) by n upper trapezoidal matrix R (R is */ | |||
| /* > upper triangular if m >= n); the elements below the diagonal, */ | |||
| /* > with the array TAU, represent the unitary matrix Q as a */ | |||
| /* > product of elementary reflectors (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] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (N) */ | |||
| /* > \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 November 2019 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(k), where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > 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-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), */ | |||
| /* > and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqr2_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, complex *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| complex alpha; | |||
| extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex * | |||
| , integer *, complex *, complex *, integer *, complex *), | |||
| clarfg_(integer *, complex *, complex *, integer *, complex *), | |||
| xerbla_(char *, integer *, ftnlen); | |||
| /* -- 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..-- */ | |||
| /* November 2019 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQR2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| k = f2cmin(*m,*n); | |||
| i__1 = k; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Generate elementary reflector H(i) to annihilate A(i+1:m,i) */ | |||
| i__2 = *m - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 1; | |||
| clarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[f2cmin(i__3,*m) + i__ * a_dim1] | |||
| , &c__1, &tau[i__]); | |||
| if (i__ < *n) { | |||
| /* Apply H(i)**H to A(i:m,i+1:n) from the left */ | |||
| i__2 = i__ + i__ * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| i__2 = *m - i__ + 1; | |||
| i__3 = *n - i__; | |||
| r_cnjg(&q__1, &tau[i__]); | |||
| clarf_("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, &q__1, | |||
| &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = alpha.r, a[i__2].i = alpha.i; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* End of CGEQR2 */ | |||
| } /* cgeqr2_ */ | |||
| @@ -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 integer c__1 = 1; | |||
| /* > \brief \b CGEQR2P computes the QR factorization of a general rectangular matrix with non-negative diagona | |||
| l elements using an unblocked algorithm. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQR2P + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqr2p | |||
| .f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqr2p | |||
| .f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqr2p | |||
| .f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQR2P( M, N, A, LDA, TAU, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQR2P computes a QR factorization of a complex m-by-n matrix A: */ | |||
| /* > */ | |||
| /* > A = Q * ( R ), */ | |||
| /* > ( 0 ) */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a m-by-m orthogonal matrix; */ | |||
| /* > R is an upper-triangular n-by-n matrix with nonnegative diagonal */ | |||
| /* > entries; */ | |||
| /* > 0 is a (m-n)-by-n zero matrix, if m > n. */ | |||
| /* > */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the m by n matrix A. */ | |||
| /* > On exit, the elements on and above the diagonal of the array */ | |||
| /* > contain the f2cmin(m,n) by n upper trapezoidal matrix R (R is */ | |||
| /* > upper triangular if m >= n). The diagonal entries of R are */ | |||
| /* > real and nonnegative; the elements below the diagonal, */ | |||
| /* > with the array TAU, represent the unitary matrix Q as a */ | |||
| /* > product of elementary reflectors (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] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (N) */ | |||
| /* > \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 November 2019 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(k), where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > 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-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), */ | |||
| /* > and tau in TAU(i). */ | |||
| /* > */ | |||
| /* > See Lapack Working Note 203 for details */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqr2p_(integer *m, integer *n, complex *a, integer * | |||
| lda, complex *tau, complex *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| complex alpha; | |||
| extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex * | |||
| , integer *, complex *, complex *, integer *, complex *), | |||
| xerbla_(char *, integer *, ftnlen), clarfgp_(integer *, complex *, | |||
| complex *, integer *, complex *); | |||
| /* -- 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..-- */ | |||
| /* November 2019 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQR2P", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| k = f2cmin(*m,*n); | |||
| i__1 = k; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Generate elementary reflector H(i) to annihilate A(i+1:m,i) */ | |||
| i__2 = *m - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 1; | |||
| clarfgp_(&i__2, &a[i__ + i__ * a_dim1], &a[f2cmin(i__3,*m) + i__ * | |||
| a_dim1], &c__1, &tau[i__]); | |||
| if (i__ < *n) { | |||
| /* Apply H(i)**H to A(i:m,i+1:n) from the left */ | |||
| i__2 = i__ + i__ * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| i__2 = *m - i__ + 1; | |||
| i__3 = *n - i__; | |||
| r_cnjg(&q__1, &tau[i__]); | |||
| clarf_("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, &q__1, | |||
| &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = alpha.r, a[i__2].i = alpha.i; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* End of CGEQR2P */ | |||
| } /* cgeqr2p_ */ | |||
| @@ -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 integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__3 = 3; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGEQRF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQRF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqrf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqrf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqrf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQRF( M, N, A, LDA, TAU, WORK, LWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LWORK, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQRF computes a QR factorization of a complex M-by-N matrix A: */ | |||
| /* > */ | |||
| /* > A = Q * ( R ), */ | |||
| /* > ( 0 ) */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a M-by-M orthogonal matrix; */ | |||
| /* > R is an upper-triangular N-by-N matrix; */ | |||
| /* > 0 is a (M-N)-by-N zero matrix, if M > N. */ | |||
| /* > */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the elements on and above the diagonal of the array */ | |||
| /* > contain the f2cmin(M,N)-by-N upper trapezoidal matrix R (R is */ | |||
| /* > upper triangular if m >= n); the elements below the diagonal, */ | |||
| /* > with the array TAU, represent the unitary matrix Q as a */ | |||
| /* > product of f2cmin(m,n) elementary reflectors (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] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= f2cmax(1,N). */ | |||
| /* > For optimum performance LWORK >= N*NB, where NB is */ | |||
| /* > the optimal blocksize. */ | |||
| /* > */ | |||
| /* > 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. */ | |||
| /* > \date November 2019 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(k), where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > 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-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), */ | |||
| /* > and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqrf_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, complex *work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| /* Local variables */ | |||
| integer i__, k, nbmin, iinfo; | |||
| extern /* Subroutine */ int cgeqr2_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *); | |||
| integer ib, nb; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *); | |||
| integer nx; | |||
| extern /* Subroutine */ int clarft_(char *, char *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *), xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| integer ldwork, lwkopt; | |||
| logical lquery; | |||
| integer iws; | |||
| /* -- 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..-- */ | |||
| /* November 2019 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| nb = ilaenv_(&c__1, "CGEQRF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, (ftnlen) | |||
| 1); | |||
| lwkopt = *n * nb; | |||
| work[1].r = (real) lwkopt, work[1].i = 0.f; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else if (*lwork < f2cmax(1,*n) && ! lquery) { | |||
| *info = -7; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQRF", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| k = f2cmin(*m,*n); | |||
| if (k == 0) { | |||
| work[1].r = 1.f, work[1].i = 0.f; | |||
| return 0; | |||
| } | |||
| nbmin = 2; | |||
| nx = 0; | |||
| iws = *n; | |||
| if (nb > 1 && nb < k) { | |||
| /* Determine when to cross over from blocked to unblocked code. */ | |||
| /* Computing MAX */ | |||
| i__1 = 0, i__2 = ilaenv_(&c__3, "CGEQRF", " ", m, n, &c_n1, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nx = f2cmax(i__1,i__2); | |||
| if (nx < k) { | |||
| /* Determine if workspace is large enough for blocked code. */ | |||
| ldwork = *n; | |||
| iws = ldwork * nb; | |||
| if (*lwork < iws) { | |||
| /* Not enough workspace to use optimal NB: reduce NB and */ | |||
| /* determine the minimum value of NB. */ | |||
| nb = *lwork / ldwork; | |||
| /* Computing MAX */ | |||
| i__1 = 2, i__2 = ilaenv_(&c__2, "CGEQRF", " ", m, n, &c_n1, & | |||
| c_n1, (ftnlen)6, (ftnlen)1); | |||
| nbmin = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| } | |||
| if (nb >= nbmin && nb < k && nx < k) { | |||
| /* Use blocked code initially */ | |||
| i__1 = k - nx; | |||
| i__2 = nb; | |||
| for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = k - i__ + 1; | |||
| ib = f2cmin(i__3,nb); | |||
| /* Compute the QR factorization of the current block */ | |||
| /* A(i:m,i:i+ib-1) */ | |||
| i__3 = *m - i__ + 1; | |||
| cgeqr2_(&i__3, &ib, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[ | |||
| 1], &iinfo); | |||
| if (i__ + ib <= *n) { | |||
| /* Form the triangular factor of the block reflector */ | |||
| /* H = H(i) H(i+1) . . . H(i+ib-1) */ | |||
| i__3 = *m - i__ + 1; | |||
| clarft_("Forward", "Columnwise", &i__3, &ib, &a[i__ + i__ * | |||
| a_dim1], lda, &tau[i__], &work[1], &ldwork); | |||
| /* Apply H**H to A(i:m,i+ib:n) from the left */ | |||
| i__3 = *m - i__ + 1; | |||
| i__4 = *n - i__ - ib + 1; | |||
| clarfb_("Left", "Conjugate transpose", "Forward", "Columnwise" | |||
| , &i__3, &i__4, &ib, &a[i__ + i__ * a_dim1], lda, & | |||
| work[1], &ldwork, &a[i__ + (i__ + ib) * a_dim1], lda, | |||
| &work[ib + 1], &ldwork); | |||
| } | |||
| /* L10: */ | |||
| } | |||
| } else { | |||
| i__ = 1; | |||
| } | |||
| /* Use unblocked code to factor the last or only block. */ | |||
| if (i__ <= k) { | |||
| i__2 = *m - i__ + 1; | |||
| i__1 = *n - i__ + 1; | |||
| cgeqr2_(&i__2, &i__1, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[1] | |||
| , &iinfo); | |||
| } | |||
| work[1].r = (real) iws, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEQRF */ | |||
| } /* cgeqrf_ */ | |||
| @@ -0,0 +1,704 @@ | |||
| /* 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; | |||
| static integer c_n1 = -1; | |||
| static integer c__3 = 3; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGEQRFP */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQRFP + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqrfp | |||
| .f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqrfp | |||
| .f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqrfp | |||
| .f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQRFP( M, N, A, LDA, TAU, WORK, LWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LWORK, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQR2P computes a QR factorization of a complex M-by-N matrix A: */ | |||
| /* > */ | |||
| /* > A = Q * ( R ), */ | |||
| /* > ( 0 ) */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a M-by-M orthogonal matrix; */ | |||
| /* > R is an upper-triangular N-by-N matrix with nonnegative diagonal */ | |||
| /* > entries; */ | |||
| /* > 0 is a (M-N)-by-N zero matrix, if M > N. */ | |||
| /* > */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the elements on and above the diagonal of the array */ | |||
| /* > contain the f2cmin(M,N)-by-N upper trapezoidal matrix R (R is */ | |||
| /* > upper triangular if m >= n). The diagonal entries of R */ | |||
| /* > are real and nonnegative; the elements below the diagonal, */ | |||
| /* > with the array TAU, represent the unitary matrix Q as a */ | |||
| /* > product of f2cmin(m,n) elementary reflectors (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] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= f2cmax(1,N). */ | |||
| /* > For optimum performance LWORK >= N*NB, where NB is */ | |||
| /* > the optimal blocksize. */ | |||
| /* > */ | |||
| /* > 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. */ | |||
| /* > \date November 2019 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(k), where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > 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-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), */ | |||
| /* > and tau in TAU(i). */ | |||
| /* > */ | |||
| /* > See Lapack Working Note 203 for details */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqrfp_(integer *m, integer *n, complex *a, integer * | |||
| lda, complex *tau, complex *work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| /* Local variables */ | |||
| integer i__, k, nbmin, iinfo, ib, nb; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *); | |||
| integer nx; | |||
| extern /* Subroutine */ int clarft_(char *, char *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *), xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| integer ldwork, lwkopt; | |||
| logical lquery; | |||
| extern /* Subroutine */ int cgeqr2p_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *); | |||
| integer iws; | |||
| /* -- 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..-- */ | |||
| /* November 2019 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| nb = ilaenv_(&c__1, "CGEQRF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, (ftnlen) | |||
| 1); | |||
| lwkopt = *n * nb; | |||
| work[1].r = (real) lwkopt, work[1].i = 0.f; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else if (*lwork < f2cmax(1,*n) && ! lquery) { | |||
| *info = -7; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQRFP", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| k = f2cmin(*m,*n); | |||
| if (k == 0) { | |||
| work[1].r = 1.f, work[1].i = 0.f; | |||
| return 0; | |||
| } | |||
| nbmin = 2; | |||
| nx = 0; | |||
| iws = *n; | |||
| if (nb > 1 && nb < k) { | |||
| /* Determine when to cross over from blocked to unblocked code. */ | |||
| /* Computing MAX */ | |||
| i__1 = 0, i__2 = ilaenv_(&c__3, "CGEQRF", " ", m, n, &c_n1, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nx = f2cmax(i__1,i__2); | |||
| if (nx < k) { | |||
| /* Determine if workspace is large enough for blocked code. */ | |||
| ldwork = *n; | |||
| iws = ldwork * nb; | |||
| if (*lwork < iws) { | |||
| /* Not enough workspace to use optimal NB: reduce NB and */ | |||
| /* determine the minimum value of NB. */ | |||
| nb = *lwork / ldwork; | |||
| /* Computing MAX */ | |||
| i__1 = 2, i__2 = ilaenv_(&c__2, "CGEQRF", " ", m, n, &c_n1, & | |||
| c_n1, (ftnlen)6, (ftnlen)1); | |||
| nbmin = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| } | |||
| if (nb >= nbmin && nb < k && nx < k) { | |||
| /* Use blocked code initially */ | |||
| i__1 = k - nx; | |||
| i__2 = nb; | |||
| for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = k - i__ + 1; | |||
| ib = f2cmin(i__3,nb); | |||
| /* Compute the QR factorization of the current block */ | |||
| /* A(i:m,i:i+ib-1) */ | |||
| i__3 = *m - i__ + 1; | |||
| cgeqr2p_(&i__3, &ib, &a[i__ + i__ * a_dim1], lda, &tau[i__], & | |||
| work[1], &iinfo); | |||
| if (i__ + ib <= *n) { | |||
| /* Form the triangular factor of the block reflector */ | |||
| /* H = H(i) H(i+1) . . . H(i+ib-1) */ | |||
| i__3 = *m - i__ + 1; | |||
| clarft_("Forward", "Columnwise", &i__3, &ib, &a[i__ + i__ * | |||
| a_dim1], lda, &tau[i__], &work[1], &ldwork); | |||
| /* Apply H**H to A(i:m,i+ib:n) from the left */ | |||
| i__3 = *m - i__ + 1; | |||
| i__4 = *n - i__ - ib + 1; | |||
| clarfb_("Left", "Conjugate transpose", "Forward", "Columnwise" | |||
| , &i__3, &i__4, &ib, &a[i__ + i__ * a_dim1], lda, & | |||
| work[1], &ldwork, &a[i__ + (i__ + ib) * a_dim1], lda, | |||
| &work[ib + 1], &ldwork); | |||
| } | |||
| /* L10: */ | |||
| } | |||
| } else { | |||
| i__ = 1; | |||
| } | |||
| /* Use unblocked code to factor the last or only block. */ | |||
| if (i__ <= k) { | |||
| i__2 = *m - i__ + 1; | |||
| i__1 = *n - i__ + 1; | |||
| cgeqr2p_(&i__2, &i__1, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[ | |||
| 1], &iinfo); | |||
| } | |||
| work[1].r = (real) iws, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEQRFP */ | |||
| } /* cgeqrfp_ */ | |||
| @@ -0,0 +1,628 @@ | |||
| /* 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 CGEQRT */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQRT + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqrt. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqrt. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqrt. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQRT( M, N, NB, A, LDA, T, LDT, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LDT, M, N, NB */ | |||
| /* COMPLEX A( LDA, * ), T( LDT, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQRT computes a blocked QR factorization of a complex M-by-N matrix A */ | |||
| /* > using the compact WY representation of Q. */ | |||
| /* > \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] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The block size to be used in the blocked QR. MIN(M,N) >= NB >= 1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the elements on and above the diagonal of the array */ | |||
| /* > contain the f2cmin(M,N)-by-N upper trapezoidal matrix R (R is */ | |||
| /* > upper triangular if M >= N); the elements below the diagonal */ | |||
| /* > are the columns of V. */ | |||
| /* > \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 array, dimension (LDT,MIN(M,N)) */ | |||
| /* > The 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[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (NB*N) */ | |||
| /* > \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 2017 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix V stores the elementary reflectors H(i) in the i-th column */ | |||
| /* > below the diagonal. For example, if M=5 and N=3, the matrix V is */ | |||
| /* > */ | |||
| /* > V = ( 1 ) */ | |||
| /* > ( v1 1 ) */ | |||
| /* > ( v1 v2 1 ) */ | |||
| /* > ( v1 v2 v3 ) */ | |||
| /* > ( v1 v2 v3 ) */ | |||
| /* > */ | |||
| /* > where the vi's represent the vectors which define H(i), which are returned */ | |||
| /* > in the matrix A. The 1's along the diagonal of V are not stored in A. */ | |||
| /* > */ | |||
| /* > Let K=MIN(M,N). The number of blocks is B = ceiling(K/NB), where each */ | |||
| /* > block is of order NB except for the last block, which is of order */ | |||
| /* > IB = K - (B-1)*NB. For each of the B blocks, a upper triangular block */ | |||
| /* > reflector factor is computed: T1, T2, ..., TB. The NB-by-NB (and IB-by-IB */ | |||
| /* > for the last block) T's are stored in the NB-by-K matrix T as */ | |||
| /* > */ | |||
| /* > T = (T1 T2 ... TB). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqrt_(integer *m, integer *n, integer *nb, complex *a, | |||
| integer *lda, complex *t, integer *ldt, complex *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, i__1, i__2, i__3, i__4, i__5; | |||
| /* Local variables */ | |||
| integer i__, k, iinfo, ib; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *), xerbla_(char *, integer *, ftnlen), | |||
| cgeqrt2_(integer *, integer *, complex *, integer *, complex *, | |||
| integer *, integer *), cgeqrt3_(integer *, integer *, complex *, | |||
| integer *, complex *, integer *, 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; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*nb < 1 || *nb > f2cmin(*m,*n) && f2cmin(*m,*n) > 0) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -5; | |||
| } else if (*ldt < *nb) { | |||
| *info = -7; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQRT", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| k = f2cmin(*m,*n); | |||
| if (k == 0) { | |||
| return 0; | |||
| } | |||
| /* Blocked loop of length K */ | |||
| i__1 = k; | |||
| i__2 = *nb; | |||
| for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = k - i__ + 1; | |||
| ib = f2cmin(i__3,*nb); | |||
| /* Compute the QR factorization of the current block A(I:M,I:I+IB-1) */ | |||
| if (TRUE_) { | |||
| i__3 = *m - i__ + 1; | |||
| cgeqrt3_(&i__3, &ib, &a[i__ + i__ * a_dim1], lda, &t[i__ * t_dim1 | |||
| + 1], ldt, &iinfo); | |||
| } else { | |||
| i__3 = *m - i__ + 1; | |||
| cgeqrt2_(&i__3, &ib, &a[i__ + i__ * a_dim1], lda, &t[i__ * t_dim1 | |||
| + 1], ldt, &iinfo); | |||
| } | |||
| if (i__ + ib <= *n) { | |||
| /* Update by applying H**H to A(I:M,I+IB:N) from the left */ | |||
| i__3 = *m - i__ + 1; | |||
| i__4 = *n - i__ - ib + 1; | |||
| i__5 = *n - i__ - ib + 1; | |||
| clarfb_("L", "C", "F", "C", &i__3, &i__4, &ib, &a[i__ + i__ * | |||
| a_dim1], lda, &t[i__ * t_dim1 + 1], ldt, &a[i__ + (i__ + | |||
| ib) * a_dim1], lda, &work[1], &i__5); | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGEQRT */ | |||
| } /* cgeqrt_ */ | |||
| @@ -0,0 +1,659 @@ | |||
| /* 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 complex c_b1 = {1.f,0.f}; | |||
| static complex c_b2 = {0.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGEQRT2 computes a QR factorization of a general real or complex matrix using the compact WY re | |||
| presentation of Q. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQRT2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqrt2 | |||
| .f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqrt2 | |||
| .f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqrt2 | |||
| .f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQRT2( M, N, A, LDA, T, LDT, INFO ) */ | |||
| /* INTEGER INFO, LDA, LDT, M, N */ | |||
| /* COMPLEX A( LDA, * ), T( LDT, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQRT2 computes a QR factorization of a complex M-by-N matrix A, */ | |||
| /* > using the compact WY representation of Q. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= N. */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the complex M-by-N matrix A. On exit, the elements on and */ | |||
| /* > above the diagonal contain the N-by-N upper triangular matrix R; the */ | |||
| /* > elements below the diagonal are the columns of V. See below for */ | |||
| /* > 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 array, dimension (LDT,N) */ | |||
| /* > The N-by-N upper triangular factor of the block reflector. */ | |||
| /* > The elements on and above the diagonal contain the block */ | |||
| /* > reflector T; the elements below the diagonal are not used. */ | |||
| /* > See below for further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= 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 */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix V stores the elementary reflectors H(i) in the i-th column */ | |||
| /* > below the diagonal. For example, if M=5 and N=3, the matrix V is */ | |||
| /* > */ | |||
| /* > V = ( 1 ) */ | |||
| /* > ( v1 1 ) */ | |||
| /* > ( v1 v2 1 ) */ | |||
| /* > ( v1 v2 v3 ) */ | |||
| /* > ( v1 v2 v3 ) */ | |||
| /* > */ | |||
| /* > where the vi's represent the vectors which define H(i), which are returned */ | |||
| /* > in the matrix A. The 1's along the diagonal of V are not stored in A. The */ | |||
| /* > block reflector H is then given by */ | |||
| /* > */ | |||
| /* > H = I - V * T * V**H */ | |||
| /* > */ | |||
| /* > where V**H is the conjugate transpose of V. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqrt2_(integer *m, integer *n, complex *a, integer * | |||
| lda, complex *t, integer *ldt, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, i__1, i__2, i__3; | |||
| complex q__1, q__2; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| extern /* Subroutine */ int cgerc_(integer *, integer *, complex *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *); | |||
| complex alpha; | |||
| extern /* Subroutine */ int cgemv_(char *, integer *, integer *, complex * | |||
| , complex *, integer *, complex *, integer *, complex *, complex * | |||
| , integer *), ctrmv_(char *, char *, char *, integer *, | |||
| complex *, integer *, complex *, integer *), clarfg_(integer *, complex *, complex *, integer *, | |||
| complex *), xerbla_(char *, integer *, ftnlen); | |||
| complex aii; | |||
| /* -- 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 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; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else if (*ldt < f2cmax(1,*n)) { | |||
| *info = -6; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQRT2", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| k = f2cmin(*m,*n); | |||
| i__1 = k; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Generate elem. refl. H(i) to annihilate A(i+1:m,i), tau(I) -> T(I,1) */ | |||
| i__2 = *m - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 1; | |||
| clarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[f2cmin(i__3,*m) + i__ * a_dim1] | |||
| , &c__1, &t[i__ + t_dim1]); | |||
| if (i__ < *n) { | |||
| /* Apply H(i) to A(I:M,I+1:N) from the left */ | |||
| i__2 = i__ + i__ * a_dim1; | |||
| aii.r = a[i__2].r, aii.i = a[i__2].i; | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| /* W(1:N-I) := A(I:M,I+1:N)**H * A(I:M,I) [W = T(:,N)] */ | |||
| i__2 = *m - i__ + 1; | |||
| i__3 = *n - i__; | |||
| cgemv_("C", &i__2, &i__3, &c_b1, &a[i__ + (i__ + 1) * a_dim1], | |||
| lda, &a[i__ + i__ * a_dim1], &c__1, &c_b2, &t[*n * t_dim1 | |||
| + 1], &c__1); | |||
| /* A(I:M,I+1:N) = A(I:m,I+1:N) + alpha*A(I:M,I)*W(1:N-1)**H */ | |||
| r_cnjg(&q__2, &t[i__ + t_dim1]); | |||
| q__1.r = -q__2.r, q__1.i = -q__2.i; | |||
| alpha.r = q__1.r, alpha.i = q__1.i; | |||
| i__2 = *m - i__ + 1; | |||
| i__3 = *n - i__; | |||
| cgerc_(&i__2, &i__3, &alpha, &a[i__ + i__ * a_dim1], &c__1, &t[*n | |||
| * t_dim1 + 1], &c__1, &a[i__ + (i__ + 1) * a_dim1], lda); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = aii.r, a[i__2].i = aii.i; | |||
| } | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 2; i__ <= i__1; ++i__) { | |||
| i__2 = i__ + i__ * a_dim1; | |||
| aii.r = a[i__2].r, aii.i = a[i__2].i; | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| /* T(1:I-1,I) := alpha * A(I:M,1:I-1)**H * A(I:M,I) */ | |||
| i__2 = i__ + t_dim1; | |||
| q__1.r = -t[i__2].r, q__1.i = -t[i__2].i; | |||
| alpha.r = q__1.r, alpha.i = q__1.i; | |||
| i__2 = *m - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| cgemv_("C", &i__2, &i__3, &alpha, &a[i__ + a_dim1], lda, &a[i__ + i__ | |||
| * a_dim1], &c__1, &c_b2, &t[i__ * t_dim1 + 1], &c__1); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = aii.r, a[i__2].i = aii.i; | |||
| /* T(1:I-1,I) := T(1:I-1,1:I-1) * T(1:I-1,I) */ | |||
| i__2 = i__ - 1; | |||
| ctrmv_("U", "N", "N", &i__2, &t[t_offset], ldt, &t[i__ * t_dim1 + 1], | |||
| &c__1); | |||
| /* T(I,I) = tau(I) */ | |||
| i__2 = i__ + i__ * t_dim1; | |||
| i__3 = i__ + t_dim1; | |||
| t[i__2].r = t[i__3].r, t[i__2].i = t[i__3].i; | |||
| i__2 = i__ + t_dim1; | |||
| t[i__2].r = 0.f, t[i__2].i = 0.f; | |||
| } | |||
| /* End of CGEQRT2 */ | |||
| return 0; | |||
| } /* cgeqrt2_ */ | |||
| @@ -0,0 +1,693 @@ | |||
| /* 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 complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief <b> CGEQRT3 recursively computes a QR factorization of a general real or complex matrix using the | |||
| compact WY representation of Q. </b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQRT3 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqrt3 | |||
| .f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqrt3 | |||
| .f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqrt3 | |||
| .f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQRT3( M, N, A, LDA, T, LDT, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N, LDT */ | |||
| /* COMPLEX A( LDA, * ), T( LDT, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQRT3 recursively computes a QR factorization of a complex M-by-N matrix A, */ | |||
| /* > using the compact WY representation of Q. */ | |||
| /* > */ | |||
| /* > Based on the algorithm of Elmroth and Gustavson, */ | |||
| /* > IBM J. Res. Develop. Vol 44 No. 4 July 2000. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= N. */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the complex M-by-N matrix A. On exit, the elements on and */ | |||
| /* > above the diagonal contain the N-by-N upper triangular matrix R; the */ | |||
| /* > elements below the diagonal are the columns of V. See below for */ | |||
| /* > 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 array, dimension (LDT,N) */ | |||
| /* > The N-by-N upper triangular factor of the block reflector. */ | |||
| /* > The elements on and above the diagonal contain the block */ | |||
| /* > reflector T; the elements below the diagonal are not used. */ | |||
| /* > See below for further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= 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 */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix V stores the elementary reflectors H(i) in the i-th column */ | |||
| /* > below the diagonal. For example, if M=5 and N=3, the matrix V is */ | |||
| /* > */ | |||
| /* > V = ( 1 ) */ | |||
| /* > ( v1 1 ) */ | |||
| /* > ( v1 v2 1 ) */ | |||
| /* > ( v1 v2 v3 ) */ | |||
| /* > ( v1 v2 v3 ) */ | |||
| /* > */ | |||
| /* > where the vi's represent the vectors which define H(i), which are returned */ | |||
| /* > in the matrix A. The 1's along the diagonal of V are not stored in A. The */ | |||
| /* > block reflector H is then given by */ | |||
| /* > */ | |||
| /* > H = I - V * T * V**H */ | |||
| /* > */ | |||
| /* > where V**H is the conjugate transpose of V. */ | |||
| /* > */ | |||
| /* > For details of the algorithm, see Elmroth and Gustavson (cited above). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqrt3_(integer *m, integer *n, complex *a, integer * | |||
| lda, complex *t, integer *ldt, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, i__1, i__2, i__3, i__4, i__5; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, | |||
| integer *, complex *, complex *, integer *, complex *, integer *, | |||
| complex *, complex *, integer *); | |||
| integer iinfo; | |||
| extern /* Subroutine */ int ctrmm_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *); | |||
| integer i1, j1, n1, n2; | |||
| extern /* Subroutine */ int clarfg_(integer *, complex *, complex *, | |||
| integer *, complex *), xerbla_(char *, integer *, ftnlen); | |||
| /* -- 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 */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*m < *n) { | |||
| *info = -1; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else if (*ldt < f2cmax(1,*n)) { | |||
| *info = -6; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQRT3", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| if (*n == 1) { | |||
| /* Compute Householder transform when N=1 */ | |||
| clarfg_(m, &a[a_dim1 + 1], &a[f2cmin(2,*m) + a_dim1], &c__1, &t[t_dim1 + | |||
| 1]); | |||
| } else { | |||
| /* Otherwise, split A into blocks... */ | |||
| n1 = *n / 2; | |||
| n2 = *n - n1; | |||
| /* Computing MIN */ | |||
| i__1 = n1 + 1; | |||
| j1 = f2cmin(i__1,*n); | |||
| /* Computing MIN */ | |||
| i__1 = *n + 1; | |||
| i1 = f2cmin(i__1,*m); | |||
| /* Compute A(1:M,1:N1) <- (Y1,R1,T1), where Q1 = I - Y1 T1 Y1**H */ | |||
| cgeqrt3_(m, &n1, &a[a_offset], lda, &t[t_offset], ldt, &iinfo); | |||
| /* Compute A(1:M,J1:N) = Q1**H A(1:M,J1:N) [workspace: T(1:N1,J1:N)] */ | |||
| i__1 = n2; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = n1; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + (j + n1) * t_dim1; | |||
| i__4 = i__ + (j + n1) * a_dim1; | |||
| t[i__3].r = a[i__4].r, t[i__3].i = a[i__4].i; | |||
| } | |||
| } | |||
| ctrmm_("L", "L", "C", "U", &n1, &n2, &c_b1, &a[a_offset], lda, &t[j1 * | |||
| t_dim1 + 1], ldt) | |||
| ; | |||
| i__1 = *m - n1; | |||
| cgemm_("C", "N", &n1, &n2, &i__1, &c_b1, &a[j1 + a_dim1], lda, &a[j1 | |||
| + j1 * a_dim1], lda, &c_b1, &t[j1 * t_dim1 + 1], ldt); | |||
| ctrmm_("L", "U", "C", "N", &n1, &n2, &c_b1, &t[t_offset], ldt, &t[j1 * | |||
| t_dim1 + 1], ldt) | |||
| ; | |||
| i__1 = *m - n1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemm_("N", "N", &i__1, &n2, &n1, &q__1, &a[j1 + a_dim1], lda, &t[j1 * | |||
| t_dim1 + 1], ldt, &c_b1, &a[j1 + j1 * a_dim1], lda); | |||
| ctrmm_("L", "L", "N", "U", &n1, &n2, &c_b1, &a[a_offset], lda, &t[j1 * | |||
| t_dim1 + 1], ldt) | |||
| ; | |||
| i__1 = n2; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = n1; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + (j + n1) * a_dim1; | |||
| i__4 = i__ + (j + n1) * a_dim1; | |||
| i__5 = i__ + (j + n1) * t_dim1; | |||
| q__1.r = a[i__4].r - t[i__5].r, q__1.i = a[i__4].i - t[i__5] | |||
| .i; | |||
| a[i__3].r = q__1.r, a[i__3].i = q__1.i; | |||
| } | |||
| } | |||
| /* Compute A(J1:M,J1:N) <- (Y2,R2,T2) where Q2 = I - Y2 T2 Y2**H */ | |||
| i__1 = *m - n1; | |||
| cgeqrt3_(&i__1, &n2, &a[j1 + j1 * a_dim1], lda, &t[j1 + j1 * t_dim1], | |||
| ldt, &iinfo); | |||
| /* Compute T3 = T(1:N1,J1:N) = -T1 Y1**H Y2 T2 */ | |||
| i__1 = n1; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = n2; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| i__3 = i__ + (j + n1) * t_dim1; | |||
| r_cnjg(&q__1, &a[j + n1 + i__ * a_dim1]); | |||
| t[i__3].r = q__1.r, t[i__3].i = q__1.i; | |||
| } | |||
| } | |||
| ctrmm_("R", "L", "N", "U", &n1, &n2, &c_b1, &a[j1 + j1 * a_dim1], lda, | |||
| &t[j1 * t_dim1 + 1], ldt); | |||
| i__1 = *m - *n; | |||
| cgemm_("C", "N", &n1, &n2, &i__1, &c_b1, &a[i1 + a_dim1], lda, &a[i1 | |||
| + j1 * a_dim1], lda, &c_b1, &t[j1 * t_dim1 + 1], ldt); | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| ctrmm_("L", "U", "N", "N", &n1, &n2, &q__1, &t[t_offset], ldt, &t[j1 * | |||
| t_dim1 + 1], ldt) | |||
| ; | |||
| ctrmm_("R", "U", "N", "N", &n1, &n2, &c_b1, &t[j1 + j1 * t_dim1], ldt, | |||
| &t[j1 * t_dim1 + 1], ldt); | |||
| /* Y = (Y1,Y2); R = [ R1 A(1:N1,J1:N) ]; T = [T1 T3] */ | |||
| /* [ 0 R2 ] [ 0 T2] */ | |||
| } | |||
| return 0; | |||
| /* End of CGEQRT3 */ | |||
| } /* cgeqrt3_ */ | |||
| @@ -0,0 +1,912 @@ | |||
| /* 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 complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGERFS */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGERFS + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgerfs. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgerfs. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgerfs. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGERFS( TRANS, N, NRHS, A, LDA, AF, LDAF, IPIV, B, LDB, */ | |||
| /* X, LDX, FERR, BERR, WORK, RWORK, INFO ) */ | |||
| /* CHARACTER TRANS */ | |||
| /* INTEGER INFO, LDA, LDAF, LDB, LDX, N, NRHS */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* REAL BERR( * ), FERR( * ), RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), AF( LDAF, * ), B( LDB, * ), */ | |||
| /* $ WORK( * ), X( LDX, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGERFS improves the computed solution to a system of linear */ | |||
| /* > equations and provides error bounds and backward error estimates for */ | |||
| /* > the solution. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > Specifies the form of the system of equations: */ | |||
| /* > = 'N': A * X = B (No transpose) */ | |||
| /* > = 'T': A**T * X = B (Transpose) */ | |||
| /* > = 'C': A**H * X = B (Conjugate transpose) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of columns */ | |||
| /* > of the matrices B and X. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > The original N-by-N matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AF */ | |||
| /* > \verbatim */ | |||
| /* > AF is COMPLEX array, dimension (LDAF,N) */ | |||
| /* > The factors L and U from the factorization A = P*L*U */ | |||
| /* > as computed by CGETRF. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAF */ | |||
| /* > \verbatim */ | |||
| /* > LDAF is INTEGER */ | |||
| /* > The leading dimension of the array AF. LDAF >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (N) */ | |||
| /* > The pivot indices from CGETRF; for 1<=i<=N, row i of the */ | |||
| /* > matrix was interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > The right hand side matrix B. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX array, dimension (LDX,NRHS) */ | |||
| /* > On entry, the solution matrix X, as computed by CGETRS. */ | |||
| /* > On exit, the improved solution matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDX */ | |||
| /* > \verbatim */ | |||
| /* > LDX is INTEGER */ | |||
| /* > The leading dimension of the array X. LDX >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] FERR */ | |||
| /* > \verbatim */ | |||
| /* > FERR is REAL array, dimension (NRHS) */ | |||
| /* > The estimated forward error bound for each solution vector */ | |||
| /* > X(j) (the j-th column of the solution matrix X). */ | |||
| /* > If XTRUE is the true solution corresponding to X(j), FERR(j) */ | |||
| /* > is an estimated upper bound for the magnitude of the largest */ | |||
| /* > element in (X(j) - XTRUE) divided by the magnitude of the */ | |||
| /* > largest element in X(j). The estimate is as reliable as */ | |||
| /* > the estimate for RCOND, and is almost always a slight */ | |||
| /* > overestimate of the true error. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] BERR */ | |||
| /* > \verbatim */ | |||
| /* > BERR is REAL array, dimension (NRHS) */ | |||
| /* > The componentwise relative backward error of each solution */ | |||
| /* > vector X(j) (i.e., the smallest relative change in */ | |||
| /* > any element of A or B that makes X(j) an exact solution). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > ITMAX is the maximum number of steps of iterative refinement. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgerfs_(char *trans, integer *n, integer *nrhs, complex * | |||
| a, integer *lda, complex *af, integer *ldaf, integer *ipiv, complex * | |||
| b, integer *ldb, complex *x, integer *ldx, real *ferr, real *berr, | |||
| complex *work, real *rwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, x_dim1, | |||
| x_offset, i__1, i__2, i__3, i__4, i__5; | |||
| real r__1, r__2, r__3, r__4; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer kase; | |||
| real safe1, safe2; | |||
| integer i__, j, k; | |||
| real s; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int cgemv_(char *, integer *, integer *, complex * | |||
| , complex *, integer *, complex *, integer *, complex *, complex * | |||
| , integer *); | |||
| integer isave[3]; | |||
| extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, | |||
| complex *, integer *), caxpy_(integer *, complex *, complex *, | |||
| integer *, complex *, integer *); | |||
| integer count; | |||
| extern /* Subroutine */ int clacn2_(integer *, complex *, complex *, real | |||
| *, integer *, integer *); | |||
| real xk; | |||
| extern real slamch_(char *); | |||
| integer nz; | |||
| real safmin; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), cgetrs_( | |||
| char *, integer *, integer *, complex *, integer *, integer *, | |||
| complex *, integer *, integer *); | |||
| logical notran; | |||
| char transn[1], transt[1]; | |||
| real lstres, eps; | |||
| /* -- 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 */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| af_dim1 = *ldaf; | |||
| af_offset = 1 + af_dim1 * 1; | |||
| af -= af_offset; | |||
| --ipiv; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| x_dim1 = *ldx; | |||
| x_offset = 1 + x_dim1 * 1; | |||
| x -= x_offset; | |||
| --ferr; | |||
| --berr; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| notran = lsame_(trans, "N"); | |||
| if (! notran && ! lsame_(trans, "T") && ! lsame_( | |||
| trans, "C")) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*nrhs < 0) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -5; | |||
| } else if (*ldaf < f2cmax(1,*n)) { | |||
| *info = -7; | |||
| } else if (*ldb < f2cmax(1,*n)) { | |||
| *info = -10; | |||
| } else if (*ldx < f2cmax(1,*n)) { | |||
| *info = -12; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGERFS", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0 || *nrhs == 0) { | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| ferr[j] = 0.f; | |||
| berr[j] = 0.f; | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| } | |||
| if (notran) { | |||
| *(unsigned char *)transn = 'N'; | |||
| *(unsigned char *)transt = 'C'; | |||
| } else { | |||
| *(unsigned char *)transn = 'C'; | |||
| *(unsigned char *)transt = 'N'; | |||
| } | |||
| /* NZ = maximum number of nonzero elements in each row of A, plus 1 */ | |||
| nz = *n + 1; | |||
| eps = slamch_("Epsilon"); | |||
| safmin = slamch_("Safe minimum"); | |||
| safe1 = nz * safmin; | |||
| safe2 = safe1 / eps; | |||
| /* Do for each right hand side */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| count = 1; | |||
| lstres = 3.f; | |||
| L20: | |||
| /* Loop until stopping criterion is satisfied. */ | |||
| /* Compute residual R = B - op(A) * X, */ | |||
| /* where op(A) = A, A**T, or A**H, depending on TRANS. */ | |||
| ccopy_(n, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1); | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemv_(trans, n, n, &q__1, &a[a_offset], lda, &x[j * x_dim1 + 1], & | |||
| c__1, &c_b1, &work[1], &c__1); | |||
| /* Compute componentwise relative backward error from formula */ | |||
| /* f2cmax(i) ( abs(R(i)) / ( abs(op(A))*abs(X) + abs(B) )(i) ) */ | |||
| /* where abs(Z) is the componentwise absolute value of the matrix */ | |||
| /* or vector Z. If the i-th component of the denominator is less */ | |||
| /* than SAFE2, then SAFE1 is added to the i-th components of the */ | |||
| /* numerator and denominator before dividing. */ | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| rwork[i__] = (r__1 = b[i__3].r, abs(r__1)) + (r__2 = r_imag(&b[ | |||
| i__ + j * b_dim1]), abs(r__2)); | |||
| /* L30: */ | |||
| } | |||
| /* Compute abs(op(A))*abs(X) + abs(B). */ | |||
| if (notran) { | |||
| i__2 = *n; | |||
| for (k = 1; k <= i__2; ++k) { | |||
| i__3 = k + j * x_dim1; | |||
| xk = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[k + j * | |||
| x_dim1]), abs(r__2)); | |||
| i__3 = *n; | |||
| for (i__ = 1; i__ <= i__3; ++i__) { | |||
| i__4 = i__ + k * a_dim1; | |||
| rwork[i__] += ((r__1 = a[i__4].r, abs(r__1)) + (r__2 = | |||
| r_imag(&a[i__ + k * a_dim1]), abs(r__2))) * xk; | |||
| /* L40: */ | |||
| } | |||
| /* L50: */ | |||
| } | |||
| } else { | |||
| i__2 = *n; | |||
| for (k = 1; k <= i__2; ++k) { | |||
| s = 0.f; | |||
| i__3 = *n; | |||
| for (i__ = 1; i__ <= i__3; ++i__) { | |||
| i__4 = i__ + k * a_dim1; | |||
| i__5 = i__ + j * x_dim1; | |||
| s += ((r__1 = a[i__4].r, abs(r__1)) + (r__2 = r_imag(&a[ | |||
| i__ + k * a_dim1]), abs(r__2))) * ((r__3 = x[i__5] | |||
| .r, abs(r__3)) + (r__4 = r_imag(&x[i__ + j * | |||
| x_dim1]), abs(r__4))); | |||
| /* L60: */ | |||
| } | |||
| rwork[k] += s; | |||
| /* L70: */ | |||
| } | |||
| } | |||
| s = 0.f; | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| if (rwork[i__] > safe2) { | |||
| /* Computing MAX */ | |||
| i__3 = i__; | |||
| r__3 = s, r__4 = ((r__1 = work[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&work[i__]), abs(r__2))) / rwork[i__]; | |||
| s = f2cmax(r__3,r__4); | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__3 = i__; | |||
| r__3 = s, r__4 = ((r__1 = work[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&work[i__]), abs(r__2)) + safe1) / (rwork[i__] | |||
| + safe1); | |||
| s = f2cmax(r__3,r__4); | |||
| } | |||
| /* L80: */ | |||
| } | |||
| berr[j] = s; | |||
| /* Test stopping criterion. Continue iterating if */ | |||
| /* 1) The residual BERR(J) is larger than machine epsilon, and */ | |||
| /* 2) BERR(J) decreased by at least a factor of 2 during the */ | |||
| /* last iteration, and */ | |||
| /* 3) At most ITMAX iterations tried. */ | |||
| if (berr[j] > eps && berr[j] * 2.f <= lstres && count <= 5) { | |||
| /* Update solution and try again. */ | |||
| cgetrs_(trans, n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[1], | |||
| n, info); | |||
| caxpy_(n, &c_b1, &work[1], &c__1, &x[j * x_dim1 + 1], &c__1); | |||
| lstres = berr[j]; | |||
| ++count; | |||
| goto L20; | |||
| } | |||
| /* Bound error from formula */ | |||
| /* norm(X - XTRUE) / norm(X) .le. FERR = */ | |||
| /* norm( abs(inv(op(A)))* */ | |||
| /* ( abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) / norm(X) */ | |||
| /* where */ | |||
| /* norm(Z) is the magnitude of the largest component of Z */ | |||
| /* inv(op(A)) is the inverse of op(A) */ | |||
| /* abs(Z) is the componentwise absolute value of the matrix or */ | |||
| /* vector Z */ | |||
| /* NZ is the maximum number of nonzeros in any row of A, plus 1 */ | |||
| /* EPS is machine epsilon */ | |||
| /* The i-th component of abs(R)+NZ*EPS*(abs(op(A))*abs(X)+abs(B)) */ | |||
| /* is incremented by SAFE1 if the i-th component of */ | |||
| /* abs(op(A))*abs(X) + abs(B) is less than SAFE2. */ | |||
| /* Use CLACN2 to estimate the infinity-norm of the matrix */ | |||
| /* inv(op(A)) * diag(W), */ | |||
| /* where W = abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) */ | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| if (rwork[i__] > safe2) { | |||
| i__3 = i__; | |||
| rwork[i__] = (r__1 = work[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&work[i__]), abs(r__2)) + nz * eps * rwork[i__] | |||
| ; | |||
| } else { | |||
| i__3 = i__; | |||
| rwork[i__] = (r__1 = work[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&work[i__]), abs(r__2)) + nz * eps * rwork[i__] | |||
| + safe1; | |||
| } | |||
| /* L90: */ | |||
| } | |||
| kase = 0; | |||
| L100: | |||
| clacn2_(n, &work[*n + 1], &work[1], &ferr[j], &kase, isave); | |||
| if (kase != 0) { | |||
| if (kase == 1) { | |||
| /* Multiply by diag(W)*inv(op(A)**H). */ | |||
| cgetrs_(transt, n, &c__1, &af[af_offset], ldaf, &ipiv[1], & | |||
| work[1], n, info); | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__; | |||
| i__4 = i__; | |||
| i__5 = i__; | |||
| q__1.r = rwork[i__4] * work[i__5].r, q__1.i = rwork[i__4] | |||
| * work[i__5].i; | |||
| work[i__3].r = q__1.r, work[i__3].i = q__1.i; | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| /* Multiply by inv(op(A))*diag(W). */ | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__; | |||
| i__4 = i__; | |||
| i__5 = i__; | |||
| q__1.r = rwork[i__4] * work[i__5].r, q__1.i = rwork[i__4] | |||
| * work[i__5].i; | |||
| work[i__3].r = q__1.r, work[i__3].i = q__1.i; | |||
| /* L120: */ | |||
| } | |||
| cgetrs_(transn, n, &c__1, &af[af_offset], ldaf, &ipiv[1], & | |||
| work[1], n, info); | |||
| } | |||
| goto L100; | |||
| } | |||
| /* Normalize error. */ | |||
| lstres = 0.f; | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__3 = i__ + j * x_dim1; | |||
| r__3 = lstres, r__4 = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&x[i__ + j * x_dim1]), abs(r__2)); | |||
| lstres = f2cmax(r__3,r__4); | |||
| /* L130: */ | |||
| } | |||
| if (lstres != 0.f) { | |||
| ferr[j] /= lstres; | |||
| } | |||
| /* L140: */ | |||
| } | |||
| return 0; | |||
| /* End of CGERFS */ | |||
| } /* cgerfs_ */ | |||
| @@ -0,0 +1,381 @@ | |||
| /* 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 | |||
| @@ -0,0 +1,594 @@ | |||
| /* 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 CGERQ2 computes the RQ factorization of a general rectangular matrix using an unblocked algorit | |||
| hm. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGERQ2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgerq2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgerq2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgerq2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGERQ2( M, N, A, LDA, TAU, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGERQ2 computes an RQ factorization of a complex m by n matrix A: */ | |||
| /* > A = R * Q. */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the m by n matrix A. */ | |||
| /* > On exit, if m <= n, the upper triangle of the subarray */ | |||
| /* > A(1:m,n-m+1:n) contains the m by m upper triangular matrix R; */ | |||
| /* > if m >= n, the elements on and above the (m-n)-th subdiagonal */ | |||
| /* > contain the m by n upper trapezoidal matrix R; the remaining */ | |||
| /* > elements, with the array TAU, represent the unitary matrix */ | |||
| /* > Q as a product of elementary reflectors (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] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (M) */ | |||
| /* > \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 complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1)**H H(2)**H . . . H(k)**H, where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > 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(n-k+i+1:n) = 0 and v(n-k+i) = 1; conjg(v(1:n-k+i-1)) is stored on */ | |||
| /* > exit in A(m-k+i,1:n-k+i-1), and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgerq2_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, complex *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| complex alpha; | |||
| extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex * | |||
| , integer *, complex *, complex *, integer *, complex *), | |||
| clarfg_(integer *, complex *, complex *, integer *, complex *), | |||
| clacgv_(integer *, complex *, integer *), xerbla_(char *, integer | |||
| *, ftnlen); | |||
| /* -- 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 arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGERQ2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| k = f2cmin(*m,*n); | |||
| for (i__ = k; i__ >= 1; --i__) { | |||
| /* Generate elementary reflector H(i) to annihilate */ | |||
| /* A(m-k+i,1:n-k+i-1) */ | |||
| i__1 = *n - k + i__; | |||
| clacgv_(&i__1, &a[*m - k + i__ + a_dim1], lda); | |||
| i__1 = *m - k + i__ + (*n - k + i__) * a_dim1; | |||
| alpha.r = a[i__1].r, alpha.i = a[i__1].i; | |||
| i__1 = *n - k + i__; | |||
| clarfg_(&i__1, &alpha, &a[*m - k + i__ + a_dim1], lda, &tau[i__]); | |||
| /* Apply H(i) to A(1:m-k+i-1,1:n-k+i) from the right */ | |||
| i__1 = *m - k + i__ + (*n - k + i__) * a_dim1; | |||
| a[i__1].r = 1.f, a[i__1].i = 0.f; | |||
| i__1 = *m - k + i__ - 1; | |||
| i__2 = *n - k + i__; | |||
| clarf_("Right", &i__1, &i__2, &a[*m - k + i__ + a_dim1], lda, &tau[ | |||
| i__], &a[a_offset], lda, &work[1]); | |||
| i__1 = *m - k + i__ + (*n - k + i__) * a_dim1; | |||
| a[i__1].r = alpha.r, a[i__1].i = alpha.i; | |||
| i__1 = *n - k + i__ - 1; | |||
| clacgv_(&i__1, &a[*m - k + i__ + a_dim1], lda); | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* End of CGERQ2 */ | |||
| } /* cgerq2_ */ | |||
| @@ -0,0 +1,709 @@ | |||
| /* 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; | |||
| static integer c_n1 = -1; | |||
| static integer c__3 = 3; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGERQF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGERQF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgerqf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgerqf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgerqf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGERQF( M, N, A, LDA, TAU, WORK, LWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LWORK, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGERQF computes an RQ factorization of a complex M-by-N matrix A: */ | |||
| /* > A = R * Q. */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, */ | |||
| /* > if m <= n, the upper triangle of the subarray */ | |||
| /* > A(1:m,n-m+1:n) contains the M-by-M upper triangular matrix R; */ | |||
| /* > if m >= n, the elements on and above the (m-n)-th subdiagonal */ | |||
| /* > contain the M-by-N upper trapezoidal matrix R; */ | |||
| /* > the remaining elements, with the array TAU, represent the */ | |||
| /* > unitary matrix Q as a product of f2cmin(m,n) elementary */ | |||
| /* > reflectors (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] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= f2cmax(1,M). */ | |||
| /* > For optimum performance LWORK >= M*NB, where NB is */ | |||
| /* > the optimal blocksize. */ | |||
| /* > */ | |||
| /* > 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. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1)**H H(2)**H . . . H(k)**H, where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > 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(n-k+i+1:n) = 0 and v(n-k+i) = 1; conjg(v(1:n-k+i-1)) is stored on */ | |||
| /* > exit in A(m-k+i,1:n-k+i-1), and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgerqf_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, complex *work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| /* Local variables */ | |||
| integer i__, k, nbmin, iinfo; | |||
| extern /* Subroutine */ int cgerq2_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *); | |||
| integer ib, nb, ki, kk; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *); | |||
| integer mu, nu, nx; | |||
| extern /* Subroutine */ int clarft_(char *, char *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *), xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| integer ldwork, lwkopt; | |||
| logical lquery; | |||
| integer iws; | |||
| /* -- 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 arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info == 0) { | |||
| k = f2cmin(*m,*n); | |||
| if (k == 0) { | |||
| lwkopt = 1; | |||
| } else { | |||
| nb = ilaenv_(&c__1, "CGERQF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, | |||
| (ftnlen)1); | |||
| lwkopt = *m * nb; | |||
| } | |||
| work[1].r = (real) lwkopt, work[1].i = 0.f; | |||
| if (*lwork < f2cmax(1,*m) && ! lquery) { | |||
| *info = -7; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGERQF", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (k == 0) { | |||
| return 0; | |||
| } | |||
| nbmin = 2; | |||
| nx = 1; | |||
| iws = *m; | |||
| if (nb > 1 && nb < k) { | |||
| /* Determine when to cross over from blocked to unblocked code. */ | |||
| /* Computing MAX */ | |||
| i__1 = 0, i__2 = ilaenv_(&c__3, "CGERQF", " ", m, n, &c_n1, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nx = f2cmax(i__1,i__2); | |||
| if (nx < k) { | |||
| /* Determine if workspace is large enough for blocked code. */ | |||
| ldwork = *m; | |||
| iws = ldwork * nb; | |||
| if (*lwork < iws) { | |||
| /* Not enough workspace to use optimal NB: reduce NB and */ | |||
| /* determine the minimum value of NB. */ | |||
| nb = *lwork / ldwork; | |||
| /* Computing MAX */ | |||
| i__1 = 2, i__2 = ilaenv_(&c__2, "CGERQF", " ", m, n, &c_n1, & | |||
| c_n1, (ftnlen)6, (ftnlen)1); | |||
| nbmin = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| } | |||
| if (nb >= nbmin && nb < k && nx < k) { | |||
| /* Use blocked code initially. */ | |||
| /* The last kk rows are handled by the block method. */ | |||
| ki = (k - nx - 1) / nb * nb; | |||
| /* Computing MIN */ | |||
| i__1 = k, i__2 = ki + nb; | |||
| kk = f2cmin(i__1,i__2); | |||
| i__1 = k - kk + 1; | |||
| i__2 = -nb; | |||
| for (i__ = k - kk + ki + 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ | |||
| += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = k - i__ + 1; | |||
| ib = f2cmin(i__3,nb); | |||
| /* Compute the RQ factorization of the current block */ | |||
| /* A(m-k+i:m-k+i+ib-1,1:n-k+i+ib-1) */ | |||
| i__3 = *n - k + i__ + ib - 1; | |||
| cgerq2_(&ib, &i__3, &a[*m - k + i__ + a_dim1], lda, &tau[i__], & | |||
| work[1], &iinfo); | |||
| if (*m - k + i__ > 1) { | |||
| /* Form the triangular factor of the block reflector */ | |||
| /* H = H(i+ib-1) . . . H(i+1) H(i) */ | |||
| i__3 = *n - k + i__ + ib - 1; | |||
| clarft_("Backward", "Rowwise", &i__3, &ib, &a[*m - k + i__ + | |||
| a_dim1], lda, &tau[i__], &work[1], &ldwork); | |||
| /* Apply H to A(1:m-k+i-1,1:n-k+i+ib-1) from the right */ | |||
| i__3 = *m - k + i__ - 1; | |||
| i__4 = *n - k + i__ + ib - 1; | |||
| clarfb_("Right", "No transpose", "Backward", "Rowwise", &i__3, | |||
| &i__4, &ib, &a[*m - k + i__ + a_dim1], lda, &work[1], | |||
| &ldwork, &a[a_offset], lda, &work[ib + 1], &ldwork); | |||
| } | |||
| /* L10: */ | |||
| } | |||
| mu = *m - k + i__ + nb - 1; | |||
| nu = *n - k + i__ + nb - 1; | |||
| } else { | |||
| mu = *m; | |||
| nu = *n; | |||
| } | |||
| /* Use unblocked code to factor the last or only block */ | |||
| if (mu > 0 && nu > 0) { | |||
| cgerq2_(&mu, &nu, &a[a_offset], lda, &tau[1], &work[1], &iinfo); | |||
| } | |||
| work[1].r = (real) iws, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGERQF */ | |||
| } /* cgerqf_ */ | |||
| @@ -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) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| static complex c_b13 = {1.f,0.f}; | |||
| static integer c_n1 = -1; | |||
| /* > \brief \b CGESC2 solves a system of linear equations using the LU factorization with complete pivoting co | |||
| mputed by sgetc2. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGESC2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgesc2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgesc2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgesc2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGESC2( N, A, LDA, RHS, IPIV, JPIV, SCALE ) */ | |||
| /* INTEGER LDA, N */ | |||
| /* REAL SCALE */ | |||
| /* INTEGER IPIV( * ), JPIV( * ) */ | |||
| /* COMPLEX A( LDA, * ), RHS( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGESC2 solves a system of linear equations */ | |||
| /* > */ | |||
| /* > A * X = scale* RHS */ | |||
| /* > */ | |||
| /* > with a general N-by-N matrix A using the LU factorization with */ | |||
| /* > complete pivoting computed by CGETC2. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA, N) */ | |||
| /* > On entry, the LU part of the factorization of the n-by-n */ | |||
| /* > matrix A computed by CGETC2: A = P * L * U * Q */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1, N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] RHS */ | |||
| /* > \verbatim */ | |||
| /* > RHS is COMPLEX array, dimension N. */ | |||
| /* > On entry, the right hand side vector b. */ | |||
| /* > On exit, the solution vector X. */ | |||
| /* > \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 */ | |||
| /* > */ | |||
| /* > \param[out] SCALE */ | |||
| /* > \verbatim */ | |||
| /* > SCALE is REAL */ | |||
| /* > On exit, SCALE contains the scale factor. SCALE is chosen */ | |||
| /* > 0 <= SCALE <= 1 to prevent overflow in the solution. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEauxiliary */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > Bo Kagstrom and Peter Poromaa, Department of Computing Science, */ | |||
| /* > Umea University, S-901 87 Umea, Sweden. */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgesc2_(integer *n, complex *a, integer *lda, complex * | |||
| rhs, integer *ipiv, integer *jpiv, real *scale) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6; | |||
| real r__1; | |||
| complex q__1, q__2, q__3; | |||
| /* Local variables */ | |||
| complex temp; | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cscal_(integer *, complex *, complex *, | |||
| integer *), slabad_(real *, real *); | |||
| extern integer icamax_(integer *, complex *, integer *); | |||
| extern real slamch_(char *); | |||
| real bignum; | |||
| extern /* Subroutine */ int claswp_(integer *, complex *, integer *, | |||
| integer *, integer *, integer *, integer *); | |||
| real smlnum, 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 */ | |||
| /* ===================================================================== */ | |||
| /* Set constant to control overflow */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --rhs; | |||
| --ipiv; | |||
| --jpiv; | |||
| /* Function Body */ | |||
| eps = slamch_("P"); | |||
| smlnum = slamch_("S") / eps; | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| /* Apply permutations IPIV to RHS */ | |||
| i__1 = *n - 1; | |||
| claswp_(&c__1, &rhs[1], lda, &c__1, &i__1, &ipiv[1], &c__1); | |||
| /* Solve for L part */ | |||
| i__1 = *n - 1; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = *n; | |||
| for (j = i__ + 1; j <= i__2; ++j) { | |||
| i__3 = j; | |||
| i__4 = j; | |||
| i__5 = j + i__ * a_dim1; | |||
| i__6 = i__; | |||
| q__2.r = a[i__5].r * rhs[i__6].r - a[i__5].i * rhs[i__6].i, | |||
| q__2.i = a[i__5].r * rhs[i__6].i + a[i__5].i * rhs[i__6] | |||
| .r; | |||
| q__1.r = rhs[i__4].r - q__2.r, q__1.i = rhs[i__4].i - q__2.i; | |||
| rhs[i__3].r = q__1.r, rhs[i__3].i = q__1.i; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| /* Solve for U part */ | |||
| *scale = 1.f; | |||
| /* Check for scaling */ | |||
| i__ = icamax_(n, &rhs[1], &c__1); | |||
| if (smlnum * 2.f * c_abs(&rhs[i__]) > c_abs(&a[*n + *n * a_dim1])) { | |||
| r__1 = c_abs(&rhs[i__]); | |||
| q__1.r = .5f / r__1, q__1.i = 0.f / r__1; | |||
| temp.r = q__1.r, temp.i = q__1.i; | |||
| cscal_(n, &temp, &rhs[1], &c__1); | |||
| *scale *= temp.r; | |||
| } | |||
| for (i__ = *n; i__ >= 1; --i__) { | |||
| c_div(&q__1, &c_b13, &a[i__ + i__ * a_dim1]); | |||
| temp.r = q__1.r, temp.i = q__1.i; | |||
| i__1 = i__; | |||
| i__2 = i__; | |||
| q__1.r = rhs[i__2].r * temp.r - rhs[i__2].i * temp.i, q__1.i = rhs[ | |||
| i__2].r * temp.i + rhs[i__2].i * temp.r; | |||
| rhs[i__1].r = q__1.r, rhs[i__1].i = q__1.i; | |||
| i__1 = *n; | |||
| for (j = i__ + 1; j <= i__1; ++j) { | |||
| i__2 = i__; | |||
| i__3 = i__; | |||
| i__4 = j; | |||
| i__5 = i__ + j * a_dim1; | |||
| q__3.r = a[i__5].r * temp.r - a[i__5].i * temp.i, q__3.i = a[i__5] | |||
| .r * temp.i + a[i__5].i * temp.r; | |||
| q__2.r = rhs[i__4].r * q__3.r - rhs[i__4].i * q__3.i, q__2.i = | |||
| rhs[i__4].r * q__3.i + rhs[i__4].i * q__3.r; | |||
| q__1.r = rhs[i__3].r - q__2.r, q__1.i = rhs[i__3].i - q__2.i; | |||
| rhs[i__2].r = q__1.r, rhs[i__2].i = q__1.i; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| /* Apply permutations JPIV to the solution (RHS) */ | |||
| i__1 = *n - 1; | |||
| claswp_(&c__1, &rhs[1], lda, &c__1, &i__1, &jpiv[1], &c_n1); | |||
| return 0; | |||
| /* End of CGESC2 */ | |||
| } /* cgesc2_ */ | |||
| @@ -0,0 +1,575 @@ | |||
| /* 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> CGESV computes the solution to system of linear equations A * X = B for GE matrices (simple dr | |||
| iver) </b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGESV + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgesv.f | |||
| "> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgesv.f | |||
| "> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgesv.f | |||
| "> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO ) */ | |||
| /* INTEGER INFO, LDA, LDB, N, NRHS */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX A( LDA, * ), B( LDB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGESV computes the solution to a complex system of linear equations */ | |||
| /* > A * X = B, */ | |||
| /* > where A is an N-by-N matrix and X and B are N-by-NRHS matrices. */ | |||
| /* > */ | |||
| /* > The LU decomposition with partial pivoting and row interchanges is */ | |||
| /* > used to factor A as */ | |||
| /* > A = P * L * U, */ | |||
| /* > where P is a permutation matrix, L is unit lower triangular, and U is */ | |||
| /* > upper triangular. The factored form of A is then used to solve the */ | |||
| /* > system of equations A * X = B. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of linear equations, i.e., the order of the */ | |||
| /* > matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of columns */ | |||
| /* > of the matrix B. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the N-by-N coefficient matrix A. */ | |||
| /* > On exit, the factors L and U from the factorization */ | |||
| /* > A = P*L*U; the unit diagonal elements of L are not stored. */ | |||
| /* > \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) */ | |||
| /* > The pivot indices that define the permutation matrix P; */ | |||
| /* > row i of the matrix was interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the N-by-NRHS matrix of right hand side matrix B. */ | |||
| /* > On exit, if INFO = 0, the N-by-NRHS solution matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= 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: if INFO = i, U(i,i) is exactly zero. The factorization */ | |||
| /* > has been completed, but the factor U is exactly */ | |||
| /* > singular, so the solution could not be computed. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2017 */ | |||
| /* > \ingroup complexGEsolve */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgesv_(integer *n, integer *nrhs, complex *a, integer * | |||
| lda, integer *ipiv, complex *b, integer *ldb, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, i__1; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int cgetrf_(integer *, integer *, complex *, | |||
| integer *, integer *, integer *), xerbla_(char *, integer *, ftnlen), cgetrs_(char *, integer *, integer *, complex *, integer | |||
| *, integer *, complex *, integer *, integer *); | |||
| /* -- LAPACK driver 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 parameters. */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --ipiv; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*n < 0) { | |||
| *info = -1; | |||
| } else if (*nrhs < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -4; | |||
| } else if (*ldb < f2cmax(1,*n)) { | |||
| *info = -7; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGESV ", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Compute the LU factorization of A. */ | |||
| cgetrf_(n, n, &a[a_offset], lda, &ipiv[1], info); | |||
| if (*info == 0) { | |||
| /* Solve the system A*X = B, overwriting B with X. */ | |||
| cgetrs_("No transpose", n, nrhs, &a[a_offset], lda, &ipiv[1], &b[ | |||
| b_offset], ldb, info); | |||
| } | |||
| return 0; | |||
| /* End of CGESV */ | |||
| } /* cgesv_ */ | |||
| @@ -0,0 +1,654 @@ | |||
| /* 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; | |||
| static complex c_b10 = {-1.f,0.f}; | |||
| /* > \brief \b CGETC2 computes the LU factorization with complete pivoting of the general n-by-n matrix. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGETC2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgetc2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgetc2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgetc2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGETC2( N, A, LDA, IPIV, JPIV, INFO ) */ | |||
| /* INTEGER INFO, LDA, N */ | |||
| /* INTEGER IPIV( * ), JPIV( * ) */ | |||
| /* COMPLEX A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGETC2 computes an LU factorization, using complete pivoting, of the */ | |||
| /* > n-by-n matrix A. The factorization has the form A = P * L * U * Q, */ | |||
| /* > where P and Q are permutation matrices, L is lower triangular with */ | |||
| /* > unit diagonal elements and U is upper triangular. */ | |||
| /* > */ | |||
| /* > This is a level 1 BLAS version of the algorithm. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA, N) */ | |||
| /* > On entry, the n-by-n matrix to be factored. */ | |||
| /* > On exit, the factors L and U from the factorization */ | |||
| /* > A = P*L*U*Q; the unit diagonal elements of L are not stored. */ | |||
| /* > If U(k, k) appears to be less than SMIN, U(k, k) is given the */ | |||
| /* > value of SMIN, giving a nonsingular perturbed system. */ | |||
| /* > \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). */ | |||
| /* > The pivot indices; for 1 <= i <= N, row i of the */ | |||
| /* > matrix has been interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] 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 */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > > 0: if INFO = k, U(k, k) is likely to produce overflow if */ | |||
| /* > one tries to solve for x in Ax = b. So U is perturbed */ | |||
| /* > to avoid the overflow. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complexGEauxiliary */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > Bo Kagstrom and Peter Poromaa, Department of Computing Science, */ | |||
| /* > Umea University, S-901 87 Umea, Sweden. */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgetc2_(integer *n, complex *a, integer *lda, integer * | |||
| ipiv, integer *jpiv, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| real r__1; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| real smin, xmax; | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cgeru_(integer *, integer *, complex *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *), | |||
| cswap_(integer *, complex *, integer *, complex *, integer *), | |||
| slabad_(real *, real *); | |||
| integer ip, jp; | |||
| extern real slamch_(char *); | |||
| real bignum, smlnum, eps; | |||
| integer ipv, jpv; | |||
| /* -- 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 */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --ipiv; | |||
| --jpiv; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| /* Quick return if possible */ | |||
| if (*n == 0) { | |||
| return 0; | |||
| } | |||
| /* Set constants to control overflow */ | |||
| eps = slamch_("P"); | |||
| smlnum = slamch_("S") / eps; | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| /* Handle the case N=1 by itself */ | |||
| if (*n == 1) { | |||
| ipiv[1] = 1; | |||
| jpiv[1] = 1; | |||
| if (c_abs(&a[a_dim1 + 1]) < smlnum) { | |||
| *info = 1; | |||
| i__1 = a_dim1 + 1; | |||
| q__1.r = smlnum, q__1.i = 0.f; | |||
| a[i__1].r = q__1.r, a[i__1].i = q__1.i; | |||
| } | |||
| return 0; | |||
| } | |||
| /* Factorize A using complete pivoting. */ | |||
| /* Set pivots less than SMIN to SMIN */ | |||
| i__1 = *n - 1; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Find f2cmax element in matrix A */ | |||
| xmax = 0.f; | |||
| i__2 = *n; | |||
| for (ip = i__; ip <= i__2; ++ip) { | |||
| i__3 = *n; | |||
| for (jp = i__; jp <= i__3; ++jp) { | |||
| if (c_abs(&a[ip + jp * a_dim1]) >= xmax) { | |||
| xmax = c_abs(&a[ip + jp * a_dim1]); | |||
| ipv = ip; | |||
| jpv = jp; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| if (i__ == 1) { | |||
| /* Computing MAX */ | |||
| r__1 = eps * xmax; | |||
| smin = f2cmax(r__1,smlnum); | |||
| } | |||
| /* Swap rows */ | |||
| if (ipv != i__) { | |||
| cswap_(n, &a[ipv + a_dim1], lda, &a[i__ + a_dim1], lda); | |||
| } | |||
| ipiv[i__] = ipv; | |||
| /* Swap columns */ | |||
| if (jpv != i__) { | |||
| cswap_(n, &a[jpv * a_dim1 + 1], &c__1, &a[i__ * a_dim1 + 1], & | |||
| c__1); | |||
| } | |||
| jpiv[i__] = jpv; | |||
| /* Check for singularity */ | |||
| if (c_abs(&a[i__ + i__ * a_dim1]) < smin) { | |||
| *info = i__; | |||
| i__2 = i__ + i__ * a_dim1; | |||
| q__1.r = smin, q__1.i = 0.f; | |||
| a[i__2].r = q__1.r, a[i__2].i = q__1.i; | |||
| } | |||
| i__2 = *n; | |||
| for (j = i__ + 1; j <= i__2; ++j) { | |||
| i__3 = j + i__ * a_dim1; | |||
| c_div(&q__1, &a[j + i__ * a_dim1], &a[i__ + i__ * a_dim1]); | |||
| a[i__3].r = q__1.r, a[i__3].i = q__1.i; | |||
| /* L30: */ | |||
| } | |||
| i__2 = *n - i__; | |||
| i__3 = *n - i__; | |||
| cgeru_(&i__2, &i__3, &c_b10, &a[i__ + 1 + i__ * a_dim1], &c__1, &a[ | |||
| i__ + (i__ + 1) * a_dim1], lda, &a[i__ + 1 + (i__ + 1) * | |||
| a_dim1], lda); | |||
| /* L40: */ | |||
| } | |||
| if (c_abs(&a[*n + *n * a_dim1]) < smin) { | |||
| *info = *n; | |||
| i__1 = *n + *n * a_dim1; | |||
| q__1.r = smin, q__1.i = 0.f; | |||
| a[i__1].r = q__1.r, a[i__1].i = q__1.i; | |||
| } | |||
| /* Set last pivots to N */ | |||
| ipiv[*n] = *n; | |||
| jpiv[*n] = *n; | |||
| return 0; | |||
| /* End of CGETC2 */ | |||
| } /* cgetc2_ */ | |||
| @@ -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) | |||
| */ | |||
| /* Table of constant values */ | |||
| static complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGETF2 computes the LU factorization of a general m-by-n matrix using partial pivoting with row | |||
| interchanges (unblocked algorithm). */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGETF2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgetf2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgetf2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgetf2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGETF2( M, N, A, LDA, IPIV, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGETF2 computes an LU factorization of a general m-by-n matrix A */ | |||
| /* > using partial pivoting with row interchanges. */ | |||
| /* > */ | |||
| /* > The factorization has the form */ | |||
| /* > A = P * L * U */ | |||
| /* > where P is a permutation matrix, L is lower triangular with unit */ | |||
| /* > diagonal elements (lower trapezoidal if m > n), and U is upper */ | |||
| /* > triangular (upper trapezoidal if m < n). */ | |||
| /* > */ | |||
| /* > This is the right-looking Level 2 BLAS version of the algorithm. */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the m by n matrix to be factored. */ | |||
| /* > On exit, the factors L and U from the factorization */ | |||
| /* > A = P*L*U; the unit diagonal elements of L are not stored. */ | |||
| /* > \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 (f2cmin(M,N)) */ | |||
| /* > The pivot indices; for 1 <= i <= f2cmin(M,N), row i of the */ | |||
| /* > matrix was interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -k, the k-th argument had an illegal value */ | |||
| /* > > 0: if INFO = k, U(k,k) is exactly zero. The factorization */ | |||
| /* > has been completed, but the factor U is exactly */ | |||
| /* > singular, and division by zero will occur if it is used */ | |||
| /* > to solve a system of equations. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgetf2_(integer *m, integer *n, complex *a, integer *lda, | |||
| integer *ipiv, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cscal_(integer *, complex *, complex *, | |||
| integer *), cgeru_(integer *, integer *, complex *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *); | |||
| real sfmin; | |||
| extern /* Subroutine */ int cswap_(integer *, complex *, integer *, | |||
| complex *, integer *); | |||
| integer jp; | |||
| extern integer icamax_(integer *, complex *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| /* -- 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 */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --ipiv; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGETF2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*m == 0 || *n == 0) { | |||
| return 0; | |||
| } | |||
| /* Compute machine safe minimum */ | |||
| sfmin = slamch_("S"); | |||
| i__1 = f2cmin(*m,*n); | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Find pivot and test for singularity. */ | |||
| i__2 = *m - j + 1; | |||
| jp = j - 1 + icamax_(&i__2, &a[j + j * a_dim1], &c__1); | |||
| ipiv[j] = jp; | |||
| i__2 = jp + j * a_dim1; | |||
| if (a[i__2].r != 0.f || a[i__2].i != 0.f) { | |||
| /* Apply the interchange to columns 1:N. */ | |||
| if (jp != j) { | |||
| cswap_(n, &a[j + a_dim1], lda, &a[jp + a_dim1], lda); | |||
| } | |||
| /* Compute elements J+1:M of J-th column. */ | |||
| if (j < *m) { | |||
| if (c_abs(&a[j + j * a_dim1]) >= sfmin) { | |||
| i__2 = *m - j; | |||
| c_div(&q__1, &c_b1, &a[j + j * a_dim1]); | |||
| cscal_(&i__2, &q__1, &a[j + 1 + j * a_dim1], &c__1); | |||
| } else { | |||
| i__2 = *m - j; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = j + i__ + j * a_dim1; | |||
| c_div(&q__1, &a[j + i__ + j * a_dim1], &a[j + j * | |||
| a_dim1]); | |||
| a[i__3].r = q__1.r, a[i__3].i = q__1.i; | |||
| /* L20: */ | |||
| } | |||
| } | |||
| } | |||
| } else if (*info == 0) { | |||
| *info = j; | |||
| } | |||
| if (j < f2cmin(*m,*n)) { | |||
| /* Update trailing submatrix. */ | |||
| i__2 = *m - j; | |||
| i__3 = *n - j; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgeru_(&i__2, &i__3, &q__1, &a[j + 1 + j * a_dim1], &c__1, &a[j + | |||
| (j + 1) * a_dim1], lda, &a[j + 1 + (j + 1) * a_dim1], lda) | |||
| ; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* End of CGETF2 */ | |||
| } /* cgetf2_ */ | |||
| @@ -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 complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| /* > \brief \b CGETRF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGETRF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgetrf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgetrf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgetrf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGETRF( M, N, A, LDA, IPIV, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGETRF computes an LU factorization of a general M-by-N matrix A */ | |||
| /* > using partial pivoting with row interchanges. */ | |||
| /* > */ | |||
| /* > The factorization has the form */ | |||
| /* > A = P * L * U */ | |||
| /* > where P is a permutation matrix, L is lower triangular with unit */ | |||
| /* > diagonal elements (lower trapezoidal if m > n), and U is upper */ | |||
| /* > triangular (upper trapezoidal if m < n). */ | |||
| /* > */ | |||
| /* > This is the right-looking Level 3 BLAS version of the algorithm. */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix to be factored. */ | |||
| /* > On exit, the factors L and U from the factorization */ | |||
| /* > A = P*L*U; the unit diagonal elements of L are not stored. */ | |||
| /* > \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 (f2cmin(M,N)) */ | |||
| /* > The pivot indices; for 1 <= i <= f2cmin(M,N), row i of the */ | |||
| /* > matrix was interchanged with row IPIV(i). */ | |||
| /* > \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 = i, U(i,i) is exactly zero. The factorization */ | |||
| /* > has been completed, but the factor U is exactly */ | |||
| /* > singular, and division by zero will occur if it is used */ | |||
| /* > to solve a system of equations. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgetrf_(integer *m, integer *n, complex *a, integer *lda, | |||
| integer *ipiv, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, | |||
| integer *, complex *, complex *, integer *, complex *, integer *, | |||
| complex *, complex *, integer *); | |||
| integer iinfo; | |||
| extern /* Subroutine */ int ctrsm_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *); | |||
| integer jb, nb; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| extern /* Subroutine */ int claswp_(integer *, complex *, integer *, | |||
| integer *, integer *, integer *, integer *), cgetrf2_(integer *, | |||
| integer *, complex *, integer *, integer *, 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 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --ipiv; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGETRF", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*m == 0 || *n == 0) { | |||
| return 0; | |||
| } | |||
| /* Determine the block size for this environment. */ | |||
| nb = ilaenv_(&c__1, "CGETRF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, (ftnlen) | |||
| 1); | |||
| if (nb <= 1 || nb >= f2cmin(*m,*n)) { | |||
| /* Use unblocked code. */ | |||
| cgetrf2_(m, n, &a[a_offset], lda, &ipiv[1], info); | |||
| } else { | |||
| /* Use blocked code. */ | |||
| i__1 = f2cmin(*m,*n); | |||
| i__2 = nb; | |||
| for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = f2cmin(*m,*n) - j + 1; | |||
| jb = f2cmin(i__3,nb); | |||
| /* Factor diagonal and subdiagonal blocks and test for exact */ | |||
| /* singularity. */ | |||
| i__3 = *m - j + 1; | |||
| cgetrf2_(&i__3, &jb, &a[j + j * a_dim1], lda, &ipiv[j], &iinfo); | |||
| /* Adjust INFO and the pivot indices. */ | |||
| if (*info == 0 && iinfo > 0) { | |||
| *info = iinfo + j - 1; | |||
| } | |||
| /* Computing MIN */ | |||
| i__4 = *m, i__5 = j + jb - 1; | |||
| i__3 = f2cmin(i__4,i__5); | |||
| for (i__ = j; i__ <= i__3; ++i__) { | |||
| ipiv[i__] = j - 1 + ipiv[i__]; | |||
| /* L10: */ | |||
| } | |||
| /* Apply interchanges to columns 1:J-1. */ | |||
| i__3 = j - 1; | |||
| i__4 = j + jb - 1; | |||
| claswp_(&i__3, &a[a_offset], lda, &j, &i__4, &ipiv[1], &c__1); | |||
| if (j + jb <= *n) { | |||
| /* Apply interchanges to columns J+JB:N. */ | |||
| i__3 = *n - j - jb + 1; | |||
| i__4 = j + jb - 1; | |||
| claswp_(&i__3, &a[(j + jb) * a_dim1 + 1], lda, &j, &i__4, & | |||
| ipiv[1], &c__1); | |||
| /* Compute block row of U. */ | |||
| i__3 = *n - j - jb + 1; | |||
| ctrsm_("Left", "Lower", "No transpose", "Unit", &jb, &i__3, & | |||
| c_b1, &a[j + j * a_dim1], lda, &a[j + (j + jb) * | |||
| a_dim1], lda); | |||
| if (j + jb <= *m) { | |||
| /* Update trailing submatrix. */ | |||
| i__3 = *m - j - jb + 1; | |||
| i__4 = *n - j - jb + 1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemm_("No transpose", "No transpose", &i__3, &i__4, &jb, | |||
| &q__1, &a[j + jb + j * a_dim1], lda, &a[j + (j + | |||
| jb) * a_dim1], lda, &c_b1, &a[j + jb + (j + jb) * | |||
| a_dim1], lda); | |||
| } | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGETRF */ | |||
| } /* cgetrf_ */ | |||
| @@ -0,0 +1,691 @@ | |||
| /* 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 complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGETRF2 */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGETRF2( M, N, A, LDA, IPIV, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGETRF2 computes an LU factorization of a general M-by-N matrix A */ | |||
| /* > using partial pivoting with row interchanges. */ | |||
| /* > */ | |||
| /* > The factorization has the form */ | |||
| /* > A = P * L * U */ | |||
| /* > where P is a permutation matrix, L is lower triangular with unit */ | |||
| /* > diagonal elements (lower trapezoidal if m > n), and U is upper */ | |||
| /* > triangular (upper trapezoidal if m < n). */ | |||
| /* > */ | |||
| /* > This is the recursive version of the algorithm. It divides */ | |||
| /* > the matrix into four submatrices: */ | |||
| /* > */ | |||
| /* > [ A11 | A12 ] where A11 is n1 by n1 and A22 is n2 by n2 */ | |||
| /* > A = [ -----|----- ] with n1 = f2cmin(m,n)/2 */ | |||
| /* > [ A21 | A22 ] n2 = n-n1 */ | |||
| /* > */ | |||
| /* > [ A11 ] */ | |||
| /* > The subroutine calls itself to factor [ --- ], */ | |||
| /* > [ A12 ] */ | |||
| /* > [ A12 ] */ | |||
| /* > do the swaps on [ --- ], solve A12, update A22, */ | |||
| /* > [ A22 ] */ | |||
| /* > */ | |||
| /* > then calls itself to factor A22 and do the swaps on A21. */ | |||
| /* > */ | |||
| /* > \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 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix to be factored. */ | |||
| /* > On exit, the factors L and U from the factorization */ | |||
| /* > A = P*L*U; the unit diagonal elements of L are not stored. */ | |||
| /* > \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 (f2cmin(M,N)) */ | |||
| /* > The pivot indices; for 1 <= i <= f2cmin(M,N), row i of the */ | |||
| /* > matrix was interchanged with row IPIV(i). */ | |||
| /* > \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 = i, U(i,i) is exactly zero. The factorization */ | |||
| /* > has been completed, but the factor U is exactly */ | |||
| /* > singular, and division by zero will occur if it is used */ | |||
| /* > to solve a system of equations. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgetrf2_(integer *m, integer *n, complex *a, integer * | |||
| lda, integer *ipiv, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| complex temp; | |||
| integer i__; | |||
| extern /* Subroutine */ int cscal_(integer *, complex *, complex *, | |||
| integer *), cgemm_(char *, char *, integer *, integer *, integer * | |||
| , complex *, complex *, integer *, complex *, integer *, complex * | |||
| , complex *, integer *); | |||
| integer iinfo; | |||
| real sfmin; | |||
| extern /* Subroutine */ int ctrsm_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *); | |||
| integer n1, n2; | |||
| extern integer icamax_(integer *, complex *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), claswp_( | |||
| integer *, complex *, integer *, integer *, integer *, integer *, | |||
| 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..-- */ | |||
| /* June 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --ipiv; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGETRF2", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*m == 0 || *n == 0) { | |||
| return 0; | |||
| } | |||
| if (*m == 1) { | |||
| /* Use unblocked code for one row case */ | |||
| /* Just need to handle IPIV and INFO */ | |||
| ipiv[1] = 1; | |||
| i__1 = a_dim1 + 1; | |||
| if (a[i__1].r == 0.f && a[i__1].i == 0.f) { | |||
| *info = 1; | |||
| } | |||
| } else if (*n == 1) { | |||
| /* Use unblocked code for one column case */ | |||
| /* Compute machine safe minimum */ | |||
| sfmin = slamch_("S"); | |||
| /* Find pivot and test for singularity */ | |||
| i__ = icamax_(m, &a[a_dim1 + 1], &c__1); | |||
| ipiv[1] = i__; | |||
| i__1 = i__ + a_dim1; | |||
| if (a[i__1].r != 0.f || a[i__1].i != 0.f) { | |||
| /* Apply the interchange */ | |||
| if (i__ != 1) { | |||
| i__1 = a_dim1 + 1; | |||
| temp.r = a[i__1].r, temp.i = a[i__1].i; | |||
| i__1 = a_dim1 + 1; | |||
| i__2 = i__ + a_dim1; | |||
| a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i; | |||
| i__1 = i__ + a_dim1; | |||
| a[i__1].r = temp.r, a[i__1].i = temp.i; | |||
| } | |||
| /* Compute elements 2:M of the column */ | |||
| if (c_abs(&a[a_dim1 + 1]) >= sfmin) { | |||
| i__1 = *m - 1; | |||
| c_div(&q__1, &c_b1, &a[a_dim1 + 1]); | |||
| cscal_(&i__1, &q__1, &a[a_dim1 + 2], &c__1); | |||
| } else { | |||
| i__1 = *m - 1; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__ + 1 + a_dim1; | |||
| c_div(&q__1, &a[i__ + 1 + a_dim1], &a[a_dim1 + 1]); | |||
| a[i__2].r = q__1.r, a[i__2].i = q__1.i; | |||
| /* L10: */ | |||
| } | |||
| } | |||
| } else { | |||
| *info = 1; | |||
| } | |||
| } else { | |||
| /* Use recursive code */ | |||
| n1 = f2cmin(*m,*n) / 2; | |||
| n2 = *n - n1; | |||
| /* [ A11 ] */ | |||
| /* Factor [ --- ] */ | |||
| /* [ A21 ] */ | |||
| cgetrf2_(m, &n1, &a[a_offset], lda, &ipiv[1], &iinfo); | |||
| if (*info == 0 && iinfo > 0) { | |||
| *info = iinfo; | |||
| } | |||
| /* [ A12 ] */ | |||
| /* Apply interchanges to [ --- ] */ | |||
| /* [ A22 ] */ | |||
| claswp_(&n2, &a[(n1 + 1) * a_dim1 + 1], lda, &c__1, &n1, &ipiv[1], & | |||
| c__1); | |||
| /* Solve A12 */ | |||
| ctrsm_("L", "L", "N", "U", &n1, &n2, &c_b1, &a[a_offset], lda, &a[(n1 | |||
| + 1) * a_dim1 + 1], lda); | |||
| /* Update A22 */ | |||
| i__1 = *m - n1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemm_("N", "N", &i__1, &n2, &n1, &q__1, &a[n1 + 1 + a_dim1], lda, &a[ | |||
| (n1 + 1) * a_dim1 + 1], lda, &c_b1, &a[n1 + 1 + (n1 + 1) * | |||
| a_dim1], lda); | |||
| /* Factor A22 */ | |||
| i__1 = *m - n1; | |||
| cgetrf2_(&i__1, &n2, &a[n1 + 1 + (n1 + 1) * a_dim1], lda, &ipiv[n1 + | |||
| 1], &iinfo); | |||
| /* Adjust INFO and the pivot indices */ | |||
| if (*info == 0 && iinfo > 0) { | |||
| *info = iinfo + n1; | |||
| } | |||
| i__1 = f2cmin(*m,*n); | |||
| for (i__ = n1 + 1; i__ <= i__1; ++i__) { | |||
| ipiv[i__] += n1; | |||
| /* L20: */ | |||
| } | |||
| /* Apply interchanges to A21 */ | |||
| i__1 = n1 + 1; | |||
| i__2 = f2cmin(*m,*n); | |||
| claswp_(&n1, &a[a_dim1 + 1], lda, &i__1, &i__2, &ipiv[1], &c__1); | |||
| } | |||
| return 0; | |||
| /* End of CGETRF2 */ | |||
| } /* cgetrf2_ */ | |||
| @@ -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 complex c_b2 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGETRI */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGETRI + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgetri. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgetri. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgetri. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGETRI( N, A, LDA, IPIV, WORK, LWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LWORK, N */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX A( LDA, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGETRI computes the inverse of a matrix using the LU factorization */ | |||
| /* > computed by CGETRF. */ | |||
| /* > */ | |||
| /* > This method inverts U and then computes inv(A) by solving the system */ | |||
| /* > inv(A)*L = inv(U) for inv(A). */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the factors L and U from the factorization */ | |||
| /* > A = P*L*U as computed by CGETRF. */ | |||
| /* > On exit, if INFO = 0, the inverse of the original matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (N) */ | |||
| /* > The pivot indices from CGETRF; for 1<=i<=N, row i of the */ | |||
| /* > matrix was interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO=0, then WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= f2cmax(1,N). */ | |||
| /* > For optimal performance LWORK >= N*NB, where NB is */ | |||
| /* > the optimal blocksize returned by ILAENV. */ | |||
| /* > */ | |||
| /* > 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 */ | |||
| /* > > 0: if INFO = i, U(i,i) is exactly zero; the matrix is */ | |||
| /* > singular and its inverse could not be computed. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgetri_(integer *n, complex *a, integer *lda, integer * | |||
| ipiv, complex *work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, | |||
| integer *, complex *, complex *, integer *, complex *, integer *, | |||
| complex *, complex *, integer *), cgemv_(char *, | |||
| integer *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *); | |||
| integer nbmin; | |||
| extern /* Subroutine */ int cswap_(integer *, complex *, integer *, | |||
| complex *, integer *), ctrsm_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *); | |||
| integer jb, nb, jj, jp, nn; | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| integer ldwork; | |||
| extern /* Subroutine */ int ctrtri_(char *, char *, integer *, complex *, | |||
| integer *, integer *); | |||
| integer lwkopt; | |||
| logical lquery; | |||
| integer iws; | |||
| /* -- 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 */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --ipiv; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| nb = ilaenv_(&c__1, "CGETRI", " ", n, &c_n1, &c_n1, &c_n1, (ftnlen)6, ( | |||
| ftnlen)1); | |||
| lwkopt = *n * nb; | |||
| work[1].r = (real) lwkopt, work[1].i = 0.f; | |||
| lquery = *lwork == -1; | |||
| if (*n < 0) { | |||
| *info = -1; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -3; | |||
| } else if (*lwork < f2cmax(1,*n) && ! lquery) { | |||
| *info = -6; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGETRI", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0) { | |||
| return 0; | |||
| } | |||
| /* Form inv(U). If INFO > 0 from CTRTRI, then U is singular, */ | |||
| /* and the inverse is not computed. */ | |||
| ctrtri_("Upper", "Non-unit", n, &a[a_offset], lda, info); | |||
| if (*info > 0) { | |||
| return 0; | |||
| } | |||
| nbmin = 2; | |||
| ldwork = *n; | |||
| if (nb > 1 && nb < *n) { | |||
| /* Computing MAX */ | |||
| i__1 = ldwork * nb; | |||
| iws = f2cmax(i__1,1); | |||
| if (*lwork < iws) { | |||
| nb = *lwork / ldwork; | |||
| /* Computing MAX */ | |||
| i__1 = 2, i__2 = ilaenv_(&c__2, "CGETRI", " ", n, &c_n1, &c_n1, & | |||
| c_n1, (ftnlen)6, (ftnlen)1); | |||
| nbmin = f2cmax(i__1,i__2); | |||
| } | |||
| } else { | |||
| iws = *n; | |||
| } | |||
| /* Solve the equation inv(A)*L = inv(U) for inv(A). */ | |||
| if (nb < nbmin || nb >= *n) { | |||
| /* Use unblocked code. */ | |||
| for (j = *n; j >= 1; --j) { | |||
| /* Copy current column of L to WORK and replace with zeros. */ | |||
| i__1 = *n; | |||
| for (i__ = j + 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| i__3 = i__ + j * a_dim1; | |||
| work[i__2].r = a[i__3].r, work[i__2].i = a[i__3].i; | |||
| i__2 = i__ + j * a_dim1; | |||
| a[i__2].r = 0.f, a[i__2].i = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* Compute current column of inv(A). */ | |||
| if (j < *n) { | |||
| i__1 = *n - j; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemv_("No transpose", n, &i__1, &q__1, &a[(j + 1) * a_dim1 + | |||
| 1], lda, &work[j + 1], &c__1, &c_b2, &a[j * a_dim1 + | |||
| 1], &c__1); | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } else { | |||
| /* Use blocked code. */ | |||
| nn = (*n - 1) / nb * nb + 1; | |||
| i__1 = -nb; | |||
| for (j = nn; i__1 < 0 ? j >= 1 : j <= 1; j += i__1) { | |||
| /* Computing MIN */ | |||
| i__2 = nb, i__3 = *n - j + 1; | |||
| jb = f2cmin(i__2,i__3); | |||
| /* Copy current block column of L to WORK and replace with */ | |||
| /* zeros. */ | |||
| i__2 = j + jb - 1; | |||
| for (jj = j; jj <= i__2; ++jj) { | |||
| i__3 = *n; | |||
| for (i__ = jj + 1; i__ <= i__3; ++i__) { | |||
| i__4 = i__ + (jj - j) * ldwork; | |||
| i__5 = i__ + jj * a_dim1; | |||
| work[i__4].r = a[i__5].r, work[i__4].i = a[i__5].i; | |||
| i__4 = i__ + jj * a_dim1; | |||
| a[i__4].r = 0.f, a[i__4].i = 0.f; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| /* Compute current block column of inv(A). */ | |||
| if (j + jb <= *n) { | |||
| i__2 = *n - j - jb + 1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemm_("No transpose", "No transpose", n, &jb, &i__2, &q__1, & | |||
| a[(j + jb) * a_dim1 + 1], lda, &work[j + jb], &ldwork, | |||
| &c_b2, &a[j * a_dim1 + 1], lda); | |||
| } | |||
| ctrsm_("Right", "Lower", "No transpose", "Unit", n, &jb, &c_b2, & | |||
| work[j], &ldwork, &a[j * a_dim1 + 1], lda); | |||
| /* L50: */ | |||
| } | |||
| } | |||
| /* Apply column interchanges. */ | |||
| for (j = *n - 1; j >= 1; --j) { | |||
| jp = ipiv[j]; | |||
| if (jp != j) { | |||
| cswap_(n, &a[j * a_dim1 + 1], &c__1, &a[jp * a_dim1 + 1], &c__1); | |||
| } | |||
| /* L60: */ | |||
| } | |||
| work[1].r = (real) iws, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGETRI */ | |||
| } /* cgetri_ */ | |||
| @@ -0,0 +1,620 @@ | |||
| /* 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 complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| /* > \brief \b CGETRS */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGETRS + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgetrs. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgetrs. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgetrs. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGETRS( TRANS, N, NRHS, A, LDA, IPIV, B, LDB, INFO ) */ | |||
| /* CHARACTER TRANS */ | |||
| /* INTEGER INFO, LDA, LDB, N, NRHS */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX A( LDA, * ), B( LDB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGETRS solves a system of linear equations */ | |||
| /* > A * X = B, A**T * X = B, or A**H * X = B */ | |||
| /* > with a general N-by-N matrix A using the LU factorization computed */ | |||
| /* > by CGETRF. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > Specifies the form of the system of equations: */ | |||
| /* > = 'N': A * X = B (No transpose) */ | |||
| /* > = 'T': A**T * X = B (Transpose) */ | |||
| /* > = 'C': A**H * X = B (Conjugate transpose) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of columns */ | |||
| /* > of the matrix B. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > The factors L and U from the factorization A = P*L*U */ | |||
| /* > as computed by CGETRF. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (N) */ | |||
| /* > The pivot indices from CGETRF; for 1<=i<=N, row i of the */ | |||
| /* > matrix was interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the right hand side matrix B. */ | |||
| /* > On exit, the solution matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= 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 */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgetrs_(char *trans, integer *n, integer *nrhs, complex * | |||
| a, integer *lda, integer *ipiv, complex *b, integer *ldb, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, i__1; | |||
| /* Local variables */ | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int ctrsm_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *), xerbla_(char *, | |||
| integer *, ftnlen), claswp_(integer *, complex *, integer *, | |||
| integer *, integer *, integer *, integer *); | |||
| logical notran; | |||
| /* -- 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 */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --ipiv; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| notran = lsame_(trans, "N"); | |||
| if (! notran && ! lsame_(trans, "T") && ! lsame_( | |||
| trans, "C")) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*nrhs < 0) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -5; | |||
| } else if (*ldb < f2cmax(1,*n)) { | |||
| *info = -8; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGETRS", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0 || *nrhs == 0) { | |||
| return 0; | |||
| } | |||
| if (notran) { | |||
| /* Solve A * X = B. */ | |||
| /* Apply row interchanges to the right hand sides. */ | |||
| claswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c__1); | |||
| /* Solve L*X = B, overwriting B with X. */ | |||
| ctrsm_("Left", "Lower", "No transpose", "Unit", n, nrhs, &c_b1, &a[ | |||
| a_offset], lda, &b[b_offset], ldb); | |||
| /* Solve U*X = B, overwriting B with X. */ | |||
| ctrsm_("Left", "Upper", "No transpose", "Non-unit", n, nrhs, &c_b1, & | |||
| a[a_offset], lda, &b[b_offset], ldb); | |||
| } else { | |||
| /* Solve A**T * X = B or A**H * X = B. */ | |||
| /* Solve U**T *X = B or U**H *X = B, overwriting B with X. */ | |||
| ctrsm_("Left", "Upper", trans, "Non-unit", n, nrhs, &c_b1, &a[ | |||
| a_offset], lda, &b[b_offset], ldb); | |||
| /* Solve L**T *X = B, or L**H *X = B overwriting B with X. */ | |||
| ctrsm_("Left", "Lower", trans, "Unit", n, nrhs, &c_b1, &a[a_offset], | |||
| lda, &b[b_offset], ldb); | |||
| /* Apply row interchanges to the solution vectors. */ | |||
| claswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c_n1); | |||
| } | |||
| return 0; | |||
| /* End of CGETRS */ | |||
| } /* cgetrs_ */ | |||
| @@ -0,0 +1,939 @@ | |||
| /* 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 complex c_b1 = {0.f,0.f}; | |||
| static integer c_n1 = -1; | |||
| static integer c_n2 = -2; | |||
| static integer c__0 = 0; | |||
| /* > \brief \b CGETSLS */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGETSLS( TRANS, M, N, NRHS, A, LDA, B, LDB, */ | |||
| /* $ WORK, LWORK, INFO ) */ | |||
| /* CHARACTER TRANS */ | |||
| /* INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS */ | |||
| /* COMPLEX A( LDA, * ), B( LDB, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGETSLS solves overdetermined or underdetermined complex linear systems */ | |||
| /* > involving an M-by-N matrix A, using a tall skinny QR or short wide LQ */ | |||
| /* > factorization of A. It is assumed that A has full rank. */ | |||
| /* > */ | |||
| /* > */ | |||
| /* > */ | |||
| /* > The following options are provided: */ | |||
| /* > */ | |||
| /* > 1. If TRANS = 'N' and m >= n: find the least squares solution of */ | |||
| /* > an overdetermined system, i.e., solve the least squares problem */ | |||
| /* > minimize || B - A*X ||. */ | |||
| /* > */ | |||
| /* > 2. If TRANS = 'N' and m < n: find the minimum norm solution of */ | |||
| /* > an underdetermined system A * X = B. */ | |||
| /* > */ | |||
| /* > 3. If TRANS = 'C' and m >= n: find the minimum norm solution of */ | |||
| /* > an undetermined system A**T * X = B. */ | |||
| /* > */ | |||
| /* > 4. If TRANS = 'C' and m < n: find the least squares solution of */ | |||
| /* > an overdetermined system, i.e., solve the least squares problem */ | |||
| /* > minimize || B - A**T * X ||. */ | |||
| /* > */ | |||
| /* > Several right hand side vectors b and solution vectors x can be */ | |||
| /* > handled in a single call; they are stored as the columns of the */ | |||
| /* > M-by-NRHS right hand side matrix B and the N-by-NRHS solution */ | |||
| /* > matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > = 'N': the linear system involves A; */ | |||
| /* > = 'C': the linear system involves A**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 A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of */ | |||
| /* > columns of the matrices B and X. NRHS >=0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, */ | |||
| /* > A is overwritten by details of its QR or LQ */ | |||
| /* > factorization as returned by CGEQR or CGELQ. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the matrix B of right hand side vectors, stored */ | |||
| /* > columnwise; B is M-by-NRHS if TRANS = 'N', or N-by-NRHS */ | |||
| /* > if TRANS = 'C'. */ | |||
| /* > On exit, if INFO = 0, B is overwritten by the solution */ | |||
| /* > vectors, stored columnwise: */ | |||
| /* > if TRANS = 'N' and m >= n, rows 1 to n of B contain the least */ | |||
| /* > squares solution vectors. */ | |||
| /* > if TRANS = 'N' and m < n, rows 1 to N of B contain the */ | |||
| /* > minimum norm solution vectors; */ | |||
| /* > if TRANS = 'C' and m >= n, rows 1 to M of B contain the */ | |||
| /* > minimum norm solution vectors; */ | |||
| /* > if TRANS = 'C' and m < n, rows 1 to M of B contain the */ | |||
| /* > least squares solution vectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= MAX(1,M,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > (workspace) COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) contains optimal (or either minimal */ | |||
| /* > or optimal, if query was assumed) LWORK. */ | |||
| /* > See LWORK for details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > If LWORK = -1 or -2, then a workspace query is assumed. */ | |||
| /* > If LWORK = -1, the routine calculates optimal size of WORK for the */ | |||
| /* > optimal performance and returns this value in WORK(1). */ | |||
| /* > If LWORK = -2, the routine calculates minimal size of WORK and */ | |||
| /* > returns this value in WORK(1). */ | |||
| /* > \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 = i, the i-th diagonal element of the */ | |||
| /* > triangular factor of A is zero, so that A does not have */ | |||
| /* > full rank; the least squares solution could not be */ | |||
| /* > computed. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2017 */ | |||
| /* > \ingroup complexGEsolve */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgetsls_(char *trans, integer *m, integer *n, integer * | |||
| nrhs, complex *a, integer *lda, complex *b, integer *ldb, complex * | |||
| work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3; | |||
| real r__1; | |||
| /* Local variables */ | |||
| real anrm, bnrm; | |||
| logical tran; | |||
| integer brow, tszm, tszo, info2, i__, j, iascl, ibscl; | |||
| extern /* Subroutine */ int cgelq_(integer *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *, integer *); | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int cgeqr_(integer *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *, integer *); | |||
| integer minmn, maxmn; | |||
| complex workq[1]; | |||
| extern /* Subroutine */ int slabad_(real *, real *); | |||
| extern real clange_(char *, integer *, integer *, complex *, integer *, | |||
| real *); | |||
| extern /* Subroutine */ int clascl_(char *, integer *, integer *, real *, | |||
| real *, integer *, integer *, complex *, integer *, integer *); | |||
| complex tq[5]; | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int cgemlq_(char *, char *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, integer *), | |||
| claset_(char *, integer *, integer *, complex *, complex *, | |||
| complex *, integer *), xerbla_(char *, integer *, ftnlen), | |||
| cgemqr_(char *, char *, integer *, integer *, integer *, complex | |||
| *, integer *, complex *, integer *, complex *, integer *, complex | |||
| *, integer *, integer *); | |||
| integer scllen; | |||
| real bignum, smlnum; | |||
| integer wsizem, wsizeo; | |||
| logical lquery; | |||
| extern /* Subroutine */ int ctrtrs_(char *, char *, char *, integer *, | |||
| integer *, complex *, integer *, complex *, integer *, integer *); | |||
| integer lw1, lw2, mnk; | |||
| real dum[1]; | |||
| integer lwm, lwo; | |||
| /* -- LAPACK driver 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; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| minmn = f2cmin(*m,*n); | |||
| maxmn = f2cmax(*m,*n); | |||
| mnk = f2cmax(minmn,*nrhs); | |||
| tran = lsame_(trans, "C"); | |||
| lquery = *lwork == -1 || *lwork == -2; | |||
| if (! (lsame_(trans, "N") || lsame_(trans, "C"))) { | |||
| *info = -1; | |||
| } else if (*m < 0) { | |||
| *info = -2; | |||
| } else if (*n < 0) { | |||
| *info = -3; | |||
| } else if (*nrhs < 0) { | |||
| *info = -4; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -6; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(1,*m); | |||
| if (*ldb < f2cmax(i__1,*n)) { | |||
| *info = -8; | |||
| } | |||
| } | |||
| if (*info == 0) { | |||
| /* Determine the block size and minimum LWORK */ | |||
| if (*m >= *n) { | |||
| cgeqr_(m, n, &a[a_offset], lda, tq, &c_n1, workq, &c_n1, &info2); | |||
| tszo = (integer) tq[0].r; | |||
| lwo = (integer) workq[0].r; | |||
| cgemqr_("L", trans, m, nrhs, n, &a[a_offset], lda, tq, &tszo, &b[ | |||
| b_offset], ldb, workq, &c_n1, &info2); | |||
| /* Computing MAX */ | |||
| i__1 = lwo, i__2 = (integer) workq[0].r; | |||
| lwo = f2cmax(i__1,i__2); | |||
| cgeqr_(m, n, &a[a_offset], lda, tq, &c_n2, workq, &c_n2, &info2); | |||
| tszm = (integer) tq[0].r; | |||
| lwm = (integer) workq[0].r; | |||
| cgemqr_("L", trans, m, nrhs, n, &a[a_offset], lda, tq, &tszm, &b[ | |||
| b_offset], ldb, workq, &c_n1, &info2); | |||
| /* Computing MAX */ | |||
| i__1 = lwm, i__2 = (integer) workq[0].r; | |||
| lwm = f2cmax(i__1,i__2); | |||
| wsizeo = tszo + lwo; | |||
| wsizem = tszm + lwm; | |||
| } else { | |||
| cgelq_(m, n, &a[a_offset], lda, tq, &c_n1, workq, &c_n1, &info2); | |||
| tszo = (integer) tq[0].r; | |||
| lwo = (integer) workq[0].r; | |||
| cgemlq_("L", trans, n, nrhs, m, &a[a_offset], lda, tq, &tszo, &b[ | |||
| b_offset], ldb, workq, &c_n1, &info2); | |||
| /* Computing MAX */ | |||
| i__1 = lwo, i__2 = (integer) workq[0].r; | |||
| lwo = f2cmax(i__1,i__2); | |||
| cgelq_(m, n, &a[a_offset], lda, tq, &c_n2, workq, &c_n2, &info2); | |||
| tszm = (integer) tq[0].r; | |||
| lwm = (integer) workq[0].r; | |||
| cgemlq_("L", trans, n, nrhs, m, &a[a_offset], lda, tq, &tszm, &b[ | |||
| b_offset], ldb, workq, &c_n1, &info2); | |||
| /* Computing MAX */ | |||
| i__1 = lwm, i__2 = (integer) workq[0].r; | |||
| lwm = f2cmax(i__1,i__2); | |||
| wsizeo = tszo + lwo; | |||
| wsizem = tszm + lwm; | |||
| } | |||
| if (*lwork < wsizem && ! lquery) { | |||
| *info = -10; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGETSLS", &i__1, (ftnlen)7); | |||
| r__1 = (real) wsizeo; | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| return 0; | |||
| } | |||
| if (lquery) { | |||
| if (*lwork == -1) { | |||
| r__1 = (real) wsizeo; | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| } | |||
| if (*lwork == -2) { | |||
| r__1 = (real) wsizem; | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| } | |||
| return 0; | |||
| } | |||
| if (*lwork < wsizeo) { | |||
| lw1 = tszm; | |||
| lw2 = lwm; | |||
| } else { | |||
| lw1 = tszo; | |||
| lw2 = lwo; | |||
| } | |||
| /* Quick return if possible */ | |||
| /* Computing MIN */ | |||
| i__1 = f2cmin(*m,*n); | |||
| if (f2cmin(i__1,*nrhs) == 0) { | |||
| i__1 = f2cmax(*m,*n); | |||
| claset_("FULL", &i__1, nrhs, &c_b1, &c_b1, &b[b_offset], ldb); | |||
| return 0; | |||
| } | |||
| /* Get machine parameters */ | |||
| smlnum = slamch_("S") / slamch_("P"); | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| /* Scale A, B if f2cmax element outside range [SMLNUM,BIGNUM] */ | |||
| anrm = clange_("M", m, n, &a[a_offset], lda, dum); | |||
| iascl = 0; | |||
| if (anrm > 0.f && anrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| clascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 1; | |||
| } else if (anrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| clascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 2; | |||
| } else if (anrm == 0.f) { | |||
| /* Matrix all zero. Return zero solution. */ | |||
| claset_("F", &maxmn, nrhs, &c_b1, &c_b1, &b[b_offset], ldb) | |||
| ; | |||
| goto L50; | |||
| } | |||
| brow = *m; | |||
| if (tran) { | |||
| brow = *n; | |||
| } | |||
| bnrm = clange_("M", &brow, nrhs, &b[b_offset], ldb, dum); | |||
| ibscl = 0; | |||
| if (bnrm > 0.f && bnrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| clascl_("G", &c__0, &c__0, &bnrm, &smlnum, &brow, nrhs, &b[b_offset], | |||
| ldb, info); | |||
| ibscl = 1; | |||
| } else if (bnrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| clascl_("G", &c__0, &c__0, &bnrm, &bignum, &brow, nrhs, &b[b_offset], | |||
| ldb, info); | |||
| ibscl = 2; | |||
| } | |||
| if (*m >= *n) { | |||
| /* compute QR factorization of A */ | |||
| cgeqr_(m, n, &a[a_offset], lda, &work[lw2 + 1], &lw1, &work[1], &lw2, | |||
| info); | |||
| if (! tran) { | |||
| /* Least-Squares Problem f2cmin || A * X - B || */ | |||
| /* B(1:M,1:NRHS) := Q**T * B(1:M,1:NRHS) */ | |||
| cgemqr_("L", "C", m, nrhs, n, &a[a_offset], lda, &work[lw2 + 1], & | |||
| lw1, &b[b_offset], ldb, &work[1], &lw2, info); | |||
| /* B(1:N,1:NRHS) := inv(R) * B(1:N,1:NRHS) */ | |||
| ctrtrs_("U", "N", "N", n, nrhs, &a[a_offset], lda, &b[b_offset], | |||
| ldb, info); | |||
| if (*info > 0) { | |||
| return 0; | |||
| } | |||
| scllen = *n; | |||
| } else { | |||
| /* Overdetermined system of equations A**T * X = B */ | |||
| /* B(1:N,1:NRHS) := inv(R**T) * B(1:N,1:NRHS) */ | |||
| ctrtrs_("U", "C", "N", n, nrhs, &a[a_offset], lda, &b[b_offset], | |||
| ldb, info); | |||
| if (*info > 0) { | |||
| return 0; | |||
| } | |||
| /* B(N+1:M,1:NRHS) = CZERO */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = *n + 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| b[i__3].r = 0.f, b[i__3].i = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| /* B(1:M,1:NRHS) := Q(1:N,:) * B(1:N,1:NRHS) */ | |||
| cgemqr_("L", "N", m, nrhs, n, &a[a_offset], lda, &work[lw2 + 1], & | |||
| lw1, &b[b_offset], ldb, &work[1], &lw2, info); | |||
| scllen = *m; | |||
| } | |||
| } else { | |||
| /* Compute LQ factorization of A */ | |||
| cgelq_(m, n, &a[a_offset], lda, &work[lw2 + 1], &lw1, &work[1], &lw2, | |||
| info); | |||
| /* workspace at least M, optimally M*NB. */ | |||
| if (! tran) { | |||
| /* underdetermined system of equations A * X = B */ | |||
| /* B(1:M,1:NRHS) := inv(L) * B(1:M,1:NRHS) */ | |||
| ctrtrs_("L", "N", "N", m, nrhs, &a[a_offset], lda, &b[b_offset], | |||
| ldb, info); | |||
| if (*info > 0) { | |||
| return 0; | |||
| } | |||
| /* B(M+1:N,1:NRHS) = 0 */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = *m + 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| b[i__3].r = 0.f, b[i__3].i = 0.f; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| /* B(1:N,1:NRHS) := Q(1:N,:)**T * B(1:M,1:NRHS) */ | |||
| cgemlq_("L", "C", n, nrhs, m, &a[a_offset], lda, &work[lw2 + 1], & | |||
| lw1, &b[b_offset], ldb, &work[1], &lw2, info); | |||
| /* workspace at least NRHS, optimally NRHS*NB */ | |||
| scllen = *n; | |||
| } else { | |||
| /* overdetermined system f2cmin || A**T * X - B || */ | |||
| /* B(1:N,1:NRHS) := Q * B(1:N,1:NRHS) */ | |||
| cgemlq_("L", "N", n, nrhs, m, &a[a_offset], lda, &work[lw2 + 1], & | |||
| lw1, &b[b_offset], ldb, &work[1], &lw2, info); | |||
| /* workspace at least NRHS, optimally NRHS*NB */ | |||
| /* B(1:M,1:NRHS) := inv(L**T) * B(1:M,1:NRHS) */ | |||
| ctrtrs_("L", "C", "N", m, nrhs, &a[a_offset], lda, &b[b_offset], | |||
| ldb, info); | |||
| if (*info > 0) { | |||
| return 0; | |||
| } | |||
| scllen = *m; | |||
| } | |||
| } | |||
| /* Undo scaling */ | |||
| if (iascl == 1) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &smlnum, &scllen, nrhs, &b[b_offset] | |||
| , ldb, info); | |||
| } else if (iascl == 2) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &bignum, &scllen, nrhs, &b[b_offset] | |||
| , ldb, info); | |||
| } | |||
| if (ibscl == 1) { | |||
| clascl_("G", &c__0, &c__0, &smlnum, &bnrm, &scllen, nrhs, &b[b_offset] | |||
| , ldb, info); | |||
| } else if (ibscl == 2) { | |||
| clascl_("G", &c__0, &c__0, &bignum, &bnrm, &scllen, nrhs, &b[b_offset] | |||
| , ldb, info); | |||
| } | |||
| L50: | |||
| r__1 = (real) (tszo + lwo); | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of ZGETSLS */ | |||
| } /* cgetsls_ */ | |||
| @@ -0,0 +1,779 @@ | |||
| /* 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 CGETSQRHRT */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGETSQRHRT + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgetsqr | |||
| hrt.f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgetsqr | |||
| hrt.f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgetsqr | |||
| hrt.f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGETSQRHRT( M, N, MB1, NB1, NB2, A, LDA, T, LDT, WORK, */ | |||
| /* $ LWORK, INFO ) */ | |||
| /* IMPLICIT NONE */ | |||
| /* INTEGER INFO, LDA, LDT, LWORK, M, N, NB1, NB2, MB1 */ | |||
| /* COMPLEX*16 A( LDA, * ), T( LDT, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGETSQRHRT computes a NB2-sized column blocked QR-factorization */ | |||
| /* > of a complex M-by-N matrix A with M >= N, */ | |||
| /* > */ | |||
| /* > A = Q * R. */ | |||
| /* > */ | |||
| /* > The routine uses internally a NB1-sized column blocked and MB1-sized */ | |||
| /* > row blocked TSQR-factorization and perfors the reconstruction */ | |||
| /* > of the Householder vectors from the TSQR output. The routine also */ | |||
| /* > converts the R_tsqr factor from the TSQR-factorization output into */ | |||
| /* > the R factor that corresponds to the Householder QR-factorization, */ | |||
| /* > */ | |||
| /* > A = Q_tsqr * R_tsqr = Q * R. */ | |||
| /* > */ | |||
| /* > The output Q and R factors are stored in the same format as in CGEQRT */ | |||
| /* > (Q is in blocked compact WY-representation). See the documentation */ | |||
| /* > of CGEQRT for more details on the format. */ | |||
| /* > \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. M >= N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] MB1 */ | |||
| /* > \verbatim */ | |||
| /* > MB1 is INTEGER */ | |||
| /* > The row block size to be used in the blocked TSQR. */ | |||
| /* > MB1 > N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB1 */ | |||
| /* > \verbatim */ | |||
| /* > NB1 is INTEGER */ | |||
| /* > The column block size to be used in the blocked TSQR. */ | |||
| /* > N >= NB1 >= 1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB2 */ | |||
| /* > \verbatim */ | |||
| /* > NB2 is INTEGER */ | |||
| /* > The block size to be used in the blocked QR that is */ | |||
| /* > output. NB2 >= 1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > */ | |||
| /* > On entry: an M-by-N matrix A. */ | |||
| /* > */ | |||
| /* > On exit: */ | |||
| /* > a) the elements on and above the diagonal */ | |||
| /* > of the array contain the N-by-N upper-triangular */ | |||
| /* > matrix R corresponding to the Householder QR; */ | |||
| /* > b) the elements below the diagonal represent Q by */ | |||
| /* > the columns of blocked V (compact WY-representation). */ | |||
| /* > \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 array, dimension (LDT,N)) */ | |||
| /* > The upper triangular block reflectors stored in compact form */ | |||
| /* > as a sequence of upper triangular blocks. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= NB2. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > (workspace) COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > LWORK >= MAX( LWT + LW1, MAX( LWT+N*N+LW2, LWT+N*N+N ) ), */ | |||
| /* > where */ | |||
| /* > NUM_ALL_ROW_BLOCKS = CEIL((M-N)/(MB1-N)), */ | |||
| /* > NB1LOCAL = MIN(NB1,N). */ | |||
| /* > LWT = NUM_ALL_ROW_BLOCKS * N * NB1LOCAL, */ | |||
| /* > LW1 = NB1LOCAL * N, */ | |||
| /* > LW2 = NB1LOCAL * MAX( NB1LOCAL, ( N - NB1LOCAL ) ), */ | |||
| /* > 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. */ | |||
| /* > \ingroup comlpexOTHERcomputational */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > November 2020, Igor Kozachenko, */ | |||
| /* > Computer Science Division, */ | |||
| /* > University of California, Berkeley */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgetsqrhrt_(integer *m, integer *n, integer *mb1, | |||
| integer *nb1, integer *nb2, complex *a, integer *lda, complex *t, | |||
| integer *ldt, complex *work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, i__1, i__2, i__3, i__4; | |||
| real r__1, r__2, r__3; | |||
| complex q__1, q__2; | |||
| /* Local variables */ | |||
| integer ldwt, lworkopt, i__, j; | |||
| extern /* Subroutine */ int cungtsqr_row_(integer *, integer *, integer * | |||
| , integer *, complex *, integer *, complex *, integer *, complex * | |||
| , integer *, integer *); | |||
| integer iinfo; | |||
| extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, | |||
| complex *, integer *), cunhr_col_(integer *, integer *, integer * | |||
| , complex *, integer *, complex *, integer *, complex *, integer * | |||
| ), xerbla_(char *, integer *, ftnlen); | |||
| logical lquery; | |||
| integer lw1, lw2, num_all_row_blocks__, lwt; | |||
| extern /* Subroutine */ int clatsqr_(integer *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, integer *, complex *, | |||
| integer *, integer *); | |||
| integer nb1local, nb2local; | |||
| /* -- LAPACK computational routine -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* ===================================================================== */ | |||
| /* 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 || *m < *n) { | |||
| *info = -2; | |||
| } else if (*mb1 <= *n) { | |||
| *info = -3; | |||
| } else if (*nb1 < 1) { | |||
| *info = -4; | |||
| } else if (*nb2 < 1) { | |||
| *info = -5; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -7; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = f2cmin(*nb2,*n); | |||
| if (*ldt < f2cmax(i__1,i__2)) { | |||
| *info = -9; | |||
| } else { | |||
| /* Test the input LWORK for the dimension of the array WORK. */ | |||
| /* This workspace is used to store array: */ | |||
| /* a) Matrix T and WORK for CLATSQR; */ | |||
| /* b) N-by-N upper-triangular factor R_tsqr; */ | |||
| /* c) Matrix T and array WORK for CUNGTSQR_ROW; */ | |||
| /* d) Diagonal D for CUNHR_COL. */ | |||
| if (*lwork < *n * *n + 1 && ! lquery) { | |||
| *info = -11; | |||
| } else { | |||
| /* Set block size for column blocks */ | |||
| nb1local = f2cmin(*nb1,*n); | |||
| /* Computing MAX */ | |||
| r__3 = (real) (*m - *n) / (real) (*mb1 - *n) + .5f; | |||
| r__1 = 1.f, r__2 = r_int(&r__3); | |||
| num_all_row_blocks__ = f2cmax(r__1,r__2); | |||
| /* Length and leading dimension of WORK array to place */ | |||
| /* T array in TSQR. */ | |||
| lwt = num_all_row_blocks__ * *n * nb1local; | |||
| ldwt = nb1local; | |||
| /* Length of TSQR work array */ | |||
| lw1 = nb1local * *n; | |||
| /* Length of CUNGTSQR_ROW work array. */ | |||
| /* Computing MAX */ | |||
| i__1 = nb1local, i__2 = *n - nb1local; | |||
| lw2 = nb1local * f2cmax(i__1,i__2); | |||
| /* Computing MAX */ | |||
| /* Computing MAX */ | |||
| i__3 = lwt + *n * *n + lw2, i__4 = lwt + *n * *n + *n; | |||
| i__1 = lwt + lw1, i__2 = f2cmax(i__3,i__4); | |||
| lworkopt = f2cmax(i__1,i__2); | |||
| if (*lwork < f2cmax(1,lworkopt) && ! lquery) { | |||
| *info = -11; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| /* Handle error in the input parameters and return workspace query. */ | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGETSQRHRT", &i__1, (ftnlen)10); | |||
| return 0; | |||
| } else if (lquery) { | |||
| q__1.r = (real) lworkopt, q__1.i = 0.f; | |||
| work[1].r = q__1.r, work[1].i = q__1.i; | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (f2cmin(*m,*n) == 0) { | |||
| q__1.r = (real) lworkopt, q__1.i = 0.f; | |||
| work[1].r = q__1.r, work[1].i = q__1.i; | |||
| return 0; | |||
| } | |||
| nb2local = f2cmin(*nb2,*n); | |||
| /* (1) Perform TSQR-factorization of the M-by-N matrix A. */ | |||
| clatsqr_(m, n, mb1, &nb1local, &a[a_offset], lda, &work[1], &ldwt, &work[ | |||
| lwt + 1], &lw1, &iinfo); | |||
| /* (2) Copy the factor R_tsqr stored in the upper-triangular part */ | |||
| /* of A into the square matrix in the work array */ | |||
| /* WORK(LWT+1:LWT+N*N) column-by-column. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| ccopy_(&j, &a[j * a_dim1 + 1], &c__1, &work[lwt + *n * (j - 1) + 1], & | |||
| c__1); | |||
| } | |||
| /* (3) Generate a M-by-N matrix Q with orthonormal columns from */ | |||
| /* the result stored below the diagonal in the array A in place. */ | |||
| cungtsqr_row_(m, n, mb1, &nb1local, &a[a_offset], lda, &work[1], &ldwt, & | |||
| work[lwt + *n * *n + 1], &lw2, &iinfo); | |||
| /* (4) Perform the reconstruction of Householder vectors from */ | |||
| /* the matrix Q (stored in A) in place. */ | |||
| cunhr_col_(m, n, &nb2local, &a[a_offset], lda, &t[t_offset], ldt, &work[ | |||
| lwt + *n * *n + 1], &iinfo); | |||
| /* (5) Copy the factor R_tsqr stored in the square matrix in the */ | |||
| /* work array WORK(LWT+1:LWT+N*N) into the upper-triangular */ | |||
| /* part of A. */ | |||
| /* (6) Compute from R_tsqr the factor R_hr corresponding to */ | |||
| /* the reconstructed Householder vectors, i.e. R_hr = S * R_tsqr. */ | |||
| /* This multiplication by the sign matrix S on the left means */ | |||
| /* changing the sign of I-th row of the matrix R_tsqr according */ | |||
| /* to sign of the I-th diagonal element DIAG(I) of the matrix S. */ | |||
| /* DIAG is stored in WORK( LWT+N*N+1 ) from the CUNHR_COL output. */ | |||
| /* (5) and (6) can be combined in a single loop, so the rows in A */ | |||
| /* are accessed only once. */ | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = lwt + *n * *n + i__; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| if (work[i__2].r == q__1.r && work[i__2].i == q__1.i) { | |||
| i__2 = *n; | |||
| for (j = i__; j <= i__2; ++j) { | |||
| i__3 = i__ + j * a_dim1; | |||
| q__2.r = -1.f, q__2.i = 0.f; | |||
| i__4 = lwt + *n * (j - 1) + i__; | |||
| q__1.r = q__2.r * work[i__4].r - q__2.i * work[i__4].i, | |||
| q__1.i = q__2.r * work[i__4].i + q__2.i * work[i__4] | |||
| .r; | |||
| a[i__3].r = q__1.r, a[i__3].i = q__1.i; | |||
| } | |||
| } else { | |||
| i__2 = *n - i__ + 1; | |||
| ccopy_(&i__2, &work[lwt + *n * (i__ - 1) + i__], n, &a[i__ + i__ * | |||
| a_dim1], lda); | |||
| } | |||
| } | |||
| q__1.r = (real) lworkopt, q__1.i = 0.f; | |||
| work[1].r = q__1.r, work[1].i = q__1.i; | |||
| return 0; | |||
| /* End of CGETSQRHRT */ | |||
| } /* cgetsqrhrt_ */ | |||
| @@ -0,0 +1,721 @@ | |||
| /* 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 CGGBAK */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGGBAK + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cggbak. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cggbak. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cggbak. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGGBAK( JOB, SIDE, N, ILO, IHI, LSCALE, RSCALE, M, V, */ | |||
| /* LDV, INFO ) */ | |||
| /* CHARACTER JOB, SIDE */ | |||
| /* INTEGER IHI, ILO, INFO, LDV, M, N */ | |||
| /* REAL LSCALE( * ), RSCALE( * ) */ | |||
| /* COMPLEX V( LDV, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGGBAK forms the right or left eigenvectors of a complex generalized */ | |||
| /* > eigenvalue problem A*x = lambda*B*x, by backward transformation on */ | |||
| /* > the computed eigenvectors of the balanced pair of matrices output by */ | |||
| /* > CGGBAL. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOB */ | |||
| /* > \verbatim */ | |||
| /* > JOB is CHARACTER*1 */ | |||
| /* > Specifies the type of backward transformation required: */ | |||
| /* > = 'N': do nothing, return immediately; */ | |||
| /* > = 'P': do backward transformation for permutation only; */ | |||
| /* > = 'S': do backward transformation for scaling only; */ | |||
| /* > = 'B': do backward transformations for both permutation and */ | |||
| /* > scaling. */ | |||
| /* > JOB must be the same as the argument JOB supplied to CGGBAL. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'R': V contains right eigenvectors; */ | |||
| /* > = 'L': V contains left eigenvectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of rows of the matrix V. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ILO */ | |||
| /* > \verbatim */ | |||
| /* > ILO is INTEGER */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IHI */ | |||
| /* > \verbatim */ | |||
| /* > IHI is INTEGER */ | |||
| /* > The integers ILO and IHI determined by CGGBAL. */ | |||
| /* > 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LSCALE */ | |||
| /* > \verbatim */ | |||
| /* > LSCALE is REAL array, dimension (N) */ | |||
| /* > Details of the permutations and/or scaling factors applied */ | |||
| /* > to the left side of A and B, as returned by CGGBAL. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] RSCALE */ | |||
| /* > \verbatim */ | |||
| /* > RSCALE is REAL array, dimension (N) */ | |||
| /* > Details of the permutations and/or scaling factors applied */ | |||
| /* > to the right side of A and B, as returned by CGGBAL. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of columns of the matrix V. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX array, dimension (LDV,M) */ | |||
| /* > On entry, the matrix of right or left eigenvectors to be */ | |||
| /* > transformed, as returned by CTGEVC. */ | |||
| /* > On exit, V is overwritten by the transformed eigenvectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the matrix V. LDV >= 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. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGBcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > See R.C. Ward, Balancing the generalized eigenvalue problem, */ | |||
| /* > SIAM J. Sci. Stat. Comp. 2 (1981), 141-152. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cggbak_(char *job, char *side, integer *n, integer *ilo, | |||
| integer *ihi, real *lscale, real *rscale, integer *m, complex *v, | |||
| integer *ldv, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer v_dim1, v_offset, i__1; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int cswap_(integer *, complex *, integer *, | |||
| complex *, integer *); | |||
| logical leftv; | |||
| extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer | |||
| *), xerbla_(char *, integer *, ftnlen); | |||
| logical rightv; | |||
| /* -- 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 */ | |||
| --lscale; | |||
| --rscale; | |||
| v_dim1 = *ldv; | |||
| v_offset = 1 + v_dim1 * 1; | |||
| v -= v_offset; | |||
| /* Function Body */ | |||
| rightv = lsame_(side, "R"); | |||
| leftv = lsame_(side, "L"); | |||
| *info = 0; | |||
| if (! lsame_(job, "N") && ! lsame_(job, "P") && ! lsame_(job, "S") | |||
| && ! lsame_(job, "B")) { | |||
| *info = -1; | |||
| } else if (! rightv && ! leftv) { | |||
| *info = -2; | |||
| } else if (*n < 0) { | |||
| *info = -3; | |||
| } else if (*ilo < 1) { | |||
| *info = -4; | |||
| } else if (*n == 0 && *ihi == 0 && *ilo != 1) { | |||
| *info = -4; | |||
| } else if (*n > 0 && (*ihi < *ilo || *ihi > f2cmax(1,*n))) { | |||
| *info = -5; | |||
| } else if (*n == 0 && *ilo == 1 && *ihi != 0) { | |||
| *info = -5; | |||
| } else if (*m < 0) { | |||
| *info = -8; | |||
| } else if (*ldv < f2cmax(1,*n)) { | |||
| *info = -10; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGGBAK", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0) { | |||
| return 0; | |||
| } | |||
| if (*m == 0) { | |||
| return 0; | |||
| } | |||
| if (lsame_(job, "N")) { | |||
| return 0; | |||
| } | |||
| if (*ilo == *ihi) { | |||
| goto L30; | |||
| } | |||
| /* Backward balance */ | |||
| if (lsame_(job, "S") || lsame_(job, "B")) { | |||
| /* Backward transformation on right eigenvectors */ | |||
| if (rightv) { | |||
| i__1 = *ihi; | |||
| for (i__ = *ilo; i__ <= i__1; ++i__) { | |||
| csscal_(m, &rscale[i__], &v[i__ + v_dim1], ldv); | |||
| /* L10: */ | |||
| } | |||
| } | |||
| /* Backward transformation on left eigenvectors */ | |||
| if (leftv) { | |||
| i__1 = *ihi; | |||
| for (i__ = *ilo; i__ <= i__1; ++i__) { | |||
| csscal_(m, &lscale[i__], &v[i__ + v_dim1], ldv); | |||
| /* L20: */ | |||
| } | |||
| } | |||
| } | |||
| /* Backward permutation */ | |||
| L30: | |||
| if (lsame_(job, "P") || lsame_(job, "B")) { | |||
| /* Backward permutation on right eigenvectors */ | |||
| if (rightv) { | |||
| if (*ilo == 1) { | |||
| goto L50; | |||
| } | |||
| for (i__ = *ilo - 1; i__ >= 1; --i__) { | |||
| k = rscale[i__]; | |||
| if (k == i__) { | |||
| goto L40; | |||
| } | |||
| cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); | |||
| L40: | |||
| ; | |||
| } | |||
| L50: | |||
| if (*ihi == *n) { | |||
| goto L70; | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = *ihi + 1; i__ <= i__1; ++i__) { | |||
| k = rscale[i__]; | |||
| if (k == i__) { | |||
| goto L60; | |||
| } | |||
| cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); | |||
| L60: | |||
| ; | |||
| } | |||
| } | |||
| /* Backward permutation on left eigenvectors */ | |||
| L70: | |||
| if (leftv) { | |||
| if (*ilo == 1) { | |||
| goto L90; | |||
| } | |||
| for (i__ = *ilo - 1; i__ >= 1; --i__) { | |||
| k = lscale[i__]; | |||
| if (k == i__) { | |||
| goto L80; | |||
| } | |||
| cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); | |||
| L80: | |||
| ; | |||
| } | |||
| L90: | |||
| if (*ihi == *n) { | |||
| goto L110; | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = *ihi + 1; i__ <= i__1; ++i__) { | |||
| k = lscale[i__]; | |||
| if (k == i__) { | |||
| goto L100; | |||
| } | |||
| cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); | |||
| L100: | |||
| ; | |||
| } | |||
| } | |||
| } | |||
| L110: | |||
| return 0; | |||
| /* End of CGGBAK */ | |||
| } /* cggbak_ */ | |||