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


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