LAPACK 3.3.0
|
00001 SUBROUTINE ZGEBRD( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK, 00002 $ INFO ) 00003 * 00004 * -- LAPACK routine (version 3.2) -- 00005 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00006 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00007 * November 2006 00008 * 00009 * .. Scalar Arguments .. 00010 INTEGER INFO, LDA, LWORK, M, N 00011 * .. 00012 * .. Array Arguments .. 00013 DOUBLE PRECISION D( * ), E( * ) 00014 COMPLEX*16 A( LDA, * ), TAUP( * ), TAUQ( * ), WORK( * ) 00015 * .. 00016 * 00017 * Purpose 00018 * ======= 00019 * 00020 * ZGEBRD reduces a general complex M-by-N matrix A to upper or lower 00021 * bidiagonal form B by a unitary transformation: Q**H * A * P = B. 00022 * 00023 * If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. 00024 * 00025 * Arguments 00026 * ========= 00027 * 00028 * M (input) INTEGER 00029 * The number of rows in the matrix A. M >= 0. 00030 * 00031 * N (input) INTEGER 00032 * The number of columns in the matrix A. N >= 0. 00033 * 00034 * A (input/output) COMPLEX*16 array, dimension (LDA,N) 00035 * On entry, the M-by-N general matrix to be reduced. 00036 * On exit, 00037 * if m >= n, the diagonal and the first superdiagonal are 00038 * overwritten with the upper bidiagonal matrix B; the 00039 * elements below the diagonal, with the array TAUQ, represent 00040 * the unitary matrix Q as a product of elementary 00041 * reflectors, and the elements above the first superdiagonal, 00042 * with the array TAUP, represent the unitary matrix P as 00043 * a product of elementary reflectors; 00044 * if m < n, the diagonal and the first subdiagonal are 00045 * overwritten with the lower bidiagonal matrix B; the 00046 * elements below the first subdiagonal, with the array TAUQ, 00047 * represent the unitary matrix Q as a product of 00048 * elementary reflectors, and the elements above the diagonal, 00049 * with the array TAUP, represent the unitary matrix P as 00050 * a product of elementary reflectors. 00051 * See Further Details. 00052 * 00053 * LDA (input) INTEGER 00054 * The leading dimension of the array A. LDA >= max(1,M). 00055 * 00056 * D (output) DOUBLE PRECISION array, dimension (min(M,N)) 00057 * The diagonal elements of the bidiagonal matrix B: 00058 * D(i) = A(i,i). 00059 * 00060 * E (output) DOUBLE PRECISION array, dimension (min(M,N)-1) 00061 * The off-diagonal elements of the bidiagonal matrix B: 00062 * if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1; 00063 * if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1. 00064 * 00065 * TAUQ (output) COMPLEX*16 array dimension (min(M,N)) 00066 * The scalar factors of the elementary reflectors which 00067 * represent the unitary matrix Q. See Further Details. 00068 * 00069 * TAUP (output) COMPLEX*16 array, dimension (min(M,N)) 00070 * The scalar factors of the elementary reflectors which 00071 * represent the unitary matrix P. See Further Details. 00072 * 00073 * WORK (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK)) 00074 * On exit, if INFO = 0, WORK(1) returns the optimal LWORK. 00075 * 00076 * LWORK (input) INTEGER 00077 * The length of the array WORK. LWORK >= max(1,M,N). 00078 * For optimum performance LWORK >= (M+N)*NB, where NB 00079 * is the optimal blocksize. 00080 * 00081 * If LWORK = -1, then a workspace query is assumed; the routine 00082 * only calculates the optimal size of the WORK array, returns 00083 * this value as the first entry of the WORK array, and no error 00084 * message related to LWORK is issued by XERBLA. 00085 * 00086 * INFO (output) INTEGER 00087 * = 0: successful exit. 00088 * < 0: if INFO = -i, the i-th argument had an illegal value. 00089 * 00090 * Further Details 00091 * =============== 00092 * 00093 * The matrices Q and P are represented as products of elementary 00094 * reflectors: 00095 * 00096 * If m >= n, 00097 * 00098 * Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1) 00099 * 00100 * Each H(i) and G(i) has the form: 00101 * 00102 * H(i) = I - tauq * v * v' and G(i) = I - taup * u * u' 00103 * 00104 * where tauq and taup are complex scalars, and v and u are complex 00105 * vectors; v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in 00106 * A(i+1:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in 00107 * A(i,i+2:n); tauq is stored in TAUQ(i) and taup in TAUP(i). 00108 * 00109 * If m < n, 00110 * 00111 * Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m) 00112 * 00113 * Each H(i) and G(i) has the form: 00114 * 00115 * H(i) = I - tauq * v * v' and G(i) = I - taup * u * u' 00116 * 00117 * where tauq and taup are complex scalars, and v and u are complex 00118 * vectors; v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in 00119 * A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in 00120 * A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i). 00121 * 00122 * The contents of A on exit are illustrated by the following examples: 00123 * 00124 * m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n): 00125 * 00126 * ( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 ) 00127 * ( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 ) 00128 * ( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 ) 00129 * ( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 ) 00130 * ( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 ) 00131 * ( v1 v2 v3 v4 v5 ) 00132 * 00133 * where d and e denote diagonal and off-diagonal elements of B, vi 00134 * denotes an element of the vector defining H(i), and ui an element of 00135 * the vector defining G(i). 00136 * 00137 * ===================================================================== 00138 * 00139 * .. Parameters .. 00140 COMPLEX*16 ONE 00141 PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) ) 00142 * .. 00143 * .. Local Scalars .. 00144 LOGICAL LQUERY 00145 INTEGER I, IINFO, J, LDWRKX, LDWRKY, LWKOPT, MINMN, NB, 00146 $ NBMIN, NX 00147 DOUBLE PRECISION WS 00148 * .. 00149 * .. External Subroutines .. 00150 EXTERNAL XERBLA, ZGEBD2, ZGEMM, ZLABRD 00151 * .. 00152 * .. Intrinsic Functions .. 00153 INTRINSIC DBLE, MAX, MIN 00154 * .. 00155 * .. External Functions .. 00156 INTEGER ILAENV 00157 EXTERNAL ILAENV 00158 * .. 00159 * .. Executable Statements .. 00160 * 00161 * Test the input parameters 00162 * 00163 INFO = 0 00164 NB = MAX( 1, ILAENV( 1, 'ZGEBRD', ' ', M, N, -1, -1 ) ) 00165 LWKOPT = ( M+N )*NB 00166 WORK( 1 ) = DBLE( LWKOPT ) 00167 LQUERY = ( LWORK.EQ.-1 ) 00168 IF( M.LT.0 ) THEN 00169 INFO = -1 00170 ELSE IF( N.LT.0 ) THEN 00171 INFO = -2 00172 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN 00173 INFO = -4 00174 ELSE IF( LWORK.LT.MAX( 1, M, N ) .AND. .NOT.LQUERY ) THEN 00175 INFO = -10 00176 END IF 00177 IF( INFO.LT.0 ) THEN 00178 CALL XERBLA( 'ZGEBRD', -INFO ) 00179 RETURN 00180 ELSE IF( LQUERY ) THEN 00181 RETURN 00182 END IF 00183 * 00184 * Quick return if possible 00185 * 00186 MINMN = MIN( M, N ) 00187 IF( MINMN.EQ.0 ) THEN 00188 WORK( 1 ) = 1 00189 RETURN 00190 END IF 00191 * 00192 WS = MAX( M, N ) 00193 LDWRKX = M 00194 LDWRKY = N 00195 * 00196 IF( NB.GT.1 .AND. NB.LT.MINMN ) THEN 00197 * 00198 * Set the crossover point NX. 00199 * 00200 NX = MAX( NB, ILAENV( 3, 'ZGEBRD', ' ', M, N, -1, -1 ) ) 00201 * 00202 * Determine when to switch from blocked to unblocked code. 00203 * 00204 IF( NX.LT.MINMN ) THEN 00205 WS = ( M+N )*NB 00206 IF( LWORK.LT.WS ) THEN 00207 * 00208 * Not enough work space for the optimal NB, consider using 00209 * a smaller block size. 00210 * 00211 NBMIN = ILAENV( 2, 'ZGEBRD', ' ', M, N, -1, -1 ) 00212 IF( LWORK.GE.( M+N )*NBMIN ) THEN 00213 NB = LWORK / ( M+N ) 00214 ELSE 00215 NB = 1 00216 NX = MINMN 00217 END IF 00218 END IF 00219 END IF 00220 ELSE 00221 NX = MINMN 00222 END IF 00223 * 00224 DO 30 I = 1, MINMN - NX, NB 00225 * 00226 * Reduce rows and columns i:i+ib-1 to bidiagonal form and return 00227 * the matrices X and Y which are needed to update the unreduced 00228 * part of the matrix 00229 * 00230 CALL ZLABRD( M-I+1, N-I+1, NB, A( I, I ), LDA, D( I ), E( I ), 00231 $ TAUQ( I ), TAUP( I ), WORK, LDWRKX, 00232 $ WORK( LDWRKX*NB+1 ), LDWRKY ) 00233 * 00234 * Update the trailing submatrix A(i+ib:m,i+ib:n), using 00235 * an update of the form A := A - V*Y' - X*U' 00236 * 00237 CALL ZGEMM( 'No transpose', 'Conjugate transpose', M-I-NB+1, 00238 $ N-I-NB+1, NB, -ONE, A( I+NB, I ), LDA, 00239 $ WORK( LDWRKX*NB+NB+1 ), LDWRKY, ONE, 00240 $ A( I+NB, I+NB ), LDA ) 00241 CALL ZGEMM( 'No transpose', 'No transpose', M-I-NB+1, N-I-NB+1, 00242 $ NB, -ONE, WORK( NB+1 ), LDWRKX, A( I, I+NB ), LDA, 00243 $ ONE, A( I+NB, I+NB ), LDA ) 00244 * 00245 * Copy diagonal and off-diagonal elements of B back into A 00246 * 00247 IF( M.GE.N ) THEN 00248 DO 10 J = I, I + NB - 1 00249 A( J, J ) = D( J ) 00250 A( J, J+1 ) = E( J ) 00251 10 CONTINUE 00252 ELSE 00253 DO 20 J = I, I + NB - 1 00254 A( J, J ) = D( J ) 00255 A( J+1, J ) = E( J ) 00256 20 CONTINUE 00257 END IF 00258 30 CONTINUE 00259 * 00260 * Use unblocked code to reduce the remainder of the matrix 00261 * 00262 CALL ZGEBD2( M-I+1, N-I+1, A( I, I ), LDA, D( I ), E( I ), 00263 $ TAUQ( I ), TAUP( I ), WORK, IINFO ) 00264 WORK( 1 ) = WS 00265 RETURN 00266 * 00267 * End of ZGEBRD 00268 * 00269 END