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 doublereal c_b5 = 0.;
00019 static integer c__1 = 1;
00020 static doublereal c_b19 = 1.;
00021
00022 int dstt21_(integer *n, integer *kband, doublereal *ad,
00023 doublereal *ae, doublereal *sd, doublereal *se, doublereal *u,
00024 integer *ldu, doublereal *work, doublereal *result)
00025 {
00026
00027 integer u_dim1, u_offset, i__1;
00028 doublereal d__1, d__2, d__3;
00029
00030
00031 integer j;
00032 doublereal ulp, unfl;
00033 extern int dsyr_(char *, integer *, doublereal *,
00034 doublereal *, integer *, doublereal *, integer *);
00035 doublereal temp1, temp2;
00036 extern int dsyr2_(char *, integer *, doublereal *,
00037 doublereal *, integer *, doublereal *, integer *, doublereal *,
00038 integer *), dgemm_(char *, char *, integer *, integer *,
00039 integer *, doublereal *, doublereal *, integer *, doublereal *,
00040 integer *, doublereal *, doublereal *, integer *);
00041 doublereal anorm, wnorm;
00042 extern doublereal dlamch_(char *), dlange_(char *, integer *,
00043 integer *, doublereal *, integer *, doublereal *);
00044 extern int dlaset_(char *, integer *, integer *,
00045 doublereal *, doublereal *, doublereal *, integer *);
00046 extern doublereal dlansy_(char *, char *, integer *, doublereal *,
00047 integer *, doublereal *);
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
00134 --ad;
00135 --ae;
00136 --sd;
00137 --se;
00138 u_dim1 = *ldu;
00139 u_offset = 1 + u_dim1;
00140 u -= u_offset;
00141 --work;
00142 --result;
00143
00144
00145 result[1] = 0.;
00146 result[2] = 0.;
00147 if (*n <= 0) {
00148 return 0;
00149 }
00150
00151 unfl = dlamch_("Safe minimum");
00152 ulp = dlamch_("Precision");
00153
00154
00155
00156
00157
00158 dlaset_("Full", n, n, &c_b5, &c_b5, &work[1], n);
00159
00160 anorm = 0.;
00161 temp1 = 0.;
00162
00163 i__1 = *n - 1;
00164 for (j = 1; j <= i__1; ++j) {
00165 work[(*n + 1) * (j - 1) + 1] = ad[j];
00166 work[(*n + 1) * (j - 1) + 2] = ae[j];
00167 temp2 = (d__1 = ae[j], abs(d__1));
00168
00169 d__2 = anorm, d__3 = (d__1 = ad[j], abs(d__1)) + temp1 + temp2;
00170 anorm = max(d__2,d__3);
00171 temp1 = temp2;
00172
00173 }
00174
00175
00176 i__1 = *n;
00177 work[i__1 * i__1] = ad[*n];
00178
00179 d__2 = anorm, d__3 = (d__1 = ad[*n], abs(d__1)) + temp1, d__2 = max(d__2,
00180 d__3);
00181 anorm = max(d__2,unfl);
00182
00183
00184
00185 i__1 = *n;
00186 for (j = 1; j <= i__1; ++j) {
00187 d__1 = -sd[j];
00188 dsyr_("L", n, &d__1, &u[j * u_dim1 + 1], &c__1, &work[1], n);
00189
00190 }
00191
00192 if (*n > 1 && *kband == 1) {
00193 i__1 = *n - 1;
00194 for (j = 1; j <= i__1; ++j) {
00195 d__1 = -se[j];
00196 dsyr2_("L", n, &d__1, &u[j * u_dim1 + 1], &c__1, &u[(j + 1) *
00197 u_dim1 + 1], &c__1, &work[1], n);
00198
00199 }
00200 }
00201
00202
00203 i__1 = *n;
00204 wnorm = dlansy_("1", "L", n, &work[1], n, &work[i__1 * i__1 + 1]);
00205
00206 if (anorm > wnorm) {
00207 result[1] = wnorm / anorm / (*n * ulp);
00208 } else {
00209 if (anorm < 1.) {
00210
00211 d__1 = wnorm, d__2 = *n * anorm;
00212 result[1] = min(d__1,d__2) / anorm / (*n * ulp);
00213 } else {
00214
00215 d__1 = wnorm / anorm, d__2 = (doublereal) (*n);
00216 result[1] = min(d__1,d__2) / (*n * ulp);
00217 }
00218 }
00219
00220
00221
00222
00223
00224 dgemm_("N", "C", n, n, n, &c_b19, &u[u_offset], ldu, &u[u_offset], ldu, &
00225 c_b5, &work[1], n);
00226
00227 i__1 = *n;
00228 for (j = 1; j <= i__1; ++j) {
00229 work[(*n + 1) * (j - 1) + 1] += -1.;
00230
00231 }
00232
00233
00234
00235 i__1 = *n;
00236 d__1 = (doublereal) (*n), d__2 = dlange_("1", n, n, &work[1], n, &work[
00237 i__1 * i__1 + 1]);
00238 result[2] = min(d__1,d__2) / (*n * ulp);
00239
00240 return 0;
00241
00242
00243
00244 }