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 doublecomplex c_b1 = {1.,0.};
00019 static doublecomplex c_b2 = {0.,0.};
00020 static integer c__1 = 1;
00021
00022 int zgghrd_(char *compq, char *compz, integer *n, integer *
00023 ilo, integer *ihi, doublecomplex *a, integer *lda, doublecomplex *b,
00024 integer *ldb, doublecomplex *q, integer *ldq, doublecomplex *z__,
00025 integer *ldz, integer *info)
00026 {
00027
00028 integer a_dim1, a_offset, b_dim1, b_offset, q_dim1, q_offset, z_dim1,
00029 z_offset, i__1, i__2, i__3;
00030 doublecomplex z__1;
00031
00032
00033 void d_cnjg(doublecomplex *, doublecomplex *);
00034
00035
00036 doublereal c__;
00037 doublecomplex s;
00038 logical ilq, ilz;
00039 integer jcol, jrow;
00040 extern int zrot_(integer *, doublecomplex *, integer *,
00041 doublecomplex *, integer *, doublereal *, doublecomplex *);
00042 extern logical lsame_(char *, char *);
00043 doublecomplex ctemp;
00044 extern int xerbla_(char *, integer *);
00045 integer icompq, icompz;
00046 extern int zlaset_(char *, integer *, integer *,
00047 doublecomplex *, doublecomplex *, doublecomplex *, integer *), zlartg_(doublecomplex *, doublecomplex *, doublereal *,
00048 doublecomplex *, doublecomplex *);
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
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 a_dim1 = *lda;
00185 a_offset = 1 + a_dim1;
00186 a -= a_offset;
00187 b_dim1 = *ldb;
00188 b_offset = 1 + b_dim1;
00189 b -= b_offset;
00190 q_dim1 = *ldq;
00191 q_offset = 1 + q_dim1;
00192 q -= q_offset;
00193 z_dim1 = *ldz;
00194 z_offset = 1 + z_dim1;
00195 z__ -= z_offset;
00196
00197
00198 if (lsame_(compq, "N")) {
00199 ilq = FALSE_;
00200 icompq = 1;
00201 } else if (lsame_(compq, "V")) {
00202 ilq = TRUE_;
00203 icompq = 2;
00204 } else if (lsame_(compq, "I")) {
00205 ilq = TRUE_;
00206 icompq = 3;
00207 } else {
00208 icompq = 0;
00209 }
00210
00211
00212
00213 if (lsame_(compz, "N")) {
00214 ilz = FALSE_;
00215 icompz = 1;
00216 } else if (lsame_(compz, "V")) {
00217 ilz = TRUE_;
00218 icompz = 2;
00219 } else if (lsame_(compz, "I")) {
00220 ilz = TRUE_;
00221 icompz = 3;
00222 } else {
00223 icompz = 0;
00224 }
00225
00226
00227
00228 *info = 0;
00229 if (icompq <= 0) {
00230 *info = -1;
00231 } else if (icompz <= 0) {
00232 *info = -2;
00233 } else if (*n < 0) {
00234 *info = -3;
00235 } else if (*ilo < 1) {
00236 *info = -4;
00237 } else if (*ihi > *n || *ihi < *ilo - 1) {
00238 *info = -5;
00239 } else if (*lda < max(1,*n)) {
00240 *info = -7;
00241 } else if (*ldb < max(1,*n)) {
00242 *info = -9;
00243 } else if (ilq && *ldq < *n || *ldq < 1) {
00244 *info = -11;
00245 } else if (ilz && *ldz < *n || *ldz < 1) {
00246 *info = -13;
00247 }
00248 if (*info != 0) {
00249 i__1 = -(*info);
00250 xerbla_("ZGGHRD", &i__1);
00251 return 0;
00252 }
00253
00254
00255
00256 if (icompq == 3) {
00257 zlaset_("Full", n, n, &c_b2, &c_b1, &q[q_offset], ldq);
00258 }
00259 if (icompz == 3) {
00260 zlaset_("Full", n, n, &c_b2, &c_b1, &z__[z_offset], ldz);
00261 }
00262
00263
00264
00265 if (*n <= 1) {
00266 return 0;
00267 }
00268
00269
00270
00271 i__1 = *n - 1;
00272 for (jcol = 1; jcol <= i__1; ++jcol) {
00273 i__2 = *n;
00274 for (jrow = jcol + 1; jrow <= i__2; ++jrow) {
00275 i__3 = jrow + jcol * b_dim1;
00276 b[i__3].r = 0., b[i__3].i = 0.;
00277
00278 }
00279
00280 }
00281
00282
00283
00284 i__1 = *ihi - 2;
00285 for (jcol = *ilo; jcol <= i__1; ++jcol) {
00286
00287 i__2 = jcol + 2;
00288 for (jrow = *ihi; jrow >= i__2; --jrow) {
00289
00290
00291
00292 i__3 = jrow - 1 + jcol * a_dim1;
00293 ctemp.r = a[i__3].r, ctemp.i = a[i__3].i;
00294 zlartg_(&ctemp, &a[jrow + jcol * a_dim1], &c__, &s, &a[jrow - 1 +
00295 jcol * a_dim1]);
00296 i__3 = jrow + jcol * a_dim1;
00297 a[i__3].r = 0., a[i__3].i = 0.;
00298 i__3 = *n - jcol;
00299 zrot_(&i__3, &a[jrow - 1 + (jcol + 1) * a_dim1], lda, &a[jrow + (
00300 jcol + 1) * a_dim1], lda, &c__, &s);
00301 i__3 = *n + 2 - jrow;
00302 zrot_(&i__3, &b[jrow - 1 + (jrow - 1) * b_dim1], ldb, &b[jrow + (
00303 jrow - 1) * b_dim1], ldb, &c__, &s);
00304 if (ilq) {
00305 d_cnjg(&z__1, &s);
00306 zrot_(n, &q[(jrow - 1) * q_dim1 + 1], &c__1, &q[jrow * q_dim1
00307 + 1], &c__1, &c__, &z__1);
00308 }
00309
00310
00311
00312 i__3 = jrow + jrow * b_dim1;
00313 ctemp.r = b[i__3].r, ctemp.i = b[i__3].i;
00314 zlartg_(&ctemp, &b[jrow + (jrow - 1) * b_dim1], &c__, &s, &b[jrow
00315 + jrow * b_dim1]);
00316 i__3 = jrow + (jrow - 1) * b_dim1;
00317 b[i__3].r = 0., b[i__3].i = 0.;
00318 zrot_(ihi, &a[jrow * a_dim1 + 1], &c__1, &a[(jrow - 1) * a_dim1 +
00319 1], &c__1, &c__, &s);
00320 i__3 = jrow - 1;
00321 zrot_(&i__3, &b[jrow * b_dim1 + 1], &c__1, &b[(jrow - 1) * b_dim1
00322 + 1], &c__1, &c__, &s);
00323 if (ilz) {
00324 zrot_(n, &z__[jrow * z_dim1 + 1], &c__1, &z__[(jrow - 1) *
00325 z_dim1 + 1], &c__1, &c__, &s);
00326 }
00327
00328 }
00329
00330 }
00331
00332 return 0;
00333
00334
00335
00336 }