1 SUBROUTINE ZLQT02( M, N, K, A, AF, Q, L, 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 A( LDA, * ), AF( LDA, * ), L( LDA, * ),
14 $ Q( LDA, * ), TAU( * ), WORK( LWORK )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * ZLQT02 tests ZUNGLQ, which generates an m-by-n matrix Q with
21 * orthonornmal rows that is defined as the product of k elementary
22 * reflectors.
23 *
24 * Given the LQ factorization of an m-by-n matrix A, ZLQT02 generates
25 * the orthogonal matrix Q defined by the factorization of the first k
26 * rows of A; it compares L(1:k,1:m) with A(1:k,1:n)*Q(1:m,1:n)', and
27 * checks that the rows of Q are orthonormal.
28 *
29 * Arguments
30 * =========
31 *
32 * M (input) INTEGER
33 * The number of rows of the matrix Q to be generated. M >= 0.
34 *
35 * N (input) INTEGER
36 * The number of columns of the matrix Q to be generated.
37 * N >= M >= 0.
38 *
39 * K (input) INTEGER
40 * The number of elementary reflectors whose product defines the
41 * matrix Q. M >= K >= 0.
42 *
43 * A (input) COMPLEX*16 array, dimension (LDA,N)
44 * The m-by-n matrix A which was factorized by ZLQT01.
45 *
46 * AF (input) COMPLEX*16 array, dimension (LDA,N)
47 * Details of the LQ factorization of A, as returned by ZGELQF.
48 * See ZGELQF for further details.
49 *
50 * Q (workspace) COMPLEX*16 array, dimension (LDA,N)
51 *
52 * L (workspace) COMPLEX*16 array, dimension (LDA,M)
53 *
54 * LDA (input) INTEGER
55 * The leading dimension of the arrays A, AF, Q and L. LDA >= N.
56 *
57 * TAU (input) COMPLEX*16 array, dimension (M)
58 * The scalar factors of the elementary reflectors corresponding
59 * to the LQ factorization in AF.
60 *
61 * WORK (workspace) COMPLEX*16 array, dimension (LWORK)
62 *
63 * LWORK (input) INTEGER
64 * The dimension of the array WORK.
65 *
66 * RWORK (workspace) DOUBLE PRECISION array, dimension (M)
67 *
68 * RESULT (output) DOUBLE PRECISION array, dimension (2)
69 * The test ratios:
70 * RESULT(1) = norm( L - A*Q' ) / ( N * norm(A) * EPS )
71 * RESULT(2) = norm( I - Q*Q' ) / ( N * EPS )
72 *
73 * =====================================================================
74 *
75 * .. Parameters ..
76 DOUBLE PRECISION ZERO, ONE
77 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
78 COMPLEX*16 ROGUE
79 PARAMETER ( ROGUE = ( -1.0D+10, -1.0D+10 ) )
80 * ..
81 * .. Local Scalars ..
82 INTEGER INFO
83 DOUBLE PRECISION ANORM, EPS, RESID
84 * ..
85 * .. External Functions ..
86 DOUBLE PRECISION DLAMCH, ZLANGE, ZLANSY
87 EXTERNAL DLAMCH, ZLANGE, ZLANSY
88 * ..
89 * .. External Subroutines ..
90 EXTERNAL ZGEMM, ZHERK, ZLACPY, ZLASET, ZUNGLQ
91 * ..
92 * .. Intrinsic Functions ..
93 INTRINSIC DBLE, DCMPLX, MAX
94 * ..
95 * .. Scalars in Common ..
96 CHARACTER*32 SRNAMT
97 * ..
98 * .. Common blocks ..
99 COMMON / SRNAMC / SRNAMT
100 * ..
101 * .. Executable Statements ..
102 *
103 EPS = DLAMCH( 'Epsilon' )
104 *
105 * Copy the first k rows of the factorization to the array Q
106 *
107 CALL ZLASET( 'Full', M, N, ROGUE, ROGUE, Q, LDA )
108 CALL ZLACPY( 'Upper', K, N-1, AF( 1, 2 ), LDA, Q( 1, 2 ), LDA )
109 *
110 * Generate the first n columns of the matrix Q
111 *
112 SRNAMT = 'ZUNGLQ'
113 CALL ZUNGLQ( M, N, K, Q, LDA, TAU, WORK, LWORK, INFO )
114 *
115 * Copy L(1:k,1:m)
116 *
117 CALL ZLASET( 'Full', K, M, DCMPLX( ZERO ), DCMPLX( ZERO ), L,
118 $ LDA )
119 CALL ZLACPY( 'Lower', K, M, AF, LDA, L, LDA )
120 *
121 * Compute L(1:k,1:m) - A(1:k,1:n) * Q(1:m,1:n)'
122 *
123 CALL ZGEMM( 'No transpose', 'Conjugate transpose', K, M, N,
124 $ DCMPLX( -ONE ), A, LDA, Q, LDA, DCMPLX( ONE ), L,
125 $ LDA )
126 *
127 * Compute norm( L - A*Q' ) / ( N * norm(A) * EPS ) .
128 *
129 ANORM = ZLANGE( '1', K, N, A, LDA, RWORK )
130 RESID = ZLANGE( '1', K, M, L, LDA, RWORK )
131 IF( ANORM.GT.ZERO ) THEN
132 RESULT( 1 ) = ( ( RESID / DBLE( MAX( 1, N ) ) ) / ANORM ) / EPS
133 ELSE
134 RESULT( 1 ) = ZERO
135 END IF
136 *
137 * Compute I - Q*Q'
138 *
139 CALL ZLASET( 'Full', M, M, DCMPLX( ZERO ), DCMPLX( ONE ), L, LDA )
140 CALL ZHERK( 'Upper', 'No transpose', M, N, -ONE, Q, LDA, ONE, L,
141 $ LDA )
142 *
143 * Compute norm( I - Q*Q' ) / ( N * EPS ) .
144 *
145 RESID = ZLANSY( '1', 'Upper', M, L, LDA, RWORK )
146 *
147 RESULT( 2 ) = ( RESID / DBLE( MAX( 1, N ) ) ) / EPS
148 *
149 RETURN
150 *
151 * End of ZLQT02
152 *
153 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 A( LDA, * ), AF( LDA, * ), L( LDA, * ),
14 $ Q( LDA, * ), TAU( * ), WORK( LWORK )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * ZLQT02 tests ZUNGLQ, which generates an m-by-n matrix Q with
21 * orthonornmal rows that is defined as the product of k elementary
22 * reflectors.
23 *
24 * Given the LQ factorization of an m-by-n matrix A, ZLQT02 generates
25 * the orthogonal matrix Q defined by the factorization of the first k
26 * rows of A; it compares L(1:k,1:m) with A(1:k,1:n)*Q(1:m,1:n)', and
27 * checks that the rows of Q are orthonormal.
28 *
29 * Arguments
30 * =========
31 *
32 * M (input) INTEGER
33 * The number of rows of the matrix Q to be generated. M >= 0.
34 *
35 * N (input) INTEGER
36 * The number of columns of the matrix Q to be generated.
37 * N >= M >= 0.
38 *
39 * K (input) INTEGER
40 * The number of elementary reflectors whose product defines the
41 * matrix Q. M >= K >= 0.
42 *
43 * A (input) COMPLEX*16 array, dimension (LDA,N)
44 * The m-by-n matrix A which was factorized by ZLQT01.
45 *
46 * AF (input) COMPLEX*16 array, dimension (LDA,N)
47 * Details of the LQ factorization of A, as returned by ZGELQF.
48 * See ZGELQF for further details.
49 *
50 * Q (workspace) COMPLEX*16 array, dimension (LDA,N)
51 *
52 * L (workspace) COMPLEX*16 array, dimension (LDA,M)
53 *
54 * LDA (input) INTEGER
55 * The leading dimension of the arrays A, AF, Q and L. LDA >= N.
56 *
57 * TAU (input) COMPLEX*16 array, dimension (M)
58 * The scalar factors of the elementary reflectors corresponding
59 * to the LQ factorization in AF.
60 *
61 * WORK (workspace) COMPLEX*16 array, dimension (LWORK)
62 *
63 * LWORK (input) INTEGER
64 * The dimension of the array WORK.
65 *
66 * RWORK (workspace) DOUBLE PRECISION array, dimension (M)
67 *
68 * RESULT (output) DOUBLE PRECISION array, dimension (2)
69 * The test ratios:
70 * RESULT(1) = norm( L - A*Q' ) / ( N * norm(A) * EPS )
71 * RESULT(2) = norm( I - Q*Q' ) / ( N * EPS )
72 *
73 * =====================================================================
74 *
75 * .. Parameters ..
76 DOUBLE PRECISION ZERO, ONE
77 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
78 COMPLEX*16 ROGUE
79 PARAMETER ( ROGUE = ( -1.0D+10, -1.0D+10 ) )
80 * ..
81 * .. Local Scalars ..
82 INTEGER INFO
83 DOUBLE PRECISION ANORM, EPS, RESID
84 * ..
85 * .. External Functions ..
86 DOUBLE PRECISION DLAMCH, ZLANGE, ZLANSY
87 EXTERNAL DLAMCH, ZLANGE, ZLANSY
88 * ..
89 * .. External Subroutines ..
90 EXTERNAL ZGEMM, ZHERK, ZLACPY, ZLASET, ZUNGLQ
91 * ..
92 * .. Intrinsic Functions ..
93 INTRINSIC DBLE, DCMPLX, MAX
94 * ..
95 * .. Scalars in Common ..
96 CHARACTER*32 SRNAMT
97 * ..
98 * .. Common blocks ..
99 COMMON / SRNAMC / SRNAMT
100 * ..
101 * .. Executable Statements ..
102 *
103 EPS = DLAMCH( 'Epsilon' )
104 *
105 * Copy the first k rows of the factorization to the array Q
106 *
107 CALL ZLASET( 'Full', M, N, ROGUE, ROGUE, Q, LDA )
108 CALL ZLACPY( 'Upper', K, N-1, AF( 1, 2 ), LDA, Q( 1, 2 ), LDA )
109 *
110 * Generate the first n columns of the matrix Q
111 *
112 SRNAMT = 'ZUNGLQ'
113 CALL ZUNGLQ( M, N, K, Q, LDA, TAU, WORK, LWORK, INFO )
114 *
115 * Copy L(1:k,1:m)
116 *
117 CALL ZLASET( 'Full', K, M, DCMPLX( ZERO ), DCMPLX( ZERO ), L,
118 $ LDA )
119 CALL ZLACPY( 'Lower', K, M, AF, LDA, L, LDA )
120 *
121 * Compute L(1:k,1:m) - A(1:k,1:n) * Q(1:m,1:n)'
122 *
123 CALL ZGEMM( 'No transpose', 'Conjugate transpose', K, M, N,
124 $ DCMPLX( -ONE ), A, LDA, Q, LDA, DCMPLX( ONE ), L,
125 $ LDA )
126 *
127 * Compute norm( L - A*Q' ) / ( N * norm(A) * EPS ) .
128 *
129 ANORM = ZLANGE( '1', K, N, A, LDA, RWORK )
130 RESID = ZLANGE( '1', K, M, L, LDA, RWORK )
131 IF( ANORM.GT.ZERO ) THEN
132 RESULT( 1 ) = ( ( RESID / DBLE( MAX( 1, N ) ) ) / ANORM ) / EPS
133 ELSE
134 RESULT( 1 ) = ZERO
135 END IF
136 *
137 * Compute I - Q*Q'
138 *
139 CALL ZLASET( 'Full', M, M, DCMPLX( ZERO ), DCMPLX( ONE ), L, LDA )
140 CALL ZHERK( 'Upper', 'No transpose', M, N, -ONE, Q, LDA, ONE, L,
141 $ LDA )
142 *
143 * Compute norm( I - Q*Q' ) / ( N * EPS ) .
144 *
145 RESID = ZLANSY( '1', 'Upper', M, L, LDA, RWORK )
146 *
147 RESULT( 2 ) = ( RESID / DBLE( MAX( 1, N ) ) ) / EPS
148 *
149 RETURN
150 *
151 * End of ZLQT02
152 *
153 END