zpptrf.c
Go to the documentation of this file.
00001 /* zpptrf.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 static doublereal c_b16 = -1.;
00020 
00021 /* Subroutine */ int zpptrf_(char *uplo, integer *n, doublecomplex *ap, 
00022         integer *info)
00023 {
00024     /* System generated locals */
00025     integer i__1, i__2, i__3;
00026     doublereal d__1;
00027     doublecomplex z__1, z__2;
00028 
00029     /* Builtin functions */
00030     double sqrt(doublereal);
00031 
00032     /* Local variables */
00033     integer j, jc, jj;
00034     doublereal ajj;
00035     extern /* Subroutine */ int zhpr_(char *, integer *, doublereal *, 
00036             doublecomplex *, integer *, doublecomplex *);
00037     extern logical lsame_(char *, char *);
00038     extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *, 
00039             doublecomplex *, integer *, doublecomplex *, integer *);
00040     logical upper;
00041     extern /* Subroutine */ int ztpsv_(char *, char *, char *, integer *, 
00042             doublecomplex *, doublecomplex *, integer *), xerbla_(char *, integer *), zdscal_(integer *, 
00043             doublereal *, doublecomplex *, integer *);
00044 
00045 
00046 /*  -- LAPACK routine (version 3.2) -- */
00047 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00048 /*     November 2006 */
00049 
00050 /*     .. Scalar Arguments .. */
00051 /*     .. */
00052 /*     .. Array Arguments .. */
00053 /*     .. */
00054 
00055 /*  Purpose */
00056 /*  ======= */
00057 
00058 /*  ZPPTRF computes the Cholesky factorization of a complex Hermitian */
00059 /*  positive definite matrix A stored in packed format. */
00060 
00061 /*  The factorization has the form */
00062 /*     A = U**H * U,  if UPLO = 'U', or */
00063 /*     A = L  * L**H,  if UPLO = 'L', */
00064 /*  where U is an upper triangular matrix and L is lower triangular. */
00065 
00066 /*  Arguments */
00067 /*  ========= */
00068 
00069 /*  UPLO    (input) CHARACTER*1 */
00070 /*          = 'U':  Upper triangle of A is stored; */
00071 /*          = 'L':  Lower triangle of A is stored. */
00072 
00073 /*  N       (input) INTEGER */
00074 /*          The order of the matrix A.  N >= 0. */
00075 
00076 /*  AP      (input/output) COMPLEX*16 array, dimension (N*(N+1)/2) */
00077 /*          On entry, the upper or lower triangle of the Hermitian matrix */
00078 /*          A, packed columnwise in a linear array.  The j-th column of A */
00079 /*          is stored in the array AP as follows: */
00080 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00081 /*          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
00082 /*          See below for further details. */
00083 
00084 /*          On exit, if INFO = 0, the triangular factor U or L from the */
00085 /*          Cholesky factorization A = U**H*U or A = L*L**H, in the same */
00086 /*          storage format as A. */
00087 
00088 /*  INFO    (output) INTEGER */
00089 /*          = 0:  successful exit */
00090 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00091 /*          > 0:  if INFO = i, the leading minor of order i is not */
00092 /*                positive definite, and the factorization could not be */
00093 /*                completed. */
00094 
00095 /*  Further Details */
00096 /*  =============== */
00097 
00098 /*  The packed storage scheme is illustrated by the following example */
00099 /*  when N = 4, UPLO = 'U': */
00100 
00101 /*  Two-dimensional storage of the Hermitian matrix A: */
00102 
00103 /*     a11 a12 a13 a14 */
00104 /*         a22 a23 a24 */
00105 /*             a33 a34     (aij = conjg(aji)) */
00106 /*                 a44 */
00107 
00108 /*  Packed storage of the upper triangle of A: */
00109 
00110 /*  AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] */
00111 
00112 /*  ===================================================================== */
00113 
00114 /*     .. Parameters .. */
00115 /*     .. */
00116 /*     .. Local Scalars .. */
00117 /*     .. */
00118 /*     .. External Functions .. */
00119 /*     .. */
00120 /*     .. External Subroutines .. */
00121 /*     .. */
00122 /*     .. Intrinsic Functions .. */
00123 /*     .. */
00124 /*     .. Executable Statements .. */
00125 
00126 /*     Test the input parameters. */
00127 
00128     /* Parameter adjustments */
00129     --ap;
00130 
00131     /* Function Body */
00132     *info = 0;
00133     upper = lsame_(uplo, "U");
00134     if (! upper && ! lsame_(uplo, "L")) {
00135         *info = -1;
00136     } else if (*n < 0) {
00137         *info = -2;
00138     }
00139     if (*info != 0) {
00140         i__1 = -(*info);
00141         xerbla_("ZPPTRF", &i__1);
00142         return 0;
00143     }
00144 
00145 /*     Quick return if possible */
00146 
00147     if (*n == 0) {
00148         return 0;
00149     }
00150 
00151     if (upper) {
00152 
00153 /*        Compute the Cholesky factorization A = U'*U. */
00154 
00155         jj = 0;
00156         i__1 = *n;
00157         for (j = 1; j <= i__1; ++j) {
00158             jc = jj + 1;
00159             jj += j;
00160 
00161 /*           Compute elements 1:J-1 of column J. */
00162 
00163             if (j > 1) {
00164                 i__2 = j - 1;
00165                 ztpsv_("Upper", "Conjugate transpose", "Non-unit", &i__2, &ap[
00166                         1], &ap[jc], &c__1);
00167             }
00168 
00169 /*           Compute U(J,J) and test for non-positive-definiteness. */
00170 
00171             i__2 = jj;
00172             d__1 = ap[i__2].r;
00173             i__3 = j - 1;
00174             zdotc_(&z__2, &i__3, &ap[jc], &c__1, &ap[jc], &c__1);
00175             z__1.r = d__1 - z__2.r, z__1.i = -z__2.i;
00176             ajj = z__1.r;
00177             if (ajj <= 0.) {
00178                 i__2 = jj;
00179                 ap[i__2].r = ajj, ap[i__2].i = 0.;
00180                 goto L30;
00181             }
00182             i__2 = jj;
00183             d__1 = sqrt(ajj);
00184             ap[i__2].r = d__1, ap[i__2].i = 0.;
00185 /* L10: */
00186         }
00187     } else {
00188 
00189 /*        Compute the Cholesky factorization A = L*L'. */
00190 
00191         jj = 1;
00192         i__1 = *n;
00193         for (j = 1; j <= i__1; ++j) {
00194 
00195 /*           Compute L(J,J) and test for non-positive-definiteness. */
00196 
00197             i__2 = jj;
00198             ajj = ap[i__2].r;
00199             if (ajj <= 0.) {
00200                 i__2 = jj;
00201                 ap[i__2].r = ajj, ap[i__2].i = 0.;
00202                 goto L30;
00203             }
00204             ajj = sqrt(ajj);
00205             i__2 = jj;
00206             ap[i__2].r = ajj, ap[i__2].i = 0.;
00207 
00208 /*           Compute elements J+1:N of column J and update the trailing */
00209 /*           submatrix. */
00210 
00211             if (j < *n) {
00212                 i__2 = *n - j;
00213                 d__1 = 1. / ajj;
00214                 zdscal_(&i__2, &d__1, &ap[jj + 1], &c__1);
00215                 i__2 = *n - j;
00216                 zhpr_("Lower", &i__2, &c_b16, &ap[jj + 1], &c__1, &ap[jj + *n 
00217                         - j + 1]);
00218                 jj = jj + *n - j + 1;
00219             }
00220 /* L20: */
00221         }
00222     }
00223     goto L40;
00224 
00225 L30:
00226     *info = j;
00227 
00228 L40:
00229     return 0;
00230 
00231 /*     End of ZPPTRF */
00232 
00233 } /* zpptrf_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:43