1
SUBROUTINE DORGBR( VECT, M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
3
* -- LAPACK routine (version 2.0) --
4
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5
* Courant Institute, Argonne National Lab, and Rice University
8
* .. Scalar Arguments ..
10
INTEGER INFO, K, LDA, LWORK, M, N
12
* .. Array Arguments ..
13
DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( LWORK )
19
* DORGBR generates one of the real orthogonal matrices Q or P**T
20
* determined by DGEBRD when reducing a real matrix A to bidiagonal
21
* form: A = Q * B * P**T. Q and P**T are defined as products of
22
* elementary reflectors H(i) or G(i) respectively.
24
* If VECT = 'Q', A is assumed to have been an M-by-K matrix, and Q
26
* if m >= k, Q = H(1) H(2) . . . H(k) and DORGBR returns the first n
27
* columns of Q, where m >= n >= k;
28
* if m < k, Q = H(1) H(2) . . . H(m-1) and DORGBR returns Q as an
31
* If VECT = 'P', A is assumed to have been a K-by-N matrix, and P**T
33
* if k < n, P**T = G(k) . . . G(2) G(1) and DORGBR returns the first m
34
* rows of P**T, where n >= m >= k;
35
* if k >= n, P**T = G(n-1) . . . G(2) G(1) and DORGBR returns P**T as
41
* VECT (input) CHARACTER*1
42
* Specifies whether the matrix Q or the matrix P**T is
43
* required, as defined in the transformation applied by DGEBRD:
45
* = 'P': generate P**T.
48
* The number of rows of the matrix Q or P**T to be returned.
52
* The number of columns of the matrix Q or P**T to be returned.
54
* If VECT = 'Q', M >= N >= min(M,K);
55
* if VECT = 'P', N >= M >= min(N,K).
58
* If VECT = 'Q', the number of columns in the original M-by-K
59
* matrix reduced by DGEBRD.
60
* If VECT = 'P', the number of rows in the original K-by-N
61
* matrix reduced by DGEBRD.
64
* A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
65
* On entry, the vectors which define the elementary reflectors,
66
* as returned by DGEBRD.
67
* On exit, the M-by-N matrix Q or P**T.
70
* The leading dimension of the array A. LDA >= max(1,M).
72
* TAU (input) DOUBLE PRECISION array, dimension
73
* (min(M,K)) if VECT = 'Q'
74
* (min(N,K)) if VECT = 'P'
75
* TAU(i) must contain the scalar factor of the elementary
76
* reflector H(i) or G(i), which determines Q or P**T, as
77
* returned by DGEBRD in its array argument TAUQ or TAUP.
79
* WORK (workspace/output) DOUBLE PRECISION array, dimension (LWORK)
80
* On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
82
* LWORK (input) INTEGER
83
* The dimension of the array WORK. LWORK >= max(1,min(M,N)).
84
* For optimum performance LWORK >= min(M,N)*NB, where NB
85
* is the optimal blocksize.
87
* INFO (output) INTEGER
88
* = 0: successful exit
89
* < 0: if INFO = -i, the i-th argument had an illegal value
91
* =====================================================================
94
DOUBLE PRECISION ZERO, ONE
95
PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
101
* .. External Functions ..
105
* .. External Subroutines ..
106
EXTERNAL DORGLQ, DORGQR, XERBLA
108
* .. Intrinsic Functions ..
111
* .. Executable Statements ..
113
* Test the input arguments
116
WANTQ = LSAME( VECT, 'Q' )
117
IF( .NOT.WANTQ .AND. .NOT.LSAME( VECT, 'P' ) ) THEN
119
ELSE IF( M.LT.0 ) THEN
121
ELSE IF( N.LT.0 .OR. ( WANTQ .AND. ( N.GT.M .OR. N.LT.MIN( M,
122
$ K ) ) ) .OR. ( .NOT.WANTQ .AND. ( M.GT.N .OR. M.LT.
123
$ MIN( N, K ) ) ) ) THEN
125
ELSE IF( K.LT.0 ) THEN
127
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
129
ELSE IF( LWORK.LT.MAX( 1, MIN( M, N ) ) ) THEN
133
CALL XERBLA( 'DORGBR', -INFO )
137
* Quick return if possible
139
IF( M.EQ.0 .OR. N.EQ.0 ) THEN
146
* Form Q, determined by a call to DGEBRD to reduce an m-by-k
151
* If m >= k, assume m >= n >= k
153
CALL DORGQR( M, N, K, A, LDA, TAU, WORK, LWORK, IINFO )
157
* If m < k, assume m = n
159
* Shift the vectors which define the elementary reflectors one
160
* column to the right, and set the first row and column of Q
161
* to those of the unit matrix
166
A( I, J ) = A( I, J-1 )
177
CALL DORGQR( M-1, M-1, M-1, A( 2, 2 ), LDA, TAU, WORK,
183
* Form P', determined by a call to DGEBRD to reduce a k-by-n
188
* If k < n, assume k <= m <= n
190
CALL DORGLQ( M, N, K, A, LDA, TAU, WORK, LWORK, IINFO )
194
* If k >= n, assume m = n
196
* Shift the vectors which define the elementary reflectors one
197
* row downward, and set the first row and column of P' to
198
* those of the unit matrix
205
DO 50 I = J - 1, 2, -1
206
A( I, J ) = A( I-1, J )
214
CALL DORGLQ( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK,