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


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