OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
dqrt04.f
Go to the documentation of this file.
1*> \brief \b DQRT04
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 DQRT04(M,N,NB,RESULT)
12*
13* .. Scalar Arguments ..
14* INTEGER M, N, NB, LDT
15* .. Return values ..
16* DOUBLE PRECISION RESULT(6)
17*
18*
19*> \par Purpose:
20* =============
21*>
22*> \verbatim
23*>
24*> DQRT04 tests DGEQRT and DGEMQRT.
25*> \endverbatim
26*
27* Arguments:
28* ==========
29*
30*> \param[in] M
31*> \verbatim
32*> M is INTEGER
33*> Number of rows in test matrix.
34*> \endverbatim
35*>
36*> \param[in] N
37*> \verbatim
38*> N is INTEGER
39*> Number of columns in test matrix.
40*> \endverbatim
41*>
42*> \param[in] NB
43*> \verbatim
44*> NB is INTEGER
45*> Block size of test matrix. NB <= Min(M,N).
46*> \endverbatim
47*>
48*> \param[out] RESULT
49*> \verbatim
50*> RESULT is DOUBLE PRECISION array, dimension (6)
51*> Results of each of the six tests below.
52*>
53*> RESULT(1) = | A - Q R |
54*> RESULT(2) = | I - Q^H Q |
55*> RESULT(3) = | Q C - Q C |
56*> RESULT(4) = | Q^H C - Q^H C |
57*> RESULT(5) = | C Q - C Q |
58*> RESULT(6) = | C Q^H - C Q^H |
59*> \endverbatim
60*
61* Authors:
62* ========
63*
64*> \author Univ. of Tennessee
65*> \author Univ. of California Berkeley
66*> \author Univ. of Colorado Denver
67*> \author NAG Ltd.
68*
69*> \ingroup double_lin
70*
71* =====================================================================
72 SUBROUTINE dqrt04(M,N,NB,RESULT)
73 IMPLICIT NONE
74*
75* -- LAPACK test routine --
76* -- LAPACK is a software package provided by Univ. of Tennessee, --
77* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
78*
79* .. Scalar Arguments ..
80 INTEGER M, N, NB, LDT
81* .. Return values ..
82 DOUBLE PRECISION RESULT(6)
83*
84* =====================================================================
85*
86* ..
87* .. Local allocatable arrays
88 DOUBLE PRECISION, ALLOCATABLE :: AF(:,:), Q(:,:),
89 $ R(:,:), RWORK(:), WORK( : ), T(:,:),
90 $ CF(:,:), DF(:,:), A(:,:), C(:,:), D(:,:)
91*
92* .. Parameters ..
93 DOUBLE PRECISION ONE, ZERO
94 parameter( zero = 0.0, one = 1.0 )
95* ..
96* .. Local Scalars ..
97 INTEGER INFO, J, K, L, LWORK
98 DOUBLE PRECISION ANORM, EPS, RESID, CNORM, DNORM
99* ..
100* .. Local Arrays ..
101 INTEGER ISEED( 4 )
102* ..
103* .. External Functions ..
104 DOUBLE PRECISION DLAMCH, DLANGE, DLANSY
105 LOGICAL LSAME
106 EXTERNAL dlamch, dlange, dlansy, lsame
107* ..
108* .. Intrinsic Functions ..
109 INTRINSIC max, min
110* ..
111* .. Data statements ..
112 DATA iseed / 1988, 1989, 1990, 1991 /
113*
114 eps = dlamch( 'Epsilon' )
115 k = min(m,n)
116 l = max(m,n)
117 lwork = max(2,l)*max(2,l)*nb
118*
119* Dynamically allocate local arrays
120*
121 ALLOCATE ( a(m,n), af(m,n), q(m,m), r(m,l), rwork(l),
122 $ work(lwork), t(nb,n), c(m,n), cf(m,n),
123 $ d(n,m), df(n,m) )
124*
125* Put random numbers into A and copy to AF
126*
127 ldt=nb
128 DO j=1,n
129 CALL dlarnv( 2, iseed, m, a( 1, j ) )
130 END DO
131 CALL dlacpy( 'Full', m, n, a, m, af, m )
132*
133* Factor the matrix A in the array AF.
134*
135 CALL dgeqrt( m, n, nb, af, m, t, ldt, work, info )
136*
137* Generate the m-by-m matrix Q
138*
139 CALL dlaset( 'Full', m, m, zero, one, q, m )
140 CALL dgemqrt( 'R', 'N', m, m, k, nb, af, m, t, ldt, q, m,
141 $ work, info )
142*
143* Copy R
144*
145 CALL dlaset( 'Full', m, n, zero, zero, r, m )
146 CALL dlacpy( 'Upper', m, n, af, m, r, m )
147*
148* Compute |R - Q'*A| / |A| and store in RESULT(1)
149*
150 CALL dgemm( 'T', 'N', m, n, m, -one, q, m, a, m, one, r, m )
151 anorm = dlange( '1', m, n, a, m, rwork )
152 resid = dlange( '1', m, n, r, m, rwork )
153 IF( anorm.GT.zero ) THEN
154 result( 1 ) = resid / (eps*max(1,m)*anorm)
155 ELSE
156 result( 1 ) = zero
157 END IF
158*
159* Compute |I - Q'*Q| and store in RESULT(2)
160*
161 CALL dlaset( 'Full', m, m, zero, one, r, m )
162 CALL dsyrk( 'U', 'C', m, m, -one, q, m, one, r, m )
163 resid = dlansy( '1', 'Upper', m, r, m, rwork )
164 result( 2 ) = resid / (eps*max(1,m))
165*
166* Generate random m-by-n matrix C and a copy CF
167*
168 DO j=1,n
169 CALL dlarnv( 2, iseed, m, c( 1, j ) )
170 END DO
171 cnorm = dlange( '1', m, n, c, m, rwork)
172 CALL dlacpy( 'full', M, N, C, M, CF, M )
173*
174* Apply Q to C as Q*C
175*
176 CALL DGEMQRT( 'l', 'n', M, N, K, NB, AF, M, T, NB, CF, M,
177 $ WORK, INFO)
178*
179* Compute |Q*C - Q*C| / |C|
180*
181 CALL DGEMM( 'n', 'n', M, N, M, -ONE, Q, M, C, M, ONE, CF, M )
182 RESID = DLANGE( '1', M, N, CF, M, RWORK )
183.GT. IF( CNORMZERO ) THEN
184 RESULT( 3 ) = RESID / (EPS*MAX(1,M)*CNORM)
185 ELSE
186 RESULT( 3 ) = ZERO
187 END IF
188*
189* Copy C into CF again
190*
191 CALL DLACPY( 'full', M, N, C, M, CF, M )
192*
193* Apply Q to C as QT*C
194*
195 CALL DGEMQRT( 'l', 't', M, N, K, NB, AF, M, T, NB, CF, M,
196 $ WORK, INFO)
197*
198* Compute |QT*C - QT*C| / |C|
199*
200 CALL DGEMM( 't', 'n', M, N, M, -ONE, Q, M, C, M, ONE, CF, M )
201 RESID = DLANGE( '1', M, N, CF, M, RWORK )
202.GT. IF( CNORMZERO ) THEN
203 RESULT( 4 ) = RESID / (EPS*MAX(1,M)*CNORM)
204 ELSE
205 RESULT( 4 ) = ZERO
206 END IF
207*
208* Generate random n-by-m matrix D and a copy DF
209*
210 DO J=1,M
211 CALL DLARNV( 2, ISEED, N, D( 1, J ) )
212 END DO
213 DNORM = DLANGE( '1', N, M, D, N, RWORK)
214 CALL DLACPY( 'full', N, M, D, N, DF, N )
215*
216* Apply Q to D as D*Q
217*
218 CALL DGEMQRT( 'r', 'n', N, M, K, NB, AF, M, T, NB, DF, N,
219 $ WORK, INFO)
220*
221* Compute |D*Q - D*Q| / |D|
222*
223 CALL DGEMM( 'n', 'n', N, M, M, -ONE, D, N, Q, M, ONE, DF, N )
224 RESID = DLANGE( '1', N, M, DF, N, RWORK )
225.GT. IF( CNORMZERO ) THEN
226 RESULT( 5 ) = RESID / (EPS*MAX(1,M)*DNORM)
227 ELSE
228 RESULT( 5 ) = ZERO
229 END IF
230*
231* Copy D into DF again
232*
233 CALL DLACPY( 'full', N, M, D, N, DF, N )
234*
235* Apply Q to D as D*QT
236*
237 CALL DGEMQRT( 'r', 't', N, M, K, NB, AF, M, T, NB, DF, N,
238 $ WORK, INFO)
239*
240* Compute |D*QT - D*QT| / |D|
241*
242 CALL DGEMM( 'n', 't', N, M, M, -ONE, D, N, Q, M, ONE, DF, N )
243 RESID = DLANGE( '1', N, M, DF, N, RWORK )
244.GT. IF( CNORMZERO ) THEN
245 RESULT( 6 ) = RESID / (EPS*MAX(1,M)*DNORM)
246 ELSE
247 RESULT( 6 ) = ZERO
248 END IF
249*
250* Deallocate all arrays
251*
252 DEALLOCATE ( A, AF, Q, R, RWORK, WORK, T, C, D, CF, DF)
253*
254 RETURN
255 END
256
subroutine dlarnv(idist, iseed, n, x)
DLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition dlarnv.f:97
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 dgeqrt(m, n, nb, a, lda, t, ldt, work, info)
DGEQRT
Definition dgeqrt.f:141
subroutine dgemqrt(side, trans, m, n, k, nb, v, ldv, t, ldt, c, ldc, work, info)
DGEMQRT
Definition dgemqrt.f:168
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 dqrt04(m, n, nb, result)
DQRT04
Definition dqrt04.f:73
#define min(a, b)
Definition macros.h:20
#define max(a, b)
Definition macros.h:21