LAPACK 3.3.0
|
00001 SUBROUTINE ZUNGBR( VECT, M, N, K, A, LDA, TAU, WORK, LWORK, INFO ) 00002 * 00003 * -- LAPACK routine (version 3.2) -- 00004 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00005 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00006 * November 2006 00007 * 00008 * .. Scalar Arguments .. 00009 CHARACTER VECT 00010 INTEGER INFO, K, LDA, LWORK, M, N 00011 * .. 00012 * .. Array Arguments .. 00013 COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * ) 00014 * .. 00015 * 00016 * Purpose 00017 * ======= 00018 * 00019 * ZUNGBR generates one of the complex unitary matrices Q or P**H 00020 * determined by ZGEBRD when reducing a complex matrix A to bidiagonal 00021 * form: A = Q * B * P**H. Q and P**H are defined as products of 00022 * elementary reflectors H(i) or G(i) respectively. 00023 * 00024 * If VECT = 'Q', A is assumed to have been an M-by-K matrix, and Q 00025 * is of order M: 00026 * if m >= k, Q = H(1) H(2) . . . H(k) and ZUNGBR returns the first n 00027 * columns of Q, where m >= n >= k; 00028 * if m < k, Q = H(1) H(2) . . . H(m-1) and ZUNGBR returns Q as an 00029 * M-by-M matrix. 00030 * 00031 * If VECT = 'P', A is assumed to have been a K-by-N matrix, and P**H 00032 * is of order N: 00033 * if k < n, P**H = G(k) . . . G(2) G(1) and ZUNGBR returns the first m 00034 * rows of P**H, where n >= m >= k; 00035 * if k >= n, P**H = G(n-1) . . . G(2) G(1) and ZUNGBR returns P**H as 00036 * an N-by-N matrix. 00037 * 00038 * Arguments 00039 * ========= 00040 * 00041 * VECT (input) CHARACTER*1 00042 * Specifies whether the matrix Q or the matrix P**H is 00043 * required, as defined in the transformation applied by ZGEBRD: 00044 * = 'Q': generate Q; 00045 * = 'P': generate P**H. 00046 * 00047 * M (input) INTEGER 00048 * The number of rows of the matrix Q or P**H to be returned. 00049 * M >= 0. 00050 * 00051 * N (input) INTEGER 00052 * The number of columns of the matrix Q or P**H to be returned. 00053 * N >= 0. 00054 * If VECT = 'Q', M >= N >= min(M,K); 00055 * if VECT = 'P', N >= M >= min(N,K). 00056 * 00057 * K (input) INTEGER 00058 * If VECT = 'Q', the number of columns in the original M-by-K 00059 * matrix reduced by ZGEBRD. 00060 * If VECT = 'P', the number of rows in the original K-by-N 00061 * matrix reduced by ZGEBRD. 00062 * K >= 0. 00063 * 00064 * A (input/output) COMPLEX*16 array, dimension (LDA,N) 00065 * On entry, the vectors which define the elementary reflectors, 00066 * as returned by ZGEBRD. 00067 * On exit, the M-by-N matrix Q or P**H. 00068 * 00069 * LDA (input) INTEGER 00070 * The leading dimension of the array A. LDA >= M. 00071 * 00072 * TAU (input) COMPLEX*16 array, dimension 00073 * (min(M,K)) if VECT = 'Q' 00074 * (min(N,K)) if VECT = 'P' 00075 * TAU(i) must contain the scalar factor of the elementary 00076 * reflector H(i) or G(i), which determines Q or P**H, as 00077 * returned by ZGEBRD in its array argument TAUQ or TAUP. 00078 * 00079 * WORK (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK)) 00080 * On exit, if INFO = 0, WORK(1) returns the optimal LWORK. 00081 * 00082 * LWORK (input) INTEGER 00083 * The dimension of the array WORK. LWORK >= max(1,min(M,N)). 00084 * For optimum performance LWORK >= min(M,N)*NB, where NB 00085 * is the optimal blocksize. 00086 * 00087 * If LWORK = -1, then a workspace query is assumed; the routine 00088 * only calculates the optimal size of the WORK array, returns 00089 * this value as the first entry of the WORK array, and no error 00090 * message related to LWORK is issued by XERBLA. 00091 * 00092 * INFO (output) INTEGER 00093 * = 0: successful exit 00094 * < 0: if INFO = -i, the i-th argument had an illegal value 00095 * 00096 * ===================================================================== 00097 * 00098 * .. Parameters .. 00099 COMPLEX*16 ZERO, ONE 00100 PARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ), 00101 $ ONE = ( 1.0D+0, 0.0D+0 ) ) 00102 * .. 00103 * .. Local Scalars .. 00104 LOGICAL LQUERY, WANTQ 00105 INTEGER I, IINFO, J, LWKOPT, MN, NB 00106 * .. 00107 * .. External Functions .. 00108 LOGICAL LSAME 00109 INTEGER ILAENV 00110 EXTERNAL LSAME, ILAENV 00111 * .. 00112 * .. External Subroutines .. 00113 EXTERNAL XERBLA, ZUNGLQ, ZUNGQR 00114 * .. 00115 * .. Intrinsic Functions .. 00116 INTRINSIC MAX, MIN 00117 * .. 00118 * .. Executable Statements .. 00119 * 00120 * Test the input arguments 00121 * 00122 INFO = 0 00123 WANTQ = LSAME( VECT, 'Q' ) 00124 MN = MIN( M, N ) 00125 LQUERY = ( LWORK.EQ.-1 ) 00126 IF( .NOT.WANTQ .AND. .NOT.LSAME( VECT, 'P' ) ) THEN 00127 INFO = -1 00128 ELSE IF( M.LT.0 ) THEN 00129 INFO = -2 00130 ELSE IF( N.LT.0 .OR. ( WANTQ .AND. ( N.GT.M .OR. N.LT.MIN( M, 00131 $ K ) ) ) .OR. ( .NOT.WANTQ .AND. ( M.GT.N .OR. M.LT. 00132 $ MIN( N, K ) ) ) ) THEN 00133 INFO = -3 00134 ELSE IF( K.LT.0 ) THEN 00135 INFO = -4 00136 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN 00137 INFO = -6 00138 ELSE IF( LWORK.LT.MAX( 1, MN ) .AND. .NOT.LQUERY ) THEN 00139 INFO = -9 00140 END IF 00141 * 00142 IF( INFO.EQ.0 ) THEN 00143 IF( WANTQ ) THEN 00144 NB = ILAENV( 1, 'ZUNGQR', ' ', M, N, K, -1 ) 00145 ELSE 00146 NB = ILAENV( 1, 'ZUNGLQ', ' ', M, N, K, -1 ) 00147 END IF 00148 LWKOPT = MAX( 1, MN )*NB 00149 WORK( 1 ) = LWKOPT 00150 END IF 00151 * 00152 IF( INFO.NE.0 ) THEN 00153 CALL XERBLA( 'ZUNGBR', -INFO ) 00154 RETURN 00155 ELSE IF( LQUERY ) THEN 00156 RETURN 00157 END IF 00158 * 00159 * Quick return if possible 00160 * 00161 IF( M.EQ.0 .OR. N.EQ.0 ) THEN 00162 WORK( 1 ) = 1 00163 RETURN 00164 END IF 00165 * 00166 IF( WANTQ ) THEN 00167 * 00168 * Form Q, determined by a call to ZGEBRD to reduce an m-by-k 00169 * matrix 00170 * 00171 IF( M.GE.K ) THEN 00172 * 00173 * If m >= k, assume m >= n >= k 00174 * 00175 CALL ZUNGQR( M, N, K, A, LDA, TAU, WORK, LWORK, IINFO ) 00176 * 00177 ELSE 00178 * 00179 * If m < k, assume m = n 00180 * 00181 * Shift the vectors which define the elementary reflectors one 00182 * column to the right, and set the first row and column of Q 00183 * to those of the unit matrix 00184 * 00185 DO 20 J = M, 2, -1 00186 A( 1, J ) = ZERO 00187 DO 10 I = J + 1, M 00188 A( I, J ) = A( I, J-1 ) 00189 10 CONTINUE 00190 20 CONTINUE 00191 A( 1, 1 ) = ONE 00192 DO 30 I = 2, M 00193 A( I, 1 ) = ZERO 00194 30 CONTINUE 00195 IF( M.GT.1 ) THEN 00196 * 00197 * Form Q(2:m,2:m) 00198 * 00199 CALL ZUNGQR( M-1, M-1, M-1, A( 2, 2 ), LDA, TAU, WORK, 00200 $ LWORK, IINFO ) 00201 END IF 00202 END IF 00203 ELSE 00204 * 00205 * Form P', determined by a call to ZGEBRD to reduce a k-by-n 00206 * matrix 00207 * 00208 IF( K.LT.N ) THEN 00209 * 00210 * If k < n, assume k <= m <= n 00211 * 00212 CALL ZUNGLQ( M, N, K, A, LDA, TAU, WORK, LWORK, IINFO ) 00213 * 00214 ELSE 00215 * 00216 * If k >= n, assume m = n 00217 * 00218 * Shift the vectors which define the elementary reflectors one 00219 * row downward, and set the first row and column of P' to 00220 * those of the unit matrix 00221 * 00222 A( 1, 1 ) = ONE 00223 DO 40 I = 2, N 00224 A( I, 1 ) = ZERO 00225 40 CONTINUE 00226 DO 60 J = 2, N 00227 DO 50 I = J - 1, 2, -1 00228 A( I, J ) = A( I-1, J ) 00229 50 CONTINUE 00230 A( 1, J ) = ZERO 00231 60 CONTINUE 00232 IF( N.GT.1 ) THEN 00233 * 00234 * Form P'(2:n,2:n) 00235 * 00236 CALL ZUNGLQ( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK, 00237 $ LWORK, IINFO ) 00238 END IF 00239 END IF 00240 END IF 00241 WORK( 1 ) = LWKOPT 00242 RETURN 00243 * 00244 * End of ZUNGBR 00245 * 00246 END