LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
clqt02.f
Go to the documentation of this file.
1 *> \brief \b CLQT02
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 CLQT02( M, N, K, A, AF, Q, L, LDA, TAU, WORK, LWORK,
12 * RWORK, RESULT )
13 *
14 * .. Scalar Arguments ..
15 * INTEGER K, LDA, LWORK, M, N
16 * ..
17 * .. Array Arguments ..
18 * REAL RESULT( * ), RWORK( * )
19 * COMPLEX A( LDA, * ), AF( LDA, * ), L( LDA, * ),
20 * $ Q( LDA, * ), TAU( * ), WORK( LWORK )
21 * ..
22 *
23 *
24 *> \par Purpose:
25 * =============
26 *>
27 *> \verbatim
28 *>
29 *> CLQT02 tests CUNGLQ, which generates an m-by-n matrix Q with
30 *> orthonornmal rows that is defined as the product of k elementary
31 *> reflectors.
32 *>
33 *> Given the LQ factorization of an m-by-n matrix A, CLQT02 generates
34 *> the orthogonal matrix Q defined by the factorization of the first k
35 *> rows of A; it compares L(1:k,1:m) with A(1:k,1:n)*Q(1:m,1:n)', and
36 *> checks that the rows of Q are orthonormal.
37 *> \endverbatim
38 *
39 * Arguments:
40 * ==========
41 *
42 *> \param[in] M
43 *> \verbatim
44 *> M is INTEGER
45 *> The number of rows of the matrix Q to be generated. M >= 0.
46 *> \endverbatim
47 *>
48 *> \param[in] N
49 *> \verbatim
50 *> N is INTEGER
51 *> The number of columns of the matrix Q to be generated.
52 *> N >= M >= 0.
53 *> \endverbatim
54 *>
55 *> \param[in] K
56 *> \verbatim
57 *> K is INTEGER
58 *> The number of elementary reflectors whose product defines the
59 *> matrix Q. M >= K >= 0.
60 *> \endverbatim
61 *>
62 *> \param[in] A
63 *> \verbatim
64 *> A is COMPLEX array, dimension (LDA,N)
65 *> The m-by-n matrix A which was factorized by CLQT01.
66 *> \endverbatim
67 *>
68 *> \param[in] AF
69 *> \verbatim
70 *> AF is COMPLEX array, dimension (LDA,N)
71 *> Details of the LQ factorization of A, as returned by CGELQF.
72 *> See CGELQF for further details.
73 *> \endverbatim
74 *>
75 *> \param[out] Q
76 *> \verbatim
77 *> Q is COMPLEX array, dimension (LDA,N)
78 *> \endverbatim
79 *>
80 *> \param[out] L
81 *> \verbatim
82 *> L is COMPLEX array, dimension (LDA,M)
83 *> \endverbatim
84 *>
85 *> \param[in] LDA
86 *> \verbatim
87 *> LDA is INTEGER
88 *> The leading dimension of the arrays A, AF, Q and L. LDA >= N.
89 *> \endverbatim
90 *>
91 *> \param[in] TAU
92 *> \verbatim
93 *> TAU is COMPLEX array, dimension (M)
94 *> The scalar factors of the elementary reflectors corresponding
95 *> to the LQ factorization in AF.
96 *> \endverbatim
97 *>
98 *> \param[out] WORK
99 *> \verbatim
100 *> WORK is COMPLEX array, dimension (LWORK)
101 *> \endverbatim
102 *>
103 *> \param[in] LWORK
104 *> \verbatim
105 *> LWORK is INTEGER
106 *> The dimension of the array WORK.
107 *> \endverbatim
108 *>
109 *> \param[out] RWORK
110 *> \verbatim
111 *> RWORK is REAL array, dimension (M)
112 *> \endverbatim
113 *>
114 *> \param[out] RESULT
115 *> \verbatim
116 *> RESULT is REAL array, dimension (2)
117 *> The test ratios:
118 *> RESULT(1) = norm( L - A*Q' ) / ( N * norm(A) * EPS )
119 *> RESULT(2) = norm( I - Q*Q' ) / ( N * EPS )
120 *> \endverbatim
121 *
122 * Authors:
123 * ========
124 *
125 *> \author Univ. of Tennessee
126 *> \author Univ. of California Berkeley
127 *> \author Univ. of Colorado Denver
128 *> \author NAG Ltd.
129 *
130 *> \date November 2011
131 *
132 *> \ingroup complex_lin
133 *
134 * =====================================================================
135  SUBROUTINE clqt02( M, N, K, A, AF, Q, L, LDA, TAU, WORK, LWORK,
136  $ rwork, result )
137 *
138 * -- LAPACK test routine (version 3.4.0) --
139 * -- LAPACK is a software package provided by Univ. of Tennessee, --
140 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
141 * November 2011
142 *
143 * .. Scalar Arguments ..
144  INTEGER K, LDA, LWORK, M, N
145 * ..
146 * .. Array Arguments ..
147  REAL RESULT( * ), RWORK( * )
148  COMPLEX A( lda, * ), AF( lda, * ), L( lda, * ),
149  $ q( lda, * ), tau( * ), work( lwork )
150 * ..
151 *
152 * =====================================================================
153 *
154 * .. Parameters ..
155  REAL ZERO, ONE
156  parameter ( zero = 0.0e+0, one = 1.0e+0 )
157  COMPLEX ROGUE
158  parameter ( rogue = ( -1.0e+10, -1.0e+10 ) )
159 * ..
160 * .. Local Scalars ..
161  INTEGER INFO
162  REAL ANORM, EPS, RESID
163 * ..
164 * .. External Functions ..
165  REAL CLANGE, CLANSY, SLAMCH
166  EXTERNAL clange, clansy, slamch
167 * ..
168 * .. External Subroutines ..
169  EXTERNAL cgemm, cherk, clacpy, claset, cunglq
170 * ..
171 * .. Intrinsic Functions ..
172  INTRINSIC cmplx, max, real
173 * ..
174 * .. Scalars in Common ..
175  CHARACTER*32 SRNAMT
176 * ..
177 * .. Common blocks ..
178  COMMON / srnamc / srnamt
179 * ..
180 * .. Executable Statements ..
181 *
182  eps = slamch( 'Epsilon' )
183 *
184 * Copy the first k rows of the factorization to the array Q
185 *
186  CALL claset( 'Full', m, n, rogue, rogue, q, lda )
187  CALL clacpy( 'Upper', k, n-1, af( 1, 2 ), lda, q( 1, 2 ), lda )
188 *
189 * Generate the first n columns of the matrix Q
190 *
191  srnamt = 'CUNGLQ'
192  CALL cunglq( m, n, k, q, lda, tau, work, lwork, info )
193 *
194 * Copy L(1:k,1:m)
195 *
196  CALL claset( 'Full', k, m, cmplx( zero ), cmplx( zero ), l, lda )
197  CALL clacpy( 'Lower', k, m, af, lda, l, lda )
198 *
199 * Compute L(1:k,1:m) - A(1:k,1:n) * Q(1:m,1:n)'
200 *
201  CALL cgemm( 'No transpose', 'Conjugate transpose', k, m, n,
202  $ cmplx( -one ), a, lda, q, lda, cmplx( one ), l, lda )
203 *
204 * Compute norm( L - A*Q' ) / ( N * norm(A) * EPS ) .
205 *
206  anorm = clange( '1', k, n, a, lda, rwork )
207  resid = clange( '1', k, m, l, lda, rwork )
208  IF( anorm.GT.zero ) THEN
209  result( 1 ) = ( ( resid / REAL( MAX( 1, N ) ) ) / anorm ) / eps
210  ELSE
211  result( 1 ) = zero
212  END IF
213 *
214 * Compute I - Q*Q'
215 *
216  CALL claset( 'Full', m, m, cmplx( zero ), cmplx( one ), l, lda )
217  CALL cherk( 'Upper', 'No transpose', m, n, -one, q, lda, one, l,
218  $ lda )
219 *
220 * Compute norm( I - Q*Q' ) / ( N * EPS ) .
221 *
222  resid = clansy( '1', 'Upper', m, l, lda, rwork )
223 *
224  result( 2 ) = ( resid / REAL( MAX( 1, N ) ) ) / eps
225 *
226  RETURN
227 *
228 * End of CLQT02
229 *
230  END
subroutine cherk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
CHERK
Definition: cherk.f:175
subroutine claset(UPLO, M, N, ALPHA, BETA, A, LDA)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values...
Definition: claset.f:108
subroutine clqt02(M, N, K, A, AF, Q, L, LDA, TAU, WORK, LWORK, RWORK, RESULT)
CLQT02
Definition: clqt02.f:137
subroutine cunglq(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
CUNGLQ
Definition: cunglq.f:129
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
Definition: clacpy.f:105
subroutine cgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
CGEMM
Definition: cgemm.f:189