1 SUBROUTINE SQLT03( 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 REAL AF( LDA, * ), C( LDA, * ), CC( LDA, * ),
13 $ Q( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
14 $ WORK( LWORK )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * SQLT03 tests SORMQL, which computes Q*C, Q'*C, C*Q or C*Q'.
21 *
22 * SQLT03 compares the results of a call to SORMQL with the results of
23 * forming Q explicitly by a call to SORGQL and then performing matrix
24 * multiplication by a call to SGEMM.
25 *
26 * Arguments
27 * =========
28 *
29 * M (input) INTEGER
30 * The order of the orthogonal matrix Q. M >= 0.
31 *
32 * N (input) INTEGER
33 * The number of rows or columns of the matrix C; C is m-by-n if
34 * Q is applied from the left, or n-by-m if Q is applied from
35 * the right. N >= 0.
36 *
37 * K (input) INTEGER
38 * The number of elementary reflectors whose product defines the
39 * orthogonal matrix Q. M >= K >= 0.
40 *
41 * AF (input) REAL array, dimension (LDA,N)
42 * Details of the QL factorization of an m-by-n matrix, as
43 * returned by SGEQLF. See SGEQLF for further details.
44 *
45 * C (workspace) REAL array, dimension (LDA,N)
46 *
47 * CC (workspace) REAL array, dimension (LDA,N)
48 *
49 * Q (workspace) REAL array, dimension (LDA,M)
50 *
51 * LDA (input) INTEGER
52 * The leading dimension of the arrays AF, C, CC, and Q.
53 *
54 * TAU (input) REAL array, dimension (min(M,N))
55 * The scalar factors of the elementary reflectors corresponding
56 * to the QL factorization in AF.
57 *
58 * WORK (workspace) REAL 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) REAL array, dimension (M)
65 *
66 * RESULT (output) REAL array, dimension (4)
67 * The test ratios compare two techniques for multiplying a
68 * random matrix C by an m-by-m orthogonal matrix Q.
69 * RESULT(1) = norm( Q*C - Q*C ) / ( M * norm(C) * EPS )
70 * RESULT(2) = norm( C*Q - C*Q ) / ( M * norm(C) * EPS )
71 * RESULT(3) = norm( Q'*C - Q'*C )/ ( M * norm(C) * EPS )
72 * RESULT(4) = norm( C*Q' - C*Q' )/ ( M * norm(C) * EPS )
73 *
74 * =====================================================================
75 *
76 * .. Parameters ..
77 REAL ZERO, ONE
78 PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
79 REAL ROGUE
80 PARAMETER ( ROGUE = -1.0E+10 )
81 * ..
82 * .. Local Scalars ..
83 CHARACTER SIDE, TRANS
84 INTEGER INFO, ISIDE, ITRANS, J, MC, MINMN, NC
85 REAL CNORM, EPS, RESID
86 * ..
87 * .. External Functions ..
88 LOGICAL LSAME
89 REAL SLAMCH, SLANGE
90 EXTERNAL LSAME, SLAMCH, SLANGE
91 * ..
92 * .. External Subroutines ..
93 EXTERNAL SGEMM, SLACPY, SLARNV, SLASET, SORGQL, SORMQL
94 * ..
95 * .. Local Arrays ..
96 INTEGER ISEED( 4 )
97 * ..
98 * .. Intrinsic Functions ..
99 INTRINSIC MAX, MIN, REAL
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 = SLAMCH( '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 columns of the factorization to the array Q
126 *
127 CALL SLASET( 'Full', M, M, ROGUE, ROGUE, Q, LDA )
128 IF( K.GT.0 .AND. M.GT.K )
129 $ CALL SLACPY( 'Full', M-K, K, AF( 1, N-K+1 ), LDA,
130 $ Q( 1, M-K+1 ), LDA )
131 IF( K.GT.1 )
132 $ CALL SLACPY( 'Upper', K-1, K-1, AF( M-K+1, N-K+2 ), LDA,
133 $ Q( M-K+1, M-K+2 ), LDA )
134 *
135 * Generate the m-by-m matrix Q
136 *
137 SRNAMT = 'SORGQL'
138 CALL SORGQL( M, M, 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 = M
145 NC = N
146 ELSE
147 SIDE = 'R'
148 MC = N
149 NC = M
150 END IF
151 *
152 * Generate MC by NC matrix C
153 *
154 DO 10 J = 1, NC
155 CALL SLARNV( 2, ISEED, MC, C( 1, J ) )
156 10 CONTINUE
157 CNORM = SLANGE( '1', MC, NC, C, LDA, RWORK )
158 IF( CNORM.EQ.0.0 )
159 $ CNORM = ONE
160 *
161 DO 20 ITRANS = 1, 2
162 IF( ITRANS.EQ.1 ) THEN
163 TRANS = 'N'
164 ELSE
165 TRANS = 'T'
166 END IF
167 *
168 * Copy C
169 *
170 CALL SLACPY( 'Full', MC, NC, C, LDA, CC, LDA )
171 *
172 * Apply Q or Q' to C
173 *
174 SRNAMT = 'SORMQL'
175 IF( K.GT.0 )
176 $ CALL SORMQL( SIDE, TRANS, MC, NC, K, AF( 1, N-K+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 SGEMM( TRANS, 'No transpose', MC, NC, MC, -ONE, Q,
184 $ LDA, C, LDA, ONE, CC, LDA )
185 ELSE
186 CALL SGEMM( 'No transpose', TRANS, MC, NC, NC, -ONE, C,
187 $ LDA, Q, LDA, ONE, CC, LDA )
188 END IF
189 *
190 * Compute error in the difference
191 *
192 RESID = SLANGE( '1', MC, NC, CC, LDA, RWORK )
193 RESULT( ( ISIDE-1 )*2+ITRANS ) = RESID /
194 $ ( REAL( MAX( 1, M ) )*CNORM*EPS )
195 *
196 20 CONTINUE
197 30 CONTINUE
198 *
199 RETURN
200 *
201 * End of SQLT03
202 *
203 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 REAL AF( LDA, * ), C( LDA, * ), CC( LDA, * ),
13 $ Q( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
14 $ WORK( LWORK )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * SQLT03 tests SORMQL, which computes Q*C, Q'*C, C*Q or C*Q'.
21 *
22 * SQLT03 compares the results of a call to SORMQL with the results of
23 * forming Q explicitly by a call to SORGQL and then performing matrix
24 * multiplication by a call to SGEMM.
25 *
26 * Arguments
27 * =========
28 *
29 * M (input) INTEGER
30 * The order of the orthogonal matrix Q. M >= 0.
31 *
32 * N (input) INTEGER
33 * The number of rows or columns of the matrix C; C is m-by-n if
34 * Q is applied from the left, or n-by-m if Q is applied from
35 * the right. N >= 0.
36 *
37 * K (input) INTEGER
38 * The number of elementary reflectors whose product defines the
39 * orthogonal matrix Q. M >= K >= 0.
40 *
41 * AF (input) REAL array, dimension (LDA,N)
42 * Details of the QL factorization of an m-by-n matrix, as
43 * returned by SGEQLF. See SGEQLF for further details.
44 *
45 * C (workspace) REAL array, dimension (LDA,N)
46 *
47 * CC (workspace) REAL array, dimension (LDA,N)
48 *
49 * Q (workspace) REAL array, dimension (LDA,M)
50 *
51 * LDA (input) INTEGER
52 * The leading dimension of the arrays AF, C, CC, and Q.
53 *
54 * TAU (input) REAL array, dimension (min(M,N))
55 * The scalar factors of the elementary reflectors corresponding
56 * to the QL factorization in AF.
57 *
58 * WORK (workspace) REAL 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) REAL array, dimension (M)
65 *
66 * RESULT (output) REAL array, dimension (4)
67 * The test ratios compare two techniques for multiplying a
68 * random matrix C by an m-by-m orthogonal matrix Q.
69 * RESULT(1) = norm( Q*C - Q*C ) / ( M * norm(C) * EPS )
70 * RESULT(2) = norm( C*Q - C*Q ) / ( M * norm(C) * EPS )
71 * RESULT(3) = norm( Q'*C - Q'*C )/ ( M * norm(C) * EPS )
72 * RESULT(4) = norm( C*Q' - C*Q' )/ ( M * norm(C) * EPS )
73 *
74 * =====================================================================
75 *
76 * .. Parameters ..
77 REAL ZERO, ONE
78 PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
79 REAL ROGUE
80 PARAMETER ( ROGUE = -1.0E+10 )
81 * ..
82 * .. Local Scalars ..
83 CHARACTER SIDE, TRANS
84 INTEGER INFO, ISIDE, ITRANS, J, MC, MINMN, NC
85 REAL CNORM, EPS, RESID
86 * ..
87 * .. External Functions ..
88 LOGICAL LSAME
89 REAL SLAMCH, SLANGE
90 EXTERNAL LSAME, SLAMCH, SLANGE
91 * ..
92 * .. External Subroutines ..
93 EXTERNAL SGEMM, SLACPY, SLARNV, SLASET, SORGQL, SORMQL
94 * ..
95 * .. Local Arrays ..
96 INTEGER ISEED( 4 )
97 * ..
98 * .. Intrinsic Functions ..
99 INTRINSIC MAX, MIN, REAL
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 = SLAMCH( '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 columns of the factorization to the array Q
126 *
127 CALL SLASET( 'Full', M, M, ROGUE, ROGUE, Q, LDA )
128 IF( K.GT.0 .AND. M.GT.K )
129 $ CALL SLACPY( 'Full', M-K, K, AF( 1, N-K+1 ), LDA,
130 $ Q( 1, M-K+1 ), LDA )
131 IF( K.GT.1 )
132 $ CALL SLACPY( 'Upper', K-1, K-1, AF( M-K+1, N-K+2 ), LDA,
133 $ Q( M-K+1, M-K+2 ), LDA )
134 *
135 * Generate the m-by-m matrix Q
136 *
137 SRNAMT = 'SORGQL'
138 CALL SORGQL( M, M, 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 = M
145 NC = N
146 ELSE
147 SIDE = 'R'
148 MC = N
149 NC = M
150 END IF
151 *
152 * Generate MC by NC matrix C
153 *
154 DO 10 J = 1, NC
155 CALL SLARNV( 2, ISEED, MC, C( 1, J ) )
156 10 CONTINUE
157 CNORM = SLANGE( '1', MC, NC, C, LDA, RWORK )
158 IF( CNORM.EQ.0.0 )
159 $ CNORM = ONE
160 *
161 DO 20 ITRANS = 1, 2
162 IF( ITRANS.EQ.1 ) THEN
163 TRANS = 'N'
164 ELSE
165 TRANS = 'T'
166 END IF
167 *
168 * Copy C
169 *
170 CALL SLACPY( 'Full', MC, NC, C, LDA, CC, LDA )
171 *
172 * Apply Q or Q' to C
173 *
174 SRNAMT = 'SORMQL'
175 IF( K.GT.0 )
176 $ CALL SORMQL( SIDE, TRANS, MC, NC, K, AF( 1, N-K+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 SGEMM( TRANS, 'No transpose', MC, NC, MC, -ONE, Q,
184 $ LDA, C, LDA, ONE, CC, LDA )
185 ELSE
186 CALL SGEMM( 'No transpose', TRANS, MC, NC, NC, -ONE, C,
187 $ LDA, Q, LDA, ONE, CC, LDA )
188 END IF
189 *
190 * Compute error in the difference
191 *
192 RESID = SLANGE( '1', MC, NC, CC, LDA, RWORK )
193 RESULT( ( ISIDE-1 )*2+ITRANS ) = RESID /
194 $ ( REAL( MAX( 1, M ) )*CNORM*EPS )
195 *
196 20 CONTINUE
197 30 CONTINUE
198 *
199 RETURN
200 *
201 * End of SQLT03
202 *
203 END