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
00020 doublereal clantr_(char *norm, char *uplo, char *diag, integer *m, integer *n,
00021 complex *a, integer *lda, real *work)
00022 {
00023
00024 integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
00025 real ret_val, r__1, r__2;
00026
00027
00028 double c_abs(complex *), sqrt(doublereal);
00029
00030
00031 integer i__, j;
00032 real sum, scale;
00033 logical udiag;
00034 extern logical lsame_(char *, char *);
00035 real value;
00036 extern int classq_(integer *, complex *, integer *, real
00037 *, real *);
00038
00039
00040
00041
00042
00043
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
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 a_dim1 = *lda;
00134 a_offset = 1 + a_dim1;
00135 a -= a_offset;
00136 --work;
00137
00138
00139 if (min(*m,*n) == 0) {
00140 value = 0.f;
00141 } else if (lsame_(norm, "M")) {
00142
00143
00144
00145 if (lsame_(diag, "U")) {
00146 value = 1.f;
00147 if (lsame_(uplo, "U")) {
00148 i__1 = *n;
00149 for (j = 1; j <= i__1; ++j) {
00150
00151 i__3 = *m, i__4 = j - 1;
00152 i__2 = min(i__3,i__4);
00153 for (i__ = 1; i__ <= i__2; ++i__) {
00154
00155 r__1 = value, r__2 = c_abs(&a[i__ + j * a_dim1]);
00156 value = dmax(r__1,r__2);
00157
00158 }
00159
00160 }
00161 } else {
00162 i__1 = *n;
00163 for (j = 1; j <= i__1; ++j) {
00164 i__2 = *m;
00165 for (i__ = j + 1; i__ <= i__2; ++i__) {
00166
00167 r__1 = value, r__2 = c_abs(&a[i__ + j * a_dim1]);
00168 value = dmax(r__1,r__2);
00169
00170 }
00171
00172 }
00173 }
00174 } else {
00175 value = 0.f;
00176 if (lsame_(uplo, "U")) {
00177 i__1 = *n;
00178 for (j = 1; j <= i__1; ++j) {
00179 i__2 = min(*m,j);
00180 for (i__ = 1; i__ <= i__2; ++i__) {
00181
00182 r__1 = value, r__2 = c_abs(&a[i__ + j * a_dim1]);
00183 value = dmax(r__1,r__2);
00184
00185 }
00186
00187 }
00188 } else {
00189 i__1 = *n;
00190 for (j = 1; j <= i__1; ++j) {
00191 i__2 = *m;
00192 for (i__ = j; i__ <= i__2; ++i__) {
00193
00194 r__1 = value, r__2 = c_abs(&a[i__ + j * a_dim1]);
00195 value = dmax(r__1,r__2);
00196
00197 }
00198
00199 }
00200 }
00201 }
00202 } else if (lsame_(norm, "O") || *(unsigned char *)
00203 norm == '1') {
00204
00205
00206
00207 value = 0.f;
00208 udiag = lsame_(diag, "U");
00209 if (lsame_(uplo, "U")) {
00210 i__1 = *n;
00211 for (j = 1; j <= i__1; ++j) {
00212 if (udiag && j <= *m) {
00213 sum = 1.f;
00214 i__2 = j - 1;
00215 for (i__ = 1; i__ <= i__2; ++i__) {
00216 sum += c_abs(&a[i__ + j * a_dim1]);
00217
00218 }
00219 } else {
00220 sum = 0.f;
00221 i__2 = min(*m,j);
00222 for (i__ = 1; i__ <= i__2; ++i__) {
00223 sum += c_abs(&a[i__ + j * a_dim1]);
00224
00225 }
00226 }
00227 value = dmax(value,sum);
00228
00229 }
00230 } else {
00231 i__1 = *n;
00232 for (j = 1; j <= i__1; ++j) {
00233 if (udiag) {
00234 sum = 1.f;
00235 i__2 = *m;
00236 for (i__ = j + 1; i__ <= i__2; ++i__) {
00237 sum += c_abs(&a[i__ + j * a_dim1]);
00238
00239 }
00240 } else {
00241 sum = 0.f;
00242 i__2 = *m;
00243 for (i__ = j; i__ <= i__2; ++i__) {
00244 sum += c_abs(&a[i__ + j * a_dim1]);
00245
00246 }
00247 }
00248 value = dmax(value,sum);
00249
00250 }
00251 }
00252 } else if (lsame_(norm, "I")) {
00253
00254
00255
00256 if (lsame_(uplo, "U")) {
00257 if (lsame_(diag, "U")) {
00258 i__1 = *m;
00259 for (i__ = 1; i__ <= i__1; ++i__) {
00260 work[i__] = 1.f;
00261
00262 }
00263 i__1 = *n;
00264 for (j = 1; j <= i__1; ++j) {
00265
00266 i__3 = *m, i__4 = j - 1;
00267 i__2 = min(i__3,i__4);
00268 for (i__ = 1; i__ <= i__2; ++i__) {
00269 work[i__] += c_abs(&a[i__ + j * a_dim1]);
00270
00271 }
00272
00273 }
00274 } else {
00275 i__1 = *m;
00276 for (i__ = 1; i__ <= i__1; ++i__) {
00277 work[i__] = 0.f;
00278
00279 }
00280 i__1 = *n;
00281 for (j = 1; j <= i__1; ++j) {
00282 i__2 = min(*m,j);
00283 for (i__ = 1; i__ <= i__2; ++i__) {
00284 work[i__] += c_abs(&a[i__ + j * a_dim1]);
00285
00286 }
00287
00288 }
00289 }
00290 } else {
00291 if (lsame_(diag, "U")) {
00292 i__1 = *n;
00293 for (i__ = 1; i__ <= i__1; ++i__) {
00294 work[i__] = 1.f;
00295
00296 }
00297 i__1 = *m;
00298 for (i__ = *n + 1; i__ <= i__1; ++i__) {
00299 work[i__] = 0.f;
00300
00301 }
00302 i__1 = *n;
00303 for (j = 1; j <= i__1; ++j) {
00304 i__2 = *m;
00305 for (i__ = j + 1; i__ <= i__2; ++i__) {
00306 work[i__] += c_abs(&a[i__ + j * a_dim1]);
00307
00308 }
00309
00310 }
00311 } else {
00312 i__1 = *m;
00313 for (i__ = 1; i__ <= i__1; ++i__) {
00314 work[i__] = 0.f;
00315
00316 }
00317 i__1 = *n;
00318 for (j = 1; j <= i__1; ++j) {
00319 i__2 = *m;
00320 for (i__ = j; i__ <= i__2; ++i__) {
00321 work[i__] += c_abs(&a[i__ + j * a_dim1]);
00322
00323 }
00324
00325 }
00326 }
00327 }
00328 value = 0.f;
00329 i__1 = *m;
00330 for (i__ = 1; i__ <= i__1; ++i__) {
00331
00332 r__1 = value, r__2 = work[i__];
00333 value = dmax(r__1,r__2);
00334
00335 }
00336 } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
00337
00338
00339
00340 if (lsame_(uplo, "U")) {
00341 if (lsame_(diag, "U")) {
00342 scale = 1.f;
00343 sum = (real) min(*m,*n);
00344 i__1 = *n;
00345 for (j = 2; j <= i__1; ++j) {
00346
00347 i__3 = *m, i__4 = j - 1;
00348 i__2 = min(i__3,i__4);
00349 classq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
00350
00351 }
00352 } else {
00353 scale = 0.f;
00354 sum = 1.f;
00355 i__1 = *n;
00356 for (j = 1; j <= i__1; ++j) {
00357 i__2 = min(*m,j);
00358 classq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
00359
00360 }
00361 }
00362 } else {
00363 if (lsame_(diag, "U")) {
00364 scale = 1.f;
00365 sum = (real) min(*m,*n);
00366 i__1 = *n;
00367 for (j = 1; j <= i__1; ++j) {
00368 i__2 = *m - j;
00369
00370 i__3 = *m, i__4 = j + 1;
00371 classq_(&i__2, &a[min(i__3, i__4)+ j * a_dim1], &c__1, &
00372 scale, &sum);
00373
00374 }
00375 } else {
00376 scale = 0.f;
00377 sum = 1.f;
00378 i__1 = *n;
00379 for (j = 1; j <= i__1; ++j) {
00380 i__2 = *m - j + 1;
00381 classq_(&i__2, &a[j + j * a_dim1], &c__1, &scale, &sum);
00382
00383 }
00384 }
00385 }
00386 value = scale * sqrt(sum);
00387 }
00388
00389 ret_val = value;
00390 return ret_val;
00391
00392
00393
00394 }