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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:30