LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
clabrd.f
Go to the documentation of this file.
1*> \brief \b CLABRD reduces the first nb rows and columns of a general matrix to a bidiagonal form.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CLABRD + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clabrd.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clabrd.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clabrd.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CLABRD( M, N, NB, A, LDA, D, E, TAUQ, TAUP, X, LDX, Y,
20* LDY )
21*
22* .. Scalar Arguments ..
23* INTEGER LDA, LDX, LDY, M, N, NB
24* ..
25* .. Array Arguments ..
26* REAL D( * ), E( * )
27* COMPLEX A( LDA, * ), TAUP( * ), TAUQ( * ), X( LDX, * ),
28* $ Y( LDY, * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> CLABRD reduces the first NB rows and columns of a complex general
38*> m by n matrix A to upper or lower real bidiagonal form by a unitary
39*> transformation Q**H * A * P, and returns the matrices X and Y which
40*> are needed to apply the transformation to the unreduced part of A.
41*>
42*> If m >= n, A is reduced to upper bidiagonal form; if m < n, to lower
43*> bidiagonal form.
44*>
45*> This is an auxiliary routine called by CGEBRD
46*> \endverbatim
47*
48* Arguments:
49* ==========
50*
51*> \param[in] M
52*> \verbatim
53*> M is INTEGER
54*> The number of rows in the matrix A.
55*> \endverbatim
56*>
57*> \param[in] N
58*> \verbatim
59*> N is INTEGER
60*> The number of columns in the matrix A.
61*> \endverbatim
62*>
63*> \param[in] NB
64*> \verbatim
65*> NB is INTEGER
66*> The number of leading rows and columns of A to be reduced.
67*> \endverbatim
68*>
69*> \param[in,out] A
70*> \verbatim
71*> A is COMPLEX array, dimension (LDA,N)
72*> On entry, the m by n general matrix to be reduced.
73*> On exit, the first NB rows and columns of the matrix are
74*> overwritten; the rest of the array is unchanged.
75*> If m >= n, elements on and below the diagonal in the first NB
76*> columns, with the array TAUQ, represent the unitary
77*> matrix Q as a product of elementary reflectors; and
78*> elements above the diagonal in the first NB rows, with the
79*> array TAUP, represent the unitary matrix P as a product
80*> of elementary reflectors.
81*> If m < n, elements below the diagonal in the first NB
82*> columns, with the array TAUQ, represent the unitary
83*> matrix Q as a product of elementary reflectors, and
84*> elements on and above the diagonal in the first NB rows,
85*> with the array TAUP, represent the unitary matrix P as
86*> a product of elementary reflectors.
87*> See Further Details.
88*> \endverbatim
89*>
90*> \param[in] LDA
91*> \verbatim
92*> LDA is INTEGER
93*> The leading dimension of the array A. LDA >= max(1,M).
94*> \endverbatim
95*>
96*> \param[out] D
97*> \verbatim
98*> D is REAL array, dimension (NB)
99*> The diagonal elements of the first NB rows and columns of
100*> the reduced matrix. D(i) = A(i,i).
101*> \endverbatim
102*>
103*> \param[out] E
104*> \verbatim
105*> E is REAL array, dimension (NB)
106*> The off-diagonal elements of the first NB rows and columns of
107*> the reduced matrix.
108*> \endverbatim
109*>
110*> \param[out] TAUQ
111*> \verbatim
112*> TAUQ is COMPLEX array, dimension (NB)
113*> The scalar factors of the elementary reflectors which
114*> represent the unitary matrix Q. See Further Details.
115*> \endverbatim
116*>
117*> \param[out] TAUP
118*> \verbatim
119*> TAUP is COMPLEX array, dimension (NB)
120*> The scalar factors of the elementary reflectors which
121*> represent the unitary matrix P. See Further Details.
122*> \endverbatim
123*>
124*> \param[out] X
125*> \verbatim
126*> X is COMPLEX array, dimension (LDX,NB)
127*> The m-by-nb matrix X required to update the unreduced part
128*> of A.
129*> \endverbatim
130*>
131*> \param[in] LDX
132*> \verbatim
133*> LDX is INTEGER
134*> The leading dimension of the array X. LDX >= max(1,M).
135*> \endverbatim
136*>
137*> \param[out] Y
138*> \verbatim
139*> Y is COMPLEX array, dimension (LDY,NB)
140*> The n-by-nb matrix Y required to update the unreduced part
141*> of A.
142*> \endverbatim
143*>
144*> \param[in] LDY
145*> \verbatim
146*> LDY is INTEGER
147*> The leading dimension of the array Y. LDY >= max(1,N).
148*> \endverbatim
149*
150* Authors:
151* ========
152*
153*> \author Univ. of Tennessee
154*> \author Univ. of California Berkeley
155*> \author Univ. of Colorado Denver
156*> \author NAG Ltd.
157*
158*> \ingroup labrd
159*
160*> \par Further Details:
161* =====================
162*>
163*> \verbatim
164*>
165*> The matrices Q and P are represented as products of elementary
166*> reflectors:
167*>
168*> Q = H(1) H(2) . . . H(nb) and P = G(1) G(2) . . . G(nb)
169*>
170*> Each H(i) and G(i) has the form:
171*>
172*> H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H
173*>
174*> where tauq and taup are complex scalars, and v and u are complex
175*> vectors.
176*>
177*> If m >= n, v(1:i-1) = 0, v(i) = 1, and v(i:m) is stored on exit in
178*> A(i:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+1:n) is stored on exit in
179*> A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
180*>
181*> If m < n, v(1:i) = 0, v(i+1) = 1, and v(i+1:m) is stored on exit in
182*> A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i:n) is stored on exit in
183*> A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
184*>
185*> The elements of the vectors v and u together form the m-by-nb matrix
186*> V and the nb-by-n matrix U**H which are needed, with X and Y, to apply
187*> the transformation to the unreduced part of the matrix, using a block
188*> update of the form: A := A - V*Y**H - X*U**H.
189*>
190*> The contents of A on exit are illustrated by the following examples
191*> with nb = 2:
192*>
193*> m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n):
194*>
195*> ( 1 1 u1 u1 u1 ) ( 1 u1 u1 u1 u1 u1 )
196*> ( v1 1 1 u2 u2 ) ( 1 1 u2 u2 u2 u2 )
197*> ( v1 v2 a a a ) ( v1 1 a a a a )
198*> ( v1 v2 a a a ) ( v1 v2 a a a a )
199*> ( v1 v2 a a a ) ( v1 v2 a a a a )
200*> ( v1 v2 a a a )
201*>
202*> where a denotes an element of the original matrix which is unchanged,
203*> vi denotes an element of the vector defining H(i), and ui an element
204*> of the vector defining G(i).
205*> \endverbatim
206*>
207* =====================================================================
208 SUBROUTINE clabrd( M, N, NB, A, LDA, D, E, TAUQ, TAUP, X, LDX,
209 $ Y,
210 $ LDY )
211*
212* -- LAPACK auxiliary routine --
213* -- LAPACK is a software package provided by Univ. of Tennessee, --
214* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
215*
216* .. Scalar Arguments ..
217 INTEGER LDA, LDX, LDY, M, N, NB
218* ..
219* .. Array Arguments ..
220 REAL D( * ), E( * )
221 COMPLEX A( LDA, * ), TAUP( * ), TAUQ( * ), X( LDX, * ),
222 $ y( ldy, * )
223* ..
224*
225* =====================================================================
226*
227* .. Parameters ..
228 COMPLEX ZERO, ONE
229 PARAMETER ( ZERO = ( 0.0e+0, 0.0e+0 ),
230 $ one = ( 1.0e+0, 0.0e+0 ) )
231* ..
232* .. Local Scalars ..
233 INTEGER I
234 COMPLEX ALPHA
235* ..
236* .. External Subroutines ..
237 EXTERNAL cgemv, clacgv, clarfg, cscal
238* ..
239* .. Intrinsic Functions ..
240 INTRINSIC min
241* ..
242* .. Executable Statements ..
243*
244* Quick return if possible
245*
246 IF( m.LE.0 .OR. n.LE.0 )
247 $ RETURN
248*
249 IF( m.GE.n ) THEN
250*
251* Reduce to upper bidiagonal form
252*
253 DO 10 i = 1, nb
254*
255* Update A(i:m,i)
256*
257 CALL clacgv( i-1, y( i, 1 ), ldy )
258 CALL cgemv( 'No transpose', m-i+1, i-1, -one, a( i, 1 ),
259 $ lda, y( i, 1 ), ldy, one, a( i, i ), 1 )
260 CALL clacgv( i-1, y( i, 1 ), ldy )
261 CALL cgemv( 'No transpose', m-i+1, i-1, -one, x( i, 1 ),
262 $ ldx, a( 1, i ), 1, one, a( i, i ), 1 )
263*
264* Generate reflection Q(i) to annihilate A(i+1:m,i)
265*
266 alpha = a( i, i )
267 CALL clarfg( m-i+1, alpha, a( min( i+1, m ), i ), 1,
268 $ tauq( i ) )
269 d( i ) = real( alpha )
270 IF( i.LT.n ) THEN
271 a( i, i ) = one
272*
273* Compute Y(i+1:n,i)
274*
275 CALL cgemv( 'Conjugate transpose', m-i+1, n-i, one,
276 $ a( i, i+1 ), lda, a( i, i ), 1, zero,
277 $ y( i+1, i ), 1 )
278 CALL cgemv( 'Conjugate transpose', m-i+1, i-1, one,
279 $ a( i, 1 ), lda, a( i, i ), 1, zero,
280 $ y( 1, i ), 1 )
281 CALL cgemv( 'No transpose', n-i, i-1, -one, y( i+1,
282 $ 1 ),
283 $ ldy, y( 1, i ), 1, one, y( i+1, i ), 1 )
284 CALL cgemv( 'Conjugate transpose', m-i+1, i-1, one,
285 $ x( i, 1 ), ldx, a( i, i ), 1, zero,
286 $ y( 1, i ), 1 )
287 CALL cgemv( 'Conjugate transpose', i-1, n-i, -one,
288 $ a( 1, i+1 ), lda, y( 1, i ), 1, one,
289 $ y( i+1, i ), 1 )
290 CALL cscal( n-i, tauq( i ), y( i+1, i ), 1 )
291*
292* Update A(i,i+1:n)
293*
294 CALL clacgv( n-i, a( i, i+1 ), lda )
295 CALL clacgv( i, a( i, 1 ), lda )
296 CALL cgemv( 'No transpose', n-i, i, -one, y( i+1, 1 ),
297 $ ldy, a( i, 1 ), lda, one, a( i, i+1 ), lda )
298 CALL clacgv( i, a( i, 1 ), lda )
299 CALL clacgv( i-1, x( i, 1 ), ldx )
300 CALL cgemv( 'Conjugate transpose', i-1, n-i, -one,
301 $ a( 1, i+1 ), lda, x( i, 1 ), ldx, one,
302 $ a( i, i+1 ), lda )
303 CALL clacgv( i-1, x( i, 1 ), ldx )
304*
305* Generate reflection P(i) to annihilate A(i,i+2:n)
306*
307 alpha = a( i, i+1 )
308 CALL clarfg( n-i, alpha, a( i, min( i+2, n ) ),
309 $ lda, taup( i ) )
310 e( i ) = real( alpha )
311 a( i, i+1 ) = one
312*
313* Compute X(i+1:m,i)
314*
315 CALL cgemv( 'No transpose', m-i, n-i, one, a( i+1,
316 $ i+1 ),
317 $ lda, a( i, i+1 ), lda, zero, x( i+1, i ), 1 )
318 CALL cgemv( 'Conjugate transpose', n-i, i, one,
319 $ y( i+1, 1 ), ldy, a( i, i+1 ), lda, zero,
320 $ x( 1, i ), 1 )
321 CALL cgemv( 'No transpose', m-i, i, -one, a( i+1, 1 ),
322 $ lda, x( 1, i ), 1, one, x( i+1, i ), 1 )
323 CALL cgemv( 'No transpose', i-1, n-i, one, a( 1,
324 $ i+1 ),
325 $ lda, a( i, i+1 ), lda, zero, x( 1, i ), 1 )
326 CALL cgemv( 'No transpose', m-i, i-1, -one, x( i+1,
327 $ 1 ),
328 $ ldx, x( 1, i ), 1, one, x( i+1, i ), 1 )
329 CALL cscal( m-i, taup( i ), x( i+1, i ), 1 )
330 CALL clacgv( n-i, a( i, i+1 ), lda )
331 END IF
332 10 CONTINUE
333 ELSE
334*
335* Reduce to lower bidiagonal form
336*
337 DO 20 i = 1, nb
338*
339* Update A(i,i:n)
340*
341 CALL clacgv( n-i+1, a( i, i ), lda )
342 CALL clacgv( i-1, a( i, 1 ), lda )
343 CALL cgemv( 'No transpose', n-i+1, i-1, -one, y( i, 1 ),
344 $ ldy, a( i, 1 ), lda, one, a( i, i ), lda )
345 CALL clacgv( i-1, a( i, 1 ), lda )
346 CALL clacgv( i-1, x( i, 1 ), ldx )
347 CALL cgemv( 'Conjugate transpose', i-1, n-i+1, -one,
348 $ a( 1, i ), lda, x( i, 1 ), ldx, one, a( i, i ),
349 $ lda )
350 CALL clacgv( i-1, x( i, 1 ), ldx )
351*
352* Generate reflection P(i) to annihilate A(i,i+1:n)
353*
354 alpha = a( i, i )
355 CALL clarfg( n-i+1, alpha, a( i, min( i+1, n ) ), lda,
356 $ taup( i ) )
357 d( i ) = real( alpha )
358 IF( i.LT.m ) THEN
359 a( i, i ) = one
360*
361* Compute X(i+1:m,i)
362*
363 CALL cgemv( 'No transpose', m-i, n-i+1, one, a( i+1,
364 $ i ),
365 $ lda, a( i, i ), lda, zero, x( i+1, i ), 1 )
366 CALL cgemv( 'Conjugate transpose', n-i+1, i-1, one,
367 $ y( i, 1 ), ldy, a( i, i ), lda, zero,
368 $ x( 1, i ), 1 )
369 CALL cgemv( 'No transpose', m-i, i-1, -one, a( i+1,
370 $ 1 ),
371 $ lda, x( 1, i ), 1, one, x( i+1, i ), 1 )
372 CALL cgemv( 'No transpose', i-1, n-i+1, one, a( 1,
373 $ i ),
374 $ lda, a( i, i ), lda, zero, x( 1, i ), 1 )
375 CALL cgemv( 'No transpose', m-i, i-1, -one, x( i+1,
376 $ 1 ),
377 $ ldx, x( 1, i ), 1, one, x( i+1, i ), 1 )
378 CALL cscal( m-i, taup( i ), x( i+1, i ), 1 )
379 CALL clacgv( n-i+1, a( i, i ), lda )
380*
381* Update A(i+1:m,i)
382*
383 CALL clacgv( i-1, y( i, 1 ), ldy )
384 CALL cgemv( 'No transpose', m-i, i-1, -one, a( i+1,
385 $ 1 ),
386 $ lda, y( i, 1 ), ldy, one, a( i+1, i ), 1 )
387 CALL clacgv( i-1, y( i, 1 ), ldy )
388 CALL cgemv( 'No transpose', m-i, i, -one, x( i+1, 1 ),
389 $ ldx, a( 1, i ), 1, one, a( i+1, i ), 1 )
390*
391* Generate reflection Q(i) to annihilate A(i+2:m,i)
392*
393 alpha = a( i+1, i )
394 CALL clarfg( m-i, alpha, a( min( i+2, m ), i ), 1,
395 $ tauq( i ) )
396 e( i ) = real( alpha )
397 a( i+1, i ) = one
398*
399* Compute Y(i+1:n,i)
400*
401 CALL cgemv( 'Conjugate transpose', m-i, n-i, one,
402 $ a( i+1, i+1 ), lda, a( i+1, i ), 1, zero,
403 $ y( i+1, i ), 1 )
404 CALL cgemv( 'Conjugate transpose', m-i, i-1, one,
405 $ a( i+1, 1 ), lda, a( i+1, i ), 1, zero,
406 $ y( 1, i ), 1 )
407 CALL cgemv( 'No transpose', n-i, i-1, -one, y( i+1,
408 $ 1 ),
409 $ ldy, y( 1, i ), 1, one, y( i+1, i ), 1 )
410 CALL cgemv( 'Conjugate transpose', m-i, i, one,
411 $ x( i+1, 1 ), ldx, a( i+1, i ), 1, zero,
412 $ y( 1, i ), 1 )
413 CALL cgemv( 'Conjugate transpose', i, n-i, -one,
414 $ a( 1, i+1 ), lda, y( 1, i ), 1, one,
415 $ y( i+1, i ), 1 )
416 CALL cscal( n-i, tauq( i ), y( i+1, i ), 1 )
417 ELSE
418 CALL clacgv( n-i+1, a( i, i ), lda )
419 END IF
420 20 CONTINUE
421 END IF
422 RETURN
423*
424* End of CLABRD
425*
426 END
subroutine cgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
CGEMV
Definition cgemv.f:160
subroutine clabrd(m, n, nb, a, lda, d, e, tauq, taup, x, ldx, y, ldy)
CLABRD reduces the first nb rows and columns of a general matrix to a bidiagonal form.
Definition clabrd.f:211
subroutine clacgv(n, x, incx)
CLACGV conjugates a complex vector.
Definition clacgv.f:72
subroutine clarfg(n, alpha, x, incx, tau)
CLARFG generates an elementary reflector (Householder matrix).
Definition clarfg.f:104
subroutine cscal(n, ca, cx, incx)
CSCAL
Definition cscal.f:78