cpotrf.c
Go to the documentation of this file.
00001 /* cpotrf.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 complex c_b1 = {1.f,0.f};
00019 static integer c__1 = 1;
00020 static integer c_n1 = -1;
00021 static real c_b14 = -1.f;
00022 static real c_b15 = 1.f;
00023 
00024 /* Subroutine */ int cpotrf_(char *uplo, integer *n, complex *a, integer *lda, 
00025          integer *info)
00026 {
00027     /* System generated locals */
00028     integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
00029     complex q__1;
00030 
00031     /* Local variables */
00032     integer j, jb, nb;
00033     extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, 
00034             integer *, complex *, complex *, integer *, complex *, integer *, 
00035             complex *, complex *, integer *), cherk_(char *, 
00036             char *, integer *, integer *, real *, complex *, integer *, real *
00037 , complex *, integer *);
00038     extern logical lsame_(char *, char *);
00039     extern /* Subroutine */ int ctrsm_(char *, char *, char *, char *, 
00040             integer *, integer *, complex *, complex *, integer *, complex *, 
00041             integer *);
00042     logical upper;
00043     extern /* Subroutine */ int cpotf2_(char *, integer *, complex *, integer 
00044             *, integer *), xerbla_(char *, integer *);
00045     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00046             integer *, integer *);
00047 
00048 
00049 /*  -- LAPACK routine (version 3.2) -- */
00050 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00051 /*     November 2006 */
00052 
00053 /*     .. Scalar Arguments .. */
00054 /*     .. */
00055 /*     .. Array Arguments .. */
00056 /*     .. */
00057 
00058 /*  Purpose */
00059 /*  ======= */
00060 
00061 /*  CPOTRF computes the Cholesky factorization of a complex Hermitian */
00062 /*  positive definite matrix A. */
00063 
00064 /*  The factorization has the form */
00065 /*     A = U**H * U,  if UPLO = 'U', or */
00066 /*     A = L  * L**H,  if UPLO = 'L', */
00067 /*  where U is an upper triangular matrix and L is lower triangular. */
00068 
00069 /*  This is the block 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 array, dimension (LDA,N) */
00082 /*          On entry, the Hermitian 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, if INFO = 0, the factor U or L from the Cholesky */
00091 /*          factorization A = U**H*U or A = L*L**H. */
00092 
00093 /*  LDA     (input) INTEGER */
00094 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00095 
00096 /*  INFO    (output) INTEGER */
00097 /*          = 0:  successful exit */
00098 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00099 /*          > 0:  if INFO = i, the leading minor of order i is not */
00100 /*                positive definite, and the factorization could not be */
00101 /*                completed. */
00102 
00103 /*  ===================================================================== */
00104 
00105 /*     .. Parameters .. */
00106 /*     .. */
00107 /*     .. Local Scalars .. */
00108 /*     .. */
00109 /*     .. External Functions .. */
00110 /*     .. */
00111 /*     .. External Subroutines .. */
00112 /*     .. */
00113 /*     .. Intrinsic Functions .. */
00114 /*     .. */
00115 /*     .. Executable Statements .. */
00116 
00117 /*     Test the input parameters. */
00118 
00119     /* Parameter adjustments */
00120     a_dim1 = *lda;
00121     a_offset = 1 + a_dim1;
00122     a -= a_offset;
00123 
00124     /* Function Body */
00125     *info = 0;
00126     upper = lsame_(uplo, "U");
00127     if (! upper && ! lsame_(uplo, "L")) {
00128         *info = -1;
00129     } else if (*n < 0) {
00130         *info = -2;
00131     } else if (*lda < max(1,*n)) {
00132         *info = -4;
00133     }
00134     if (*info != 0) {
00135         i__1 = -(*info);
00136         xerbla_("CPOTRF", &i__1);
00137         return 0;
00138     }
00139 
00140 /*     Quick return if possible */
00141 
00142     if (*n == 0) {
00143         return 0;
00144     }
00145 
00146 /*     Determine the block size for this environment. */
00147 
00148     nb = ilaenv_(&c__1, "CPOTRF", uplo, n, &c_n1, &c_n1, &c_n1);
00149     if (nb <= 1 || nb >= *n) {
00150 
00151 /*        Use unblocked code. */
00152 
00153         cpotf2_(uplo, n, &a[a_offset], lda, info);
00154     } else {
00155 
00156 /*        Use blocked code. */
00157 
00158         if (upper) {
00159 
00160 /*           Compute the Cholesky factorization A = U'*U. */
00161 
00162             i__1 = *n;
00163             i__2 = nb;
00164             for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00165 
00166 /*              Update and factorize the current diagonal block and test */
00167 /*              for non-positive-definiteness. */
00168 
00169 /* Computing MIN */
00170                 i__3 = nb, i__4 = *n - j + 1;
00171                 jb = min(i__3,i__4);
00172                 i__3 = j - 1;
00173                 cherk_("Upper", "Conjugate transpose", &jb, &i__3, &c_b14, &a[
00174                         j * a_dim1 + 1], lda, &c_b15, &a[j + j * a_dim1], lda);
00175                 cpotf2_("Upper", &jb, &a[j + j * a_dim1], lda, info);
00176                 if (*info != 0) {
00177                     goto L30;
00178                 }
00179                 if (j + jb <= *n) {
00180 
00181 /*                 Compute the current block row. */
00182 
00183                     i__3 = *n - j - jb + 1;
00184                     i__4 = j - 1;
00185                     q__1.r = -1.f, q__1.i = -0.f;
00186                     cgemm_("Conjugate transpose", "No transpose", &jb, &i__3, 
00187                             &i__4, &q__1, &a[j * a_dim1 + 1], lda, &a[(j + jb)
00188                              * a_dim1 + 1], lda, &c_b1, &a[j + (j + jb) * 
00189                             a_dim1], lda);
00190                     i__3 = *n - j - jb + 1;
00191                     ctrsm_("Left", "Upper", "Conjugate transpose", "Non-unit", 
00192                              &jb, &i__3, &c_b1, &a[j + j * a_dim1], lda, &a[j 
00193                             + (j + jb) * a_dim1], lda);
00194                 }
00195 /* L10: */
00196             }
00197 
00198         } else {
00199 
00200 /*           Compute the Cholesky factorization A = L*L'. */
00201 
00202             i__2 = *n;
00203             i__1 = nb;
00204             for (j = 1; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
00205 
00206 /*              Update and factorize the current diagonal block and test */
00207 /*              for non-positive-definiteness. */
00208 
00209 /* Computing MIN */
00210                 i__3 = nb, i__4 = *n - j + 1;
00211                 jb = min(i__3,i__4);
00212                 i__3 = j - 1;
00213                 cherk_("Lower", "No transpose", &jb, &i__3, &c_b14, &a[j + 
00214                         a_dim1], lda, &c_b15, &a[j + j * a_dim1], lda);
00215                 cpotf2_("Lower", &jb, &a[j + j * a_dim1], lda, info);
00216                 if (*info != 0) {
00217                     goto L30;
00218                 }
00219                 if (j + jb <= *n) {
00220 
00221 /*                 Compute the current block column. */
00222 
00223                     i__3 = *n - j - jb + 1;
00224                     i__4 = j - 1;
00225                     q__1.r = -1.f, q__1.i = -0.f;
00226                     cgemm_("No transpose", "Conjugate transpose", &i__3, &jb, 
00227                             &i__4, &q__1, &a[j + jb + a_dim1], lda, &a[j + 
00228                             a_dim1], lda, &c_b1, &a[j + jb + j * a_dim1], lda);
00229                     i__3 = *n - j - jb + 1;
00230                     ctrsm_("Right", "Lower", "Conjugate transpose", "Non-unit"
00231 , &i__3, &jb, &c_b1, &a[j + j * a_dim1], lda, &a[
00232                             j + jb + j * a_dim1], lda);
00233                 }
00234 /* L20: */
00235             }
00236         }
00237     }
00238     goto L40;
00239 
00240 L30:
00241     *info = *info + j - 1;
00242 
00243 L40:
00244     return 0;
00245 
00246 /*     End of CPOTRF */
00247 
00248 } /* cpotrf_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:33