Go to the documentation of this file.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 zlansp_(char *norm, char *uplo, integer *n, doublecomplex *ap,
00021 doublereal *work)
00022 {
00023
00024 integer i__1, i__2;
00025 doublereal ret_val, d__1, d__2;
00026
00027
00028 double z_abs(doublecomplex *), d_imag(doublecomplex *), sqrt(doublereal);
00029
00030
00031 integer i__, j, k;
00032 doublereal sum, absa, scale;
00033 extern logical lsame_(char *, char *);
00034 doublereal value;
00035 extern int zlassq_(integer *, doublecomplex *, integer *,
00036 doublereal *, doublereal *);
00037
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 --work;
00117 --ap;
00118
00119
00120 if (*n == 0) {
00121 value = 0.;
00122 } else if (lsame_(norm, "M")) {
00123
00124
00125
00126 value = 0.;
00127 if (lsame_(uplo, "U")) {
00128 k = 1;
00129 i__1 = *n;
00130 for (j = 1; j <= i__1; ++j) {
00131 i__2 = k + j - 1;
00132 for (i__ = k; i__ <= i__2; ++i__) {
00133
00134 d__1 = value, d__2 = z_abs(&ap[i__]);
00135 value = max(d__1,d__2);
00136
00137 }
00138 k += j;
00139
00140 }
00141 } else {
00142 k = 1;
00143 i__1 = *n;
00144 for (j = 1; j <= i__1; ++j) {
00145 i__2 = k + *n - j;
00146 for (i__ = k; i__ <= i__2; ++i__) {
00147
00148 d__1 = value, d__2 = z_abs(&ap[i__]);
00149 value = max(d__1,d__2);
00150
00151 }
00152 k = k + *n - j + 1;
00153
00154 }
00155 }
00156 } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') {
00157
00158
00159
00160 value = 0.;
00161 k = 1;
00162 if (lsame_(uplo, "U")) {
00163 i__1 = *n;
00164 for (j = 1; j <= i__1; ++j) {
00165 sum = 0.;
00166 i__2 = j - 1;
00167 for (i__ = 1; i__ <= i__2; ++i__) {
00168 absa = z_abs(&ap[k]);
00169 sum += absa;
00170 work[i__] += absa;
00171 ++k;
00172
00173 }
00174 work[j] = sum + z_abs(&ap[k]);
00175 ++k;
00176
00177 }
00178 i__1 = *n;
00179 for (i__ = 1; i__ <= i__1; ++i__) {
00180
00181 d__1 = value, d__2 = work[i__];
00182 value = max(d__1,d__2);
00183
00184 }
00185 } else {
00186 i__1 = *n;
00187 for (i__ = 1; i__ <= i__1; ++i__) {
00188 work[i__] = 0.;
00189
00190 }
00191 i__1 = *n;
00192 for (j = 1; j <= i__1; ++j) {
00193 sum = work[j] + z_abs(&ap[k]);
00194 ++k;
00195 i__2 = *n;
00196 for (i__ = j + 1; i__ <= i__2; ++i__) {
00197 absa = z_abs(&ap[k]);
00198 sum += absa;
00199 work[i__] += absa;
00200 ++k;
00201
00202 }
00203 value = max(value,sum);
00204
00205 }
00206 }
00207 } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
00208
00209
00210
00211 scale = 0.;
00212 sum = 1.;
00213 k = 2;
00214 if (lsame_(uplo, "U")) {
00215 i__1 = *n;
00216 for (j = 2; j <= i__1; ++j) {
00217 i__2 = j - 1;
00218 zlassq_(&i__2, &ap[k], &c__1, &scale, &sum);
00219 k += j;
00220
00221 }
00222 } else {
00223 i__1 = *n - 1;
00224 for (j = 1; j <= i__1; ++j) {
00225 i__2 = *n - j;
00226 zlassq_(&i__2, &ap[k], &c__1, &scale, &sum);
00227 k = k + *n - j + 1;
00228
00229 }
00230 }
00231 sum *= 2;
00232 k = 1;
00233 i__1 = *n;
00234 for (i__ = 1; i__ <= i__1; ++i__) {
00235 i__2 = k;
00236 if (ap[i__2].r != 0.) {
00237 i__2 = k;
00238 absa = (d__1 = ap[i__2].r, abs(d__1));
00239 if (scale < absa) {
00240
00241 d__1 = scale / absa;
00242 sum = sum * (d__1 * d__1) + 1.;
00243 scale = absa;
00244 } else {
00245
00246 d__1 = absa / scale;
00247 sum += d__1 * d__1;
00248 }
00249 }
00250 if (d_imag(&ap[k]) != 0.) {
00251 absa = (d__1 = d_imag(&ap[k]), abs(d__1));
00252 if (scale < absa) {
00253
00254 d__1 = scale / absa;
00255 sum = sum * (d__1 * d__1) + 1.;
00256 scale = absa;
00257 } else {
00258
00259 d__1 = absa / scale;
00260 sum += d__1 * d__1;
00261 }
00262 }
00263 if (lsame_(uplo, "U")) {
00264 k = k + i__ + 1;
00265 } else {
00266 k = k + *n - i__ + 1;
00267 }
00268
00269 }
00270 value = scale * sqrt(sum);
00271 }
00272
00273 ret_val = value;
00274 return ret_val;
00275
00276
00277
00278 }