1 /* f2c.h -- Standard Fortran to C header file */
3 /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
5 - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
23 typedef long long BLASLONG;
24 typedef unsigned long long BLASULONG;
26 typedef long BLASLONG;
27 typedef unsigned long BLASULONG;
31 typedef BLASLONG blasint;
33 #define blasabs(x) llabs(x)
35 #define blasabs(x) labs(x)
39 #define blasabs(x) abs(x)
42 typedef blasint integer;
44 typedef unsigned int uinteger;
45 typedef char *address;
46 typedef short int shortint;
48 typedef double doublereal;
49 typedef struct { real r, i; } complex;
50 typedef struct { doublereal r, i; } doublecomplex;
51 static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
52 static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
53 static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
54 static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
55 #define pCf(z) (*_pCf(z))
56 #define pCd(z) (*_pCd(z))
58 typedef short int shortlogical;
59 typedef char logical1;
60 typedef char integer1;
65 /* Extern is for use with -E */
76 /*external read, write*/
85 /*internal read, write*/
115 /*rewind, backspace, endfile*/
127 ftnint *inex; /*parameters in standard's order*/
153 union Multitype { /* for multiple entry points */
164 typedef union Multitype Multitype;
166 struct Vardesc { /* for Namelist */
172 typedef struct Vardesc Vardesc;
179 typedef struct Namelist Namelist;
181 #define abs(x) ((x) >= 0 ? (x) : -(x))
182 #define dabs(x) (fabs(x))
183 #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
184 #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
185 #define dmin(a,b) (f2cmin(a,b))
186 #define dmax(a,b) (f2cmax(a,b))
187 #define bit_test(a,b) ((a) >> (b) & 1)
188 #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
189 #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
191 #define abort_() { sig_die("Fortran abort routine called", 1); }
192 #define c_abs(z) (cabsf(Cf(z)))
193 #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
194 #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
195 #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
196 #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
197 #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
198 #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
199 //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
200 #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
201 #define d_abs(x) (fabs(*(x)))
202 #define d_acos(x) (acos(*(x)))
203 #define d_asin(x) (asin(*(x)))
204 #define d_atan(x) (atan(*(x)))
205 #define d_atn2(x, y) (atan2(*(x),*(y)))
206 #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
207 #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); }
208 #define d_cos(x) (cos(*(x)))
209 #define d_cosh(x) (cosh(*(x)))
210 #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
211 #define d_exp(x) (exp(*(x)))
212 #define d_imag(z) (cimag(Cd(z)))
213 #define r_imag(z) (cimag(Cf(z)))
214 #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
215 #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
216 #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
217 #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
218 #define d_log(x) (log(*(x)))
219 #define d_mod(x, y) (fmod(*(x), *(y)))
220 #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
221 #define d_nint(x) u_nint(*(x))
222 #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
223 #define d_sign(a,b) u_sign(*(a),*(b))
224 #define r_sign(a,b) u_sign(*(a),*(b))
225 #define d_sin(x) (sin(*(x)))
226 #define d_sinh(x) (sinh(*(x)))
227 #define d_sqrt(x) (sqrt(*(x)))
228 #define d_tan(x) (tan(*(x)))
229 #define d_tanh(x) (tanh(*(x)))
230 #define i_abs(x) abs(*(x))
231 #define i_dnnt(x) ((integer)u_nint(*(x)))
232 #define i_len(s, n) (n)
233 #define i_nint(x) ((integer)u_nint(*(x)))
234 #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
235 #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
236 #define pow_si(B,E) spow_ui(*(B),*(E))
237 #define pow_ri(B,E) spow_ui(*(B),*(E))
238 #define pow_di(B,E) dpow_ui(*(B),*(E))
239 #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
240 #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
241 #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
242 #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++ = ' '; }
243 #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
244 #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]; }
245 #define sig_die(s, kill) { exit(1); }
246 #define s_stop(s, n) {exit(0);}
247 static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
248 #define z_abs(z) (cabs(Cd(z)))
249 #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
250 #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
251 #define myexit_() break;
252 #define mycycle() continue;
253 #define myceiling(w) {ceil(w)}
254 #define myhuge(w) {HUGE_VAL}
255 //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
256 #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
258 /* procedure parameter types for -A and -C++ */
260 #define F2C_proc_par_types 1
262 typedef logical (*L_fp)(...);
264 typedef logical (*L_fp)();
267 static float spow_ui(float x, integer n) {
268 float pow=1.0; unsigned long int u;
270 if(n < 0) n = -n, x = 1/x;
279 static double dpow_ui(double x, integer n) {
280 double pow=1.0; unsigned long int u;
282 if(n < 0) n = -n, x = 1/x;
291 static _Complex float cpow_ui(_Complex float x, integer n) {
292 _Complex float pow=1.0; unsigned long int u;
294 if(n < 0) n = -n, x = 1/x;
303 static _Complex double zpow_ui(_Complex double x, integer n) {
304 _Complex double pow=1.0; unsigned long int u;
306 if(n < 0) n = -n, x = 1/x;
315 static integer pow_ii(integer x, integer n) {
316 integer pow; unsigned long int u;
318 if (n == 0 || x == 1) pow = 1;
319 else if (x != -1) pow = x == 0 ? 1/x : 0;
322 if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
332 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
334 double m; integer i, mi;
335 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
336 if (w[i-1]>m) mi=i ,m=w[i-1];
339 static integer smaxloc_(float *w, integer s, integer e, integer *n)
341 float m; integer i, mi;
342 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
343 if (w[i-1]>m) mi=i ,m=w[i-1];
346 static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
347 integer n = *n_, incx = *incx_, incy = *incy_, i;
348 _Complex float zdotc = 0.0;
349 if (incx == 1 && incy == 1) {
350 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
351 zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
354 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
355 zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
360 static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
361 integer n = *n_, incx = *incx_, incy = *incy_, i;
362 _Complex double zdotc = 0.0;
363 if (incx == 1 && incy == 1) {
364 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
365 zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
368 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
369 zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
374 static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
375 integer n = *n_, incx = *incx_, incy = *incy_, i;
376 _Complex float zdotc = 0.0;
377 if (incx == 1 && incy == 1) {
378 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
379 zdotc += Cf(&x[i]) * Cf(&y[i]);
382 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
383 zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
388 static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
389 integer n = *n_, incx = *incx_, incy = *incy_, i;
390 _Complex double zdotc = 0.0;
391 if (incx == 1 && incy == 1) {
392 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
393 zdotc += Cd(&x[i]) * Cd(&y[i]);
396 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
397 zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
403 /* -- translated by f2c (version 20000121).
404 You must link the resulting object file with the libraries:
405 -lf2c -lm (in that order)
410 /* Table of constant values */
412 static integer c__1 = 1;
413 static real c_b16 = -1.f;
415 /* > \brief \b CPPTRF */
417 /* =========== DOCUMENTATION =========== */
419 /* Online html documentation available at */
420 /* http://www.netlib.org/lapack/explore-html/ */
423 /* > Download CPPTRF + dependencies */
424 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cpptrf.
427 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cpptrf.
430 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cpptrf.
438 /* SUBROUTINE CPPTRF( UPLO, N, AP, INFO ) */
441 /* INTEGER INFO, N */
442 /* COMPLEX AP( * ) */
445 /* > \par Purpose: */
450 /* > CPPTRF computes the Cholesky factorization of a complex Hermitian */
451 /* > positive definite matrix A stored in packed format. */
453 /* > The factorization has the form */
454 /* > A = U**H * U, if UPLO = 'U', or */
455 /* > A = L * L**H, if UPLO = 'L', */
456 /* > where U is an upper triangular matrix and L is lower triangular. */
462 /* > \param[in] UPLO */
464 /* > UPLO is CHARACTER*1 */
465 /* > = 'U': Upper triangle of A is stored; */
466 /* > = 'L': Lower triangle of A is stored. */
472 /* > The order of the matrix A. N >= 0. */
475 /* > \param[in,out] AP */
477 /* > AP is COMPLEX array, dimension (N*(N+1)/2) */
478 /* > On entry, the upper or lower triangle of the Hermitian matrix */
479 /* > A, packed columnwise in a linear array. The j-th column of A */
480 /* > is stored in the array AP as follows: */
481 /* > if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
482 /* > if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
483 /* > See below for further details. */
485 /* > On exit, if INFO = 0, the triangular factor U or L from the */
486 /* > Cholesky factorization A = U**H*U or A = L*L**H, in the same */
487 /* > storage format as A. */
490 /* > \param[out] INFO */
492 /* > INFO is INTEGER */
493 /* > = 0: successful exit */
494 /* > < 0: if INFO = -i, the i-th argument had an illegal value */
495 /* > > 0: if INFO = i, the leading minor of order i is not */
496 /* > positive definite, and the factorization could not be */
503 /* > \author Univ. of Tennessee */
504 /* > \author Univ. of California Berkeley */
505 /* > \author Univ. of Colorado Denver */
506 /* > \author NAG Ltd. */
508 /* > \date December 2016 */
510 /* > \ingroup complexOTHERcomputational */
512 /* > \par Further Details: */
513 /* ===================== */
517 /* > The packed storage scheme is illustrated by the following example */
518 /* > when N = 4, UPLO = 'U': */
520 /* > Two-dimensional storage of the Hermitian matrix A: */
522 /* > a11 a12 a13 a14 */
524 /* > a33 a34 (aij = conjg(aji)) */
527 /* > Packed storage of the upper triangle of A: */
529 /* > AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] */
532 /* ===================================================================== */
533 /* Subroutine */ int cpptrf_(char *uplo, integer *n, complex *ap, integer *
536 /* System generated locals */
537 integer i__1, i__2, i__3;
541 /* Local variables */
542 extern /* Subroutine */ int chpr_(char *, integer *, real *, complex *,
543 integer *, complex *);
545 extern /* Complex */ VOID cdotc_(complex *, integer *, complex *, integer
546 *, complex *, integer *);
547 extern logical lsame_(char *, char *);
549 extern /* Subroutine */ int ctpsv_(char *, char *, char *, integer *,
550 complex *, complex *, integer *);
552 extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer
553 *), xerbla_(char *, integer *, ftnlen);
557 /* -- LAPACK computational routine (version 3.7.0) -- */
558 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
559 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
563 /* ===================================================================== */
566 /* Test the input parameters. */
568 /* Parameter adjustments */
573 upper = lsame_(uplo, "U");
574 if (! upper && ! lsame_(uplo, "L")) {
581 xerbla_("CPPTRF", &i__1, (ftnlen)6);
585 /* Quick return if possible */
593 /* Compute the Cholesky factorization A = U**H * U. */
597 for (j = 1; j <= i__1; ++j) {
601 /* Compute elements 1:J-1 of column J. */
605 ctpsv_("Upper", "Conjugate transpose", "Non-unit", &i__2, &ap[
609 /* Compute U(J,J) and test for non-positive-definiteness. */
614 cdotc_(&q__2, &i__3, &ap[jc], &c__1, &ap[jc], &c__1);
615 q__1.r = r__1 - q__2.r, q__1.i = -q__2.i;
619 ap[i__2].r = ajj, ap[i__2].i = 0.f;
624 ap[i__2].r = r__1, ap[i__2].i = 0.f;
629 /* Compute the Cholesky factorization A = L * L**H. */
633 for (j = 1; j <= i__1; ++j) {
635 /* Compute L(J,J) and test for non-positive-definiteness. */
641 ap[i__2].r = ajj, ap[i__2].i = 0.f;
646 ap[i__2].r = ajj, ap[i__2].i = 0.f;
648 /* Compute elements J+1:N of column J and update the trailing */
654 csscal_(&i__2, &r__1, &ap[jj + 1], &c__1);
656 chpr_("Lower", &i__2, &c_b16, &ap[jj + 1], &c__1, &ap[jj + *n
658 jj = jj + *n - j + 1;