1 /* ./src_f77/spotrf.f -- translated by f2c (version 20030320).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include <punc/vf2c.h>
7 
8 /* Table of constant values */
9 
10 static integer c__1 = 1;
11 static integer c_n1 = -1;
12 static real c_b13 = -1.f;
13 static real c_b14 = 1.f;
14 
spotrf_(char * uplo,integer * n,real * a,integer * lda,integer * info,ftnlen uplo_len)15 /* Subroutine */ int spotrf_(char *uplo, integer *n, real *a, integer *lda,
16 	integer *info, ftnlen uplo_len)
17 {
18     /* System generated locals */
19     integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
20 
21     /* Local variables */
22     static integer j, jb, nb;
23     extern logical lsame_(char *, char *, ftnlen, ftnlen);
24     extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *,
25 	    integer *, real *, real *, integer *, real *, integer *, real *,
26 	    real *, integer *, ftnlen, ftnlen);
27     static logical upper;
28     extern /* Subroutine */ int strsm_(char *, char *, char *, char *,
29 	    integer *, integer *, real *, real *, integer *, real *, integer *
30 	    , ftnlen, ftnlen, ftnlen, ftnlen), ssyrk_(char *, char *, integer
31 	    *, integer *, real *, real *, integer *, real *, real *, integer *
32 	    , ftnlen, ftnlen), spotf2_(char *, integer *, real *, integer *,
33 	    integer *, ftnlen), xerbla_(char *, integer *, ftnlen);
34     extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
35 	    integer *, integer *, ftnlen, ftnlen);
36 
37 
38 /*  -- LAPACK routine (version 3.0) -- */
39 /*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
40 /*     Courant Institute, Argonne National Lab, and Rice University */
41 /*     March 31, 1993 */
42 
43 /*     .. Scalar Arguments .. */
44 /*     .. */
45 /*     .. Array Arguments .. */
46 /*     .. */
47 
48 /*  Purpose */
49 /*  ======= */
50 
51 /*  SPOTRF computes the Cholesky factorization of a real symmetric */
52 /*  positive definite matrix A. */
53 
54 /*  The factorization has the form */
55 /*     A = U**T * U,  if UPLO = 'U', or */
56 /*     A = L  * L**T,  if UPLO = 'L', */
57 /*  where U is an upper triangular matrix and L is lower triangular. */
58 
59 /*  This is the block version of the algorithm, calling Level 3 BLAS. */
60 
61 /*  Arguments */
62 /*  ========= */
63 
64 /*  UPLO    (input) CHARACTER*1 */
65 /*          = 'U':  Upper triangle of A is stored; */
66 /*          = 'L':  Lower triangle of A is stored. */
67 
68 /*  N       (input) INTEGER */
69 /*          The order of the matrix A.  N >= 0. */
70 
71 /*  A       (input/output) REAL array, dimension (LDA,N) */
72 /*          On entry, the symmetric matrix A.  If UPLO = 'U', the leading */
73 /*          N-by-N upper triangular part of A contains the upper */
74 /*          triangular part of the matrix A, and the strictly lower */
75 /*          triangular part of A is not referenced.  If UPLO = 'L', the */
76 /*          leading N-by-N lower triangular part of A contains the lower */
77 /*          triangular part of the matrix A, and the strictly upper */
78 /*          triangular part of A is not referenced. */
79 
80 /*          On exit, if INFO = 0, the factor U or L from the Cholesky */
81 /*          factorization A = U**T*U or A = L*L**T. */
82 
83 /*  LDA     (input) INTEGER */
84 /*          The leading dimension of the array A.  LDA >= max(1,N). */
85 
86 /*  INFO    (output) INTEGER */
87 /*          = 0:  successful exit */
88 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
89 /*          > 0:  if INFO = i, the leading minor of order i is not */
90 /*                positive definite, and the factorization could not be */
91 /*                completed. */
92 
93 /*  ===================================================================== */
94 
95 /*     .. Parameters .. */
96 /*     .. */
97 /*     .. Local Scalars .. */
98 /*     .. */
99 /*     .. External Functions .. */
100 /*     .. */
101 /*     .. External Subroutines .. */
102 /*     .. */
103 /*     .. Intrinsic Functions .. */
104 /*     .. */
105 /*     .. Executable Statements .. */
106 
107 /*     Test the input parameters. */
108 
109     /* Parameter adjustments */
110     a_dim1 = *lda;
111     a_offset = 1 + a_dim1;
112     a -= a_offset;
113 
114     /* Function Body */
115     *info = 0;
116     upper = lsame_(uplo, "U", (ftnlen)1, (ftnlen)1);
117     if (! upper && ! lsame_(uplo, "L", (ftnlen)1, (ftnlen)1)) {
118 	*info = -1;
119     } else if (*n < 0) {
120 	*info = -2;
121     } else if (*lda < max(1,*n)) {
122 	*info = -4;
123     }
124     if (*info != 0) {
125 	i__1 = -(*info);
126 	xerbla_("SPOTRF", &i__1, (ftnlen)6);
127 	return 0;
128     }
129 
130 /*     Quick return if possible */
131 
132     if (*n == 0) {
133 	return 0;
134     }
135 
136 /*     Determine the block size for this environment. */
137 
138     nb = ilaenv_(&c__1, "SPOTRF", uplo, n, &c_n1, &c_n1, &c_n1, (ftnlen)6, (
139 	    ftnlen)1);
140     if (nb <= 1 || nb >= *n) {
141 
142 /*        Use unblocked code. */
143 
144 	spotf2_(uplo, n, &a[a_offset], lda, info, (ftnlen)1);
145     } else {
146 
147 /*        Use blocked code. */
148 
149 	if (upper) {
150 
151 /*           Compute the Cholesky factorization A = U'*U. */
152 
153 	    i__1 = *n;
154 	    i__2 = nb;
155 	    for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
156 
157 /*              Update and factorize the current diagonal block and test */
158 /*              for non-positive-definiteness. */
159 
160 /* Computing MIN */
161 		i__3 = nb, i__4 = *n - j + 1;
162 		jb = min(i__3,i__4);
163 		i__3 = j - 1;
164 		ssyrk_("Upper", "Transpose", &jb, &i__3, &c_b13, &a[j *
165 			a_dim1 + 1], lda, &c_b14, &a[j + j * a_dim1], lda, (
166 			ftnlen)5, (ftnlen)9);
167 		spotf2_("Upper", &jb, &a[j + j * a_dim1], lda, info, (ftnlen)
168 			5);
169 		if (*info != 0) {
170 		    goto L30;
171 		}
172 		if (j + jb <= *n) {
173 
174 /*                 Compute the current block row. */
175 
176 		    i__3 = *n - j - jb + 1;
177 		    i__4 = j - 1;
178 		    sgemm_("Transpose", "No transpose", &jb, &i__3, &i__4, &
179 			    c_b13, &a[j * a_dim1 + 1], lda, &a[(j + jb) *
180 			    a_dim1 + 1], lda, &c_b14, &a[j + (j + jb) *
181 			    a_dim1], lda, (ftnlen)9, (ftnlen)12);
182 		    i__3 = *n - j - jb + 1;
183 		    strsm_("Left", "Upper", "Transpose", "Non-unit", &jb, &
184 			    i__3, &c_b14, &a[j + j * a_dim1], lda, &a[j + (j
185 			    + jb) * a_dim1], lda, (ftnlen)4, (ftnlen)5, (
186 			    ftnlen)9, (ftnlen)8);
187 		}
188 /* L10: */
189 	    }
190 
191 	} else {
192 
193 /*           Compute the Cholesky factorization A = L*L'. */
194 
195 	    i__2 = *n;
196 	    i__1 = nb;
197 	    for (j = 1; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
198 
199 /*              Update and factorize the current diagonal block and test */
200 /*              for non-positive-definiteness. */
201 
202 /* Computing MIN */
203 		i__3 = nb, i__4 = *n - j + 1;
204 		jb = min(i__3,i__4);
205 		i__3 = j - 1;
206 		ssyrk_("Lower", "No transpose", &jb, &i__3, &c_b13, &a[j +
207 			a_dim1], lda, &c_b14, &a[j + j * a_dim1], lda, (
208 			ftnlen)5, (ftnlen)12);
209 		spotf2_("Lower", &jb, &a[j + j * a_dim1], lda, info, (ftnlen)
210 			5);
211 		if (*info != 0) {
212 		    goto L30;
213 		}
214 		if (j + jb <= *n) {
215 
216 /*                 Compute the current block column. */
217 
218 		    i__3 = *n - j - jb + 1;
219 		    i__4 = j - 1;
220 		    sgemm_("No transpose", "Transpose", &i__3, &jb, &i__4, &
221 			    c_b13, &a[j + jb + a_dim1], lda, &a[j + a_dim1],
222 			    lda, &c_b14, &a[j + jb + j * a_dim1], lda, (
223 			    ftnlen)12, (ftnlen)9);
224 		    i__3 = *n - j - jb + 1;
225 		    strsm_("Right", "Lower", "Transpose", "Non-unit", &i__3, &
226 			    jb, &c_b14, &a[j + j * a_dim1], lda, &a[j + jb +
227 			    j * a_dim1], lda, (ftnlen)5, (ftnlen)5, (ftnlen)9,
228 			     (ftnlen)8);
229 		}
230 /* L20: */
231 	    }
232 	}
233     }
234     goto L40;
235 
236 L30:
237     *info = *info + j - 1;
238 
239 L40:
240     return 0;
241 
242 /*     End of SPOTRF */
243 
244 } /* spotrf_ */
245 
246