Use f2c translations of LAPACK when no Fortran compiler is available (#3539)
[platform/upstream/openblas.git] / lapack-netlib / SRC / cpptrf.c
1 /* f2c.h  --  Standard Fortran to C header file */
2
3 /**  barf  [ba:rf]  2.  "He suggested using FORTRAN, and everybody barfed."
4
5         - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
6
7 #ifndef F2C_INCLUDE
8 #define F2C_INCLUDE
9
10 #include <math.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <stdio.h>
14 #include <complex.h>
15 #ifdef complex
16 #undef complex
17 #endif
18 #ifdef I
19 #undef I
20 #endif
21
22 #if defined(_WIN64)
23 typedef long long BLASLONG;
24 typedef unsigned long long BLASULONG;
25 #else
26 typedef long BLASLONG;
27 typedef unsigned long BLASULONG;
28 #endif
29
30 #ifdef LAPACK_ILP64
31 typedef BLASLONG blasint;
32 #if defined(_WIN64)
33 #define blasabs(x) llabs(x)
34 #else
35 #define blasabs(x) labs(x)
36 #endif
37 #else
38 typedef int blasint;
39 #define blasabs(x) abs(x)
40 #endif
41
42 typedef blasint integer;
43
44 typedef unsigned int uinteger;
45 typedef char *address;
46 typedef short int shortint;
47 typedef float real;
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))
57 typedef int logical;
58 typedef short int shortlogical;
59 typedef char logical1;
60 typedef char integer1;
61
62 #define TRUE_ (1)
63 #define FALSE_ (0)
64
65 /* Extern is for use with -E */
66 #ifndef Extern
67 #define Extern extern
68 #endif
69
70 /* I/O stuff */
71
72 typedef int flag;
73 typedef int ftnlen;
74 typedef int ftnint;
75
76 /*external read, write*/
77 typedef struct
78 {       flag cierr;
79         ftnint ciunit;
80         flag ciend;
81         char *cifmt;
82         ftnint cirec;
83 } cilist;
84
85 /*internal read, write*/
86 typedef struct
87 {       flag icierr;
88         char *iciunit;
89         flag iciend;
90         char *icifmt;
91         ftnint icirlen;
92         ftnint icirnum;
93 } icilist;
94
95 /*open*/
96 typedef struct
97 {       flag oerr;
98         ftnint ounit;
99         char *ofnm;
100         ftnlen ofnmlen;
101         char *osta;
102         char *oacc;
103         char *ofm;
104         ftnint orl;
105         char *oblnk;
106 } olist;
107
108 /*close*/
109 typedef struct
110 {       flag cerr;
111         ftnint cunit;
112         char *csta;
113 } cllist;
114
115 /*rewind, backspace, endfile*/
116 typedef struct
117 {       flag aerr;
118         ftnint aunit;
119 } alist;
120
121 /* inquire */
122 typedef struct
123 {       flag inerr;
124         ftnint inunit;
125         char *infile;
126         ftnlen infilen;
127         ftnint  *inex;  /*parameters in standard's order*/
128         ftnint  *inopen;
129         ftnint  *innum;
130         ftnint  *innamed;
131         char    *inname;
132         ftnlen  innamlen;
133         char    *inacc;
134         ftnlen  inacclen;
135         char    *inseq;
136         ftnlen  inseqlen;
137         char    *indir;
138         ftnlen  indirlen;
139         char    *infmt;
140         ftnlen  infmtlen;
141         char    *inform;
142         ftnint  informlen;
143         char    *inunf;
144         ftnlen  inunflen;
145         ftnint  *inrecl;
146         ftnint  *innrec;
147         char    *inblank;
148         ftnlen  inblanklen;
149 } inlist;
150
151 #define VOID void
152
153 union Multitype {       /* for multiple entry points */
154         integer1 g;
155         shortint h;
156         integer i;
157         /* longint j; */
158         real r;
159         doublereal d;
160         complex c;
161         doublecomplex z;
162         };
163
164 typedef union Multitype Multitype;
165
166 struct Vardesc {        /* for Namelist */
167         char *name;
168         char *addr;
169         ftnlen *dims;
170         int  type;
171         };
172 typedef struct Vardesc Vardesc;
173
174 struct Namelist {
175         char *name;
176         Vardesc **vars;
177         int nvars;
178         };
179 typedef struct Namelist Namelist;
180
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)))
190
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)}
257
258 /* procedure parameter types for -A and -C++ */
259
260 #define F2C_proc_par_types 1
261 #ifdef __cplusplus
262 typedef logical (*L_fp)(...);
263 #else
264 typedef logical (*L_fp)();
265 #endif
266
267 static float spow_ui(float x, integer n) {
268         float pow=1.0; unsigned long int u;
269         if(n != 0) {
270                 if(n < 0) n = -n, x = 1/x;
271                 for(u = n; ; ) {
272                         if(u & 01) pow *= x;
273                         if(u >>= 1) x *= x;
274                         else break;
275                 }
276         }
277         return pow;
278 }
279 static double dpow_ui(double x, integer n) {
280         double pow=1.0; unsigned long int u;
281         if(n != 0) {
282                 if(n < 0) n = -n, x = 1/x;
283                 for(u = n; ; ) {
284                         if(u & 01) pow *= x;
285                         if(u >>= 1) x *= x;
286                         else break;
287                 }
288         }
289         return pow;
290 }
291 static _Complex float cpow_ui(_Complex float x, integer n) {
292         _Complex float pow=1.0; unsigned long int u;
293         if(n != 0) {
294                 if(n < 0) n = -n, x = 1/x;
295                 for(u = n; ; ) {
296                         if(u & 01) pow *= x;
297                         if(u >>= 1) x *= x;
298                         else break;
299                 }
300         }
301         return pow;
302 }
303 static _Complex double zpow_ui(_Complex double x, integer n) {
304         _Complex double pow=1.0; unsigned long int u;
305         if(n != 0) {
306                 if(n < 0) n = -n, x = 1/x;
307                 for(u = n; ; ) {
308                         if(u & 01) pow *= x;
309                         if(u >>= 1) x *= x;
310                         else break;
311                 }
312         }
313         return pow;
314 }
315 static integer pow_ii(integer x, integer n) {
316         integer pow; unsigned long int u;
317         if (n <= 0) {
318                 if (n == 0 || x == 1) pow = 1;
319                 else if (x != -1) pow = x == 0 ? 1/x : 0;
320                 else n = -n;
321         }
322         if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
323                 u = n;
324                 for(pow = 1; ; ) {
325                         if(u & 01) pow *= x;
326                         if(u >>= 1) x *= x;
327                         else break;
328                 }
329         }
330         return pow;
331 }
332 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
333 {
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];
337         return mi-s+1;
338 }
339 static integer smaxloc_(float *w, integer s, integer e, integer *n)
340 {
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];
344         return mi-s+1;
345 }
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]);
352                 }
353         } else {
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]);
356                 }
357         }
358         pCf(z) = zdotc;
359 }
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]);
366                 }
367         } else {
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]);
370                 }
371         }
372         pCd(z) = zdotc;
373 }       
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]);
380                 }
381         } else {
382                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
383                         zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
384                 }
385         }
386         pCf(z) = zdotc;
387 }
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]);
394                 }
395         } else {
396                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
397                         zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
398                 }
399         }
400         pCd(z) = zdotc;
401 }
402 #endif
403 /*  -- translated by f2c (version 20000121).
404    You must link the resulting object file with the libraries:
405         -lf2c -lm   (in that order)
406 */
407
408
409
410 /* Table of constant values */
411
412 static integer c__1 = 1;
413 static real c_b16 = -1.f;
414
415 /* > \brief \b CPPTRF */
416
417 /*  =========== DOCUMENTATION =========== */
418
419 /* Online html documentation available at */
420 /*            http://www.netlib.org/lapack/explore-html/ */
421
422 /* > \htmlonly */
423 /* > Download CPPTRF + dependencies */
424 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cpptrf.
425 f"> */
426 /* > [TGZ]</a> */
427 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cpptrf.
428 f"> */
429 /* > [ZIP]</a> */
430 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cpptrf.
431 f"> */
432 /* > [TXT]</a> */
433 /* > \endhtmlonly */
434
435 /*  Definition: */
436 /*  =========== */
437
438 /*       SUBROUTINE CPPTRF( UPLO, N, AP, INFO ) */
439
440 /*       CHARACTER          UPLO */
441 /*       INTEGER            INFO, N */
442 /*       COMPLEX            AP( * ) */
443
444
445 /* > \par Purpose: */
446 /*  ============= */
447 /* > */
448 /* > \verbatim */
449 /* > */
450 /* > CPPTRF computes the Cholesky factorization of a complex Hermitian */
451 /* > positive definite matrix A stored in packed format. */
452 /* > */
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. */
457 /* > \endverbatim */
458
459 /*  Arguments: */
460 /*  ========== */
461
462 /* > \param[in] UPLO */
463 /* > \verbatim */
464 /* >          UPLO is CHARACTER*1 */
465 /* >          = 'U':  Upper triangle of A is stored; */
466 /* >          = 'L':  Lower triangle of A is stored. */
467 /* > \endverbatim */
468 /* > */
469 /* > \param[in] N */
470 /* > \verbatim */
471 /* >          N is INTEGER */
472 /* >          The order of the matrix A.  N >= 0. */
473 /* > \endverbatim */
474 /* > */
475 /* > \param[in,out] AP */
476 /* > \verbatim */
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. */
484 /* > */
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. */
488 /* > \endverbatim */
489 /* > */
490 /* > \param[out] INFO */
491 /* > \verbatim */
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 */
497 /* >                completed. */
498 /* > \endverbatim */
499
500 /*  Authors: */
501 /*  ======== */
502
503 /* > \author Univ. of Tennessee */
504 /* > \author Univ. of California Berkeley */
505 /* > \author Univ. of Colorado Denver */
506 /* > \author NAG Ltd. */
507
508 /* > \date December 2016 */
509
510 /* > \ingroup complexOTHERcomputational */
511
512 /* > \par Further Details: */
513 /*  ===================== */
514 /* > */
515 /* > \verbatim */
516 /* > */
517 /* >  The packed storage scheme is illustrated by the following example */
518 /* >  when N = 4, UPLO = 'U': */
519 /* > */
520 /* >  Two-dimensional storage of the Hermitian matrix A: */
521 /* > */
522 /* >     a11 a12 a13 a14 */
523 /* >         a22 a23 a24 */
524 /* >             a33 a34     (aij = conjg(aji)) */
525 /* >                 a44 */
526 /* > */
527 /* >  Packed storage of the upper triangle of A: */
528 /* > */
529 /* >  AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] */
530 /* > \endverbatim */
531 /* > */
532 /*  ===================================================================== */
533 /* Subroutine */ int cpptrf_(char *uplo, integer *n, complex *ap, integer *
534         info)
535 {
536     /* System generated locals */
537     integer i__1, i__2, i__3;
538     real r__1;
539     complex q__1, q__2;
540
541     /* Local variables */
542     extern /* Subroutine */ int chpr_(char *, integer *, real *, complex *, 
543             integer *, complex *);
544     integer j;
545     extern /* Complex */ VOID cdotc_(complex *, integer *, complex *, integer 
546             *, complex *, integer *);
547     extern logical lsame_(char *, char *);
548     logical upper;
549     extern /* Subroutine */ int ctpsv_(char *, char *, char *, integer *, 
550             complex *, complex *, integer *);
551     integer jc, jj;
552     extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer 
553             *), xerbla_(char *, integer *, ftnlen);
554     real ajj;
555
556
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..-- */
560 /*     December 2016 */
561
562
563 /*  ===================================================================== */
564
565
566 /*     Test the input parameters. */
567
568     /* Parameter adjustments */
569     --ap;
570
571     /* Function Body */
572     *info = 0;
573     upper = lsame_(uplo, "U");
574     if (! upper && ! lsame_(uplo, "L")) {
575         *info = -1;
576     } else if (*n < 0) {
577         *info = -2;
578     }
579     if (*info != 0) {
580         i__1 = -(*info);
581         xerbla_("CPPTRF", &i__1, (ftnlen)6);
582         return 0;
583     }
584
585 /*     Quick return if possible */
586
587     if (*n == 0) {
588         return 0;
589     }
590
591     if (upper) {
592
593 /*        Compute the Cholesky factorization A = U**H * U. */
594
595         jj = 0;
596         i__1 = *n;
597         for (j = 1; j <= i__1; ++j) {
598             jc = jj + 1;
599             jj += j;
600
601 /*           Compute elements 1:J-1 of column J. */
602
603             if (j > 1) {
604                 i__2 = j - 1;
605                 ctpsv_("Upper", "Conjugate transpose", "Non-unit", &i__2, &ap[
606                         1], &ap[jc], &c__1);
607             }
608
609 /*           Compute U(J,J) and test for non-positive-definiteness. */
610
611             i__2 = jj;
612             r__1 = ap[i__2].r;
613             i__3 = j - 1;
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;
616             ajj = q__1.r;
617             if (ajj <= 0.f) {
618                 i__2 = jj;
619                 ap[i__2].r = ajj, ap[i__2].i = 0.f;
620                 goto L30;
621             }
622             i__2 = jj;
623             r__1 = sqrt(ajj);
624             ap[i__2].r = r__1, ap[i__2].i = 0.f;
625 /* L10: */
626         }
627     } else {
628
629 /*        Compute the Cholesky factorization A = L * L**H. */
630
631         jj = 1;
632         i__1 = *n;
633         for (j = 1; j <= i__1; ++j) {
634
635 /*           Compute L(J,J) and test for non-positive-definiteness. */
636
637             i__2 = jj;
638             ajj = ap[i__2].r;
639             if (ajj <= 0.f) {
640                 i__2 = jj;
641                 ap[i__2].r = ajj, ap[i__2].i = 0.f;
642                 goto L30;
643             }
644             ajj = sqrt(ajj);
645             i__2 = jj;
646             ap[i__2].r = ajj, ap[i__2].i = 0.f;
647
648 /*           Compute elements J+1:N of column J and update the trailing */
649 /*           submatrix. */
650
651             if (j < *n) {
652                 i__2 = *n - j;
653                 r__1 = 1.f / ajj;
654                 csscal_(&i__2, &r__1, &ap[jj + 1], &c__1);
655                 i__2 = *n - j;
656                 chpr_("Lower", &i__2, &c_b16, &ap[jj + 1], &c__1, &ap[jj + *n 
657                         - j + 1]);
658                 jj = jj + *n - j + 1;
659             }
660 /* L20: */
661         }
662     }
663     goto L40;
664
665 L30:
666     *info = j;
667
668 L40:
669     return 0;
670
671 /*     End of CPPTRF */
672
673 } /* cpptrf_ */
674