OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
drqt02.f
Go to the documentation of this file.
1*> \brief \b DRQT02
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 DRQT02( M, N, K, A, AF, Q, R, LDA, TAU, WORK, LWORK,
12* RWORK, RESULT )
13*
14* .. Scalar Arguments ..
15* INTEGER K, LDA, LWORK, M, N
16* ..
17* .. Array Arguments ..
18* DOUBLE PRECISION A( LDA, * ), AF( LDA, * ), Q( LDA, * ),
19* $ R( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
20* $ WORK( LWORK )
21* ..
22*
23*
24*> \par Purpose:
25* =============
26*>
27*> \verbatim
28*>
29*> DRQT02 tests DORGRQ, 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 RQ factorization of an m-by-n matrix A, DRQT02 generates
34*> the orthogonal matrix Q defined by the factorization of the last k
35*> rows of A; it compares R(m-k+1:m,n-m+1:n) with
36*> A(m-k+1:m,1:n)*Q(n-m+1:n,1:n)', and checks that the rows 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*> N >= M >= 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. M >= K >= 0.
61*> \endverbatim
62*>
63*> \param[in] A
64*> \verbatim
65*> A is DOUBLE PRECISION array, dimension (LDA,N)
66*> The m-by-n matrix A which was factorized by DRQT01.
67*> \endverbatim
68*>
69*> \param[in] AF
70*> \verbatim
71*> AF is DOUBLE PRECISION array, dimension (LDA,N)
72*> Details of the RQ factorization of A, as returned by DGERQF.
73*> See DGERQF for further details.
74*> \endverbatim
75*>
76*> \param[out] Q
77*> \verbatim
78*> Q is DOUBLE PRECISION array, dimension (LDA,N)
79*> \endverbatim
80*>
81*> \param[out] R
82*> \verbatim
83*> R is DOUBLE PRECISION array, dimension (LDA,M)
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 >= N.
90*> \endverbatim
91*>
92*> \param[in] TAU
93*> \verbatim
94*> TAU is DOUBLE PRECISION array, dimension (M)
95*> The scalar factors of the elementary reflectors corresponding
96*> to the RQ factorization in AF.
97*> \endverbatim
98*>
99*> \param[out] WORK
100*> \verbatim
101*> WORK is DOUBLE PRECISION 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 DOUBLE PRECISION array, dimension (M)
113*> \endverbatim
114*>
115*> \param[out] RESULT
116*> \verbatim
117*> RESULT is DOUBLE PRECISION array, dimension (2)
118*> The test ratios:
119*> RESULT(1) = norm( R - A*Q' ) / ( N * norm(A) * EPS )
120*> RESULT(2) = norm( I - Q*Q' ) / ( N * 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*> \ingroup double_lin
132*
133* =====================================================================
134 SUBROUTINE drqt02( M, N, K, A, AF, Q, R, LDA, TAU, WORK, LWORK,
135 $ RWORK, RESULT )
136*
137* -- LAPACK test routine --
138* -- LAPACK is a software package provided by Univ. of Tennessee, --
139* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
140*
141* .. Scalar Arguments ..
142 INTEGER K, LDA, LWORK, M, N
143* ..
144* .. Array Arguments ..
145 DOUBLE PRECISION A( LDA, * ), AF( LDA, * ), Q( LDA, * ),
146 $ r( lda, * ), result( * ), rwork( * ), tau( * ),
147 $ work( lwork )
148* ..
149*
150* =====================================================================
151*
152* .. Parameters ..
153 DOUBLE PRECISION ZERO, ONE
154 parameter( zero = 0.0d+0, one = 1.0d+0 )
155 DOUBLE PRECISION ROGUE
156 parameter( rogue = -1.0d+10 )
157* ..
158* .. Local Scalars ..
159 INTEGER INFO
160 DOUBLE PRECISION ANORM, EPS, RESID
161* ..
162* .. External Functions ..
163 DOUBLE PRECISION DLAMCH, DLANGE, DLANSY
164 EXTERNAL dlamch, dlange, dlansy
165* ..
166* .. External Subroutines ..
167 EXTERNAL dgemm, dlacpy, dlaset, dorgrq, dsyrk
168* ..
169* .. Intrinsic Functions ..
170 INTRINSIC dble, max
171* ..
172* .. Scalars in Common ..
173 CHARACTER*32 SRNAMT
174* ..
175* .. Common blocks ..
176 COMMON / srnamc / srnamt
177* ..
178* .. Executable Statements ..
179*
180* Quick return if possible
181*
182 IF( m.EQ.0 .OR. n.EQ.0 .OR. k.EQ.0 ) THEN
183 result( 1 ) = zero
184 result( 2 ) = zero
185 RETURN
186 END IF
187*
188 eps = dlamch( 'epsilon' )
189*
190* Copy the last k rows of the factorization to the array Q
191*
192 CALL DLASET( 'full', M, N, ROGUE, ROGUE, Q, LDA )
193.LT. IF( KN )
194 $ CALL DLACPY( 'full', K, N-K, AF( M-K+1, 1 ), LDA,
195 $ Q( M-K+1, 1 ), LDA )
196.GT. IF( K1 )
197 $ CALL DLACPY( 'lower', K-1, K-1, AF( M-K+2, N-K+1 ), LDA,
198 $ Q( M-K+2, N-K+1 ), LDA )
199*
200* Generate the last n rows of the matrix Q
201*
202 SRNAMT = 'dorgrq'
203 CALL DORGRQ( M, N, K, Q, LDA, TAU( M-K+1 ), WORK, LWORK, INFO )
204*
205* Copy R(m-k+1:m,n-m+1:n)
206*
207 CALL DLASET( 'full', K, M, ZERO, ZERO, R( M-K+1, N-M+1 ), LDA )
208 CALL DLACPY( 'upper', K, K, AF( M-K+1, N-K+1 ), LDA,
209 $ R( M-K+1, N-K+1 ), LDA )
210*
211* Compute R(m-k+1:m,n-m+1:n) - A(m-k+1:m,1:n) * Q(n-m+1:n,1:n)'
212*
213 CALL DGEMM( 'no transpose', 'transpose', K, M, N, -ONE,
214 $ A( M-K+1, 1 ), LDA, Q, LDA, ONE, R( M-K+1, N-M+1 ),
215 $ LDA )
216*
217* Compute norm( R - A*Q' ) / ( N * norm(A) * EPS ) .
218*
219 ANORM = DLANGE( '1', K, N, A( M-K+1, 1 ), LDA, RWORK )
220 RESID = DLANGE( '1', K, M, R( M-K+1, N-M+1 ), LDA, RWORK )
221.GT. IF( ANORMZERO ) THEN
222 RESULT( 1 ) = ( ( RESID / DBLE( MAX( 1, N ) ) ) / ANORM ) / EPS
223 ELSE
224 RESULT( 1 ) = ZERO
225 END IF
226*
227* Compute I - Q*Q'
228*
229 CALL DLASET( 'full', M, M, ZERO, ONE, R, LDA )
230 CALL DSYRK( 'upper', 'no transpose', M, N, -ONE, Q, LDA, ONE, R,
231 $ LDA )
232*
233* Compute norm( I - Q*Q' ) / ( N * EPS ) .
234*
235 RESID = DLANSY( '1', 'upper', M, R, LDA, RWORK )
236*
237 RESULT( 2 ) = ( RESID / DBLE( MAX( 1, N ) ) ) / EPS
238*
239 RETURN
240*
241* End of DRQT02
242*
243 END
subroutine dlacpy(uplo, m, n, a, lda, b, ldb)
DLACPY copies all or part of one two-dimensional array to another.
Definition dlacpy.f:103
subroutine dlaset(uplo, m, n, alpha, beta, a, lda)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition dlaset.f:110
subroutine dorgrq(m, n, k, a, lda, tau, work, lwork, info)
DORGRQ
Definition dorgrq.f:128
subroutine dsyrk(uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
DSYRK
Definition dsyrk.f:169
subroutine dgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
DGEMM
Definition dgemm.f:187
subroutine drqt02(m, n, k, a, af, q, r, lda, tau, work, lwork, rwork, result)
DRQT02
Definition drqt02.f:136
#define max(a, b)
Definition macros.h:21