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