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


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