1 SUBROUTINE DLQT03( 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 AF( LDA, * ), C( LDA, * ), CC( LDA, * ),
13 $ Q( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
14 $ WORK( LWORK )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * DLQT03 tests DORMLQ, which computes Q*C, Q'*C, C*Q or C*Q'.
21 *
22 * DLQT03 compares the results of a call to DORMLQ with the results of
23 * forming Q explicitly by a call to DORGLQ and then performing matrix
24 * multiplication by a call to DGEMM.
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) DOUBLE PRECISION array, dimension (LDA,N)
42 * Details of the LQ factorization of an m-by-n matrix, as
43 * returned by DGELQF. See SGELQF for further details.
44 *
45 * C (workspace) DOUBLE PRECISION array, dimension (LDA,N)
46 *
47 * CC (workspace) DOUBLE PRECISION array, dimension (LDA,N)
48 *
49 * Q (workspace) DOUBLE PRECISION 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) DOUBLE PRECISION array, dimension (min(M,N))
55 * The scalar factors of the elementary reflectors corresponding
56 * to the LQ factorization in AF.
57 *
58 * WORK (workspace) DOUBLE PRECISION 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 ONE
78 PARAMETER ( ONE = 1.0D0 )
79 DOUBLE PRECISION ROGUE
80 PARAMETER ( ROGUE = -1.0D+10 )
81 * ..
82 * .. Local Scalars ..
83 CHARACTER SIDE, TRANS
84 INTEGER INFO, ISIDE, ITRANS, J, MC, NC
85 DOUBLE PRECISION CNORM, EPS, RESID
86 * ..
87 * .. External Functions ..
88 LOGICAL LSAME
89 DOUBLE PRECISION DLAMCH, DLANGE
90 EXTERNAL LSAME, DLAMCH, DLANGE
91 * ..
92 * .. External Subroutines ..
93 EXTERNAL DGEMM, DLACPY, DLARNV, DLASET, DORGLQ, DORMLQ
94 * ..
95 * .. Local Arrays ..
96 INTEGER ISEED( 4 )
97 * ..
98 * .. Intrinsic Functions ..
99 INTRINSIC DBLE, MAX
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 *
114 * Copy the first k rows of the factorization to the array Q
115 *
116 CALL DLASET( 'Full', N, N, ROGUE, ROGUE, Q, LDA )
117 CALL DLACPY( 'Upper', K, N-1, AF( 1, 2 ), LDA, Q( 1, 2 ), LDA )
118 *
119 * Generate the n-by-n matrix Q
120 *
121 SRNAMT = 'DORGLQ'
122 CALL DORGLQ( N, N, K, Q, LDA, TAU, WORK, LWORK, INFO )
123 *
124 DO 30 ISIDE = 1, 2
125 IF( ISIDE.EQ.1 ) THEN
126 SIDE = 'L'
127 MC = N
128 NC = M
129 ELSE
130 SIDE = 'R'
131 MC = M
132 NC = N
133 END IF
134 *
135 * Generate MC by NC matrix C
136 *
137 DO 10 J = 1, NC
138 CALL DLARNV( 2, ISEED, MC, C( 1, J ) )
139 10 CONTINUE
140 CNORM = DLANGE( '1', MC, NC, C, LDA, RWORK )
141 IF( CNORM.EQ.0.0D0 )
142 $ CNORM = ONE
143 *
144 DO 20 ITRANS = 1, 2
145 IF( ITRANS.EQ.1 ) THEN
146 TRANS = 'N'
147 ELSE
148 TRANS = 'T'
149 END IF
150 *
151 * Copy C
152 *
153 CALL DLACPY( 'Full', MC, NC, C, LDA, CC, LDA )
154 *
155 * Apply Q or Q' to C
156 *
157 SRNAMT = 'DORMLQ'
158 CALL DORMLQ( SIDE, TRANS, MC, NC, K, AF, LDA, TAU, CC, LDA,
159 $ WORK, LWORK, INFO )
160 *
161 * Form explicit product and subtract
162 *
163 IF( LSAME( SIDE, 'L' ) ) THEN
164 CALL DGEMM( TRANS, 'No transpose', MC, NC, MC, -ONE, Q,
165 $ LDA, C, LDA, ONE, CC, LDA )
166 ELSE
167 CALL DGEMM( 'No transpose', TRANS, MC, NC, NC, -ONE, C,
168 $ LDA, Q, LDA, ONE, CC, LDA )
169 END IF
170 *
171 * Compute error in the difference
172 *
173 RESID = DLANGE( '1', MC, NC, CC, LDA, RWORK )
174 RESULT( ( ISIDE-1 )*2+ITRANS ) = RESID /
175 $ ( DBLE( MAX( 1, N ) )*CNORM*EPS )
176 *
177 20 CONTINUE
178 30 CONTINUE
179 *
180 RETURN
181 *
182 * End of DLQT03
183 *
184 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 AF( LDA, * ), C( LDA, * ), CC( LDA, * ),
13 $ Q( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
14 $ WORK( LWORK )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * DLQT03 tests DORMLQ, which computes Q*C, Q'*C, C*Q or C*Q'.
21 *
22 * DLQT03 compares the results of a call to DORMLQ with the results of
23 * forming Q explicitly by a call to DORGLQ and then performing matrix
24 * multiplication by a call to DGEMM.
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) DOUBLE PRECISION array, dimension (LDA,N)
42 * Details of the LQ factorization of an m-by-n matrix, as
43 * returned by DGELQF. See SGELQF for further details.
44 *
45 * C (workspace) DOUBLE PRECISION array, dimension (LDA,N)
46 *
47 * CC (workspace) DOUBLE PRECISION array, dimension (LDA,N)
48 *
49 * Q (workspace) DOUBLE PRECISION 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) DOUBLE PRECISION array, dimension (min(M,N))
55 * The scalar factors of the elementary reflectors corresponding
56 * to the LQ factorization in AF.
57 *
58 * WORK (workspace) DOUBLE PRECISION 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 ONE
78 PARAMETER ( ONE = 1.0D0 )
79 DOUBLE PRECISION ROGUE
80 PARAMETER ( ROGUE = -1.0D+10 )
81 * ..
82 * .. Local Scalars ..
83 CHARACTER SIDE, TRANS
84 INTEGER INFO, ISIDE, ITRANS, J, MC, NC
85 DOUBLE PRECISION CNORM, EPS, RESID
86 * ..
87 * .. External Functions ..
88 LOGICAL LSAME
89 DOUBLE PRECISION DLAMCH, DLANGE
90 EXTERNAL LSAME, DLAMCH, DLANGE
91 * ..
92 * .. External Subroutines ..
93 EXTERNAL DGEMM, DLACPY, DLARNV, DLASET, DORGLQ, DORMLQ
94 * ..
95 * .. Local Arrays ..
96 INTEGER ISEED( 4 )
97 * ..
98 * .. Intrinsic Functions ..
99 INTRINSIC DBLE, MAX
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 *
114 * Copy the first k rows of the factorization to the array Q
115 *
116 CALL DLASET( 'Full', N, N, ROGUE, ROGUE, Q, LDA )
117 CALL DLACPY( 'Upper', K, N-1, AF( 1, 2 ), LDA, Q( 1, 2 ), LDA )
118 *
119 * Generate the n-by-n matrix Q
120 *
121 SRNAMT = 'DORGLQ'
122 CALL DORGLQ( N, N, K, Q, LDA, TAU, WORK, LWORK, INFO )
123 *
124 DO 30 ISIDE = 1, 2
125 IF( ISIDE.EQ.1 ) THEN
126 SIDE = 'L'
127 MC = N
128 NC = M
129 ELSE
130 SIDE = 'R'
131 MC = M
132 NC = N
133 END IF
134 *
135 * Generate MC by NC matrix C
136 *
137 DO 10 J = 1, NC
138 CALL DLARNV( 2, ISEED, MC, C( 1, J ) )
139 10 CONTINUE
140 CNORM = DLANGE( '1', MC, NC, C, LDA, RWORK )
141 IF( CNORM.EQ.0.0D0 )
142 $ CNORM = ONE
143 *
144 DO 20 ITRANS = 1, 2
145 IF( ITRANS.EQ.1 ) THEN
146 TRANS = 'N'
147 ELSE
148 TRANS = 'T'
149 END IF
150 *
151 * Copy C
152 *
153 CALL DLACPY( 'Full', MC, NC, C, LDA, CC, LDA )
154 *
155 * Apply Q or Q' to C
156 *
157 SRNAMT = 'DORMLQ'
158 CALL DORMLQ( SIDE, TRANS, MC, NC, K, AF, LDA, TAU, CC, LDA,
159 $ WORK, LWORK, INFO )
160 *
161 * Form explicit product and subtract
162 *
163 IF( LSAME( SIDE, 'L' ) ) THEN
164 CALL DGEMM( TRANS, 'No transpose', MC, NC, MC, -ONE, Q,
165 $ LDA, C, LDA, ONE, CC, LDA )
166 ELSE
167 CALL DGEMM( 'No transpose', TRANS, MC, NC, NC, -ONE, C,
168 $ LDA, Q, LDA, ONE, CC, LDA )
169 END IF
170 *
171 * Compute error in the difference
172 *
173 RESID = DLANGE( '1', MC, NC, CC, LDA, RWORK )
174 RESULT( ( ISIDE-1 )*2+ITRANS ) = RESID /
175 $ ( DBLE( MAX( 1, N ) )*CNORM*EPS )
176 *
177 20 CONTINUE
178 30 CONTINUE
179 *
180 RETURN
181 *
182 * End of DLQT03
183 *
184 END