LAPACK 3.3.1
Linear Algebra PACKage

clahr2.f

Go to the documentation of this file.
00001       SUBROUTINE CLAHR2( N, K, NB, A, LDA, TAU, T, LDT, Y, LDY )
00002 *
00003 *  -- LAPACK auxiliary routine (version 3.3.1)                        --
00004 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00005 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00006 *  -- April 2009                                                      --
00007 *
00008 *     .. Scalar Arguments ..
00009       INTEGER            K, LDA, LDT, LDY, N, NB
00010 *     ..
00011 *     .. Array Arguments ..
00012       COMPLEX            A( LDA, * ), T( LDT, NB ), TAU( NB ),
00013      $                   Y( LDY, NB )
00014 *     ..
00015 *
00016 *  Purpose
00017 *  =======
00018 *
00019 *  CLAHR2 reduces the first NB columns of A complex general n-BY-(n-k+1)
00020 *  matrix A so that elements below the k-th subdiagonal are zero. The
00021 *  reduction is performed by an unitary similarity transformation
00022 *  Q**H * A * Q. The routine returns the matrices V and T which determine
00023 *  Q as a block reflector I - V*T*v**H, and also the matrix Y = A * V * T.
00024 *
00025 *  This is an auxiliary routine called by CGEHRD.
00026 *
00027 *  Arguments
00028 *  =========
00029 *
00030 *  N       (input) INTEGER
00031 *          The order of the matrix A.
00032 *
00033 *  K       (input) INTEGER
00034 *          The offset for the reduction. Elements below the k-th
00035 *          subdiagonal in the first NB columns are reduced to zero.
00036 *          K < N.
00037 *
00038 *  NB      (input) INTEGER
00039 *          The number of columns to be reduced.
00040 *
00041 *  A       (input/output) COMPLEX array, dimension (LDA,N-K+1)
00042 *          On entry, the n-by-(n-k+1) general matrix A.
00043 *          On exit, the elements on and above the k-th subdiagonal in
00044 *          the first NB columns are overwritten with the corresponding
00045 *          elements of the reduced matrix; the elements below the k-th
00046 *          subdiagonal, with the array TAU, represent the matrix Q as a
00047 *          product of elementary reflectors. The other columns of A are
00048 *          unchanged. See Further Details.
00049 *
00050 *  LDA     (input) INTEGER
00051 *          The leading dimension of the array A.  LDA >= max(1,N).
00052 *
00053 *  TAU     (output) COMPLEX array, dimension (NB)
00054 *          The scalar factors of the elementary reflectors. See Further
00055 *          Details.
00056 *
00057 *  T       (output) COMPLEX array, dimension (LDT,NB)
00058 *          The upper triangular matrix T.
00059 *
00060 *  LDT     (input) INTEGER
00061 *          The leading dimension of the array T.  LDT >= NB.
00062 *
00063 *  Y       (output) COMPLEX array, dimension (LDY,NB)
00064 *          The n-by-nb matrix Y.
00065 *
00066 *  LDY     (input) INTEGER
00067 *          The leading dimension of the array Y. LDY >= N.
00068 *
00069 *  Further Details
00070 *  ===============
00071 *
00072 *  The matrix Q is represented as a product of nb elementary reflectors
00073 *
00074 *     Q = H(1) H(2) . . . H(nb).
00075 *
00076 *  Each H(i) has the form
00077 *
00078 *     H(i) = I - tau * v * v**H
00079 *
00080 *  where tau is a complex scalar, and v is a complex vector with
00081 *  v(1:i+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in
00082 *  A(i+k+1:n,i), and tau in TAU(i).
00083 *
00084 *  The elements of the vectors v together form the (n-k+1)-by-nb matrix
00085 *  V which is needed, with T and Y, to apply the transformation to the
00086 *  unreduced part of the matrix, using an update of the form:
00087 *  A := (I - V*T*V**H) * (A - Y*V**H).
00088 *
00089 *  The contents of A on exit are illustrated by the following example
00090 *  with n = 7, k = 3 and nb = 2:
00091 *
00092 *     ( a   a   a   a   a )
00093 *     ( a   a   a   a   a )
00094 *     ( a   a   a   a   a )
00095 *     ( h   h   a   a   a )
00096 *     ( v1  h   a   a   a )
00097 *     ( v1  v2  a   a   a )
00098 *     ( v1  v2  a   a   a )
00099 *
00100 *  where a denotes an element of the original matrix A, h denotes a
00101 *  modified element of the upper Hessenberg matrix H, and vi denotes an
00102 *  element of the vector defining H(i).
00103 *
00104 *  This subroutine is a slight modification of LAPACK-3.0's DLAHRD
00105 *  incorporating improvements proposed by Quintana-Orti and Van de
00106 *  Gejin. Note that the entries of A(1:K,2:NB) differ from those
00107 *  returned by the original LAPACK-3.0's DLAHRD routine. (This
00108 *  subroutine is not backward compatible with LAPACK-3.0's DLAHRD.)
00109 *
00110 *  References
00111 *  ==========
00112 *
00113 *  Gregorio Quintana-Orti and Robert van de Geijn, "Improving the
00114 *  performance of reduction to Hessenberg form," ACM Transactions on
00115 *  Mathematical Software, 32(2):180-194, June 2006.
00116 *
00117 *  =====================================================================
00118 *
00119 *     .. Parameters ..
00120       COMPLEX            ZERO, ONE
00121       PARAMETER          ( ZERO = ( 0.0E+0, 0.0E+0 ), 
00122      $                     ONE = ( 1.0E+0, 0.0E+0 ) )
00123 *     ..
00124 *     .. Local Scalars ..
00125       INTEGER            I
00126       COMPLEX            EI
00127 *     ..
00128 *     .. External Subroutines ..
00129       EXTERNAL           CAXPY, CCOPY, CGEMM, CGEMV, CLACPY,
00130      $                   CLARFG, CSCAL, CTRMM, CTRMV, CLACGV
00131 *     ..
00132 *     .. Intrinsic Functions ..
00133       INTRINSIC          MIN
00134 *     ..
00135 *     .. Executable Statements ..
00136 *
00137 *     Quick return if possible
00138 *
00139       IF( N.LE.1 )
00140      $   RETURN
00141 *
00142       DO 10 I = 1, NB
00143          IF( I.GT.1 ) THEN
00144 *
00145 *           Update A(K+1:N,I)
00146 *
00147 *           Update I-th column of A - Y * V**H
00148 *
00149             CALL CLACGV( I-1, A( K+I-1, 1 ), LDA ) 
00150             CALL CGEMV( 'NO TRANSPOSE', N-K, I-1, -ONE, Y(K+1,1), LDY,
00151      $                  A( K+I-1, 1 ), LDA, ONE, A( K+1, I ), 1 )
00152             CALL CLACGV( I-1, A( K+I-1, 1 ), LDA ) 
00153 *
00154 *           Apply I - V * T**H * V**H to this column (call it b) from the
00155 *           left, using the last column of T as workspace
00156 *
00157 *           Let  V = ( V1 )   and   b = ( b1 )   (first I-1 rows)
00158 *                    ( V2 )             ( b2 )
00159 *
00160 *           where V1 is unit lower triangular
00161 *
00162 *           w := V1**H * b1
00163 *
00164             CALL CCOPY( I-1, A( K+1, I ), 1, T( 1, NB ), 1 )
00165             CALL CTRMV( 'Lower', 'Conjugate transpose', 'UNIT', 
00166      $                  I-1, A( K+1, 1 ),
00167      $                  LDA, T( 1, NB ), 1 )
00168 *
00169 *           w := w + V2**H * b2
00170 *
00171             CALL CGEMV( 'Conjugate transpose', N-K-I+1, I-1, 
00172      $                  ONE, A( K+I, 1 ),
00173      $                  LDA, A( K+I, I ), 1, ONE, T( 1, NB ), 1 )
00174 *
00175 *           w := T**H * w
00176 *
00177             CALL CTRMV( 'Upper', 'Conjugate transpose', 'NON-UNIT', 
00178      $                  I-1, T, LDT,
00179      $                  T( 1, NB ), 1 )
00180 *
00181 *           b2 := b2 - V2*w
00182 *
00183             CALL CGEMV( 'NO TRANSPOSE', N-K-I+1, I-1, -ONE, 
00184      $                  A( K+I, 1 ),
00185      $                  LDA, T( 1, NB ), 1, ONE, A( K+I, I ), 1 )
00186 *
00187 *           b1 := b1 - V1*w
00188 *
00189             CALL CTRMV( 'Lower', 'NO TRANSPOSE', 
00190      $                  'UNIT', I-1,
00191      $                  A( K+1, 1 ), LDA, T( 1, NB ), 1 )
00192             CALL CAXPY( I-1, -ONE, T( 1, NB ), 1, A( K+1, I ), 1 )
00193 *
00194             A( K+I-1, I-1 ) = EI
00195          END IF
00196 *
00197 *        Generate the elementary reflector H(I) to annihilate
00198 *        A(K+I+1:N,I)
00199 *
00200          CALL CLARFG( N-K-I+1, A( K+I, I ), A( MIN( K+I+1, N ), I ), 1,
00201      $                TAU( I ) )
00202          EI = A( K+I, I )
00203          A( K+I, I ) = ONE
00204 *
00205 *        Compute  Y(K+1:N,I)
00206 *
00207          CALL CGEMV( 'NO TRANSPOSE', N-K, N-K-I+1, 
00208      $               ONE, A( K+1, I+1 ),
00209      $               LDA, A( K+I, I ), 1, ZERO, Y( K+1, I ), 1 )
00210          CALL CGEMV( 'Conjugate transpose', N-K-I+1, I-1, 
00211      $               ONE, A( K+I, 1 ), LDA,
00212      $               A( K+I, I ), 1, ZERO, T( 1, I ), 1 )
00213          CALL CGEMV( 'NO TRANSPOSE', N-K, I-1, -ONE, 
00214      $               Y( K+1, 1 ), LDY,
00215      $               T( 1, I ), 1, ONE, Y( K+1, I ), 1 )
00216          CALL CSCAL( N-K, TAU( I ), Y( K+1, I ), 1 )
00217 *
00218 *        Compute T(1:I,I)
00219 *
00220          CALL CSCAL( I-1, -TAU( I ), T( 1, I ), 1 )
00221          CALL CTRMV( 'Upper', 'No Transpose', 'NON-UNIT', 
00222      $               I-1, T, LDT,
00223      $               T( 1, I ), 1 )
00224          T( I, I ) = TAU( I )
00225 *
00226    10 CONTINUE
00227       A( K+NB, NB ) = EI
00228 *
00229 *     Compute Y(1:K,1:NB)
00230 *
00231       CALL CLACPY( 'ALL', K, NB, A( 1, 2 ), LDA, Y, LDY )
00232       CALL CTRMM( 'RIGHT', 'Lower', 'NO TRANSPOSE', 
00233      $            'UNIT', K, NB,
00234      $            ONE, A( K+1, 1 ), LDA, Y, LDY )
00235       IF( N.GT.K+NB )
00236      $   CALL CGEMM( 'NO TRANSPOSE', 'NO TRANSPOSE', K, 
00237      $               NB, N-K-NB, ONE,
00238      $               A( 1, 2+NB ), LDA, A( K+1+NB, 1 ), LDA, ONE, Y,
00239      $               LDY )
00240       CALL CTRMM( 'RIGHT', 'Upper', 'NO TRANSPOSE', 
00241      $            'NON-UNIT', K, NB,
00242      $            ONE, T, LDT, Y, LDY )
00243 *
00244       RETURN
00245 *
00246 *     End of CLAHR2
00247 *
00248       END
 All Files Functions