LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
zgrqts.f
Go to the documentation of this file.
1 *> \brief \b ZGRQTS
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 ZGRQTS( M, P, N, 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 RESULT( 4 ), RWORK( * )
19 * COMPLEX*16 A( LDA, * ), AF( LDA, * ), B( LDB, * ),
20 * $ BF( LDB, * ), BWK( LDB, * ), Q( LDA, * ),
21 * $ R( LDA, * ), T( LDB, * ), TAUA( * ), TAUB( * ),
22 * $ WORK( LWORK ), Z( LDB, * )
23 * ..
24 *
25 *
26 *> \par Purpose:
27 * =============
28 *>
29 *> \verbatim
30 *>
31 *> ZGRQTS tests ZGGRQF, which computes the GRQ factorization of an
32 *> M-by-N matrix A and a P-by-N matrix B: A = R*Q and B = Z*T*Q.
33 *> \endverbatim
34 *
35 * Arguments:
36 * ==========
37 *
38 *> \param[in] M
39 *> \verbatim
40 *> M is INTEGER
41 *> The number of rows of the matrix A. M >= 0.
42 *> \endverbatim
43 *>
44 *> \param[in] P
45 *> \verbatim
46 *> P is INTEGER
47 *> The number of rows of the matrix B. P >= 0.
48 *> \endverbatim
49 *>
50 *> \param[in] N
51 *> \verbatim
52 *> N is INTEGER
53 *> The number of columns of the matrices A and B. N >= 0.
54 *> \endverbatim
55 *>
56 *> \param[in] A
57 *> \verbatim
58 *> A is COMPLEX*16 array, dimension (LDA,N)
59 *> The M-by-N matrix A.
60 *> \endverbatim
61 *>
62 *> \param[out] AF
63 *> \verbatim
64 *> AF is COMPLEX*16 array, dimension (LDA,N)
65 *> Details of the GRQ factorization of A and B, as returned
66 *> by ZGGRQF, see CGGRQF for further details.
67 *> \endverbatim
68 *>
69 *> \param[out] Q
70 *> \verbatim
71 *> Q is COMPLEX*16 array, dimension (LDA,N)
72 *> The N-by-N unitary matrix Q.
73 *> \endverbatim
74 *>
75 *> \param[out] R
76 *> \verbatim
77 *> R is COMPLEX*16 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 COMPLEX*16 array, dimension (min(M,N))
90 *> The scalar factors of the elementary reflectors, as returned
91 *> by DGGQRC.
92 *> \endverbatim
93 *>
94 *> \param[in] B
95 *> \verbatim
96 *> B is COMPLEX*16 array, dimension (LDB,N)
97 *> On entry, the P-by-N matrix A.
98 *> \endverbatim
99 *>
100 *> \param[out] BF
101 *> \verbatim
102 *> BF is COMPLEX*16 array, dimension (LDB,N)
103 *> Details of the GQR factorization of A and B, as returned
104 *> by ZGGRQF, see CGGRQF 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 unitary matrix Z.
111 *> \endverbatim
112 *>
113 *> \param[out] T
114 *> \verbatim
115 *> T is COMPLEX*16 array, dimension (LDB,max(P,N))
116 *> \endverbatim
117 *>
118 *> \param[out] BWK
119 *> \verbatim
120 *> BWK is COMPLEX*16 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 COMPLEX*16 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 COMPLEX*16 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(M,P,N)**2.
146 *> \endverbatim
147 *>
148 *> \param[out] RWORK
149 *> \verbatim
150 *> RWORK is DOUBLE PRECISION array, dimension (M)
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 - A*Q' ) / ( MAX(M,N)*norm(A)*ULP)
158 *> RESULT(2) = norm( T*Q - Z'*B ) / (MAX(P,N)*norm(B)*ULP)
159 *> RESULT(3) = norm( I - Q'*Q ) / ( N*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 *> \date November 2011
172 *
173 *> \ingroup complex16_eig
174 *
175 * =====================================================================
176  SUBROUTINE zgrqts( M, P, N, A, AF, Q, R, LDA, TAUA, B, BF, Z, T,
177  $ bwk, ldb, taub, work, lwork, rwork, result )
178 *
179 * -- LAPACK test routine (version 3.4.0) --
180 * -- LAPACK is a software package provided by Univ. of Tennessee, --
181 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
182 * November 2011
183 *
184 * .. Scalar Arguments ..
185  INTEGER LDA, LDB, LWORK, M, N, P
186 * ..
187 * .. Array Arguments ..
188  DOUBLE PRECISION RESULT( 4 ), RWORK( * )
189  COMPLEX*16 A( lda, * ), AF( lda, * ), B( ldb, * ),
190  $ bf( ldb, * ), bwk( ldb, * ), q( lda, * ),
191  $ r( lda, * ), t( ldb, * ), taua( * ), taub( * ),
192  $ work( lwork ), z( ldb, * )
193 * ..
194 *
195 * =====================================================================
196 *
197 * .. Parameters ..
198  DOUBLE PRECISION ZERO, ONE
199  parameter ( zero = 0.0d+0, one = 1.0d+0 )
200  COMPLEX*16 CZERO, CONE
201  parameter ( czero = ( 0.0d+0, 0.0d+0 ),
202  $ cone = ( 1.0d+0, 0.0d+0 ) )
203  COMPLEX*16 CROGUE
204  parameter ( crogue = ( -1.0d+10, 0.0d+0 ) )
205 * ..
206 * .. Local Scalars ..
207  INTEGER INFO
208  DOUBLE PRECISION ANORM, BNORM, RESID, ULP, UNFL
209 * ..
210 * .. External Functions ..
211  DOUBLE PRECISION DLAMCH, ZLANGE, ZLANHE
212  EXTERNAL dlamch, zlange, zlanhe
213 * ..
214 * .. External Subroutines ..
215  EXTERNAL zgemm, zggrqf, zherk, zlacpy, zlaset, zungqr,
216  $ zungrq
217 * ..
218 * .. Intrinsic Functions ..
219  INTRINSIC dble, max, min
220 * ..
221 * .. Executable Statements ..
222 *
223  ulp = dlamch( 'Precision' )
224  unfl = dlamch( 'Safe minimum' )
225 *
226 * Copy the matrix A to the array AF.
227 *
228  CALL zlacpy( 'Full', m, n, a, lda, af, lda )
229  CALL zlacpy( 'Full', p, n, b, ldb, bf, ldb )
230 *
231  anorm = max( zlange( '1', m, n, a, lda, rwork ), unfl )
232  bnorm = max( zlange( '1', p, n, b, ldb, rwork ), unfl )
233 *
234 * Factorize the matrices A and B in the arrays AF and BF.
235 *
236  CALL zggrqf( m, p, n, af, lda, taua, bf, ldb, taub, work, lwork,
237  $ info )
238 *
239 * Generate the N-by-N matrix Q
240 *
241  CALL zlaset( 'Full', n, n, crogue, crogue, q, lda )
242  IF( m.LE.n ) THEN
243  IF( m.GT.0 .AND. m.LT.n )
244  $ CALL zlacpy( 'Full', m, n-m, af, lda, q( n-m+1, 1 ), lda )
245  IF( m.GT.1 )
246  $ CALL zlacpy( 'Lower', m-1, m-1, af( 2, n-m+1 ), lda,
247  $ q( n-m+2, n-m+1 ), lda )
248  ELSE
249  IF( n.GT.1 )
250  $ CALL zlacpy( 'Lower', n-1, n-1, af( m-n+2, 1 ), lda,
251  $ q( 2, 1 ), lda )
252  END IF
253  CALL zungrq( n, n, min( m, n ), q, lda, taua, work, lwork, info )
254 *
255 * Generate the P-by-P matrix Z
256 *
257  CALL zlaset( 'Full', p, p, crogue, crogue, z, ldb )
258  IF( p.GT.1 )
259  $ CALL zlacpy( 'Lower', p-1, n, bf( 2, 1 ), ldb, z( 2, 1 ), ldb )
260  CALL zungqr( p, p, min( p, n ), z, ldb, taub, work, lwork, info )
261 *
262 * Copy R
263 *
264  CALL zlaset( 'Full', m, n, czero, czero, r, lda )
265  IF( m.LE.n ) THEN
266  CALL zlacpy( 'Upper', m, m, af( 1, n-m+1 ), lda, r( 1, n-m+1 ),
267  $ lda )
268  ELSE
269  CALL zlacpy( 'Full', m-n, n, af, lda, r, lda )
270  CALL zlacpy( 'Upper', n, n, af( m-n+1, 1 ), lda, r( m-n+1, 1 ),
271  $ lda )
272  END IF
273 *
274 * Copy T
275 *
276  CALL zlaset( 'Full', p, n, czero, czero, t, ldb )
277  CALL zlacpy( 'Upper', p, n, bf, ldb, t, ldb )
278 *
279 * Compute R - A*Q'
280 *
281  CALL zgemm( 'No transpose', 'Conjugate transpose', m, n, n, -cone,
282  $ a, lda, q, lda, cone, r, lda )
283 *
284 * Compute norm( R - A*Q' ) / ( MAX(M,N)*norm(A)*ULP ) .
285 *
286  resid = zlange( '1', m, n, r, lda, rwork )
287  IF( anorm.GT.zero ) THEN
288  result( 1 ) = ( ( resid / dble( max( 1, m, n ) ) ) / anorm ) /
289  $ ulp
290  ELSE
291  result( 1 ) = zero
292  END IF
293 *
294 * Compute T*Q - Z'*B
295 *
296  CALL zgemm( 'Conjugate transpose', 'No transpose', p, n, p, cone,
297  $ z, ldb, b, ldb, czero, bwk, ldb )
298  CALL zgemm( 'No transpose', 'No transpose', p, n, n, cone, t, ldb,
299  $ q, lda, -cone, bwk, ldb )
300 *
301 * Compute norm( T*Q - Z'*B ) / ( MAX(P,N)*norm(A)*ULP ) .
302 *
303  resid = zlange( '1', p, n, bwk, ldb, rwork )
304  IF( bnorm.GT.zero ) THEN
305  result( 2 ) = ( ( resid / dble( max( 1, p, m ) ) ) / bnorm ) /
306  $ ulp
307  ELSE
308  result( 2 ) = zero
309  END IF
310 *
311 * Compute I - Q*Q'
312 *
313  CALL zlaset( 'Full', n, n, czero, cone, r, lda )
314  CALL zherk( 'Upper', 'No Transpose', n, n, -one, q, lda, one, r,
315  $ lda )
316 *
317 * Compute norm( I - Q'*Q ) / ( N * ULP ) .
318 *
319  resid = zlanhe( '1', 'Upper', n, r, lda, rwork )
320  result( 3 ) = ( resid / dble( max( 1, n ) ) ) / ulp
321 *
322 * Compute I - Z'*Z
323 *
324  CALL zlaset( 'Full', p, p, czero, cone, t, ldb )
325  CALL zherk( 'Upper', 'Conjugate transpose', p, p, -one, z, ldb,
326  $ one, t, ldb )
327 *
328 * Compute norm( I - Z'*Z ) / ( P*ULP ) .
329 *
330  resid = zlanhe( '1', 'Upper', p, t, ldb, rwork )
331  result( 4 ) = ( resid / dble( max( 1, p ) ) ) / ulp
332 *
333  RETURN
334 *
335 * End of ZGRQTS
336 *
337  END
subroutine zlacpy(UPLO, M, N, A, LDA, B, LDB)
ZLACPY copies all or part of one two-dimensional array to another.
Definition: zlacpy.f:105
subroutine zggrqf(M, P, N, A, LDA, TAUA, B, LDB, TAUB, WORK, LWORK, INFO)
ZGGRQF
Definition: zggrqf.f:216
subroutine zgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
ZGEMM
Definition: zgemm.f:189
subroutine zlaset(UPLO, M, N, ALPHA, BETA, A, LDA)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values...
Definition: zlaset.f:108
subroutine zgrqts(M, P, N, A, AF, Q, R, LDA, TAUA, B, BF, Z, T, BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT)
ZGRQTS
Definition: zgrqts.f:178
subroutine zungqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
ZUNGQR
Definition: zungqr.f:130
subroutine zungrq(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
ZUNGRQ
Definition: zungrq.f:130
subroutine zherk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
ZHERK
Definition: zherk.f:175