zgehd2.c
Go to the documentation of this file.
00001 /* zgehd2.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 
00020 /* Subroutine */ int zgehd2_(integer *n, integer *ilo, integer *ihi, 
00021         doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *
00022         work, integer *info)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, i__1, i__2, i__3;
00026     doublecomplex z__1;
00027 
00028     /* Builtin functions */
00029     void d_cnjg(doublecomplex *, doublecomplex *);
00030 
00031     /* Local variables */
00032     integer i__;
00033     doublecomplex alpha;
00034     extern /* Subroutine */ int zlarf_(char *, integer *, integer *, 
00035             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00036             integer *, doublecomplex *), xerbla_(char *, integer *), zlarfg_(integer *, doublecomplex *, doublecomplex *, 
00037             integer *, doublecomplex *);
00038 
00039 
00040 /*  -- LAPACK routine (version 3.2) -- */
00041 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00042 /*     November 2006 */
00043 
00044 /*     .. Scalar Arguments .. */
00045 /*     .. */
00046 /*     .. Array Arguments .. */
00047 /*     .. */
00048 
00049 /*  Purpose */
00050 /*  ======= */
00051 
00052 /*  ZGEHD2 reduces a complex general matrix A to upper Hessenberg form H */
00053 /*  by a unitary similarity transformation:  Q' * A * Q = H . */
00054 
00055 /*  Arguments */
00056 /*  ========= */
00057 
00058 /*  N       (input) INTEGER */
00059 /*          The order of the matrix A.  N >= 0. */
00060 
00061 /*  ILO     (input) INTEGER */
00062 /*  IHI     (input) INTEGER */
00063 /*          It is assumed that A is already upper triangular in rows */
00064 /*          and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally */
00065 /*          set by a previous call to ZGEBAL; otherwise they should be */
00066 /*          set to 1 and N respectively. See Further Details. */
00067 /*          1 <= ILO <= IHI <= max(1,N). */
00068 
00069 /*  A       (input/output) COMPLEX*16 array, dimension (LDA,N) */
00070 /*          On entry, the n by n general matrix to be reduced. */
00071 /*          On exit, the upper triangle and the first subdiagonal of A */
00072 /*          are overwritten with the upper Hessenberg matrix H, and the */
00073 /*          elements below the first subdiagonal, with the array TAU, */
00074 /*          represent the unitary matrix Q as a product of elementary */
00075 /*          reflectors. See Further Details. */
00076 
00077 /*  LDA     (input) INTEGER */
00078 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00079 
00080 /*  TAU     (output) COMPLEX*16 array, dimension (N-1) */
00081 /*          The scalar factors of the elementary reflectors (see Further */
00082 /*          Details). */
00083 
00084 /*  WORK    (workspace) COMPLEX*16 array, dimension (N) */
00085 
00086 /*  INFO    (output) INTEGER */
00087 /*          = 0:  successful exit */
00088 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00089 
00090 /*  Further Details */
00091 /*  =============== */
00092 
00093 /*  The matrix Q is represented as a product of (ihi-ilo) elementary */
00094 /*  reflectors */
00095 
00096 /*     Q = H(ilo) H(ilo+1) . . . H(ihi-1). */
00097 
00098 /*  Each H(i) has the form */
00099 
00100 /*     H(i) = I - tau * v * v' */
00101 
00102 /*  where tau is a complex scalar, and v is a complex vector with */
00103 /*  v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on */
00104 /*  exit in A(i+2:ihi,i), and tau in TAU(i). */
00105 
00106 /*  The contents of A are illustrated by the following example, with */
00107 /*  n = 7, ilo = 2 and ihi = 6: */
00108 
00109 /*  on entry,                        on exit, */
00110 
00111 /*  ( a   a   a   a   a   a   a )    (  a   a   h   h   h   h   a ) */
00112 /*  (     a   a   a   a   a   a )    (      a   h   h   h   h   a ) */
00113 /*  (     a   a   a   a   a   a )    (      h   h   h   h   h   h ) */
00114 /*  (     a   a   a   a   a   a )    (      v2  h   h   h   h   h ) */
00115 /*  (     a   a   a   a   a   a )    (      v2  v3  h   h   h   h ) */
00116 /*  (     a   a   a   a   a   a )    (      v2  v3  v4  h   h   h ) */
00117 /*  (                         a )    (                          a ) */
00118 
00119 /*  where a denotes an element of the original matrix A, h denotes a */
00120 /*  modified element of the upper Hessenberg matrix H, and vi denotes an */
00121 /*  element of the vector defining H(i). */
00122 
00123 /*  ===================================================================== */
00124 
00125 /*     .. Parameters .. */
00126 /*     .. */
00127 /*     .. Local Scalars .. */
00128 /*     .. */
00129 /*     .. External Subroutines .. */
00130 /*     .. */
00131 /*     .. Intrinsic Functions .. */
00132 /*     .. */
00133 /*     .. Executable Statements .. */
00134 
00135 /*     Test the input parameters */
00136 
00137     /* Parameter adjustments */
00138     a_dim1 = *lda;
00139     a_offset = 1 + a_dim1;
00140     a -= a_offset;
00141     --tau;
00142     --work;
00143 
00144     /* Function Body */
00145     *info = 0;
00146     if (*n < 0) {
00147         *info = -1;
00148     } else if (*ilo < 1 || *ilo > max(1,*n)) {
00149         *info = -2;
00150     } else if (*ihi < min(*ilo,*n) || *ihi > *n) {
00151         *info = -3;
00152     } else if (*lda < max(1,*n)) {
00153         *info = -5;
00154     }
00155     if (*info != 0) {
00156         i__1 = -(*info);
00157         xerbla_("ZGEHD2", &i__1);
00158         return 0;
00159     }
00160 
00161     i__1 = *ihi - 1;
00162     for (i__ = *ilo; i__ <= i__1; ++i__) {
00163 
00164 /*        Compute elementary reflector H(i) to annihilate A(i+2:ihi,i) */
00165 
00166         i__2 = i__ + 1 + i__ * a_dim1;
00167         alpha.r = a[i__2].r, alpha.i = a[i__2].i;
00168         i__2 = *ihi - i__;
00169 /* Computing MIN */
00170         i__3 = i__ + 2;
00171         zlarfg_(&i__2, &alpha, &a[min(i__3, *n)+ i__ * a_dim1], &c__1, &tau[
00172                 i__]);
00173         i__2 = i__ + 1 + i__ * a_dim1;
00174         a[i__2].r = 1., a[i__2].i = 0.;
00175 
00176 /*        Apply H(i) to A(1:ihi,i+1:ihi) from the right */
00177 
00178         i__2 = *ihi - i__;
00179         zlarf_("Right", ihi, &i__2, &a[i__ + 1 + i__ * a_dim1], &c__1, &tau[
00180                 i__], &a[(i__ + 1) * a_dim1 + 1], lda, &work[1]);
00181 
00182 /*        Apply H(i)' to A(i+1:ihi,i+1:n) from the left */
00183 
00184         i__2 = *ihi - i__;
00185         i__3 = *n - i__;
00186         d_cnjg(&z__1, &tau[i__]);
00187         zlarf_("Left", &i__2, &i__3, &a[i__ + 1 + i__ * a_dim1], &c__1, &z__1, 
00188                  &a[i__ + 1 + (i__ + 1) * a_dim1], lda, &work[1]);
00189 
00190         i__2 = i__ + 1 + i__ * a_dim1;
00191         a[i__2].r = alpha.r, a[i__2].i = alpha.i;
00192 /* L10: */
00193     }
00194 
00195     return 0;
00196 
00197 /*     End of ZGEHD2 */
00198 
00199 } /* zgehd2_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:32