zsytrf.c
Go to the documentation of this file.
00001 /* zsytrf.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 integer c_n1 = -1;
00020 static integer c__2 = 2;
00021 
00022 /* Subroutine */ int zsytrf_(char *uplo, integer *n, doublecomplex *a, 
00023         integer *lda, integer *ipiv, doublecomplex *work, integer *lwork, 
00024         integer *info)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, i__1, i__2;
00028 
00029     /* Local variables */
00030     integer j, k, kb, nb, iws;
00031     extern logical lsame_(char *, char *);
00032     integer nbmin, iinfo;
00033     logical upper;
00034     extern /* Subroutine */ int zsytf2_(char *, integer *, doublecomplex *, 
00035             integer *, integer *, integer *), xerbla_(char *, integer 
00036             *);
00037     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00038             integer *, integer *);
00039     integer ldwork;
00040     extern /* Subroutine */ int zlasyf_(char *, integer *, integer *, integer 
00041             *, doublecomplex *, integer *, integer *, doublecomplex *, 
00042             integer *, integer *);
00043     integer lwkopt;
00044     logical lquery;
00045 
00046 
00047 /*  -- LAPACK routine (version 3.2) -- */
00048 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00049 /*     November 2006 */
00050 
00051 /*     .. Scalar Arguments .. */
00052 /*     .. */
00053 /*     .. Array Arguments .. */
00054 /*     .. */
00055 
00056 /*  Purpose */
00057 /*  ======= */
00058 
00059 /*  ZSYTRF computes the factorization of a complex symmetric matrix A */
00060 /*  using the Bunch-Kaufman diagonal pivoting method.  The form of the */
00061 /*  factorization is */
00062 
00063 /*     A = U*D*U**T  or  A = L*D*L**T */
00064 
00065 /*  where U (or L) is a product of permutation and unit upper (lower) */
00066 /*  triangular matrices, and D is symmetric and block diagonal with */
00067 /*  with 1-by-1 and 2-by-2 diagonal blocks. */
00068 
00069 /*  This is the blocked version of the algorithm, calling Level 3 BLAS. */
00070 
00071 /*  Arguments */
00072 /*  ========= */
00073 
00074 /*  UPLO    (input) CHARACTER*1 */
00075 /*          = 'U':  Upper triangle of A is stored; */
00076 /*          = 'L':  Lower triangle of A is stored. */
00077 
00078 /*  N       (input) INTEGER */
00079 /*          The order of the matrix A.  N >= 0. */
00080 
00081 /*  A       (input/output) COMPLEX*16 array, dimension (LDA,N) */
00082 /*          On entry, the symmetric matrix A.  If UPLO = 'U', the leading */
00083 /*          N-by-N upper triangular part of A contains the upper */
00084 /*          triangular part of the matrix A, and the strictly lower */
00085 /*          triangular part of A is not referenced.  If UPLO = 'L', the */
00086 /*          leading N-by-N lower triangular part of A contains the lower */
00087 /*          triangular part of the matrix A, and the strictly upper */
00088 /*          triangular part of A is not referenced. */
00089 
00090 /*          On exit, the block diagonal matrix D and the multipliers used */
00091 /*          to obtain the factor U or L (see below for further details). */
00092 
00093 /*  LDA     (input) INTEGER */
00094 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00095 
00096 /*  IPIV    (output) INTEGER array, dimension (N) */
00097 /*          Details of the interchanges and the block structure of D. */
00098 /*          If IPIV(k) > 0, then rows and columns k and IPIV(k) were */
00099 /*          interchanged and D(k,k) is a 1-by-1 diagonal block. */
00100 /*          If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and */
00101 /*          columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k) */
00102 /*          is a 2-by-2 diagonal block.  If UPLO = 'L' and IPIV(k) = */
00103 /*          IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were */
00104 /*          interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */
00105 
00106 /*  WORK    (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK)) */
00107 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00108 
00109 /*  LWORK   (input) INTEGER */
00110 /*          The length of WORK.  LWORK >=1.  For best performance */
00111 /*          LWORK >= N*NB, where NB is the block size returned by ILAENV. */
00112 
00113 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00114 /*          only calculates the optimal size of the WORK array, returns */
00115 /*          this value as the first entry of the WORK array, and no error */
00116 /*          message related to LWORK is issued by XERBLA. */
00117 
00118 /*  INFO    (output) INTEGER */
00119 /*          = 0:  successful exit */
00120 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00121 /*          > 0:  if INFO = i, D(i,i) is exactly zero.  The factorization */
00122 /*                has been completed, but the block diagonal matrix D is */
00123 /*                exactly singular, and division by zero will occur if it */
00124 /*                is used to solve a system of equations. */
00125 
00126 /*  Further Details */
00127 /*  =============== */
00128 
00129 /*  If UPLO = 'U', then A = U*D*U', where */
00130 /*     U = P(n)*U(n)* ... *P(k)U(k)* ..., */
00131 /*  i.e., U is a product of terms P(k)*U(k), where k decreases from n to */
00132 /*  1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1 */
00133 /*  and 2-by-2 diagonal blocks D(k).  P(k) is a permutation matrix as */
00134 /*  defined by IPIV(k), and U(k) is a unit upper triangular matrix, such */
00135 /*  that if the diagonal block D(k) is of order s (s = 1 or 2), then */
00136 
00137 /*             (   I    v    0   )   k-s */
00138 /*     U(k) =  (   0    I    0   )   s */
00139 /*             (   0    0    I   )   n-k */
00140 /*                k-s   s   n-k */
00141 
00142 /*  If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k). */
00143 /*  If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k), */
00144 /*  and A(k,k), and v overwrites A(1:k-2,k-1:k). */
00145 
00146 /*  If UPLO = 'L', then A = L*D*L', where */
00147 /*     L = P(1)*L(1)* ... *P(k)*L(k)* ..., */
00148 /*  i.e., L is a product of terms P(k)*L(k), where k increases from 1 to */
00149 /*  n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1 */
00150 /*  and 2-by-2 diagonal blocks D(k).  P(k) is a permutation matrix as */
00151 /*  defined by IPIV(k), and L(k) is a unit lower triangular matrix, such */
00152 /*  that if the diagonal block D(k) is of order s (s = 1 or 2), then */
00153 
00154 /*             (   I    0     0   )  k-1 */
00155 /*     L(k) =  (   0    I     0   )  s */
00156 /*             (   0    v     I   )  n-k-s+1 */
00157 /*                k-1   s  n-k-s+1 */
00158 
00159 /*  If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k). */
00160 /*  If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k), */
00161 /*  and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1). */
00162 
00163 /*  ===================================================================== */
00164 
00165 /*     .. Local Scalars .. */
00166 /*     .. */
00167 /*     .. External Functions .. */
00168 /*     .. */
00169 /*     .. External Subroutines .. */
00170 /*     .. */
00171 /*     .. Intrinsic Functions .. */
00172 /*     .. */
00173 /*     .. Executable Statements .. */
00174 
00175 /*     Test the input parameters. */
00176 
00177     /* Parameter adjustments */
00178     a_dim1 = *lda;
00179     a_offset = 1 + a_dim1;
00180     a -= a_offset;
00181     --ipiv;
00182     --work;
00183 
00184     /* Function Body */
00185     *info = 0;
00186     upper = lsame_(uplo, "U");
00187     lquery = *lwork == -1;
00188     if (! upper && ! lsame_(uplo, "L")) {
00189         *info = -1;
00190     } else if (*n < 0) {
00191         *info = -2;
00192     } else if (*lda < max(1,*n)) {
00193         *info = -4;
00194     } else if (*lwork < 1 && ! lquery) {
00195         *info = -7;
00196     }
00197 
00198     if (*info == 0) {
00199 
00200 /*        Determine the block size */
00201 
00202         nb = ilaenv_(&c__1, "ZSYTRF", uplo, n, &c_n1, &c_n1, &c_n1);
00203         lwkopt = *n * nb;
00204         work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00205     }
00206 
00207     if (*info != 0) {
00208         i__1 = -(*info);
00209         xerbla_("ZSYTRF", &i__1);
00210         return 0;
00211     } else if (lquery) {
00212         return 0;
00213     }
00214 
00215     nbmin = 2;
00216     ldwork = *n;
00217     if (nb > 1 && nb < *n) {
00218         iws = ldwork * nb;
00219         if (*lwork < iws) {
00220 /* Computing MAX */
00221             i__1 = *lwork / ldwork;
00222             nb = max(i__1,1);
00223 /* Computing MAX */
00224             i__1 = 2, i__2 = ilaenv_(&c__2, "ZSYTRF", uplo, n, &c_n1, &c_n1, &
00225                     c_n1);
00226             nbmin = max(i__1,i__2);
00227         }
00228     } else {
00229         iws = 1;
00230     }
00231     if (nb < nbmin) {
00232         nb = *n;
00233     }
00234 
00235     if (upper) {
00236 
00237 /*        Factorize A as U*D*U' using the upper triangle of A */
00238 
00239 /*        K is the main loop index, decreasing from N to 1 in steps of */
00240 /*        KB, where KB is the number of columns factorized by ZLASYF; */
00241 /*        KB is either NB or NB-1, or K for the last block */
00242 
00243         k = *n;
00244 L10:
00245 
00246 /*        If K < 1, exit from loop */
00247 
00248         if (k < 1) {
00249             goto L40;
00250         }
00251 
00252         if (k > nb) {
00253 
00254 /*           Factorize columns k-kb+1:k of A and use blocked code to */
00255 /*           update columns 1:k-kb */
00256 
00257             zlasyf_(uplo, &k, &nb, &kb, &a[a_offset], lda, &ipiv[1], &work[1], 
00258                      n, &iinfo);
00259         } else {
00260 
00261 /*           Use unblocked code to factorize columns 1:k of A */
00262 
00263             zsytf2_(uplo, &k, &a[a_offset], lda, &ipiv[1], &iinfo);
00264             kb = k;
00265         }
00266 
00267 /*        Set INFO on the first occurrence of a zero pivot */
00268 
00269         if (*info == 0 && iinfo > 0) {
00270             *info = iinfo;
00271         }
00272 
00273 /*        Decrease K and return to the start of the main loop */
00274 
00275         k -= kb;
00276         goto L10;
00277 
00278     } else {
00279 
00280 /*        Factorize A as L*D*L' using the lower triangle of A */
00281 
00282 /*        K is the main loop index, increasing from 1 to N in steps of */
00283 /*        KB, where KB is the number of columns factorized by ZLASYF; */
00284 /*        KB is either NB or NB-1, or N-K+1 for the last block */
00285 
00286         k = 1;
00287 L20:
00288 
00289 /*        If K > N, exit from loop */
00290 
00291         if (k > *n) {
00292             goto L40;
00293         }
00294 
00295         if (k <= *n - nb) {
00296 
00297 /*           Factorize columns k:k+kb-1 of A and use blocked code to */
00298 /*           update columns k+kb:n */
00299 
00300             i__1 = *n - k + 1;
00301             zlasyf_(uplo, &i__1, &nb, &kb, &a[k + k * a_dim1], lda, &ipiv[k], 
00302                     &work[1], n, &iinfo);
00303         } else {
00304 
00305 /*           Use unblocked code to factorize columns k:n of A */
00306 
00307             i__1 = *n - k + 1;
00308             zsytf2_(uplo, &i__1, &a[k + k * a_dim1], lda, &ipiv[k], &iinfo);
00309             kb = *n - k + 1;
00310         }
00311 
00312 /*        Set INFO on the first occurrence of a zero pivot */
00313 
00314         if (*info == 0 && iinfo > 0) {
00315             *info = iinfo + k - 1;
00316         }
00317 
00318 /*        Adjust IPIV */
00319 
00320         i__1 = k + kb - 1;
00321         for (j = k; j <= i__1; ++j) {
00322             if (ipiv[j] > 0) {
00323                 ipiv[j] = ipiv[j] + k - 1;
00324             } else {
00325                 ipiv[j] = ipiv[j] - k + 1;
00326             }
00327 /* L30: */
00328         }
00329 
00330 /*        Increase K and return to the start of the main loop */
00331 
00332         k += kb;
00333         goto L20;
00334 
00335     }
00336 
00337 L40:
00338     work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00339     return 0;
00340 
00341 /*     End of ZSYTRF */
00342 
00343 } /* zsytrf_ */


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