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__3 = 3;
00019 static integer c__1 = 1;
00020 static doublereal c_b12 = 0.;
00021 static doublereal c_b19 = -1.;
00022 static doublereal c_b26 = 1.;
00023
00024 int dlagsy_(integer *n, integer *k, doublereal *d__,
00025 doublereal *a, integer *lda, integer *iseed, doublereal *work,
00026 integer *info)
00027 {
00028
00029 integer a_dim1, a_offset, i__1, i__2, i__3;
00030 doublereal d__1;
00031
00032
00033 double d_sign(doublereal *, doublereal *);
00034
00035
00036 integer i__, j;
00037 doublereal wa, wb, wn, tau;
00038 extern int dger_(integer *, integer *, doublereal *,
00039 doublereal *, integer *, doublereal *, integer *, doublereal *,
00040 integer *);
00041 extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *,
00042 integer *), dnrm2_(integer *, doublereal *, integer *);
00043 extern int dsyr2_(char *, integer *, doublereal *,
00044 doublereal *, integer *, doublereal *, integer *, doublereal *,
00045 integer *);
00046 doublereal alpha;
00047 extern int dscal_(integer *, doublereal *, doublereal *,
00048 integer *), dgemv_(char *, integer *, integer *, doublereal *,
00049 doublereal *, integer *, doublereal *, integer *, doublereal *,
00050 doublereal *, integer *), daxpy_(integer *, doublereal *,
00051 doublereal *, integer *, doublereal *, integer *), dsymv_(char *,
00052 integer *, doublereal *, doublereal *, integer *, doublereal *,
00053 integer *, doublereal *, doublereal *, integer *),
00054 xerbla_(char *, integer *), dlarnv_(integer *, integer *,
00055 integer *, doublereal *);
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 --d__;
00125 a_dim1 = *lda;
00126 a_offset = 1 + a_dim1;
00127 a -= a_offset;
00128 --iseed;
00129 --work;
00130
00131
00132 *info = 0;
00133 if (*n < 0) {
00134 *info = -1;
00135 } else if (*k < 0 || *k > *n - 1) {
00136 *info = -2;
00137 } else if (*lda < max(1,*n)) {
00138 *info = -5;
00139 }
00140 if (*info < 0) {
00141 i__1 = -(*info);
00142 xerbla_("DLAGSY", &i__1);
00143 return 0;
00144 }
00145
00146
00147
00148 i__1 = *n;
00149 for (j = 1; j <= i__1; ++j) {
00150 i__2 = *n;
00151 for (i__ = j + 1; i__ <= i__2; ++i__) {
00152 a[i__ + j * a_dim1] = 0.;
00153
00154 }
00155
00156 }
00157 i__1 = *n;
00158 for (i__ = 1; i__ <= i__1; ++i__) {
00159 a[i__ + i__ * a_dim1] = d__[i__];
00160
00161 }
00162
00163
00164
00165 for (i__ = *n - 1; i__ >= 1; --i__) {
00166
00167
00168
00169 i__1 = *n - i__ + 1;
00170 dlarnv_(&c__3, &iseed[1], &i__1, &work[1]);
00171 i__1 = *n - i__ + 1;
00172 wn = dnrm2_(&i__1, &work[1], &c__1);
00173 wa = d_sign(&wn, &work[1]);
00174 if (wn == 0.) {
00175 tau = 0.;
00176 } else {
00177 wb = work[1] + wa;
00178 i__1 = *n - i__;
00179 d__1 = 1. / wb;
00180 dscal_(&i__1, &d__1, &work[2], &c__1);
00181 work[1] = 1.;
00182 tau = wb / wa;
00183 }
00184
00185
00186
00187
00188
00189
00190 i__1 = *n - i__ + 1;
00191 dsymv_("Lower", &i__1, &tau, &a[i__ + i__ * a_dim1], lda, &work[1], &
00192 c__1, &c_b12, &work[*n + 1], &c__1);
00193
00194
00195
00196 i__1 = *n - i__ + 1;
00197 alpha = tau * -.5 * ddot_(&i__1, &work[*n + 1], &c__1, &work[1], &
00198 c__1);
00199 i__1 = *n - i__ + 1;
00200 daxpy_(&i__1, &alpha, &work[1], &c__1, &work[*n + 1], &c__1);
00201
00202
00203
00204 i__1 = *n - i__ + 1;
00205 dsyr2_("Lower", &i__1, &c_b19, &work[1], &c__1, &work[*n + 1], &c__1,
00206 &a[i__ + i__ * a_dim1], lda);
00207
00208 }
00209
00210
00211
00212 i__1 = *n - 1 - *k;
00213 for (i__ = 1; i__ <= i__1; ++i__) {
00214
00215
00216
00217 i__2 = *n - *k - i__ + 1;
00218 wn = dnrm2_(&i__2, &a[*k + i__ + i__ * a_dim1], &c__1);
00219 wa = d_sign(&wn, &a[*k + i__ + i__ * a_dim1]);
00220 if (wn == 0.) {
00221 tau = 0.;
00222 } else {
00223 wb = a[*k + i__ + i__ * a_dim1] + wa;
00224 i__2 = *n - *k - i__;
00225 d__1 = 1. / wb;
00226 dscal_(&i__2, &d__1, &a[*k + i__ + 1 + i__ * a_dim1], &c__1);
00227 a[*k + i__ + i__ * a_dim1] = 1.;
00228 tau = wb / wa;
00229 }
00230
00231
00232
00233 i__2 = *n - *k - i__ + 1;
00234 i__3 = *k - 1;
00235 dgemv_("Transpose", &i__2, &i__3, &c_b26, &a[*k + i__ + (i__ + 1) *
00236 a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b12, &
00237 work[1], &c__1);
00238 i__2 = *n - *k - i__ + 1;
00239 i__3 = *k - 1;
00240 d__1 = -tau;
00241 dger_(&i__2, &i__3, &d__1, &a[*k + i__ + i__ * a_dim1], &c__1, &work[
00242 1], &c__1, &a[*k + i__ + (i__ + 1) * a_dim1], lda);
00243
00244
00245
00246
00247
00248 i__2 = *n - *k - i__ + 1;
00249 dsymv_("Lower", &i__2, &tau, &a[*k + i__ + (*k + i__) * a_dim1], lda,
00250 &a[*k + i__ + i__ * a_dim1], &c__1, &c_b12, &work[1], &c__1);
00251
00252
00253
00254 i__2 = *n - *k - i__ + 1;
00255 alpha = tau * -.5 * ddot_(&i__2, &work[1], &c__1, &a[*k + i__ + i__ *
00256 a_dim1], &c__1);
00257 i__2 = *n - *k - i__ + 1;
00258 daxpy_(&i__2, &alpha, &a[*k + i__ + i__ * a_dim1], &c__1, &work[1], &
00259 c__1);
00260
00261
00262
00263 i__2 = *n - *k - i__ + 1;
00264 dsyr2_("Lower", &i__2, &c_b19, &a[*k + i__ + i__ * a_dim1], &c__1, &
00265 work[1], &c__1, &a[*k + i__ + (*k + i__) * a_dim1], lda);
00266
00267 a[*k + i__ + i__ * a_dim1] = -wa;
00268 i__2 = *n;
00269 for (j = *k + i__ + 1; j <= i__2; ++j) {
00270 a[j + i__ * a_dim1] = 0.;
00271
00272 }
00273
00274 }
00275
00276
00277
00278 i__1 = *n;
00279 for (j = 1; j <= i__1; ++j) {
00280 i__2 = *n;
00281 for (i__ = j + 1; i__ <= i__2; ++i__) {
00282 a[j + i__ * a_dim1] = a[i__ + j * a_dim1];
00283
00284 }
00285
00286 }
00287 return 0;
00288
00289
00290
00291 }