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