LAPACK 3.11.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dgqrts.f
Go to the documentation of this file.
1*> \brief \b DGQRTS
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8* Definition:
9* ===========
10*
11* SUBROUTINE DGQRTS( N, M, P, A, AF, Q, R, LDA, TAUA, B, BF, Z, T,
12* BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT )
13*
14* .. Scalar Arguments ..
15* INTEGER LDA, LDB, LWORK, M, N, P
16* ..
17* .. Array Arguments ..
18* DOUBLE PRECISION A( LDA, * ), AF( LDA, * ), B( LDB, * ),
19* $ BF( LDB, * ), BWK( LDB, * ), Q( LDA, * ),
20* $ R( LDA, * ), RESULT( 4 ), RWORK( * ),
21* $ T( LDB, * ), TAUA( * ), TAUB( * ),
22* $ WORK( LWORK ), Z( LDB, * )
23* ..
24*
25*
26*> \par Purpose:
27* =============
28*>
29*> \verbatim
30*>
31*> DGQRTS tests DGGQRF, which computes the GQR factorization of an
32*> N-by-M matrix A and a N-by-P matrix B: A = Q*R and B = Q*T*Z.
33*> \endverbatim
34*
35* Arguments:
36* ==========
37*
38*> \param[in] N
39*> \verbatim
40*> N is INTEGER
41*> The number of rows of the matrices A and B. N >= 0.
42*> \endverbatim
43*>
44*> \param[in] M
45*> \verbatim
46*> M is INTEGER
47*> The number of columns of the matrix A. M >= 0.
48*> \endverbatim
49*>
50*> \param[in] P
51*> \verbatim
52*> P is INTEGER
53*> The number of columns of the matrix B. P >= 0.
54*> \endverbatim
55*>
56*> \param[in] A
57*> \verbatim
58*> A is DOUBLE PRECISION array, dimension (LDA,M)
59*> The N-by-M matrix A.
60*> \endverbatim
61*>
62*> \param[out] AF
63*> \verbatim
64*> AF is DOUBLE PRECISION array, dimension (LDA,N)
65*> Details of the GQR factorization of A and B, as returned
66*> by DGGQRF, see SGGQRF for further details.
67*> \endverbatim
68*>
69*> \param[out] Q
70*> \verbatim
71*> Q is DOUBLE PRECISION array, dimension (LDA,N)
72*> The M-by-M orthogonal matrix Q.
73*> \endverbatim
74*>
75*> \param[out] R
76*> \verbatim
77*> R is DOUBLE PRECISION array, dimension (LDA,MAX(M,N))
78*> \endverbatim
79*>
80*> \param[in] LDA
81*> \verbatim
82*> LDA is INTEGER
83*> The leading dimension of the arrays A, AF, R and Q.
84*> LDA >= max(M,N).
85*> \endverbatim
86*>
87*> \param[out] TAUA
88*> \verbatim
89*> TAUA is DOUBLE PRECISION array, dimension (min(M,N))
90*> The scalar factors of the elementary reflectors, as returned
91*> by DGGQRF.
92*> \endverbatim
93*>
94*> \param[in] B
95*> \verbatim
96*> B is DOUBLE PRECISION array, dimension (LDB,P)
97*> On entry, the N-by-P matrix A.
98*> \endverbatim
99*>
100*> \param[out] BF
101*> \verbatim
102*> BF is DOUBLE PRECISION array, dimension (LDB,N)
103*> Details of the GQR factorization of A and B, as returned
104*> by DGGQRF, see SGGQRF for further details.
105*> \endverbatim
106*>
107*> \param[out] Z
108*> \verbatim
109*> Z is DOUBLE PRECISION array, dimension (LDB,P)
110*> The P-by-P orthogonal matrix Z.
111*> \endverbatim
112*>
113*> \param[out] T
114*> \verbatim
115*> T is DOUBLE PRECISION array, dimension (LDB,max(P,N))
116*> \endverbatim
117*>
118*> \param[out] BWK
119*> \verbatim
120*> BWK is DOUBLE PRECISION array, dimension (LDB,N)
121*> \endverbatim
122*>
123*> \param[in] LDB
124*> \verbatim
125*> LDB is INTEGER
126*> The leading dimension of the arrays B, BF, Z and T.
127*> LDB >= max(P,N).
128*> \endverbatim
129*>
130*> \param[out] TAUB
131*> \verbatim
132*> TAUB is DOUBLE PRECISION array, dimension (min(P,N))
133*> The scalar factors of the elementary reflectors, as returned
134*> by DGGRQF.
135*> \endverbatim
136*>
137*> \param[out] WORK
138*> \verbatim
139*> WORK is DOUBLE PRECISION array, dimension (LWORK)
140*> \endverbatim
141*>
142*> \param[in] LWORK
143*> \verbatim
144*> LWORK is INTEGER
145*> The dimension of the array WORK, LWORK >= max(N,M,P)**2.
146*> \endverbatim
147*>
148*> \param[out] RWORK
149*> \verbatim
150*> RWORK is DOUBLE PRECISION array, dimension (max(N,M,P))
151*> \endverbatim
152*>
153*> \param[out] RESULT
154*> \verbatim
155*> RESULT is DOUBLE PRECISION array, dimension (4)
156*> The test ratios:
157*> RESULT(1) = norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP)
158*> RESULT(2) = norm( T*Z - Q'*B ) / (MAX(P,N)*norm(B)*ULP)
159*> RESULT(3) = norm( I - Q'*Q ) / ( M*ULP )
160*> RESULT(4) = norm( I - Z'*Z ) / ( P*ULP )
161*> \endverbatim
162*
163* Authors:
164* ========
165*
166*> \author Univ. of Tennessee
167*> \author Univ. of California Berkeley
168*> \author Univ. of Colorado Denver
169*> \author NAG Ltd.
170*
171*> \ingroup double_eig
172*
173* =====================================================================
174 SUBROUTINE dgqrts( N, M, P, A, AF, Q, R, LDA, TAUA, B, BF, Z, T,
175 $ BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT )
176*
177* -- LAPACK test routine --
178* -- LAPACK is a software package provided by Univ. of Tennessee, --
179* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
180*
181* .. Scalar Arguments ..
182 INTEGER LDA, LDB, LWORK, M, N, P
183* ..
184* .. Array Arguments ..
185 DOUBLE PRECISION A( LDA, * ), AF( LDA, * ), B( LDB, * ),
186 $ bf( ldb, * ), bwk( ldb, * ), q( lda, * ),
187 $ r( lda, * ), result( 4 ), rwork( * ),
188 $ t( ldb, * ), taua( * ), taub( * ),
189 $ work( lwork ), z( ldb, * )
190* ..
191*
192* =====================================================================
193*
194* .. Parameters ..
195 DOUBLE PRECISION ZERO, ONE
196 parameter( zero = 0.0d+0, one = 1.0d+0 )
197 DOUBLE PRECISION ROGUE
198 parameter( rogue = -1.0d+10 )
199* ..
200* .. Local Scalars ..
201 INTEGER INFO
202 DOUBLE PRECISION ANORM, BNORM, RESID, ULP, UNFL
203* ..
204* .. External Functions ..
205 DOUBLE PRECISION DLAMCH, DLANGE, DLANSY
206 EXTERNAL dlamch, dlange, dlansy
207* ..
208* .. External Subroutines ..
209 EXTERNAL dgemm, dggqrf, dlacpy, dlaset, dorgqr, dorgrq,
210 $ dsyrk
211* ..
212* .. Intrinsic Functions ..
213 INTRINSIC dble, max, min
214* ..
215* .. Executable Statements ..
216*
217 ulp = dlamch( 'Precision' )
218 unfl = dlamch( 'Safe minimum' )
219*
220* Copy the matrix A to the array AF.
221*
222 CALL dlacpy( 'Full', n, m, a, lda, af, lda )
223 CALL dlacpy( 'Full', n, p, b, ldb, bf, ldb )
224*
225 anorm = max( dlange( '1', n, m, a, lda, rwork ), unfl )
226 bnorm = max( dlange( '1', n, p, b, ldb, rwork ), unfl )
227*
228* Factorize the matrices A and B in the arrays AF and BF.
229*
230 CALL dggqrf( n, m, p, af, lda, taua, bf, ldb, taub, work, lwork,
231 $ info )
232*
233* Generate the N-by-N matrix Q
234*
235 CALL dlaset( 'Full', n, n, rogue, rogue, q, lda )
236 CALL dlacpy( 'Lower', n-1, m, af( 2, 1 ), lda, q( 2, 1 ), lda )
237 CALL dorgqr( n, n, min( n, m ), q, lda, taua, work, lwork, info )
238*
239* Generate the P-by-P matrix Z
240*
241 CALL dlaset( 'Full', p, p, rogue, rogue, z, ldb )
242 IF( n.LE.p ) THEN
243 IF( n.GT.0 .AND. n.LT.p )
244 $ CALL dlacpy( 'Full', n, p-n, bf, ldb, z( p-n+1, 1 ), ldb )
245 IF( n.GT.1 )
246 $ CALL dlacpy( 'Lower', n-1, n-1, bf( 2, p-n+1 ), ldb,
247 $ z( p-n+2, p-n+1 ), ldb )
248 ELSE
249 IF( p.GT.1 )
250 $ CALL dlacpy( 'Lower', p-1, p-1, bf( n-p+2, 1 ), ldb,
251 $ z( 2, 1 ), ldb )
252 END IF
253 CALL dorgrq( p, p, min( n, p ), z, ldb, taub, work, lwork, info )
254*
255* Copy R
256*
257 CALL dlaset( 'Full', n, m, zero, zero, r, lda )
258 CALL dlacpy( 'Upper', n, m, af, lda, r, lda )
259*
260* Copy T
261*
262 CALL dlaset( 'Full', n, p, zero, zero, t, ldb )
263 IF( n.LE.p ) THEN
264 CALL dlacpy( 'Upper', n, n, bf( 1, p-n+1 ), ldb, t( 1, p-n+1 ),
265 $ ldb )
266 ELSE
267 CALL dlacpy( 'Full', n-p, p, bf, ldb, t, ldb )
268 CALL dlacpy( 'Upper', p, p, bf( n-p+1, 1 ), ldb, t( n-p+1, 1 ),
269 $ ldb )
270 END IF
271*
272* Compute R - Q'*A
273*
274 CALL dgemm( 'Transpose', 'No transpose', n, m, n, -one, q, lda, a,
275 $ lda, one, r, lda )
276*
277* Compute norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP ) .
278*
279 resid = dlange( '1', n, m, r, lda, rwork )
280 IF( anorm.GT.zero ) THEN
281 result( 1 ) = ( ( resid / dble( max( 1, m, n ) ) ) / anorm ) /
282 $ ulp
283 ELSE
284 result( 1 ) = zero
285 END IF
286*
287* Compute T*Z - Q'*B
288*
289 CALL dgemm( 'No Transpose', 'No transpose', n, p, p, one, t, ldb,
290 $ z, ldb, zero, bwk, ldb )
291 CALL dgemm( 'Transpose', 'No transpose', n, p, n, -one, q, lda, b,
292 $ ldb, one, bwk, ldb )
293*
294* Compute norm( T*Z - Q'*B ) / ( MAX(P,N)*norm(A)*ULP ) .
295*
296 resid = dlange( '1', n, p, bwk, ldb, rwork )
297 IF( bnorm.GT.zero ) THEN
298 result( 2 ) = ( ( resid / dble( max( 1, p, n ) ) ) / bnorm ) /
299 $ ulp
300 ELSE
301 result( 2 ) = zero
302 END IF
303*
304* Compute I - Q'*Q
305*
306 CALL dlaset( 'Full', n, n, zero, one, r, lda )
307 CALL dsyrk( 'Upper', 'Transpose', n, n, -one, q, lda, one, r,
308 $ lda )
309*
310* Compute norm( I - Q'*Q ) / ( N * ULP ) .
311*
312 resid = dlansy( '1', 'Upper', n, r, lda, rwork )
313 result( 3 ) = ( resid / dble( max( 1, n ) ) ) / ulp
314*
315* Compute I - Z'*Z
316*
317 CALL dlaset( 'Full', p, p, zero, one, t, ldb )
318 CALL dsyrk( 'Upper', 'Transpose', p, p, -one, z, ldb, one, t,
319 $ ldb )
320*
321* Compute norm( I - Z'*Z ) / ( P*ULP ) .
322*
323 resid = dlansy( '1', 'Upper', p, t, ldb, rwork )
324 result( 4 ) = ( resid / dble( max( 1, p ) ) ) / ulp
325*
326 RETURN
327*
328* End of DGQRTS
329*
330 END
subroutine dlacpy(UPLO, M, N, A, LDA, B, LDB)
DLACPY copies all or part of one two-dimensional array to another.
Definition: dlacpy.f:103
subroutine dlaset(UPLO, M, N, ALPHA, BETA, A, LDA)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition: dlaset.f:110
subroutine dsyrk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
DSYRK
Definition: dsyrk.f:169
subroutine dgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
DGEMM
Definition: dgemm.f:187
subroutine dgqrts(N, M, P, A, AF, Q, R, LDA, TAUA, B, BF, Z, T, BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT)
DGQRTS
Definition: dgqrts.f:176
subroutine dorgrq(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
DORGRQ
Definition: dorgrq.f:128
subroutine dorgqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
DORGQR
Definition: dorgqr.f:128
subroutine dggqrf(N, M, P, A, LDA, TAUA, B, LDB, TAUB, WORK, LWORK, INFO)
DGGQRF
Definition: dggqrf.f:215