LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
sqlt02.f
Go to the documentation of this file.
1 *> \brief \b SQLT02
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 SQLT02( 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 A( LDA, * ), AF( LDA, * ), L( LDA, * ),
19 * $ Q( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
20 * $ WORK( LWORK )
21 * ..
22 *
23 *
24 *> \par Purpose:
25 * =============
26 *>
27 *> \verbatim
28 *>
29 *> SQLT02 tests SORGQL, which generates an m-by-n matrix Q with
30 *> orthonornmal columns that is defined as the product of k elementary
31 *> reflectors.
32 *>
33 *> Given the QL factorization of an m-by-n matrix A, SQLT02 generates
34 *> the orthogonal matrix Q defined by the factorization of the last k
35 *> columns of A; it compares L(m-n+1:m,n-k+1:n) with
36 *> Q(1:m,m-n+1:m)'*A(1:m,n-k+1:n), and checks that the columns of Q are
37 *> orthonormal.
38 *> \endverbatim
39 *
40 * Arguments:
41 * ==========
42 *
43 *> \param[in] M
44 *> \verbatim
45 *> M is INTEGER
46 *> The number of rows of the matrix Q to be generated. M >= 0.
47 *> \endverbatim
48 *>
49 *> \param[in] N
50 *> \verbatim
51 *> N is INTEGER
52 *> The number of columns of the matrix Q to be generated.
53 *> M >= N >= 0.
54 *> \endverbatim
55 *>
56 *> \param[in] K
57 *> \verbatim
58 *> K is INTEGER
59 *> The number of elementary reflectors whose product defines the
60 *> matrix Q. N >= K >= 0.
61 *> \endverbatim
62 *>
63 *> \param[in] A
64 *> \verbatim
65 *> A is REAL array, dimension (LDA,N)
66 *> The m-by-n matrix A which was factorized by SQLT01.
67 *> \endverbatim
68 *>
69 *> \param[in] AF
70 *> \verbatim
71 *> AF is REAL array, dimension (LDA,N)
72 *> Details of the QL factorization of A, as returned by SGEQLF.
73 *> See SGEQLF for further details.
74 *> \endverbatim
75 *>
76 *> \param[out] Q
77 *> \verbatim
78 *> Q is REAL array, dimension (LDA,N)
79 *> \endverbatim
80 *>
81 *> \param[out] L
82 *> \verbatim
83 *> L is REAL array, dimension (LDA,N)
84 *> \endverbatim
85 *>
86 *> \param[in] LDA
87 *> \verbatim
88 *> LDA is INTEGER
89 *> The leading dimension of the arrays A, AF, Q and L. LDA >= M.
90 *> \endverbatim
91 *>
92 *> \param[in] TAU
93 *> \verbatim
94 *> TAU is REAL array, dimension (N)
95 *> The scalar factors of the elementary reflectors corresponding
96 *> to the QL factorization in AF.
97 *> \endverbatim
98 *>
99 *> \param[out] WORK
100 *> \verbatim
101 *> WORK is REAL array, dimension (LWORK)
102 *> \endverbatim
103 *>
104 *> \param[in] LWORK
105 *> \verbatim
106 *> LWORK is INTEGER
107 *> The dimension of the array WORK.
108 *> \endverbatim
109 *>
110 *> \param[out] RWORK
111 *> \verbatim
112 *> RWORK is REAL array, dimension (M)
113 *> \endverbatim
114 *>
115 *> \param[out] RESULT
116 *> \verbatim
117 *> RESULT is REAL array, dimension (2)
118 *> The test ratios:
119 *> RESULT(1) = norm( L - Q'*A ) / ( M * norm(A) * EPS )
120 *> RESULT(2) = norm( I - Q'*Q ) / ( M * EPS )
121 *> \endverbatim
122 *
123 * Authors:
124 * ========
125 *
126 *> \author Univ. of Tennessee
127 *> \author Univ. of California Berkeley
128 *> \author Univ. of Colorado Denver
129 *> \author NAG Ltd.
130 *
131 *> \date November 2011
132 *
133 *> \ingroup single_lin
134 *
135 * =====================================================================
136  SUBROUTINE sqlt02( M, N, K, A, AF, Q, L, LDA, TAU, WORK, LWORK,
137  $ rwork, result )
138 *
139 * -- LAPACK test routine (version 3.4.0) --
140 * -- LAPACK is a software package provided by Univ. of Tennessee, --
141 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
142 * November 2011
143 *
144 * .. Scalar Arguments ..
145  INTEGER k, lda, lwork, m, n
146 * ..
147 * .. Array Arguments ..
148  REAL a( lda, * ), af( lda, * ), l( lda, * ),
149  $ q( lda, * ), result( * ), rwork( * ), tau( * ),
150  $ work( lwork )
151 * ..
152 *
153 * =====================================================================
154 *
155 * .. Parameters ..
156  REAL zero, one
157  parameter( zero = 0.0e+0, one = 1.0e+0 )
158  REAL rogue
159  parameter( rogue = -1.0e+10 )
160 * ..
161 * .. Local Scalars ..
162  INTEGER info
163  REAL anorm, eps, resid
164 * ..
165 * .. External Functions ..
166  REAL slamch, slange, slansy
167  EXTERNAL slamch, slange, slansy
168 * ..
169 * .. External Subroutines ..
170  EXTERNAL sgemm, slacpy, slaset, sorgql, ssyrk
171 * ..
172 * .. Intrinsic Functions ..
173  INTRINSIC max, real
174 * ..
175 * .. Scalars in Common ..
176  CHARACTER*32 srnamt
177 * ..
178 * .. Common blocks ..
179  common / srnamc / srnamt
180 * ..
181 * .. Executable Statements ..
182 *
183 * Quick return if possible
184 *
185  IF( m.EQ.0 .OR. n.EQ.0 .OR. k.EQ.0 ) THEN
186  result( 1 ) = zero
187  result( 2 ) = zero
188  return
189  END IF
190 *
191  eps = slamch( 'Epsilon' )
192 *
193 * Copy the last k columns of the factorization to the array Q
194 *
195  CALL slaset( 'Full', m, n, rogue, rogue, q, lda )
196  IF( k.LT.m )
197  $ CALL slacpy( 'Full', m-k, k, af( 1, n-k+1 ), lda,
198  $ q( 1, n-k+1 ), lda )
199  IF( k.GT.1 )
200  $ CALL slacpy( 'Upper', k-1, k-1, af( m-k+1, n-k+2 ), lda,
201  $ q( m-k+1, n-k+2 ), lda )
202 *
203 * Generate the last n columns of the matrix Q
204 *
205  srnamt = 'SORGQL'
206  CALL sorgql( m, n, k, q, lda, tau( n-k+1 ), work, lwork, info )
207 *
208 * Copy L(m-n+1:m,n-k+1:n)
209 *
210  CALL slaset( 'Full', n, k, zero, zero, l( m-n+1, n-k+1 ), lda )
211  CALL slacpy( 'Lower', k, k, af( m-k+1, n-k+1 ), lda,
212  $ l( m-k+1, n-k+1 ), lda )
213 *
214 * Compute L(m-n+1:m,n-k+1:n) - Q(1:m,m-n+1:m)' * A(1:m,n-k+1:n)
215 *
216  CALL sgemm( 'Transpose', 'No transpose', n, k, m, -one, q, lda,
217  $ a( 1, n-k+1 ), lda, one, l( m-n+1, n-k+1 ), lda )
218 *
219 * Compute norm( L - Q'*A ) / ( M * norm(A) * EPS ) .
220 *
221  anorm = slange( '1', m, k, a( 1, n-k+1 ), lda, rwork )
222  resid = slange( '1', n, k, l( m-n+1, n-k+1 ), lda, rwork )
223  IF( anorm.GT.zero ) THEN
224  result( 1 ) = ( ( resid / REAL( MAX( 1, M ) ) ) / anorm ) / eps
225  ELSE
226  result( 1 ) = zero
227  END IF
228 *
229 * Compute I - Q'*Q
230 *
231  CALL slaset( 'Full', n, n, zero, one, l, lda )
232  CALL ssyrk( 'Upper', 'Transpose', n, m, -one, q, lda, one, l,
233  $ lda )
234 *
235 * Compute norm( I - Q'*Q ) / ( M * EPS ) .
236 *
237  resid = slansy( '1', 'Upper', n, l, lda, rwork )
238 *
239  result( 2 ) = ( resid / REAL( MAX( 1, M ) ) ) / eps
240 *
241  return
242 *
243 * End of SQLT02
244 *
245  END