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 static integer c_n1 = -1;
00021 static integer c__2 = 2;
00022
00023 int ctrtri_(char *uplo, char *diag, integer *n, complex *a,
00024 integer *lda, integer *info)
00025 {
00026
00027 address a__1[2];
00028 integer a_dim1, a_offset, i__1, i__2, i__3[2], i__4, i__5;
00029 complex q__1;
00030 char ch__1[2];
00031
00032
00033 int s_cat(char *, char **, integer *, integer *, ftnlen);
00034
00035
00036 integer j, jb, nb, nn;
00037 extern logical lsame_(char *, char *);
00038 extern int ctrmm_(char *, char *, char *, char *,
00039 integer *, integer *, complex *, complex *, integer *, complex *,
00040 integer *), ctrsm_(char *, char *,
00041 char *, char *, integer *, integer *, complex *, complex *,
00042 integer *, complex *, integer *);
00043 logical upper;
00044 extern int ctrti2_(char *, char *, integer *, complex *,
00045 integer *, integer *), xerbla_(char *, integer *);
00046 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00047 integer *, integer *);
00048 logical nounit;
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 nounit = lsame_(diag, "N");
00129 if (! upper && ! lsame_(uplo, "L")) {
00130 *info = -1;
00131 } else if (! nounit && ! lsame_(diag, "U")) {
00132 *info = -2;
00133 } else if (*n < 0) {
00134 *info = -3;
00135 } else if (*lda < max(1,*n)) {
00136 *info = -5;
00137 }
00138 if (*info != 0) {
00139 i__1 = -(*info);
00140 xerbla_("CTRTRI", &i__1);
00141 return 0;
00142 }
00143
00144
00145
00146 if (*n == 0) {
00147 return 0;
00148 }
00149
00150
00151
00152 if (nounit) {
00153 i__1 = *n;
00154 for (*info = 1; *info <= i__1; ++(*info)) {
00155 i__2 = *info + *info * a_dim1;
00156 if (a[i__2].r == 0.f && a[i__2].i == 0.f) {
00157 return 0;
00158 }
00159
00160 }
00161 *info = 0;
00162 }
00163
00164
00165
00166
00167 i__3[0] = 1, a__1[0] = uplo;
00168 i__3[1] = 1, a__1[1] = diag;
00169 s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00170 nb = ilaenv_(&c__1, "CTRTRI", ch__1, n, &c_n1, &c_n1, &c_n1);
00171 if (nb <= 1 || nb >= *n) {
00172
00173
00174
00175 ctrti2_(uplo, diag, n, &a[a_offset], lda, info);
00176 } else {
00177
00178
00179
00180 if (upper) {
00181
00182
00183
00184 i__1 = *n;
00185 i__2 = nb;
00186 for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00187
00188 i__4 = nb, i__5 = *n - j + 1;
00189 jb = min(i__4,i__5);
00190
00191
00192
00193 i__4 = j - 1;
00194 ctrmm_("Left", "Upper", "No transpose", diag, &i__4, &jb, &
00195 c_b1, &a[a_offset], lda, &a[j * a_dim1 + 1], lda);
00196 i__4 = j - 1;
00197 q__1.r = -1.f, q__1.i = -0.f;
00198 ctrsm_("Right", "Upper", "No transpose", diag, &i__4, &jb, &
00199 q__1, &a[j + j * a_dim1], lda, &a[j * a_dim1 + 1],
00200 lda);
00201
00202
00203
00204 ctrti2_("Upper", diag, &jb, &a[j + j * a_dim1], lda, info);
00205
00206 }
00207 } else {
00208
00209
00210
00211 nn = (*n - 1) / nb * nb + 1;
00212 i__2 = -nb;
00213 for (j = nn; i__2 < 0 ? j >= 1 : j <= 1; j += i__2) {
00214
00215 i__1 = nb, i__4 = *n - j + 1;
00216 jb = min(i__1,i__4);
00217 if (j + jb <= *n) {
00218
00219
00220
00221 i__1 = *n - j - jb + 1;
00222 ctrmm_("Left", "Lower", "No transpose", diag, &i__1, &jb,
00223 &c_b1, &a[j + jb + (j + jb) * a_dim1], lda, &a[j
00224 + jb + j * a_dim1], lda);
00225 i__1 = *n - j - jb + 1;
00226 q__1.r = -1.f, q__1.i = -0.f;
00227 ctrsm_("Right", "Lower", "No transpose", diag, &i__1, &jb,
00228 &q__1, &a[j + j * a_dim1], lda, &a[j + jb + j *
00229 a_dim1], lda);
00230 }
00231
00232
00233
00234 ctrti2_("Lower", diag, &jb, &a[j + j * a_dim1], lda, info);
00235
00236 }
00237 }
00238 }
00239
00240 return 0;
00241
00242
00243
00244 }