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