1 SUBROUTINE ZRQT03( M, N, K, AF, C, CC, Q, LDA, TAU, WORK, LWORK,
2 $ RWORK, RESULT )
3 *
4 * -- LAPACK test routine (version 3.1) --
5 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
6 * November 2006
7 *
8 * .. Scalar Arguments ..
9 INTEGER K, LDA, LWORK, M, N
10 * ..
11 * .. Array Arguments ..
12 DOUBLE PRECISION RESULT( * ), RWORK( * )
13 COMPLEX*16 AF( LDA, * ), C( LDA, * ), CC( LDA, * ),
14 $ Q( LDA, * ), TAU( * ), WORK( LWORK )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * ZRQT03 tests ZUNMRQ, which computes Q*C, Q'*C, C*Q or C*Q'.
21 *
22 * ZRQT03 compares the results of a call to ZUNMRQ with the results of
23 * forming Q explicitly by a call to ZUNGRQ and then performing matrix
24 * multiplication by a call to ZGEMM.
25 *
26 * Arguments
27 * =========
28 *
29 * M (input) INTEGER
30 * The number of rows or columns of the matrix C; C is n-by-m if
31 * Q is applied from the left, or m-by-n if Q is applied from
32 * the right. M >= 0.
33 *
34 * N (input) INTEGER
35 * The order of the orthogonal matrix Q. N >= 0.
36 *
37 * K (input) INTEGER
38 * The number of elementary reflectors whose product defines the
39 * orthogonal matrix Q. N >= K >= 0.
40 *
41 * AF (input) COMPLEX*16 array, dimension (LDA,N)
42 * Details of the RQ factorization of an m-by-n matrix, as
43 * returned by ZGERQF. See CGERQF for further details.
44 *
45 * C (workspace) COMPLEX*16 array, dimension (LDA,N)
46 *
47 * CC (workspace) COMPLEX*16 array, dimension (LDA,N)
48 *
49 * Q (workspace) COMPLEX*16 array, dimension (LDA,N)
50 *
51 * LDA (input) INTEGER
52 * The leading dimension of the arrays AF, C, CC, and Q.
53 *
54 * TAU (input) COMPLEX*16 array, dimension (min(M,N))
55 * The scalar factors of the elementary reflectors corresponding
56 * to the RQ factorization in AF.
57 *
58 * WORK (workspace) COMPLEX*16 array, dimension (LWORK)
59 *
60 * LWORK (input) INTEGER
61 * The length of WORK. LWORK must be at least M, and should be
62 * M*NB, where NB is the blocksize for this environment.
63 *
64 * RWORK (workspace) DOUBLE PRECISION array, dimension (M)
65 *
66 * RESULT (output) DOUBLE PRECISION array, dimension (4)
67 * The test ratios compare two techniques for multiplying a
68 * random matrix C by an n-by-n orthogonal matrix Q.
69 * RESULT(1) = norm( Q*C - Q*C ) / ( N * norm(C) * EPS )
70 * RESULT(2) = norm( C*Q - C*Q ) / ( N * norm(C) * EPS )
71 * RESULT(3) = norm( Q'*C - Q'*C )/ ( N * norm(C) * EPS )
72 * RESULT(4) = norm( C*Q' - C*Q' )/ ( N * norm(C) * EPS )
73 *
74 * =====================================================================
75 *
76 * .. Parameters ..
77 DOUBLE PRECISION ZERO, ONE
78 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
79 COMPLEX*16 ROGUE
80 PARAMETER ( ROGUE = ( -1.0D+10, -1.0D+10 ) )
81 * ..
82 * .. Local Scalars ..
83 CHARACTER SIDE, TRANS
84 INTEGER INFO, ISIDE, ITRANS, J, MC, MINMN, NC
85 DOUBLE PRECISION CNORM, EPS, RESID
86 * ..
87 * .. External Functions ..
88 LOGICAL LSAME
89 DOUBLE PRECISION DLAMCH, ZLANGE
90 EXTERNAL LSAME, DLAMCH, ZLANGE
91 * ..
92 * .. External Subroutines ..
93 EXTERNAL ZGEMM, ZLACPY, ZLARNV, ZLASET, ZUNGRQ, ZUNMRQ
94 * ..
95 * .. Local Arrays ..
96 INTEGER ISEED( 4 )
97 * ..
98 * .. Intrinsic Functions ..
99 INTRINSIC DBLE, DCMPLX, MAX, MIN
100 * ..
101 * .. Scalars in Common ..
102 CHARACTER*32 SRNAMT
103 * ..
104 * .. Common blocks ..
105 COMMON / SRNAMC / SRNAMT
106 * ..
107 * .. Data statements ..
108 DATA ISEED / 1988, 1989, 1990, 1991 /
109 * ..
110 * .. Executable Statements ..
111 *
112 EPS = DLAMCH( 'Epsilon' )
113 MINMN = MIN( M, N )
114 *
115 * Quick return if possible
116 *
117 IF( MINMN.EQ.0 ) THEN
118 RESULT( 1 ) = ZERO
119 RESULT( 2 ) = ZERO
120 RESULT( 3 ) = ZERO
121 RESULT( 4 ) = ZERO
122 RETURN
123 END IF
124 *
125 * Copy the last k rows of the factorization to the array Q
126 *
127 CALL ZLASET( 'Full', N, N, ROGUE, ROGUE, Q, LDA )
128 IF( K.GT.0 .AND. N.GT.K )
129 $ CALL ZLACPY( 'Full', K, N-K, AF( M-K+1, 1 ), LDA,
130 $ Q( N-K+1, 1 ), LDA )
131 IF( K.GT.1 )
132 $ CALL ZLACPY( 'Lower', K-1, K-1, AF( M-K+2, N-K+1 ), LDA,
133 $ Q( N-K+2, N-K+1 ), LDA )
134 *
135 * Generate the n-by-n matrix Q
136 *
137 SRNAMT = 'ZUNGRQ'
138 CALL ZUNGRQ( N, N, K, Q, LDA, TAU( MINMN-K+1 ), WORK, LWORK,
139 $ INFO )
140 *
141 DO 30 ISIDE = 1, 2
142 IF( ISIDE.EQ.1 ) THEN
143 SIDE = 'L'
144 MC = N
145 NC = M
146 ELSE
147 SIDE = 'R'
148 MC = M
149 NC = N
150 END IF
151 *
152 * Generate MC by NC matrix C
153 *
154 DO 10 J = 1, NC
155 CALL ZLARNV( 2, ISEED, MC, C( 1, J ) )
156 10 CONTINUE
157 CNORM = ZLANGE( '1', MC, NC, C, LDA, RWORK )
158 IF( CNORM.EQ.ZERO )
159 $ CNORM = ONE
160 *
161 DO 20 ITRANS = 1, 2
162 IF( ITRANS.EQ.1 ) THEN
163 TRANS = 'N'
164 ELSE
165 TRANS = 'C'
166 END IF
167 *
168 * Copy C
169 *
170 CALL ZLACPY( 'Full', MC, NC, C, LDA, CC, LDA )
171 *
172 * Apply Q or Q' to C
173 *
174 SRNAMT = 'ZUNMRQ'
175 IF( K.GT.0 )
176 $ CALL ZUNMRQ( SIDE, TRANS, MC, NC, K, AF( M-K+1, 1 ), LDA,
177 $ TAU( MINMN-K+1 ), CC, LDA, WORK, LWORK,
178 $ INFO )
179 *
180 * Form explicit product and subtract
181 *
182 IF( LSAME( SIDE, 'L' ) ) THEN
183 CALL ZGEMM( TRANS, 'No transpose', MC, NC, MC,
184 $ DCMPLX( -ONE ), Q, LDA, C, LDA,
185 $ DCMPLX( ONE ), CC, LDA )
186 ELSE
187 CALL ZGEMM( 'No transpose', TRANS, MC, NC, NC,
188 $ DCMPLX( -ONE ), C, LDA, Q, LDA,
189 $ DCMPLX( ONE ), CC, LDA )
190 END IF
191 *
192 * Compute error in the difference
193 *
194 RESID = ZLANGE( '1', MC, NC, CC, LDA, RWORK )
195 RESULT( ( ISIDE-1 )*2+ITRANS ) = RESID /
196 $ ( DBLE( MAX( 1, N ) )*CNORM*EPS )
197 *
198 20 CONTINUE
199 30 CONTINUE
200 *
201 RETURN
202 *
203 * End of ZRQT03
204 *
205 END
2 $ RWORK, RESULT )
3 *
4 * -- LAPACK test routine (version 3.1) --
5 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
6 * November 2006
7 *
8 * .. Scalar Arguments ..
9 INTEGER K, LDA, LWORK, M, N
10 * ..
11 * .. Array Arguments ..
12 DOUBLE PRECISION RESULT( * ), RWORK( * )
13 COMPLEX*16 AF( LDA, * ), C( LDA, * ), CC( LDA, * ),
14 $ Q( LDA, * ), TAU( * ), WORK( LWORK )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * ZRQT03 tests ZUNMRQ, which computes Q*C, Q'*C, C*Q or C*Q'.
21 *
22 * ZRQT03 compares the results of a call to ZUNMRQ with the results of
23 * forming Q explicitly by a call to ZUNGRQ and then performing matrix
24 * multiplication by a call to ZGEMM.
25 *
26 * Arguments
27 * =========
28 *
29 * M (input) INTEGER
30 * The number of rows or columns of the matrix C; C is n-by-m if
31 * Q is applied from the left, or m-by-n if Q is applied from
32 * the right. M >= 0.
33 *
34 * N (input) INTEGER
35 * The order of the orthogonal matrix Q. N >= 0.
36 *
37 * K (input) INTEGER
38 * The number of elementary reflectors whose product defines the
39 * orthogonal matrix Q. N >= K >= 0.
40 *
41 * AF (input) COMPLEX*16 array, dimension (LDA,N)
42 * Details of the RQ factorization of an m-by-n matrix, as
43 * returned by ZGERQF. See CGERQF for further details.
44 *
45 * C (workspace) COMPLEX*16 array, dimension (LDA,N)
46 *
47 * CC (workspace) COMPLEX*16 array, dimension (LDA,N)
48 *
49 * Q (workspace) COMPLEX*16 array, dimension (LDA,N)
50 *
51 * LDA (input) INTEGER
52 * The leading dimension of the arrays AF, C, CC, and Q.
53 *
54 * TAU (input) COMPLEX*16 array, dimension (min(M,N))
55 * The scalar factors of the elementary reflectors corresponding
56 * to the RQ factorization in AF.
57 *
58 * WORK (workspace) COMPLEX*16 array, dimension (LWORK)
59 *
60 * LWORK (input) INTEGER
61 * The length of WORK. LWORK must be at least M, and should be
62 * M*NB, where NB is the blocksize for this environment.
63 *
64 * RWORK (workspace) DOUBLE PRECISION array, dimension (M)
65 *
66 * RESULT (output) DOUBLE PRECISION array, dimension (4)
67 * The test ratios compare two techniques for multiplying a
68 * random matrix C by an n-by-n orthogonal matrix Q.
69 * RESULT(1) = norm( Q*C - Q*C ) / ( N * norm(C) * EPS )
70 * RESULT(2) = norm( C*Q - C*Q ) / ( N * norm(C) * EPS )
71 * RESULT(3) = norm( Q'*C - Q'*C )/ ( N * norm(C) * EPS )
72 * RESULT(4) = norm( C*Q' - C*Q' )/ ( N * norm(C) * EPS )
73 *
74 * =====================================================================
75 *
76 * .. Parameters ..
77 DOUBLE PRECISION ZERO, ONE
78 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
79 COMPLEX*16 ROGUE
80 PARAMETER ( ROGUE = ( -1.0D+10, -1.0D+10 ) )
81 * ..
82 * .. Local Scalars ..
83 CHARACTER SIDE, TRANS
84 INTEGER INFO, ISIDE, ITRANS, J, MC, MINMN, NC
85 DOUBLE PRECISION CNORM, EPS, RESID
86 * ..
87 * .. External Functions ..
88 LOGICAL LSAME
89 DOUBLE PRECISION DLAMCH, ZLANGE
90 EXTERNAL LSAME, DLAMCH, ZLANGE
91 * ..
92 * .. External Subroutines ..
93 EXTERNAL ZGEMM, ZLACPY, ZLARNV, ZLASET, ZUNGRQ, ZUNMRQ
94 * ..
95 * .. Local Arrays ..
96 INTEGER ISEED( 4 )
97 * ..
98 * .. Intrinsic Functions ..
99 INTRINSIC DBLE, DCMPLX, MAX, MIN
100 * ..
101 * .. Scalars in Common ..
102 CHARACTER*32 SRNAMT
103 * ..
104 * .. Common blocks ..
105 COMMON / SRNAMC / SRNAMT
106 * ..
107 * .. Data statements ..
108 DATA ISEED / 1988, 1989, 1990, 1991 /
109 * ..
110 * .. Executable Statements ..
111 *
112 EPS = DLAMCH( 'Epsilon' )
113 MINMN = MIN( M, N )
114 *
115 * Quick return if possible
116 *
117 IF( MINMN.EQ.0 ) THEN
118 RESULT( 1 ) = ZERO
119 RESULT( 2 ) = ZERO
120 RESULT( 3 ) = ZERO
121 RESULT( 4 ) = ZERO
122 RETURN
123 END IF
124 *
125 * Copy the last k rows of the factorization to the array Q
126 *
127 CALL ZLASET( 'Full', N, N, ROGUE, ROGUE, Q, LDA )
128 IF( K.GT.0 .AND. N.GT.K )
129 $ CALL ZLACPY( 'Full', K, N-K, AF( M-K+1, 1 ), LDA,
130 $ Q( N-K+1, 1 ), LDA )
131 IF( K.GT.1 )
132 $ CALL ZLACPY( 'Lower', K-1, K-1, AF( M-K+2, N-K+1 ), LDA,
133 $ Q( N-K+2, N-K+1 ), LDA )
134 *
135 * Generate the n-by-n matrix Q
136 *
137 SRNAMT = 'ZUNGRQ'
138 CALL ZUNGRQ( N, N, K, Q, LDA, TAU( MINMN-K+1 ), WORK, LWORK,
139 $ INFO )
140 *
141 DO 30 ISIDE = 1, 2
142 IF( ISIDE.EQ.1 ) THEN
143 SIDE = 'L'
144 MC = N
145 NC = M
146 ELSE
147 SIDE = 'R'
148 MC = M
149 NC = N
150 END IF
151 *
152 * Generate MC by NC matrix C
153 *
154 DO 10 J = 1, NC
155 CALL ZLARNV( 2, ISEED, MC, C( 1, J ) )
156 10 CONTINUE
157 CNORM = ZLANGE( '1', MC, NC, C, LDA, RWORK )
158 IF( CNORM.EQ.ZERO )
159 $ CNORM = ONE
160 *
161 DO 20 ITRANS = 1, 2
162 IF( ITRANS.EQ.1 ) THEN
163 TRANS = 'N'
164 ELSE
165 TRANS = 'C'
166 END IF
167 *
168 * Copy C
169 *
170 CALL ZLACPY( 'Full', MC, NC, C, LDA, CC, LDA )
171 *
172 * Apply Q or Q' to C
173 *
174 SRNAMT = 'ZUNMRQ'
175 IF( K.GT.0 )
176 $ CALL ZUNMRQ( SIDE, TRANS, MC, NC, K, AF( M-K+1, 1 ), LDA,
177 $ TAU( MINMN-K+1 ), CC, LDA, WORK, LWORK,
178 $ INFO )
179 *
180 * Form explicit product and subtract
181 *
182 IF( LSAME( SIDE, 'L' ) ) THEN
183 CALL ZGEMM( TRANS, 'No transpose', MC, NC, MC,
184 $ DCMPLX( -ONE ), Q, LDA, C, LDA,
185 $ DCMPLX( ONE ), CC, LDA )
186 ELSE
187 CALL ZGEMM( 'No transpose', TRANS, MC, NC, NC,
188 $ DCMPLX( -ONE ), C, LDA, Q, LDA,
189 $ DCMPLX( ONE ), CC, LDA )
190 END IF
191 *
192 * Compute error in the difference
193 *
194 RESID = ZLANGE( '1', MC, NC, CC, LDA, RWORK )
195 RESULT( ( ISIDE-1 )*2+ITRANS ) = RESID /
196 $ ( DBLE( MAX( 1, N ) )*CNORM*EPS )
197 *
198 20 CONTINUE
199 30 CONTINUE
200 *
201 RETURN
202 *
203 * End of ZRQT03
204 *
205 END