zlahrd.c
Go to the documentation of this file.
00001 /* zlahrd.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 doublecomplex c_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__1 = 1;
00021 
00022 /* Subroutine */ int zlahrd_(integer *n, integer *k, integer *nb, 
00023         doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *t, 
00024         integer *ldt, doublecomplex *y, integer *ldy)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, t_dim1, t_offset, y_dim1, y_offset, i__1, i__2, 
00028             i__3;
00029     doublecomplex z__1;
00030 
00031     /* Local variables */
00032     integer i__;
00033     doublecomplex ei;
00034     extern /* Subroutine */ int zscal_(integer *, doublecomplex *, 
00035             doublecomplex *, integer *), zgemv_(char *, integer *, integer *, 
00036             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00037             integer *, doublecomplex *, doublecomplex *, integer *), 
00038             zcopy_(integer *, doublecomplex *, integer *, doublecomplex *, 
00039             integer *), zaxpy_(integer *, doublecomplex *, doublecomplex *, 
00040             integer *, doublecomplex *, integer *), ztrmv_(char *, char *, 
00041             char *, integer *, doublecomplex *, integer *, doublecomplex *, 
00042             integer *), zlarfg_(integer *, 
00043             doublecomplex *, doublecomplex *, integer *, doublecomplex *), 
00044             zlacgv_(integer *, doublecomplex *, integer *);
00045 
00046 
00047 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00048 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00049 /*     November 2006 */
00050 
00051 /*     .. Scalar Arguments .. */
00052 /*     .. */
00053 /*     .. Array Arguments .. */
00054 /*     .. */
00055 
00056 /*  Purpose */
00057 /*  ======= */
00058 
00059 /*  ZLAHRD reduces the first NB columns of a complex general n-by-(n-k+1) */
00060 /*  matrix A so that elements below the k-th subdiagonal are zero. The */
00061 /*  reduction is performed by a unitary similarity transformation */
00062 /*  Q' * A * Q. The routine returns the matrices V and T which determine */
00063 /*  Q as a block reflector I - V*T*V', and also the matrix Y = A * V * T. */
00064 
00065 /*  This is an OBSOLETE auxiliary routine. */
00066 /*  This routine will be 'deprecated' in a  future release. */
00067 /*  Please use the new routine ZLAHR2 instead. */
00068 
00069 /*  Arguments */
00070 /*  ========= */
00071 
00072 /*  N       (input) INTEGER */
00073 /*          The order of the matrix A. */
00074 
00075 /*  K       (input) INTEGER */
00076 /*          The offset for the reduction. Elements below the k-th */
00077 /*          subdiagonal in the first NB columns are reduced to zero. */
00078 
00079 /*  NB      (input) INTEGER */
00080 /*          The number of columns to be reduced. */
00081 
00082 /*  A       (input/output) COMPLEX*16 array, dimension (LDA,N-K+1) */
00083 /*          On entry, the n-by-(n-k+1) general matrix A. */
00084 /*          On exit, the elements on and above the k-th subdiagonal in */
00085 /*          the first NB columns are overwritten with the corresponding */
00086 /*          elements of the reduced matrix; the elements below the k-th */
00087 /*          subdiagonal, with the array TAU, represent the matrix Q as a */
00088 /*          product of elementary reflectors. The other columns of A are */
00089 /*          unchanged. See Further Details. */
00090 
00091 /*  LDA     (input) INTEGER */
00092 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00093 
00094 /*  TAU     (output) COMPLEX*16 array, dimension (NB) */
00095 /*          The scalar factors of the elementary reflectors. See Further */
00096 /*          Details. */
00097 
00098 /*  T       (output) COMPLEX*16 array, dimension (LDT,NB) */
00099 /*          The upper triangular matrix T. */
00100 
00101 /*  LDT     (input) INTEGER */
00102 /*          The leading dimension of the array T.  LDT >= NB. */
00103 
00104 /*  Y       (output) COMPLEX*16 array, dimension (LDY,NB) */
00105 /*          The n-by-nb matrix Y. */
00106 
00107 /*  LDY     (input) INTEGER */
00108 /*          The leading dimension of the array Y. LDY >= max(1,N). */
00109 
00110 /*  Further Details */
00111 /*  =============== */
00112 
00113 /*  The matrix Q is represented as a product of nb elementary reflectors */
00114 
00115 /*     Q = H(1) H(2) . . . H(nb). */
00116 
00117 /*  Each H(i) has the form */
00118 
00119 /*     H(i) = I - tau * v * v' */
00120 
00121 /*  where tau is a complex scalar, and v is a complex vector with */
00122 /*  v(1:i+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in */
00123 /*  A(i+k+1:n,i), and tau in TAU(i). */
00124 
00125 /*  The elements of the vectors v together form the (n-k+1)-by-nb matrix */
00126 /*  V which is needed, with T and Y, to apply the transformation to the */
00127 /*  unreduced part of the matrix, using an update of the form: */
00128 /*  A := (I - V*T*V') * (A - Y*V'). */
00129 
00130 /*  The contents of A on exit are illustrated by the following example */
00131 /*  with n = 7, k = 3 and nb = 2: */
00132 
00133 /*     ( a   h   a   a   a ) */
00134 /*     ( a   h   a   a   a ) */
00135 /*     ( a   h   a   a   a ) */
00136 /*     ( h   h   a   a   a ) */
00137 /*     ( v1  h   a   a   a ) */
00138 /*     ( v1  v2  a   a   a ) */
00139 /*     ( v1  v2  a   a   a ) */
00140 
00141 /*  where a denotes an element of the original matrix A, h denotes a */
00142 /*  modified element of the upper Hessenberg matrix H, and vi denotes an */
00143 /*  element of the vector defining H(i). */
00144 
00145 /*  ===================================================================== */
00146 
00147 /*     .. Parameters .. */
00148 /*     .. */
00149 /*     .. Local Scalars .. */
00150 /*     .. */
00151 /*     .. External Subroutines .. */
00152 /*     .. */
00153 /*     .. Intrinsic Functions .. */
00154 /*     .. */
00155 /*     .. Executable Statements .. */
00156 
00157 /*     Quick return if possible */
00158 
00159     /* Parameter adjustments */
00160     --tau;
00161     a_dim1 = *lda;
00162     a_offset = 1 + a_dim1;
00163     a -= a_offset;
00164     t_dim1 = *ldt;
00165     t_offset = 1 + t_dim1;
00166     t -= t_offset;
00167     y_dim1 = *ldy;
00168     y_offset = 1 + y_dim1;
00169     y -= y_offset;
00170 
00171     /* Function Body */
00172     if (*n <= 1) {
00173         return 0;
00174     }
00175 
00176     i__1 = *nb;
00177     for (i__ = 1; i__ <= i__1; ++i__) {
00178         if (i__ > 1) {
00179 
00180 /*           Update A(1:n,i) */
00181 
00182 /*           Compute i-th column of A - Y * V' */
00183 
00184             i__2 = i__ - 1;
00185             zlacgv_(&i__2, &a[*k + i__ - 1 + a_dim1], lda);
00186             i__2 = i__ - 1;
00187             z__1.r = -1., z__1.i = -0.;
00188             zgemv_("No transpose", n, &i__2, &z__1, &y[y_offset], ldy, &a[*k 
00189                     + i__ - 1 + a_dim1], lda, &c_b2, &a[i__ * a_dim1 + 1], &
00190                     c__1);
00191             i__2 = i__ - 1;
00192             zlacgv_(&i__2, &a[*k + i__ - 1 + a_dim1], lda);
00193 
00194 /*           Apply I - V * T' * V' to this column (call it b) from the */
00195 /*           left, using the last column of T as workspace */
00196 
00197 /*           Let  V = ( V1 )   and   b = ( b1 )   (first I-1 rows) */
00198 /*                    ( V2 )             ( b2 ) */
00199 
00200 /*           where V1 is unit lower triangular */
00201 
00202 /*           w := V1' * b1 */
00203 
00204             i__2 = i__ - 1;
00205             zcopy_(&i__2, &a[*k + 1 + i__ * a_dim1], &c__1, &t[*nb * t_dim1 + 
00206                     1], &c__1);
00207             i__2 = i__ - 1;
00208             ztrmv_("Lower", "Conjugate transpose", "Unit", &i__2, &a[*k + 1 + 
00209                     a_dim1], lda, &t[*nb * t_dim1 + 1], &c__1);
00210 
00211 /*           w := w + V2'*b2 */
00212 
00213             i__2 = *n - *k - i__ + 1;
00214             i__3 = i__ - 1;
00215             zgemv_("Conjugate transpose", &i__2, &i__3, &c_b2, &a[*k + i__ + 
00216                     a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b2, &
00217                     t[*nb * t_dim1 + 1], &c__1);
00218 
00219 /*           w := T'*w */
00220 
00221             i__2 = i__ - 1;
00222             ztrmv_("Upper", "Conjugate transpose", "Non-unit", &i__2, &t[
00223                     t_offset], ldt, &t[*nb * t_dim1 + 1], &c__1);
00224 
00225 /*           b2 := b2 - V2*w */
00226 
00227             i__2 = *n - *k - i__ + 1;
00228             i__3 = i__ - 1;
00229             z__1.r = -1., z__1.i = -0.;
00230             zgemv_("No transpose", &i__2, &i__3, &z__1, &a[*k + i__ + a_dim1], 
00231                      lda, &t[*nb * t_dim1 + 1], &c__1, &c_b2, &a[*k + i__ + 
00232                     i__ * a_dim1], &c__1);
00233 
00234 /*           b1 := b1 - V1*w */
00235 
00236             i__2 = i__ - 1;
00237             ztrmv_("Lower", "No transpose", "Unit", &i__2, &a[*k + 1 + a_dim1]
00238 , lda, &t[*nb * t_dim1 + 1], &c__1);
00239             i__2 = i__ - 1;
00240             z__1.r = -1., z__1.i = -0.;
00241             zaxpy_(&i__2, &z__1, &t[*nb * t_dim1 + 1], &c__1, &a[*k + 1 + i__ 
00242                     * a_dim1], &c__1);
00243 
00244             i__2 = *k + i__ - 1 + (i__ - 1) * a_dim1;
00245             a[i__2].r = ei.r, a[i__2].i = ei.i;
00246         }
00247 
00248 /*        Generate the elementary reflector H(i) to annihilate */
00249 /*        A(k+i+1:n,i) */
00250 
00251         i__2 = *k + i__ + i__ * a_dim1;
00252         ei.r = a[i__2].r, ei.i = a[i__2].i;
00253         i__2 = *n - *k - i__ + 1;
00254 /* Computing MIN */
00255         i__3 = *k + i__ + 1;
00256         zlarfg_(&i__2, &ei, &a[min(i__3, *n)+ i__ * a_dim1], &c__1, &tau[i__])
00257                 ;
00258         i__2 = *k + i__ + i__ * a_dim1;
00259         a[i__2].r = 1., a[i__2].i = 0.;
00260 
00261 /*        Compute  Y(1:n,i) */
00262 
00263         i__2 = *n - *k - i__ + 1;
00264         zgemv_("No transpose", n, &i__2, &c_b2, &a[(i__ + 1) * a_dim1 + 1], 
00265                 lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b1, &y[i__ * 
00266                 y_dim1 + 1], &c__1);
00267         i__2 = *n - *k - i__ + 1;
00268         i__3 = i__ - 1;
00269         zgemv_("Conjugate transpose", &i__2, &i__3, &c_b2, &a[*k + i__ + 
00270                 a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b1, &t[
00271                 i__ * t_dim1 + 1], &c__1);
00272         i__2 = i__ - 1;
00273         z__1.r = -1., z__1.i = -0.;
00274         zgemv_("No transpose", n, &i__2, &z__1, &y[y_offset], ldy, &t[i__ * 
00275                 t_dim1 + 1], &c__1, &c_b2, &y[i__ * y_dim1 + 1], &c__1);
00276         zscal_(n, &tau[i__], &y[i__ * y_dim1 + 1], &c__1);
00277 
00278 /*        Compute T(1:i,i) */
00279 
00280         i__2 = i__ - 1;
00281         i__3 = i__;
00282         z__1.r = -tau[i__3].r, z__1.i = -tau[i__3].i;
00283         zscal_(&i__2, &z__1, &t[i__ * t_dim1 + 1], &c__1);
00284         i__2 = i__ - 1;
00285         ztrmv_("Upper", "No transpose", "Non-unit", &i__2, &t[t_offset], ldt, 
00286                 &t[i__ * t_dim1 + 1], &c__1)
00287                 ;
00288         i__2 = i__ + i__ * t_dim1;
00289         i__3 = i__;
00290         t[i__2].r = tau[i__3].r, t[i__2].i = tau[i__3].i;
00291 
00292 /* L10: */
00293     }
00294     i__1 = *k + *nb + *nb * a_dim1;
00295     a[i__1].r = ei.r, a[i__1].i = ei.i;
00296 
00297     return 0;
00298 
00299 /*     End of ZLAHRD */
00300 
00301 } /* zlahrd_ */


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