00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016
00017
00018 static integer c__1 = 1;
00019 static integer c_n1 = -1;
00020 static real c_b13 = -1.f;
00021 static real c_b14 = 1.f;
00022
00023 int spotrf_(char *uplo, integer *n, real *a, integer *lda,
00024 integer *info)
00025 {
00026
00027 integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
00028
00029
00030 integer j, jb, nb;
00031 extern logical lsame_(char *, char *);
00032 extern int sgemm_(char *, char *, integer *, integer *,
00033 integer *, real *, real *, integer *, real *, integer *, real *,
00034 real *, integer *);
00035 logical upper;
00036 extern int strsm_(char *, char *, char *, char *,
00037 integer *, integer *, real *, real *, integer *, real *, integer *
00038 ), ssyrk_(char *, char *, integer
00039 *, integer *, real *, real *, integer *, real *, real *, integer *
00040 ), spotf2_(char *, integer *, real *, integer *,
00041 integer *), xerbla_(char *, integer *);
00042 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00043 integer *, integer *);
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 a_dim1 = *lda;
00118 a_offset = 1 + a_dim1;
00119 a -= a_offset;
00120
00121
00122 *info = 0;
00123 upper = lsame_(uplo, "U");
00124 if (! upper && ! lsame_(uplo, "L")) {
00125 *info = -1;
00126 } else if (*n < 0) {
00127 *info = -2;
00128 } else if (*lda < max(1,*n)) {
00129 *info = -4;
00130 }
00131 if (*info != 0) {
00132 i__1 = -(*info);
00133 xerbla_("SPOTRF", &i__1);
00134 return 0;
00135 }
00136
00137
00138
00139 if (*n == 0) {
00140 return 0;
00141 }
00142
00143
00144
00145 nb = ilaenv_(&c__1, "SPOTRF", uplo, n, &c_n1, &c_n1, &c_n1);
00146 if (nb <= 1 || nb >= *n) {
00147
00148
00149
00150 spotf2_(uplo, n, &a[a_offset], lda, info);
00151 } else {
00152
00153
00154
00155 if (upper) {
00156
00157
00158
00159 i__1 = *n;
00160 i__2 = nb;
00161 for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00162
00163
00164
00165
00166
00167 i__3 = nb, i__4 = *n - j + 1;
00168 jb = min(i__3,i__4);
00169 i__3 = j - 1;
00170 ssyrk_("Upper", "Transpose", &jb, &i__3, &c_b13, &a[j *
00171 a_dim1 + 1], lda, &c_b14, &a[j + j * a_dim1], lda);
00172 spotf2_("Upper", &jb, &a[j + j * a_dim1], lda, info);
00173 if (*info != 0) {
00174 goto L30;
00175 }
00176 if (j + jb <= *n) {
00177
00178
00179
00180 i__3 = *n - j - jb + 1;
00181 i__4 = j - 1;
00182 sgemm_("Transpose", "No transpose", &jb, &i__3, &i__4, &
00183 c_b13, &a[j * a_dim1 + 1], lda, &a[(j + jb) *
00184 a_dim1 + 1], lda, &c_b14, &a[j + (j + jb) *
00185 a_dim1], lda);
00186 i__3 = *n - j - jb + 1;
00187 strsm_("Left", "Upper", "Transpose", "Non-unit", &jb, &
00188 i__3, &c_b14, &a[j + j * a_dim1], lda, &a[j + (j
00189 + jb) * a_dim1], lda);
00190 }
00191
00192 }
00193
00194 } else {
00195
00196
00197
00198 i__2 = *n;
00199 i__1 = nb;
00200 for (j = 1; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
00201
00202
00203
00204
00205
00206 i__3 = nb, i__4 = *n - j + 1;
00207 jb = min(i__3,i__4);
00208 i__3 = j - 1;
00209 ssyrk_("Lower", "No transpose", &jb, &i__3, &c_b13, &a[j +
00210 a_dim1], lda, &c_b14, &a[j + j * a_dim1], lda);
00211 spotf2_("Lower", &jb, &a[j + j * a_dim1], lda, info);
00212 if (*info != 0) {
00213 goto L30;
00214 }
00215 if (j + jb <= *n) {
00216
00217
00218
00219 i__3 = *n - j - jb + 1;
00220 i__4 = j - 1;
00221 sgemm_("No transpose", "Transpose", &i__3, &jb, &i__4, &
00222 c_b13, &a[j + jb + a_dim1], lda, &a[j + a_dim1],
00223 lda, &c_b14, &a[j + jb + j * a_dim1], lda);
00224 i__3 = *n - j - jb + 1;
00225 strsm_("Right", "Lower", "Transpose", "Non-unit", &i__3, &
00226 jb, &c_b14, &a[j + j * a_dim1], lda, &a[j + jb +
00227 j * a_dim1], lda);
00228 }
00229
00230 }
00231 }
00232 }
00233 goto L40;
00234
00235 L30:
00236 *info = *info + j - 1;
00237
00238 L40:
00239 return 0;
00240
00241
00242
00243 }