LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
sqrt05.f
Go to the documentation of this file.
1*> \brief \b SQRT05
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 SQRT05(M,N,L,NB,RESULT)
12*
13* .. Scalar Arguments ..
14* INTEGER LWORK, M, N, L, NB, LDT
15* .. Return values ..
16* REAL RESULT(6)
17*
18*
19*> \par Purpose:
20* =============
21*>
22*> \verbatim
23*>
24*> SQRT05 tests STPQRT and STPMQRT.
25*> \endverbatim
26*
27* Arguments:
28* ==========
29*
30*> \param[in] M
31*> \verbatim
32*> M is INTEGER
33*> Number of rows in lower part of the 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] L
43*> \verbatim
44*> L is INTEGER
45*> The number of rows of the upper trapezoidal part the
46*> lower test matrix. 0 <= L <= M.
47*> \endverbatim
48*>
49*> \param[in] NB
50*> \verbatim
51*> NB is INTEGER
52*> Block size of test matrix. NB <= N.
53*> \endverbatim
54*>
55*> \param[out] RESULT
56*> \verbatim
57*> RESULT is REAL array, dimension (6)
58*> Results of each of the six tests below.
59*>
60*> RESULT(1) = | A - Q R |
61*> RESULT(2) = | I - Q^H Q |
62*> RESULT(3) = | Q C - Q C |
63*> RESULT(4) = | Q^H C - Q^H C |
64*> RESULT(5) = | C Q - C Q |
65*> RESULT(6) = | C Q^H - C Q^H |
66*> \endverbatim
67*
68* Authors:
69* ========
70*
71*> \author Univ. of Tennessee
72*> \author Univ. of California Berkeley
73*> \author Univ. of Colorado Denver
74*> \author NAG Ltd.
75*
76*> \ingroup single_lin
77*
78* =====================================================================
79 SUBROUTINE sqrt05(M,N,L,NB,RESULT)
80 IMPLICIT NONE
81*
82* -- LAPACK test routine --
83* -- LAPACK is a software package provided by Univ. of Tennessee, --
84* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
85*
86* .. Scalar Arguments ..
87 INTEGER LWORK, M, N, L, NB, LDT
88* .. Return values ..
89 REAL RESULT(6)
90*
91* =====================================================================
92*
93* ..
94* .. Local allocatable arrays
95 REAL, ALLOCATABLE :: AF(:,:), Q(:,:),
96 $ R(:,:), RWORK(:), WORK( : ), T(:,:),
97 $ CF(:,:), DF(:,:), A(:,:), C(:,:), D(:,:)
98*
99* .. Parameters ..
100 REAL ZERO, ONE
101 parameter( zero = 0.0, one = 1.0 )
102* ..
103* .. Local Scalars ..
104 INTEGER INFO, J, K, M2, NP1
105 REAL ANORM, EPS, RESID, CNORM, DNORM
106* ..
107* .. Local Arrays ..
108 INTEGER ISEED( 4 )
109* ..
110* .. External Subroutine ..
112 $ slaset
113* ..
114* .. External Functions ..
115 REAL SLAMCH
116 REAL SLANGE, SLANSY
117 LOGICAL LSAME
118 EXTERNAL slamch, slange, slansy, lsame
119* ..
120* .. Data statements ..
121 DATA iseed / 1988, 1989, 1990, 1991 /
122*
123 eps = slamch( 'Epsilon' )
124 k = n
125 m2 = m+n
126 IF( m.GT.0 ) THEN
127 np1 = n+1
128 ELSE
129 np1 = 1
130 END IF
131 lwork = m2*m2*nb
132*
133* Dynamically allocate all arrays
134*
135 ALLOCATE(a(m2,n),af(m2,n),q(m2,m2),r(m2,m2),rwork(m2),
136 $ work(lwork),t(nb,n),c(m2,n),cf(m2,n),
137 $ d(n,m2),df(n,m2) )
138*
139* Put random stuff into A
140*
141 ldt=nb
142 CALL slaset( 'Full', m2, n, zero, zero, a, m2 )
143 CALL slaset( 'Full', nb, n, zero, zero, t, nb )
144 DO j=1,n
145 CALL slarnv( 2, iseed, j, a( 1, j ) )
146 END DO
147 IF( m.GT.0 ) THEN
148 DO j=1,n
149 CALL slarnv( 2, iseed, m-l, a( n+1, j ) )
150 END DO
151 END IF
152 IF( l.GT.0 ) THEN
153 DO j=1,n
154 CALL slarnv( 2, iseed, min(j,l), a( n+m-l+1, j ) )
155 END DO
156 END IF
157*
158* Copy the matrix A to the array AF.
159*
160 CALL slacpy( 'Full', m2, n, a, m2, af, m2 )
161*
162* Factor the matrix A in the array AF.
163*
164 CALL stpqrt( m,n,l,nb,af,m2,af(np1,1),m2,t,ldt,work,info)
165*
166* Generate the (M+N)-by-(M+N) matrix Q by applying H to I
167*
168 CALL slaset( 'Full', m2, m2, zero, one, q, m2 )
169 CALL sgemqrt( 'R', 'N', m2, m2, k, nb, af, m2, t, ldt, q, m2,
170 $ work, info )
171*
172* Copy R
173*
174 CALL slaset( 'Full', m2, n, zero, zero, r, m2 )
175 CALL slacpy( 'Upper', m2, n, af, m2, r, m2 )
176*
177* Compute |R - Q'*A| / |A| and store in RESULT(1)
178*
179 CALL sgemm( 'T', 'N', m2, n, m2, -one, q, m2, a, m2, one, r, m2 )
180 anorm = slange( '1', m2, n, a, m2, rwork )
181 resid = slange( '1', m2, n, r, m2, rwork )
182 IF( anorm.GT.zero ) THEN
183 result( 1 ) = resid / (eps*anorm*max(1,m2))
184 ELSE
185 result( 1 ) = zero
186 END IF
187*
188* Compute |I - Q'*Q| and store in RESULT(2)
189*
190 CALL slaset( 'Full', m2, m2, zero, one, r, m2 )
191 CALL ssyrk( 'U', 'C', m2, m2, -one, q, m2, one,
192 $ r, m2 )
193 resid = slansy( '1', 'Upper', m2, r, m2, rwork )
194 result( 2 ) = resid / (eps*max(1,m2))
195*
196* Generate random m-by-n matrix C and a copy CF
197*
198 DO j=1,n
199 CALL slarnv( 2, iseed, m2, c( 1, j ) )
200 END DO
201 cnorm = slange( '1', m2, n, c, m2, rwork)
202 CALL slacpy( 'Full', m2, n, c, m2, cf, m2 )
203*
204* Apply Q to C as Q*C
205*
206 CALL stpmqrt( 'L','N', m,n,k,l,nb,af(np1,1),m2,t,ldt,cf,
207 $ m2,cf(np1,1),m2,work,info)
208*
209* Compute |Q*C - Q*C| / |C|
210*
211 CALL sgemm( 'N', 'N', m2, n, m2, -one, q,m2,c,m2,one,cf,m2)
212 resid = slange( '1', m2, n, cf, m2, rwork )
213 IF( cnorm.GT.zero ) THEN
214 result( 3 ) = resid / (eps*max(1,m2)*cnorm)
215 ELSE
216 result( 3 ) = zero
217 END IF
218*
219* Copy C into CF again
220*
221 CALL slacpy( 'Full', m2, n, c, m2, cf, m2 )
222*
223* Apply Q to C as QT*C
224*
225 CALL stpmqrt('L','T',m,n,k,l,nb,af(np1,1),m2,t,ldt,cf,m2,
226 $ cf(np1,1),m2,work,info)
227*
228* Compute |QT*C - QT*C| / |C|
229*
230 CALL sgemm('T','N',m2,n,m2,-one,q,m2,c,m2,one,cf,m2)
231 resid = slange( '1', m2, n, cf, m2, rwork )
232 IF( cnorm.GT.zero ) THEN
233 result( 4 ) = resid / (eps*max(1,m2)*cnorm)
234 ELSE
235 result( 4 ) = zero
236 END IF
237*
238* Generate random n-by-m matrix D and a copy DF
239*
240 DO j=1,m2
241 CALL slarnv( 2, iseed, n, d( 1, j ) )
242 END DO
243 dnorm = slange( '1', n, m2, d, n, rwork)
244 CALL slacpy( 'Full', n, m2, d, n, df, n )
245*
246* Apply Q to D as D*Q
247*
248 CALL stpmqrt('R','N',n,m,n,l,nb,af(np1,1),m2,t,ldt,df,n,
249 $ df(1,np1),n,work,info)
250*
251* Compute |D*Q - D*Q| / |D|
252*
253 CALL sgemm('N','N',n,m2,m2,-one,d,n,q,m2,one,df,n)
254 resid = slange('1',n, m2,df,n,rwork )
255 IF( cnorm.GT.zero ) THEN
256 result( 5 ) = resid / (eps*max(1,m2)*dnorm)
257 ELSE
258 result( 5 ) = zero
259 END IF
260*
261* Copy D into DF again
262*
263 CALL slacpy('Full',n,m2,d,n,df,n )
264*
265* Apply Q to D as D*QT
266*
267 CALL stpmqrt('R','T',n,m,n,l,nb,af(np1,1),m2,t,ldt,df,n,
268 $ df(1,np1),n,work,info)
269
270*
271* Compute |D*QT - D*QT| / |D|
272*
273 CALL sgemm( 'N', 'T', n, m2, m2, -one, d, n, q, m2, one, df, n )
274 resid = slange( '1', n, m2, df, n, rwork )
275 IF( cnorm.GT.zero ) THEN
276 result( 6 ) = resid / (eps*max(1,m2)*dnorm)
277 ELSE
278 result( 6 ) = zero
279 END IF
280*
281* Deallocate all arrays
282*
283 DEALLOCATE ( a, af, q, r, rwork, work, t, c, d, cf, df)
284 RETURN
285 END
286
subroutine sgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
SGEMM
Definition sgemm.f:188
subroutine sgemqrt(side, trans, m, n, k, nb, v, ldv, t, ldt, c, ldc, work, info)
SGEMQRT
Definition sgemqrt.f:168
subroutine ssyrk(uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
SSYRK
Definition ssyrk.f:169
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 slarnv(idist, iseed, n, x)
SLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition slarnv.f:97
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 stpmqrt(side, trans, m, n, k, l, nb, v, ldv, t, ldt, a, lda, b, ldb, work, info)
STPMQRT
Definition stpmqrt.f:216
subroutine stpqrt(m, n, l, nb, a, lda, b, ldb, t, ldt, work, info)
STPQRT
Definition stpqrt.f:189
subroutine sqrt05(m, n, l, nb, result)
SQRT05
Definition sqrt05.f:80