KTH framework for Nek5000 toolboxes; testing version  0.0.1
dorgbr.f
Go to the documentation of this file.
1  SUBROUTINE dorgbr( VECT, M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
2 *
3 * -- LAPACK routine (version 3.0) --
4 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5 * Courant Institute, Argonne National Lab, and Rice University
6 * June 30, 1999
7 *
8 * .. Scalar Arguments ..
9  CHARACTER VECT
10  INTEGER INFO, K, LDA, LWORK, M, N
11 * ..
12 * .. Array Arguments ..
13  DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
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.
23 *
24 * If VECT = 'Q', A is assumed to have been an M-by-K matrix, and Q
25 * is of order M:
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
29 * M-by-M matrix.
30 *
31 * If VECT = 'P', A is assumed to have been a K-by-N matrix, and P**T
32 * is of order N:
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
36 * an N-by-N matrix.
37 *
38 * Arguments
39 * =========
40 *
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:
44 * = 'Q': generate Q;
45 * = 'P': generate P**T.
46 *
47 * M (input) INTEGER
48 * The number of rows of the matrix Q or P**T to be returned.
49 * M >= 0.
50 *
51 * N (input) INTEGER
52 * The number of columns of the matrix Q or P**T to be returned.
53 * N >= 0.
54 * If VECT = 'Q', M >= N >= min(M,K);
55 * if VECT = 'P', N >= M >= min(N,K).
56 *
57 * K (input) INTEGER
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.
62 * K >= 0.
63 *
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.
68 *
69 * LDA (input) INTEGER
70 * The leading dimension of the array A. LDA >= max(1,M).
71 *
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.
78 *
79 * WORK (workspace/output) DOUBLE PRECISION array, dimension (LWORK)
80 * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
81 *
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.
86 *
87 * If LWORK = -1, then a workspace query is assumed; the routine
88 * only calculates the optimal size of the WORK array, returns
89 * this value as the first entry of the WORK array, and no error
90 * message related to LWORK is issued by XERBLA.
91 *
92 * INFO (output) INTEGER
93 * = 0: successful exit
94 * < 0: if INFO = -i, the i-th argument had an illegal value
95 *
96 * =====================================================================
97 *
98 * .. Parameters ..
99  DOUBLE PRECISION ZERO, ONE
100  parameter( zero = 0.0d+0, one = 1.0d+0 )
101 * ..
102 * .. Local Scalars ..
103  LOGICAL LQUERY, WANTQ
104  INTEGER I, IINFO, J, LWKOPT, MN, NB
105 * ..
106 * .. External Functions ..
107  LOGICAL LSAME
108  INTEGER ILAENV
109  EXTERNAL lsame, ilaenv
110 * ..
111 * .. External Subroutines ..
112  EXTERNAL dorglq, dorgqr, xerbla
113 * ..
114 * .. Intrinsic Functions ..
115  INTRINSIC max, min
116 * ..
117 * .. Executable Statements ..
118 *
119 * Test the input arguments
120 *
121  info = 0
122  wantq = lsame( vect, 'Q' )
123  mn = min( m, n )
124  lquery = ( lwork.EQ.-1 )
125  IF( .NOT.wantq .AND. .NOT.lsame( vect, 'P' ) ) THEN
126  info = -1
127  ELSE IF( m.LT.0 ) THEN
128  info = -2
129  ELSE IF( n.LT.0 .OR. ( wantq .AND. ( n.GT.m .OR. n.LT.min( m,
130  $ k ) ) ) .OR. ( .NOT.wantq .AND. ( m.GT.n .OR. m.LT.
131  $ min( n, k ) ) ) ) THEN
132  info = -3
133  ELSE IF( k.LT.0 ) THEN
134  info = -4
135  ELSE IF( lda.LT.max( 1, m ) ) THEN
136  info = -6
137  ELSE IF( lwork.LT.max( 1, mn ) .AND. .NOT.lquery ) THEN
138  info = -9
139  END IF
140 *
141  IF( info.EQ.0 ) THEN
142  IF( wantq ) THEN
143  nb = ilaenv( 1, 'DORGQR', ' ', m, n, k, -1 )
144  ELSE
145  nb = ilaenv( 1, 'DORGLQ', ' ', m, n, k, -1 )
146  END IF
147  lwkopt = max( 1, mn )*nb
148  work( 1 ) = lwkopt
149  END IF
150 *
151  IF( info.NE.0 ) THEN
152  CALL xerbla( 'DORGBR', -info )
153  RETURN
154  ELSE IF( lquery ) THEN
155  RETURN
156  END IF
157 *
158 * Quick return if possible
159 *
160  IF( m.EQ.0 .OR. n.EQ.0 ) THEN
161  work( 1 ) = 1
162  RETURN
163  END IF
164 *
165  IF( wantq ) THEN
166 *
167 * Form Q, determined by a call to DGEBRD to reduce an m-by-k
168 * matrix
169 *
170  IF( m.GE.k ) THEN
171 *
172 * If m >= k, assume m >= n >= k
173 *
174  CALL dorgqr( m, n, k, a, lda, tau, work, lwork, iinfo )
175 *
176  ELSE
177 *
178 * If m < k, assume m = n
179 *
180 * Shift the vectors which define the elementary reflectors one
181 * column to the right, and set the first row and column of Q
182 * to those of the unit matrix
183 *
184  DO 20 j = m, 2, -1
185  a( 1, j ) = zero
186  DO 10 i = j + 1, m
187  a( i, j ) = a( i, j-1 )
188  10 CONTINUE
189  20 CONTINUE
190  a( 1, 1 ) = one
191  DO 30 i = 2, m
192  a( i, 1 ) = zero
193  30 CONTINUE
194  IF( m.GT.1 ) THEN
195 *
196 * Form Q(2:m,2:m)
197 *
198  CALL dorgqr( m-1, m-1, m-1, a( 2, 2 ), lda, tau, work,
199  $ lwork, iinfo )
200  END IF
201  END IF
202  ELSE
203 *
204 * Form P', determined by a call to DGEBRD to reduce a k-by-n
205 * matrix
206 *
207  IF( k.LT.n ) THEN
208 *
209 * If k < n, assume k <= m <= n
210 *
211  CALL dorglq( m, n, k, a, lda, tau, work, lwork, iinfo )
212 *
213  ELSE
214 *
215 * If k >= n, assume m = n
216 *
217 * Shift the vectors which define the elementary reflectors one
218 * row downward, and set the first row and column of P' to
219 * those of the unit matrix
220 *
221  a( 1, 1 ) = one
222  DO 40 i = 2, n
223  a( i, 1 ) = zero
224  40 CONTINUE
225  DO 60 j = 2, n
226  DO 50 i = j - 1, 2, -1
227  a( i, j ) = a( i-1, j )
228  50 CONTINUE
229  a( 1, j ) = zero
230  60 CONTINUE
231  IF( n.GT.1 ) THEN
232 *
233 * Form P'(2:n,2:n)
234 *
235  CALL dorglq( n-1, n-1, n-1, a( 2, 2 ), lda, tau, work,
236  $ lwork, iinfo )
237  END IF
238  END IF
239  END IF
240  work( 1 ) = lwkopt
241  RETURN
242 *
243 * End of DORGBR
244 *
245  END
subroutine dorgbr(VECT, M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
Definition: dorgbr.f:2
subroutine dorglq(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
Definition: dorglq.f:2
subroutine dorgqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
Definition: dorgqr.f:2
subroutine xerbla(SRNAME, INFO)
Definition: xerbla.f:2