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


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