1 SUBROUTINE ZGEBD2( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, INFO )
2 *
3 * -- LAPACK routine (version 3.3.1) --
4 * -- LAPACK is a software package provided by Univ. of Tennessee, --
5 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
6 * -- April 2011 --
7 *
8 * .. Scalar Arguments ..
9 INTEGER INFO, LDA, M, N
10 * ..
11 * .. Array Arguments ..
12 DOUBLE PRECISION D( * ), E( * )
13 COMPLEX*16 A( LDA, * ), TAUP( * ), TAUQ( * ), WORK( * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * ZGEBD2 reduces a complex general m by n matrix A to upper or lower
20 * real bidiagonal form B by a unitary transformation: Q**H * A * P = B.
21 *
22 * If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal.
23 *
24 * Arguments
25 * =========
26 *
27 * M (input) INTEGER
28 * The number of rows in the matrix A. M >= 0.
29 *
30 * N (input) INTEGER
31 * The number of columns in the matrix A. N >= 0.
32 *
33 * A (input/output) COMPLEX*16 array, dimension (LDA,N)
34 * On entry, the m by n general matrix to be reduced.
35 * On exit,
36 * if m >= n, the diagonal and the first superdiagonal are
37 * overwritten with the upper bidiagonal matrix B; the
38 * elements below the diagonal, with the array TAUQ, represent
39 * the unitary matrix Q as a product of elementary
40 * reflectors, and the elements above the first superdiagonal,
41 * with the array TAUP, represent the unitary matrix P as
42 * a product of elementary reflectors;
43 * if m < n, the diagonal and the first subdiagonal are
44 * overwritten with the lower bidiagonal matrix B; the
45 * elements below the first subdiagonal, with the array TAUQ,
46 * represent the unitary matrix Q as a product of
47 * elementary reflectors, and the elements above the diagonal,
48 * with the array TAUP, represent the unitary matrix P as
49 * a product of elementary reflectors.
50 * See Further Details.
51 *
52 * LDA (input) INTEGER
53 * The leading dimension of the array A. LDA >= max(1,M).
54 *
55 * D (output) DOUBLE PRECISION array, dimension (min(M,N))
56 * The diagonal elements of the bidiagonal matrix B:
57 * D(i) = A(i,i).
58 *
59 * E (output) DOUBLE PRECISION array, dimension (min(M,N)-1)
60 * The off-diagonal elements of the bidiagonal matrix B:
61 * if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1;
62 * if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1.
63 *
64 * TAUQ (output) COMPLEX*16 array dimension (min(M,N))
65 * The scalar factors of the elementary reflectors which
66 * represent the unitary matrix Q. See Further Details.
67 *
68 * TAUP (output) COMPLEX*16 array, dimension (min(M,N))
69 * The scalar factors of the elementary reflectors which
70 * represent the unitary matrix P. See Further Details.
71 *
72 * WORK (workspace) COMPLEX*16 array, dimension (max(M,N))
73 *
74 * INFO (output) INTEGER
75 * = 0: successful exit
76 * < 0: if INFO = -i, the i-th argument had an illegal value.
77 *
78 * Further Details
79 * ===============
80 *
81 * The matrices Q and P are represented as products of elementary
82 * reflectors:
83 *
84 * If m >= n,
85 *
86 * Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1)
87 *
88 * Each H(i) and G(i) has the form:
89 *
90 * H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H
91 *
92 * where tauq and taup are complex scalars, and v and u are complex
93 * vectors; v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in
94 * A(i+1:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in
95 * A(i,i+2:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
96 *
97 * If m < n,
98 *
99 * Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m)
100 *
101 * Each H(i) and G(i) has the form:
102 *
103 * H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H
104 *
105 * where tauq and taup are complex scalars, v and u are complex vectors;
106 * v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i);
107 * u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n);
108 * tauq is stored in TAUQ(i) and taup in TAUP(i).
109 *
110 * The contents of A on exit are illustrated by the following examples:
111 *
112 * m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n):
113 *
114 * ( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 )
115 * ( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 )
116 * ( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 )
117 * ( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 )
118 * ( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 )
119 * ( v1 v2 v3 v4 v5 )
120 *
121 * where d and e denote diagonal and off-diagonal elements of B, vi
122 * denotes an element of the vector defining H(i), and ui an element of
123 * the vector defining G(i).
124 *
125 * =====================================================================
126 *
127 * .. Parameters ..
128 COMPLEX*16 ZERO, ONE
129 PARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),
130 $ ONE = ( 1.0D+0, 0.0D+0 ) )
131 * ..
132 * .. Local Scalars ..
133 INTEGER I
134 COMPLEX*16 ALPHA
135 * ..
136 * .. External Subroutines ..
137 EXTERNAL XERBLA, ZLACGV, ZLARF, ZLARFG
138 * ..
139 * .. Intrinsic Functions ..
140 INTRINSIC DCONJG, MAX, MIN
141 * ..
142 * .. Executable Statements ..
143 *
144 * Test the input parameters
145 *
146 INFO = 0
147 IF( M.LT.0 ) THEN
148 INFO = -1
149 ELSE IF( N.LT.0 ) THEN
150 INFO = -2
151 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
152 INFO = -4
153 END IF
154 IF( INFO.LT.0 ) THEN
155 CALL XERBLA( 'ZGEBD2', -INFO )
156 RETURN
157 END IF
158 *
159 IF( M.GE.N ) THEN
160 *
161 * Reduce to upper bidiagonal form
162 *
163 DO 10 I = 1, N
164 *
165 * Generate elementary reflector H(i) to annihilate A(i+1:m,i)
166 *
167 ALPHA = A( I, I )
168 CALL ZLARFG( M-I+1, ALPHA, A( MIN( I+1, M ), I ), 1,
169 $ TAUQ( I ) )
170 D( I ) = ALPHA
171 A( I, I ) = ONE
172 *
173 * Apply H(i)**H to A(i:m,i+1:n) from the left
174 *
175 IF( I.LT.N )
176 $ CALL ZLARF( 'Left', M-I+1, N-I, A( I, I ), 1,
177 $ DCONJG( TAUQ( I ) ), A( I, I+1 ), LDA, WORK )
178 A( I, I ) = D( I )
179 *
180 IF( I.LT.N ) THEN
181 *
182 * Generate elementary reflector G(i) to annihilate
183 * A(i,i+2:n)
184 *
185 CALL ZLACGV( N-I, A( I, I+1 ), LDA )
186 ALPHA = A( I, I+1 )
187 CALL ZLARFG( N-I, ALPHA, A( I, MIN( I+2, N ) ), LDA,
188 $ TAUP( I ) )
189 E( I ) = ALPHA
190 A( I, I+1 ) = ONE
191 *
192 * Apply G(i) to A(i+1:m,i+1:n) from the right
193 *
194 CALL ZLARF( 'Right', M-I, N-I, A( I, I+1 ), LDA,
195 $ TAUP( I ), A( I+1, I+1 ), LDA, WORK )
196 CALL ZLACGV( N-I, A( I, I+1 ), LDA )
197 A( I, I+1 ) = E( I )
198 ELSE
199 TAUP( I ) = ZERO
200 END IF
201 10 CONTINUE
202 ELSE
203 *
204 * Reduce to lower bidiagonal form
205 *
206 DO 20 I = 1, M
207 *
208 * Generate elementary reflector G(i) to annihilate A(i,i+1:n)
209 *
210 CALL ZLACGV( N-I+1, A( I, I ), LDA )
211 ALPHA = A( I, I )
212 CALL ZLARFG( N-I+1, ALPHA, A( I, MIN( I+1, N ) ), LDA,
213 $ TAUP( I ) )
214 D( I ) = ALPHA
215 A( I, I ) = ONE
216 *
217 * Apply G(i) to A(i+1:m,i:n) from the right
218 *
219 IF( I.LT.M )
220 $ CALL ZLARF( 'Right', M-I, N-I+1, A( I, I ), LDA,
221 $ TAUP( I ), A( I+1, I ), LDA, WORK )
222 CALL ZLACGV( N-I+1, A( I, I ), LDA )
223 A( I, I ) = D( I )
224 *
225 IF( I.LT.M ) THEN
226 *
227 * Generate elementary reflector H(i) to annihilate
228 * A(i+2:m,i)
229 *
230 ALPHA = A( I+1, I )
231 CALL ZLARFG( M-I, ALPHA, A( MIN( I+2, M ), I ), 1,
232 $ TAUQ( I ) )
233 E( I ) = ALPHA
234 A( I+1, I ) = ONE
235 *
236 * Apply H(i)**H to A(i+1:m,i+1:n) from the left
237 *
238 CALL ZLARF( 'Left', M-I, N-I, A( I+1, I ), 1,
239 $ DCONJG( TAUQ( I ) ), A( I+1, I+1 ), LDA,
240 $ WORK )
241 A( I+1, I ) = E( I )
242 ELSE
243 TAUQ( I ) = ZERO
244 END IF
245 20 CONTINUE
246 END IF
247 RETURN
248 *
249 * End of ZGEBD2
250 *
251 END
2 *
3 * -- LAPACK routine (version 3.3.1) --
4 * -- LAPACK is a software package provided by Univ. of Tennessee, --
5 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
6 * -- April 2011 --
7 *
8 * .. Scalar Arguments ..
9 INTEGER INFO, LDA, M, N
10 * ..
11 * .. Array Arguments ..
12 DOUBLE PRECISION D( * ), E( * )
13 COMPLEX*16 A( LDA, * ), TAUP( * ), TAUQ( * ), WORK( * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * ZGEBD2 reduces a complex general m by n matrix A to upper or lower
20 * real bidiagonal form B by a unitary transformation: Q**H * A * P = B.
21 *
22 * If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal.
23 *
24 * Arguments
25 * =========
26 *
27 * M (input) INTEGER
28 * The number of rows in the matrix A. M >= 0.
29 *
30 * N (input) INTEGER
31 * The number of columns in the matrix A. N >= 0.
32 *
33 * A (input/output) COMPLEX*16 array, dimension (LDA,N)
34 * On entry, the m by n general matrix to be reduced.
35 * On exit,
36 * if m >= n, the diagonal and the first superdiagonal are
37 * overwritten with the upper bidiagonal matrix B; the
38 * elements below the diagonal, with the array TAUQ, represent
39 * the unitary matrix Q as a product of elementary
40 * reflectors, and the elements above the first superdiagonal,
41 * with the array TAUP, represent the unitary matrix P as
42 * a product of elementary reflectors;
43 * if m < n, the diagonal and the first subdiagonal are
44 * overwritten with the lower bidiagonal matrix B; the
45 * elements below the first subdiagonal, with the array TAUQ,
46 * represent the unitary matrix Q as a product of
47 * elementary reflectors, and the elements above the diagonal,
48 * with the array TAUP, represent the unitary matrix P as
49 * a product of elementary reflectors.
50 * See Further Details.
51 *
52 * LDA (input) INTEGER
53 * The leading dimension of the array A. LDA >= max(1,M).
54 *
55 * D (output) DOUBLE PRECISION array, dimension (min(M,N))
56 * The diagonal elements of the bidiagonal matrix B:
57 * D(i) = A(i,i).
58 *
59 * E (output) DOUBLE PRECISION array, dimension (min(M,N)-1)
60 * The off-diagonal elements of the bidiagonal matrix B:
61 * if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1;
62 * if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1.
63 *
64 * TAUQ (output) COMPLEX*16 array dimension (min(M,N))
65 * The scalar factors of the elementary reflectors which
66 * represent the unitary matrix Q. See Further Details.
67 *
68 * TAUP (output) COMPLEX*16 array, dimension (min(M,N))
69 * The scalar factors of the elementary reflectors which
70 * represent the unitary matrix P. See Further Details.
71 *
72 * WORK (workspace) COMPLEX*16 array, dimension (max(M,N))
73 *
74 * INFO (output) INTEGER
75 * = 0: successful exit
76 * < 0: if INFO = -i, the i-th argument had an illegal value.
77 *
78 * Further Details
79 * ===============
80 *
81 * The matrices Q and P are represented as products of elementary
82 * reflectors:
83 *
84 * If m >= n,
85 *
86 * Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1)
87 *
88 * Each H(i) and G(i) has the form:
89 *
90 * H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H
91 *
92 * where tauq and taup are complex scalars, and v and u are complex
93 * vectors; v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in
94 * A(i+1:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in
95 * A(i,i+2:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
96 *
97 * If m < n,
98 *
99 * Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m)
100 *
101 * Each H(i) and G(i) has the form:
102 *
103 * H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H
104 *
105 * where tauq and taup are complex scalars, v and u are complex vectors;
106 * v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i);
107 * u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n);
108 * tauq is stored in TAUQ(i) and taup in TAUP(i).
109 *
110 * The contents of A on exit are illustrated by the following examples:
111 *
112 * m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n):
113 *
114 * ( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 )
115 * ( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 )
116 * ( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 )
117 * ( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 )
118 * ( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 )
119 * ( v1 v2 v3 v4 v5 )
120 *
121 * where d and e denote diagonal and off-diagonal elements of B, vi
122 * denotes an element of the vector defining H(i), and ui an element of
123 * the vector defining G(i).
124 *
125 * =====================================================================
126 *
127 * .. Parameters ..
128 COMPLEX*16 ZERO, ONE
129 PARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),
130 $ ONE = ( 1.0D+0, 0.0D+0 ) )
131 * ..
132 * .. Local Scalars ..
133 INTEGER I
134 COMPLEX*16 ALPHA
135 * ..
136 * .. External Subroutines ..
137 EXTERNAL XERBLA, ZLACGV, ZLARF, ZLARFG
138 * ..
139 * .. Intrinsic Functions ..
140 INTRINSIC DCONJG, MAX, MIN
141 * ..
142 * .. Executable Statements ..
143 *
144 * Test the input parameters
145 *
146 INFO = 0
147 IF( M.LT.0 ) THEN
148 INFO = -1
149 ELSE IF( N.LT.0 ) THEN
150 INFO = -2
151 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
152 INFO = -4
153 END IF
154 IF( INFO.LT.0 ) THEN
155 CALL XERBLA( 'ZGEBD2', -INFO )
156 RETURN
157 END IF
158 *
159 IF( M.GE.N ) THEN
160 *
161 * Reduce to upper bidiagonal form
162 *
163 DO 10 I = 1, N
164 *
165 * Generate elementary reflector H(i) to annihilate A(i+1:m,i)
166 *
167 ALPHA = A( I, I )
168 CALL ZLARFG( M-I+1, ALPHA, A( MIN( I+1, M ), I ), 1,
169 $ TAUQ( I ) )
170 D( I ) = ALPHA
171 A( I, I ) = ONE
172 *
173 * Apply H(i)**H to A(i:m,i+1:n) from the left
174 *
175 IF( I.LT.N )
176 $ CALL ZLARF( 'Left', M-I+1, N-I, A( I, I ), 1,
177 $ DCONJG( TAUQ( I ) ), A( I, I+1 ), LDA, WORK )
178 A( I, I ) = D( I )
179 *
180 IF( I.LT.N ) THEN
181 *
182 * Generate elementary reflector G(i) to annihilate
183 * A(i,i+2:n)
184 *
185 CALL ZLACGV( N-I, A( I, I+1 ), LDA )
186 ALPHA = A( I, I+1 )
187 CALL ZLARFG( N-I, ALPHA, A( I, MIN( I+2, N ) ), LDA,
188 $ TAUP( I ) )
189 E( I ) = ALPHA
190 A( I, I+1 ) = ONE
191 *
192 * Apply G(i) to A(i+1:m,i+1:n) from the right
193 *
194 CALL ZLARF( 'Right', M-I, N-I, A( I, I+1 ), LDA,
195 $ TAUP( I ), A( I+1, I+1 ), LDA, WORK )
196 CALL ZLACGV( N-I, A( I, I+1 ), LDA )
197 A( I, I+1 ) = E( I )
198 ELSE
199 TAUP( I ) = ZERO
200 END IF
201 10 CONTINUE
202 ELSE
203 *
204 * Reduce to lower bidiagonal form
205 *
206 DO 20 I = 1, M
207 *
208 * Generate elementary reflector G(i) to annihilate A(i,i+1:n)
209 *
210 CALL ZLACGV( N-I+1, A( I, I ), LDA )
211 ALPHA = A( I, I )
212 CALL ZLARFG( N-I+1, ALPHA, A( I, MIN( I+1, N ) ), LDA,
213 $ TAUP( I ) )
214 D( I ) = ALPHA
215 A( I, I ) = ONE
216 *
217 * Apply G(i) to A(i+1:m,i:n) from the right
218 *
219 IF( I.LT.M )
220 $ CALL ZLARF( 'Right', M-I, N-I+1, A( I, I ), LDA,
221 $ TAUP( I ), A( I+1, I ), LDA, WORK )
222 CALL ZLACGV( N-I+1, A( I, I ), LDA )
223 A( I, I ) = D( I )
224 *
225 IF( I.LT.M ) THEN
226 *
227 * Generate elementary reflector H(i) to annihilate
228 * A(i+2:m,i)
229 *
230 ALPHA = A( I+1, I )
231 CALL ZLARFG( M-I, ALPHA, A( MIN( I+2, M ), I ), 1,
232 $ TAUQ( I ) )
233 E( I ) = ALPHA
234 A( I+1, I ) = ONE
235 *
236 * Apply H(i)**H to A(i+1:m,i+1:n) from the left
237 *
238 CALL ZLARF( 'Left', M-I, N-I, A( I+1, I ), 1,
239 $ DCONJG( TAUQ( I ) ), A( I+1, I+1 ), LDA,
240 $ WORK )
241 A( I+1, I ) = E( I )
242 ELSE
243 TAUQ( I ) = ZERO
244 END IF
245 20 CONTINUE
246 END IF
247 RETURN
248 *
249 * End of ZGEBD2
250 *
251 END