OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
sgqrts.f
Go to the documentation of this file.
1*> \brief \b SGQRTS
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 SGQRTS( N, M, P, A, AF, Q, R, LDA, TAUA, B, BF, Z, T,
12* BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT )
13*
14* .. Scalar Arguments ..
15* INTEGER LDA, LDB, LWORK, M, P, N
16* ..
17* .. Array Arguments ..
18* REAL A( LDA, * ), AF( LDA, * ), R( LDA, * ),
19* $ Q( LDA, * ), B( LDB, * ), BF( LDB, * ),
20* $ T( LDB, * ), Z( LDB, * ), BWK( LDB, * ),
21* $ TAUA( * ), TAUB( * ), RESULT( 4 ),
22* $ RWORK( * ), WORK( LWORK )
23* ..
24*
25*
26*> \par Purpose:
27* =============
28*>
29*> \verbatim
30*>
31*> SGQRTS tests SGGQRF, which computes the GQR factorization of an
32*> N-by-M matrix A and a N-by-P matrix B: A = Q*R and B = Q*T*Z.
33*> \endverbatim
34*
35* Arguments:
36* ==========
37*
38*> \param[in] N
39*> \verbatim
40*> N is INTEGER
41*> The number of rows of the matrices A and B. N >= 0.
42*> \endverbatim
43*>
44*> \param[in] M
45*> \verbatim
46*> M is INTEGER
47*> The number of columns of the matrix A. M >= 0.
48*> \endverbatim
49*>
50*> \param[in] P
51*> \verbatim
52*> P is INTEGER
53*> The number of columns of the matrix B. P >= 0.
54*> \endverbatim
55*>
56*> \param[in] A
57*> \verbatim
58*> A is REAL array, dimension (LDA,M)
59*> The N-by-M matrix A.
60*> \endverbatim
61*>
62*> \param[out] AF
63*> \verbatim
64*> AF is REAL array, dimension (LDA,N)
65*> Details of the GQR factorization of A and B, as returned
66*> by SGGQRF, see SGGQRF for further details.
67*> \endverbatim
68*>
69*> \param[out] Q
70*> \verbatim
71*> Q is REAL array, dimension (LDA,N)
72*> The M-by-M orthogonal matrix Q.
73*> \endverbatim
74*>
75*> \param[out] R
76*> \verbatim
77*> R is REAL array, dimension (LDA,MAX(M,N))
78*> \endverbatim
79*>
80*> \param[in] LDA
81*> \verbatim
82*> LDA is INTEGER
83*> The leading dimension of the arrays A, AF, R and Q.
84*> LDA >= max(M,N).
85*> \endverbatim
86*>
87*> \param[out] TAUA
88*> \verbatim
89*> TAUA is REAL array, dimension (min(M,N))
90*> The scalar factors of the elementary reflectors, as returned
91*> by SGGQRF.
92*> \endverbatim
93*>
94*> \param[in] B
95*> \verbatim
96*> B is REAL array, dimension (LDB,P)
97*> On entry, the N-by-P matrix A.
98*> \endverbatim
99*>
100*> \param[out] BF
101*> \verbatim
102*> BF is REAL array, dimension (LDB,N)
103*> Details of the GQR factorization of A and B, as returned
104*> by SGGQRF, see SGGQRF for further details.
105*> \endverbatim
106*>
107*> \param[out] Z
108*> \verbatim
109*> Z is REAL array, dimension (LDB,P)
110*> The P-by-P orthogonal matrix Z.
111*> \endverbatim
112*>
113*> \param[out] T
114*> \verbatim
115*> T is REAL array, dimension (LDB,max(P,N))
116*> \endverbatim
117*>
118*> \param[out] BWK
119*> \verbatim
120*> BWK is REAL array, dimension (LDB,N)
121*> \endverbatim
122*>
123*> \param[in] LDB
124*> \verbatim
125*> LDB is INTEGER
126*> The leading dimension of the arrays B, BF, Z and T.
127*> LDB >= max(P,N).
128*> \endverbatim
129*>
130*> \param[out] TAUB
131*> \verbatim
132*> TAUB is REAL array, dimension (min(P,N))
133*> The scalar factors of the elementary reflectors, as returned
134*> by SGGRQF.
135*> \endverbatim
136*>
137*> \param[out] WORK
138*> \verbatim
139*> WORK is REAL array, dimension (LWORK)
140*> \endverbatim
141*>
142*> \param[in] LWORK
143*> \verbatim
144*> LWORK is INTEGER
145*> The dimension of the array WORK, LWORK >= max(N,M,P)**2.
146*> \endverbatim
147*>
148*> \param[out] RWORK
149*> \verbatim
150*> RWORK is REAL array, dimension (max(N,M,P))
151*> \endverbatim
152*>
153*> \param[out] RESULT
154*> \verbatim
155*> RESULT is REAL array, dimension (4)
156*> The test ratios:
157*> RESULT(1) = norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP)
158*> RESULT(2) = norm( T*Z - Q'*B ) / (MAX(P,N)*norm(B)*ULP)
159*> RESULT(3) = norm( I - Q'*Q ) / ( M*ULP )
160*> RESULT(4) = norm( I - Z'*Z ) / ( P*ULP )
161*> \endverbatim
162*
163* Authors:
164* ========
165*
166*> \author Univ. of Tennessee
167*> \author Univ. of California Berkeley
168*> \author Univ. of Colorado Denver
169*> \author NAG Ltd.
170*
171*> \ingroup single_eig
172*
173* =====================================================================
174 SUBROUTINE sgqrts( N, M, P, A, AF, Q, R, LDA, TAUA, B, BF, Z, T,
175 $ BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT )
176*
177* -- LAPACK test routine --
178* -- LAPACK is a software package provided by Univ. of Tennessee, --
179* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
180*
181* .. Scalar Arguments ..
182 INTEGER LDA, LDB, LWORK, M, P, N
183* ..
184* .. Array Arguments ..
185 REAL A( LDA, * ), AF( LDA, * ), R( LDA, * ),
186 $ q( lda, * ), b( ldb, * ), bf( ldb, * ),
187 $ t( ldb, * ), z( ldb, * ), bwk( ldb, * ),
188 $ taua( * ), taub( * ), result( 4 ),
189 $ rwork( * ), work( lwork )
190* ..
191*
192* =====================================================================
193*
194* .. Parameters ..
195 REAL ZERO, ONE
196 parameter( zero = 0.0e+0, one = 1.0e+0 )
197 REAL ROGUE
198 parameter( rogue = -1.0e+10 )
199* ..
200* .. Local Scalars ..
201 INTEGER INFO
202 REAL ANORM, BNORM, ULP, UNFL, RESID
203* ..
204* .. External Functions ..
205 REAL SLAMCH, SLANGE, SLANSY
206 EXTERNAL slamch, slange, slansy
207* ..
208* .. External Subroutines ..
209 EXTERNAL sgemm, slacpy, slaset, sorgqr,
210 $ sorgrq, ssyrk
211* ..
212* .. Intrinsic Functions ..
213 INTRINSIC max, min, real
214* ..
215* .. Executable Statements ..
216*
217 ulp = slamch( 'precision' )
218 UNFL = SLAMCH( 'safe minimum' )
219*
220* Copy the matrix A to the array AF.
221*
222 CALL SLACPY( 'full', N, M, A, LDA, AF, LDA )
223 CALL SLACPY( 'full', N, P, B, LDB, BF, LDB )
224*
225 ANORM = MAX( SLANGE( '1', N, M, A, LDA, RWORK ), UNFL )
226 BNORM = MAX( SLANGE( '1', N, P, B, LDB, RWORK ), UNFL )
227*
228* Factorize the matrices A and B in the arrays AF and BF.
229*
230 CALL SGGQRF( N, M, P, AF, LDA, TAUA, BF, LDB, TAUB, WORK,
231 $ LWORK, INFO )
232*
233* Generate the N-by-N matrix Q
234*
235 CALL SLASET( 'full', N, N, ROGUE, ROGUE, Q, LDA )
236 CALL SLACPY( 'lower', N-1, M, AF( 2,1 ), LDA, Q( 2,1 ), LDA )
237 CALL SORGQR( N, N, MIN( N, M ), Q, LDA, TAUA, WORK, LWORK, INFO )
238*
239* Generate the P-by-P matrix Z
240*
241 CALL SLASET( 'full', P, P, ROGUE, ROGUE, Z, LDB )
242.LE. IF( NP ) THEN
243.GT..AND..LT. IF( N0 NP )
244 $ CALL SLACPY( 'full', N, P-N, BF, LDB, Z( P-N+1, 1 ), LDB )
245.GT. IF( N1 )
246 $ CALL SLACPY( 'lower', N-1, N-1, BF( 2, P-N+1 ), LDB,
247 $ Z( P-N+2, P-N+1 ), LDB )
248 ELSE
249.GT. IF( P1)
250 $ CALL SLACPY( 'lower', P-1, P-1, BF( N-P+2, 1 ), LDB,
251 $ Z( 2, 1 ), LDB )
252 END IF
253 CALL SORGRQ( P, P, MIN( N, P ), Z, LDB, TAUB, WORK, LWORK, INFO )
254*
255* Copy R
256*
257 CALL SLASET( 'full', N, M, ZERO, ZERO, R, LDA )
258 CALL SLACPY( 'upper', N, M, AF, LDA, R, LDA )
259*
260* Copy T
261*
262 CALL SLASET( 'full', N, P, ZERO, ZERO, T, LDB )
263.LE. IF( NP ) THEN
264 CALL SLACPY( 'upper', N, N, BF( 1, P-N+1 ), LDB, T( 1, P-N+1 ),
265 $ LDB )
266 ELSE
267 CALL SLACPY( 'full', N-P, P, BF, LDB, T, LDB )
268 CALL SLACPY( 'upper', P, P, BF( N-P+1, 1 ), LDB, T( N-P+1, 1 ),
269 $ LDB )
270 END IF
271*
272* Compute R - Q'*A
273*
274 CALL SGEMM( 'transpose', 'no transpose', N, M, N, -ONE, Q, LDA, A,
275 $ LDA, ONE, R, LDA )
276*
277* Compute norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP ) .
278*
279 RESID = SLANGE( '1', N, M, R, LDA, RWORK )
280.GT. IF( ANORMZERO ) THEN
281 RESULT( 1 ) = ( ( RESID / REAL( MAX(1,M,N) ) ) / ANORM ) / ULP
282 ELSE
283 RESULT( 1 ) = ZERO
284 END IF
285*
286* Compute T*Z - Q'*B
287*
288 CALL SGEMM( 'no transpose', 'no transpose', N, P, P, ONE, T, LDB,
289 $ Z, LDB, ZERO, BWK, LDB )
290 CALL SGEMM( 'transpose', 'no transpose', N, P, N, -ONE, Q, LDA,
291 $ B, LDB, ONE, BWK, LDB )
292*
293* Compute norm( T*Z - Q'*B ) / ( MAX(P,N)*norm(A)*ULP ) .
294*
295 RESID = SLANGE( '1', N, P, BWK, LDB, RWORK )
296.GT. IF( BNORMZERO ) THEN
297 RESULT( 2 ) = ( ( RESID / REAL( MAX(1,P,N ) ) )/BNORM ) / ULP
298 ELSE
299 RESULT( 2 ) = ZERO
300 END IF
301*
302* Compute I - Q'*Q
303*
304 CALL SLASET( 'full', N, N, ZERO, ONE, R, LDA )
305 CALL SSYRK( 'upper', 'transpose', N, N, -ONE, Q, LDA, ONE, R,
306 $ LDA )
307*
308* Compute norm( I - Q'*Q ) / ( N * ULP ) .
309*
310 RESID = SLANSY( '1', 'upper', N, R, LDA, RWORK )
311 RESULT( 3 ) = ( RESID / REAL( MAX( 1, N ) ) ) / ULP
312*
313* Compute I - Z'*Z
314*
315 CALL SLASET( 'full', P, P, ZERO, ONE, T, LDB )
316 CALL SSYRK( 'upper', 'transpose', P, P, -ONE, Z, LDB, ONE, T,
317 $ LDB )
318*
319* Compute norm( I - Z'*Z ) / ( P*ULP ) .
320*
321 RESID = SLANSY( '1', 'upper', P, T, LDB, RWORK )
322 RESULT( 4 ) = ( RESID / REAL( MAX( 1, P ) ) ) / ULP
323*
324 RETURN
325*
326* End of SGQRTS
327*
328 END
subroutine slaset(uplo, m, n, alpha, beta, a, lda)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition slaset.f:110
subroutine slacpy(uplo, m, n, a, lda, b, ldb)
SLACPY copies all or part of one two-dimensional array to another.
Definition slacpy.f:103
subroutine sorgrq(m, n, k, a, lda, tau, work, lwork, info)
SORGRQ
Definition sorgrq.f:128
subroutine sorgqr(m, n, k, a, lda, tau, work, lwork, info)
SORGQR
Definition sorgqr.f:128
subroutine ssyrk(uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
SSYRK
Definition ssyrk.f:169
subroutine sgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
SGEMM
Definition sgemm.f:187
subroutine sgqrts(n, m, p, a, af, q, r, lda, taua, b, bf, z, t, bwk, ldb, taub, work, lwork, rwork, result)
SGQRTS
Definition sgqrts.f:176
#define min(a, b)
Definition macros.h:20
#define max(a, b)
Definition macros.h:21