KTH framework for Nek5000 toolboxes; testing version  0.0.1
dlabrd.f
Go to the documentation of this file.
1  SUBROUTINE dlabrd( M, N, NB, A, LDA, D, E, TAUQ, TAUP, X, LDX, Y,
2  $ LDY )
3 *
4 * -- LAPACK auxiliary routine (version 3.0) --
5 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
6 * Courant Institute, Argonne National Lab, and Rice University
7 * February 29, 1992
8 *
9 * .. Scalar Arguments ..
10  INTEGER LDA, LDX, LDY, M, N, NB
11 * ..
12 * .. Array Arguments ..
13  DOUBLE PRECISION A( LDA, * ), D( * ), E( * ), TAUP( * ),
14  $ tauq( * ), x( ldx, * ), y( ldy, * )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * DLABRD reduces the first NB rows and columns of a real general
21 * m by n matrix A to upper or lower bidiagonal form by an orthogonal
22 * transformation Q' * A * P, and returns the matrices X and Y which
23 * are needed to apply the transformation to the unreduced part of A.
24 *
25 * If m >= n, A is reduced to upper bidiagonal form; if m < n, to lower
26 * bidiagonal form.
27 *
28 * This is an auxiliary routine called by DGEBRD
29 *
30 * Arguments
31 * =========
32 *
33 * M (input) INTEGER
34 * The number of rows in the matrix A.
35 *
36 * N (input) INTEGER
37 * The number of columns in the matrix A.
38 *
39 * NB (input) INTEGER
40 * The number of leading rows and columns of A to be reduced.
41 *
42 * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
43 * On entry, the m by n general matrix to be reduced.
44 * On exit, the first NB rows and columns of the matrix are
45 * overwritten; the rest of the array is unchanged.
46 * If m >= n, elements on and below the diagonal in the first NB
47 * columns, with the array TAUQ, represent the orthogonal
48 * matrix Q as a product of elementary reflectors; and
49 * elements above the diagonal in the first NB rows, with the
50 * array TAUP, represent the orthogonal matrix P as a product
51 * of elementary reflectors.
52 * If m < n, elements below the diagonal in the first NB
53 * columns, with the array TAUQ, represent the orthogonal
54 * matrix Q as a product of elementary reflectors, and
55 * elements on and above the diagonal in the first NB rows,
56 * with the array TAUP, represent the orthogonal matrix P as
57 * a product of elementary reflectors.
58 * See Further Details.
59 *
60 * LDA (input) INTEGER
61 * The leading dimension of the array A. LDA >= max(1,M).
62 *
63 * D (output) DOUBLE PRECISION array, dimension (NB)
64 * The diagonal elements of the first NB rows and columns of
65 * the reduced matrix. D(i) = A(i,i).
66 *
67 * E (output) DOUBLE PRECISION array, dimension (NB)
68 * The off-diagonal elements of the first NB rows and columns of
69 * the reduced matrix.
70 *
71 * TAUQ (output) DOUBLE PRECISION array dimension (NB)
72 * The scalar factors of the elementary reflectors which
73 * represent the orthogonal matrix Q. See Further Details.
74 *
75 * TAUP (output) DOUBLE PRECISION array, dimension (NB)
76 * The scalar factors of the elementary reflectors which
77 * represent the orthogonal matrix P. See Further Details.
78 *
79 * X (output) DOUBLE PRECISION array, dimension (LDX,NB)
80 * The m-by-nb matrix X required to update the unreduced part
81 * of A.
82 *
83 * LDX (input) INTEGER
84 * The leading dimension of the array X. LDX >= M.
85 *
86 * Y (output) DOUBLE PRECISION array, dimension (LDY,NB)
87 * The n-by-nb matrix Y required to update the unreduced part
88 * of A.
89 *
90 * LDY (output) INTEGER
91 * The leading dimension of the array Y. LDY >= N.
92 *
93 * Further Details
94 * ===============
95 *
96 * The matrices Q and P are represented as products of elementary
97 * reflectors:
98 *
99 * Q = H(1) H(2) . . . H(nb) and P = G(1) G(2) . . . G(nb)
100 *
101 * Each H(i) and G(i) has the form:
102 *
103 * H(i) = I - tauq * v * v' and G(i) = I - taup * u * u'
104 *
105 * where tauq and taup are real scalars, and v and u are real vectors.
106 *
107 * If m >= n, v(1:i-1) = 0, v(i) = 1, and v(i:m) is stored on exit in
108 * A(i:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+1:n) is stored on exit in
109 * A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
110 *
111 * If m < n, v(1:i) = 0, v(i+1) = 1, and v(i+1:m) is stored on exit in
112 * A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i:n) is stored on exit in
113 * A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
114 *
115 * The elements of the vectors v and u together form the m-by-nb matrix
116 * V and the nb-by-n matrix U' which are needed, with X and Y, to apply
117 * the transformation to the unreduced part of the matrix, using a block
118 * update of the form: A := A - V*Y' - X*U'.
119 *
120 * The contents of A on exit are illustrated by the following examples
121 * with nb = 2:
122 *
123 * m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n):
124 *
125 * ( 1 1 u1 u1 u1 ) ( 1 u1 u1 u1 u1 u1 )
126 * ( v1 1 1 u2 u2 ) ( 1 1 u2 u2 u2 u2 )
127 * ( v1 v2 a a a ) ( v1 1 a a a a )
128 * ( v1 v2 a a a ) ( v1 v2 a a a a )
129 * ( v1 v2 a a a ) ( v1 v2 a a a a )
130 * ( v1 v2 a a a )
131 *
132 * where a denotes an element of the original matrix which is unchanged,
133 * vi denotes an element of the vector defining H(i), and ui an element
134 * of the vector defining G(i).
135 *
136 * =====================================================================
137 *
138 * .. Parameters ..
139  DOUBLE PRECISION ZERO, ONE
140  parameter( zero = 0.0d0, one = 1.0d0 )
141 * ..
142 * .. Local Scalars ..
143  INTEGER I
144 * ..
145 * .. External Subroutines ..
146  EXTERNAL dgemv, dlarfg, dscal
147 * ..
148 * .. Intrinsic Functions ..
149  INTRINSIC min
150 * ..
151 * .. Executable Statements ..
152 *
153 * Quick return if possible
154 *
155  IF( m.LE.0 .OR. n.LE.0 )
156  $ RETURN
157 *
158  IF( m.GE.n ) THEN
159 *
160 * Reduce to upper bidiagonal form
161 *
162  DO 10 i = 1, nb
163 *
164 * Update A(i:m,i)
165 *
166  CALL dgemv( 'No transpose', m-i+1, i-1, -one, a( i, 1 ),
167  $ lda, y( i, 1 ), ldy, one, a( i, i ), 1 )
168  CALL dgemv( 'No transpose', m-i+1, i-1, -one, x( i, 1 ),
169  $ ldx, a( 1, i ), 1, one, a( i, i ), 1 )
170 *
171 * Generate reflection Q(i) to annihilate A(i+1:m,i)
172 *
173  CALL dlarfg( m-i+1, a( i, i ), a( min( i+1, m ), i ), 1,
174  $ tauq( i ) )
175  d( i ) = a( i, i )
176  IF( i.LT.n ) THEN
177  a( i, i ) = one
178 *
179 * Compute Y(i+1:n,i)
180 *
181  CALL dgemv( 'Transpose', m-i+1, n-i, one, a( i, i+1 ),
182  $ lda, a( i, i ), 1, zero, y( i+1, i ), 1 )
183  CALL dgemv( 'Transpose', m-i+1, i-1, one, a( i, 1 ), lda,
184  $ a( i, i ), 1, zero, y( 1, i ), 1 )
185  CALL dgemv( 'No transpose', n-i, i-1, -one, y( i+1, 1 ),
186  $ ldy, y( 1, i ), 1, one, y( i+1, i ), 1 )
187  CALL dgemv( 'Transpose', m-i+1, i-1, one, x( i, 1 ), ldx,
188  $ a( i, i ), 1, zero, y( 1, i ), 1 )
189  CALL dgemv( 'Transpose', i-1, n-i, -one, a( 1, i+1 ),
190  $ lda, y( 1, i ), 1, one, y( i+1, i ), 1 )
191  CALL dscal( n-i, tauq( i ), y( i+1, i ), 1 )
192 *
193 * Update A(i,i+1:n)
194 *
195  CALL dgemv( 'No transpose', n-i, i, -one, y( i+1, 1 ),
196  $ ldy, a( i, 1 ), lda, one, a( i, i+1 ), lda )
197  CALL dgemv( 'Transpose', i-1, n-i, -one, a( 1, i+1 ),
198  $ lda, x( i, 1 ), ldx, one, a( i, i+1 ), lda )
199 *
200 * Generate reflection P(i) to annihilate A(i,i+2:n)
201 *
202  CALL dlarfg( n-i, a( i, i+1 ), a( i, min( i+2, n ) ),
203  $ lda, taup( i ) )
204  e( i ) = a( i, i+1 )
205  a( i, i+1 ) = one
206 *
207 * Compute X(i+1:m,i)
208 *
209  CALL dgemv( 'No transpose', m-i, n-i, one, a( i+1, i+1 ),
210  $ lda, a( i, i+1 ), lda, zero, x( i+1, i ), 1 )
211  CALL dgemv( 'Transpose', n-i, i, one, y( i+1, 1 ), ldy,
212  $ a( i, i+1 ), lda, zero, x( 1, i ), 1 )
213  CALL dgemv( 'No transpose', m-i, i, -one, a( i+1, 1 ),
214  $ lda, x( 1, i ), 1, one, x( i+1, i ), 1 )
215  CALL dgemv( 'No transpose', i-1, n-i, one, a( 1, i+1 ),
216  $ lda, a( i, i+1 ), lda, zero, x( 1, i ), 1 )
217  CALL dgemv( 'No transpose', m-i, i-1, -one, x( i+1, 1 ),
218  $ ldx, x( 1, i ), 1, one, x( i+1, i ), 1 )
219  CALL dscal( m-i, taup( i ), x( i+1, i ), 1 )
220  END IF
221  10 CONTINUE
222  ELSE
223 *
224 * Reduce to lower bidiagonal form
225 *
226  DO 20 i = 1, nb
227 *
228 * Update A(i,i:n)
229 *
230  CALL dgemv( 'No transpose', n-i+1, i-1, -one, y( i, 1 ),
231  $ ldy, a( i, 1 ), lda, one, a( i, i ), lda )
232  CALL dgemv( 'Transpose', i-1, n-i+1, -one, a( 1, i ), lda,
233  $ x( i, 1 ), ldx, one, a( i, i ), lda )
234 *
235 * Generate reflection P(i) to annihilate A(i,i+1:n)
236 *
237  CALL dlarfg( n-i+1, a( i, i ), a( i, min( i+1, n ) ), lda,
238  $ taup( i ) )
239  d( i ) = a( i, i )
240  IF( i.LT.m ) THEN
241  a( i, i ) = one
242 *
243 * Compute X(i+1:m,i)
244 *
245  CALL dgemv( 'No transpose', m-i, n-i+1, one, a( i+1, i ),
246  $ lda, a( i, i ), lda, zero, x( i+1, i ), 1 )
247  CALL dgemv( 'Transpose', n-i+1, i-1, one, y( i, 1 ), ldy,
248  $ a( i, i ), lda, zero, x( 1, i ), 1 )
249  CALL dgemv( 'No transpose', m-i, i-1, -one, a( i+1, 1 ),
250  $ lda, x( 1, i ), 1, one, x( i+1, i ), 1 )
251  CALL dgemv( 'No transpose', i-1, n-i+1, one, a( 1, i ),
252  $ lda, a( i, i ), lda, zero, x( 1, i ), 1 )
253  CALL dgemv( 'No transpose', m-i, i-1, -one, x( i+1, 1 ),
254  $ ldx, x( 1, i ), 1, one, x( i+1, i ), 1 )
255  CALL dscal( m-i, taup( i ), x( i+1, i ), 1 )
256 *
257 * Update A(i+1:m,i)
258 *
259  CALL dgemv( 'No transpose', m-i, i-1, -one, a( i+1, 1 ),
260  $ lda, y( i, 1 ), ldy, one, a( i+1, i ), 1 )
261  CALL dgemv( 'No transpose', m-i, i, -one, x( i+1, 1 ),
262  $ ldx, a( 1, i ), 1, one, a( i+1, i ), 1 )
263 *
264 * Generate reflection Q(i) to annihilate A(i+2:m,i)
265 *
266  CALL dlarfg( m-i, a( i+1, i ), a( min( i+2, m ), i ), 1,
267  $ tauq( i ) )
268  e( i ) = a( i+1, i )
269  a( i+1, i ) = one
270 *
271 * Compute Y(i+1:n,i)
272 *
273  CALL dgemv( 'Transpose', m-i, n-i, one, a( i+1, i+1 ),
274  $ lda, a( i+1, i ), 1, zero, y( i+1, i ), 1 )
275  CALL dgemv( 'Transpose', m-i, i-1, one, a( i+1, 1 ), lda,
276  $ a( i+1, i ), 1, zero, y( 1, i ), 1 )
277  CALL dgemv( 'No transpose', n-i, i-1, -one, y( i+1, 1 ),
278  $ ldy, y( 1, i ), 1, one, y( i+1, i ), 1 )
279  CALL dgemv( 'Transpose', m-i, i, one, x( i+1, 1 ), ldx,
280  $ a( i+1, i ), 1, zero, y( 1, i ), 1 )
281  CALL dgemv( 'Transpose', i, n-i, -one, a( 1, i+1 ), lda,
282  $ y( 1, i ), 1, one, y( i+1, i ), 1 )
283  CALL dscal( n-i, tauq( i ), y( i+1, i ), 1 )
284  END IF
285  20 CONTINUE
286  END IF
287  RETURN
288 *
289 * End of DLABRD
290 *
291  END
subroutine dgemv(TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
Definition: dgemv.f:3
subroutine dlabrd(M, N, NB, A, LDA, D, E, TAUQ, TAUP, X, LDX, Y, LDY)
Definition: dlabrd.f:3
subroutine dlarfg(N, ALPHA, X, INCX, TAU)
Definition: dlarfg.f:2
subroutine dscal(n, da, dx, incx)
Definition: dscal.f:2