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 complex c_b1 = {1.f,0.f};
00019 static integer c__1 = 1;
00020
00021 int cpotf2_(char *uplo, integer *n, complex *a, integer *lda,
00022 integer *info)
00023 {
00024
00025 integer a_dim1, a_offset, i__1, i__2, i__3;
00026 real r__1;
00027 complex q__1, q__2;
00028
00029
00030 double sqrt(doublereal);
00031
00032
00033 integer j;
00034 real ajj;
00035 extern VOID cdotc_(complex *, integer *, complex *, integer
00036 *, complex *, integer *);
00037 extern logical lsame_(char *, char *);
00038 extern int cgemv_(char *, integer *, integer *, complex *
00039 , complex *, integer *, complex *, integer *, complex *, complex *
00040 , integer *);
00041 logical upper;
00042 extern int clacgv_(integer *, complex *, integer *),
00043 csscal_(integer *, real *, complex *, integer *), xerbla_(char *,
00044 integer *);
00045 extern logical sisnan_(real *);
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
00118
00119
00120
00121 a_dim1 = *lda;
00122 a_offset = 1 + a_dim1;
00123 a -= a_offset;
00124
00125
00126 *info = 0;
00127 upper = lsame_(uplo, "U");
00128 if (! upper && ! lsame_(uplo, "L")) {
00129 *info = -1;
00130 } else if (*n < 0) {
00131 *info = -2;
00132 } else if (*lda < max(1,*n)) {
00133 *info = -4;
00134 }
00135 if (*info != 0) {
00136 i__1 = -(*info);
00137 xerbla_("CPOTF2", &i__1);
00138 return 0;
00139 }
00140
00141
00142
00143 if (*n == 0) {
00144 return 0;
00145 }
00146
00147 if (upper) {
00148
00149
00150
00151 i__1 = *n;
00152 for (j = 1; j <= i__1; ++j) {
00153
00154
00155
00156 i__2 = j + j * a_dim1;
00157 r__1 = a[i__2].r;
00158 i__3 = j - 1;
00159 cdotc_(&q__2, &i__3, &a[j * a_dim1 + 1], &c__1, &a[j * a_dim1 + 1]
00160 , &c__1);
00161 q__1.r = r__1 - q__2.r, q__1.i = -q__2.i;
00162 ajj = q__1.r;
00163 if (ajj <= 0.f || sisnan_(&ajj)) {
00164 i__2 = j + j * a_dim1;
00165 a[i__2].r = ajj, a[i__2].i = 0.f;
00166 goto L30;
00167 }
00168 ajj = sqrt(ajj);
00169 i__2 = j + j * a_dim1;
00170 a[i__2].r = ajj, a[i__2].i = 0.f;
00171
00172
00173
00174 if (j < *n) {
00175 i__2 = j - 1;
00176 clacgv_(&i__2, &a[j * a_dim1 + 1], &c__1);
00177 i__2 = j - 1;
00178 i__3 = *n - j;
00179 q__1.r = -1.f, q__1.i = -0.f;
00180 cgemv_("Transpose", &i__2, &i__3, &q__1, &a[(j + 1) * a_dim1
00181 + 1], lda, &a[j * a_dim1 + 1], &c__1, &c_b1, &a[j + (
00182 j + 1) * a_dim1], lda);
00183 i__2 = j - 1;
00184 clacgv_(&i__2, &a[j * a_dim1 + 1], &c__1);
00185 i__2 = *n - j;
00186 r__1 = 1.f / ajj;
00187 csscal_(&i__2, &r__1, &a[j + (j + 1) * a_dim1], lda);
00188 }
00189
00190 }
00191 } else {
00192
00193
00194
00195 i__1 = *n;
00196 for (j = 1; j <= i__1; ++j) {
00197
00198
00199
00200 i__2 = j + j * a_dim1;
00201 r__1 = a[i__2].r;
00202 i__3 = j - 1;
00203 cdotc_(&q__2, &i__3, &a[j + a_dim1], lda, &a[j + a_dim1], lda);
00204 q__1.r = r__1 - q__2.r, q__1.i = -q__2.i;
00205 ajj = q__1.r;
00206 if (ajj <= 0.f || sisnan_(&ajj)) {
00207 i__2 = j + j * a_dim1;
00208 a[i__2].r = ajj, a[i__2].i = 0.f;
00209 goto L30;
00210 }
00211 ajj = sqrt(ajj);
00212 i__2 = j + j * a_dim1;
00213 a[i__2].r = ajj, a[i__2].i = 0.f;
00214
00215
00216
00217 if (j < *n) {
00218 i__2 = j - 1;
00219 clacgv_(&i__2, &a[j + a_dim1], lda);
00220 i__2 = *n - j;
00221 i__3 = j - 1;
00222 q__1.r = -1.f, q__1.i = -0.f;
00223 cgemv_("No transpose", &i__2, &i__3, &q__1, &a[j + 1 + a_dim1]
00224 , lda, &a[j + a_dim1], lda, &c_b1, &a[j + 1 + j *
00225 a_dim1], &c__1);
00226 i__2 = j - 1;
00227 clacgv_(&i__2, &a[j + a_dim1], lda);
00228 i__2 = *n - j;
00229 r__1 = 1.f / ajj;
00230 csscal_(&i__2, &r__1, &a[j + 1 + j * a_dim1], &c__1);
00231 }
00232
00233 }
00234 }
00235 goto L40;
00236
00237 L30:
00238 *info = j;
00239
00240 L40:
00241 return 0;
00242
00243
00244
00245 }