LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zunhr_col02.f
Go to the documentation of this file.
1*> \brief \b ZUNHR_COL02
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 ZUNHR_COL02( M, N, MB1, NB1, NB2, RESULT )
12*
13* .. Scalar Arguments ..
14* INTEGER M, N, MB1, NB1, NB2
15* .. Return values ..
16* DOUBLE PRECISION RESULT(6)
17*
18*
19*> \par Purpose:
20* =============
21*>
22*> \verbatim
23*>
24*> ZUNHR_COL02 tests ZUNGTSQR_ROW and ZUNHR_COL inside ZGETSQRHRT
25*> (which calls ZLATSQR, ZUNGTSQR_ROW and ZUNHR_COL) using ZGEMQRT.
26*> Therefore, ZLATSQR (part of ZGEQR), ZGEMQRT (part of ZGEMQR)
27*> have to be tested before this test.
28*>
29*> \endverbatim
30*
31* Arguments:
32* ==========
33*
34*> \param[in] M
35*> \verbatim
36*> M is INTEGER
37*> Number of rows in test matrix.
38*> \endverbatim
39*> \param[in] N
40*> \verbatim
41*> N is INTEGER
42*> Number of columns in test matrix.
43*> \endverbatim
44*> \param[in] MB1
45*> \verbatim
46*> MB1 is INTEGER
47*> Number of row in row block in an input test matrix.
48*> \endverbatim
49*>
50*> \param[in] NB1
51*> \verbatim
52*> NB1 is INTEGER
53*> Number of columns in column block an input test matrix.
54*> \endverbatim
55*>
56*> \param[in] NB2
57*> \verbatim
58*> NB2 is INTEGER
59*> Number of columns in column block in an output test matrix.
60*> \endverbatim
61*>
62*> \param[out] RESULT
63*> \verbatim
64*> RESULT is DOUBLE PRECISION array, dimension (6)
65*> Results of each of the six tests below.
66*>
67*> A is a m-by-n test input matrix to be factored.
68*> so that A = Q_gr * ( R )
69*> ( 0 ),
70*>
71*> Q_qr is an implicit m-by-m unitary Q matrix, the result
72*> of factorization in blocked WY-representation,
73*> stored in ZGEQRT output format.
74*>
75*> R is a n-by-n upper-triangular matrix,
76*>
77*> 0 is a (m-n)-by-n zero matrix,
78*>
79*> Q is an explicit m-by-m unitary matrix Q = Q_gr * I
80*>
81*> C is an m-by-n random matrix,
82*>
83*> D is an n-by-m random matrix.
84*>
85*> The six tests are:
86*>
87*> RESULT(1) = |R - (Q**H) * A| / ( eps * m * |A| )
88*> is equivalent to test for | A - Q * R | / (eps * m * |A|),
89*>
90*> RESULT(2) = |I - (Q**H) * Q| / ( eps * m ),
91*>
92*> RESULT(3) = | Q_qr * C - Q * C | / (eps * m * |C|),
93*>
94*> RESULT(4) = | (Q_gr**H) * C - (Q**H) * C | / (eps * m * |C|)
95*>
96*> RESULT(5) = | D * Q_qr - D * Q | / (eps * m * |D|)
97*>
98*> RESULT(6) = | D * (Q_qr**H) - D * (Q**H) | / (eps * m * |D|),
99*>
100*> where:
101*> Q_qr * C, (Q_gr**H) * C, D * Q_qr, D * (Q_qr**H) are
102*> computed using ZGEMQRT,
103*>
104*> Q * C, (Q**H) * C, D * Q, D * (Q**H) are
105*> computed using ZGEMM.
106*> \endverbatim
107*
108* Authors:
109* ========
110*
111*> \author Univ. of Tennessee
112*> \author Univ. of California Berkeley
113*> \author Univ. of Colorado Denver
114*> \author NAG Ltd.
115*
116*> \ingroup complex16_lin
117*
118* =====================================================================
119 SUBROUTINE zunhr_col02( M, N, MB1, NB1, NB2, RESULT )
120 IMPLICIT NONE
121*
122* -- LAPACK test routine --
123* -- LAPACK is a software package provided by Univ. of Tennessee, --
124* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
125*
126* .. Scalar Arguments ..
127 INTEGER M, N, MB1, NB1, NB2
128* .. Return values ..
129 DOUBLE PRECISION RESULT(6)
130*
131* =====================================================================
132*
133* ..
134* .. Local allocatable arrays
135 COMPLEX*16 , ALLOCATABLE :: A(:,:), AF(:,:), Q(:,:), R(:,:),
136 $ WORK( : ), T1(:,:), T2(:,:), DIAG(:),
137 $ C(:,:), CF(:,:), D(:,:), DF(:,:)
138 DOUBLE PRECISION, ALLOCATABLE :: RWORK(:)
139*
140* .. Parameters ..
141 DOUBLE PRECISION ZERO
142 parameter( zero = 0.0d+0 )
143 COMPLEX*16 CONE, CZERO
144 parameter( cone = ( 1.0d+0, 0.0d+0 ),
145 $ czero = ( 0.0d+0, 0.0d+0 ) )
146* ..
147* .. Local Scalars ..
148 LOGICAL TESTZEROS
149 INTEGER INFO, J, K, L, LWORK, NB2_UB, NRB
150 DOUBLE PRECISION ANORM, EPS, RESID, CNORM, DNORM
151* ..
152* .. Local Arrays ..
153 INTEGER ISEED( 4 )
154 COMPLEX*16 WORKQUERY( 1 )
155* ..
156* .. External Functions ..
157 DOUBLE PRECISION DLAMCH, ZLANGE, ZLANSY
158 EXTERNAL dlamch, zlange, zlansy
159* ..
160* .. External Subroutines ..
161 EXTERNAL zlacpy, zlarnv, zlaset, zgetsqrhrt,
163* ..
164* .. Intrinsic Functions ..
165 INTRINSIC ceiling, dble, max, min
166* ..
167* .. Scalars in Common ..
168 CHARACTER(LEN=32) SRNAMT
169* ..
170* .. Common blocks ..
171 COMMON / srmnamc / srnamt
172* ..
173* .. Data statements ..
174 DATA iseed / 1988, 1989, 1990, 1991 /
175*
176* TEST MATRICES WITH HALF OF MATRIX BEING ZEROS
177*
178 testzeros = .false.
179*
180 eps = dlamch( 'Epsilon' )
181 k = min( m, n )
182 l = max( m, n, 1)
183*
184* Dynamically allocate local arrays
185*
186 ALLOCATE ( a(m,n), af(m,n), q(l,l), r(m,l), rwork(l),
187 $ c(m,n), cf(m,n),
188 $ d(n,m), df(n,m) )
189*
190* Put random numbers into A and copy to AF
191*
192 DO j = 1, n
193 CALL zlarnv( 2, iseed, m, a( 1, j ) )
194 END DO
195 IF( testzeros ) THEN
196 IF( m.GE.4 ) THEN
197 DO j = 1, n
198 CALL zlarnv( 2, iseed, m/2, a( m/4, j ) )
199 END DO
200 END IF
201 END IF
202 CALL zlacpy( 'Full', m, n, a, m, af, m )
203*
204* Number of row blocks in ZLATSQR
205*
206 nrb = max( 1, ceiling( dble( m - n ) / dble( mb1 - n ) ) )
207*
208 ALLOCATE ( t1( nb1, n * nrb ) )
209 ALLOCATE ( t2( nb2, n ) )
210 ALLOCATE ( diag( n ) )
211*
212* Begin determine LWORK for the array WORK and allocate memory.
213*
214* ZGEMQRT requires NB2 to be bounded by N.
215*
216 nb2_ub = min( nb2, n)
217*
218*
219 CALL zgetsqrhrt( m, n, mb1, nb1, nb2, af, m, t2, nb2,
220 $ workquery, -1, info )
221*
222 lwork = int( workquery( 1 ) )
223*
224* In ZGEMQRT, WORK is N*NB2_UB if SIDE = 'L',
225* or M*NB2_UB if SIDE = 'R'.
226*
227 lwork = max( lwork, nb2_ub * n, nb2_ub * m )
228*
229 ALLOCATE ( work( lwork ) )
230*
231* End allocate memory for WORK.
232*
233*
234* Begin Householder reconstruction routines
235*
236* Factor the matrix A in the array AF.
237*
238 srnamt = 'ZGETSQRHRT'
239 CALL zgetsqrhrt( m, n, mb1, nb1, nb2, af, m, t2, nb2,
240 $ work, lwork, info )
241*
242* End Householder reconstruction routines.
243*
244*
245* Generate the m-by-m matrix Q
246*
247 CALL zlaset( 'Full', m, m, czero, cone, q, m )
248*
249 srnamt = 'ZGEMQRT'
250 CALL zgemqrt( 'L', 'N', m, m, k, nb2_ub, af, m, t2, nb2, q, m,
251 $ work, info )
252*
253* Copy R
254*
255 CALL zlaset( 'Full', m, n, czero, czero, r, m )
256*
257 CALL zlacpy( 'Upper', m, n, af, m, r, m )
258*
259* TEST 1
260* Compute |R - (Q**T)*A| / ( eps * m * |A| ) and store in RESULT(1)
261*
262 CALL zgemm( 'C', 'N', m, n, m, -cone, q, m, a, m, cone, r, m )
263*
264 anorm = zlange( '1', m, n, a, m, rwork )
265 resid = zlange( '1', m, n, r, m, rwork )
266 IF( anorm.GT.zero ) THEN
267 result( 1 ) = resid / ( eps * max( 1, m ) * anorm )
268 ELSE
269 result( 1 ) = zero
270 END IF
271*
272* TEST 2
273* Compute |I - (Q**T)*Q| / ( eps * m ) and store in RESULT(2)
274*
275 CALL zlaset( 'Full', m, m, czero, cone, r, m )
276 CALL zherk( 'U', 'C', m, m, real(-cone), q, m, real(cone), r, m )
277 resid = zlansy( '1', 'Upper', m, r, m, rwork )
278 result( 2 ) = resid / ( eps * max( 1, m ) )
279*
280* Generate random m-by-n matrix C
281*
282 DO j = 1, n
283 CALL zlarnv( 2, iseed, m, c( 1, j ) )
284 END DO
285 cnorm = zlange( '1', m, n, c, m, rwork )
286 CALL zlacpy( 'Full', m, n, c, m, cf, m )
287*
288* Apply Q to C as Q*C = CF
289*
290 srnamt = 'ZGEMQRT'
291 CALL zgemqrt( 'L', 'N', m, n, k, nb2_ub, af, m, t2, nb2, cf, m,
292 $ work, info )
293*
294* TEST 3
295* Compute |CF - Q*C| / ( eps * m * |C| )
296*
297 CALL zgemm( 'N', 'N', m, n, m, -cone, q, m, c, m, cone, cf, m )
298 resid = zlange( '1', m, n, cf, m, rwork )
299 IF( cnorm.GT.zero ) THEN
300 result( 3 ) = resid / ( eps * max( 1, m ) * cnorm )
301 ELSE
302 result( 3 ) = zero
303 END IF
304*
305* Copy C into CF again
306*
307 CALL zlacpy( 'Full', m, n, c, m, cf, m )
308*
309* Apply Q to C as (Q**T)*C = CF
310*
311 srnamt = 'ZGEMQRT'
312 CALL zgemqrt( 'L', 'C', m, n, k, nb2_ub, af, m, t2, nb2, cf, m,
313 $ work, info )
314*
315* TEST 4
316* Compute |CF - (Q**T)*C| / ( eps * m * |C|)
317*
318 CALL zgemm( 'C', 'N', m, n, m, -cone, q, m, c, m, cone, cf, m )
319 resid = zlange( '1', m, n, cf, m, rwork )
320 IF( cnorm.GT.zero ) THEN
321 result( 4 ) = resid / ( eps * max( 1, m ) * cnorm )
322 ELSE
323 result( 4 ) = zero
324 END IF
325*
326* Generate random n-by-m matrix D and a copy DF
327*
328 DO j = 1, m
329 CALL zlarnv( 2, iseed, n, d( 1, j ) )
330 END DO
331 dnorm = zlange( '1', n, m, d, n, rwork )
332 CALL zlacpy( 'Full', n, m, d, n, df, n )
333*
334* Apply Q to D as D*Q = DF
335*
336 srnamt = 'ZGEMQRT'
337 CALL zgemqrt( 'R', 'N', n, m, k, nb2_ub, af, m, t2, nb2, df, n,
338 $ work, info )
339*
340* TEST 5
341* Compute |DF - D*Q| / ( eps * m * |D| )
342*
343 CALL zgemm( 'N', 'N', n, m, m, -cone, d, n, q, m, cone, df, n )
344 resid = zlange( '1', n, m, df, n, rwork )
345 IF( dnorm.GT.zero ) THEN
346 result( 5 ) = resid / ( eps * max( 1, m ) * dnorm )
347 ELSE
348 result( 5 ) = zero
349 END IF
350*
351* Copy D into DF again
352*
353 CALL zlacpy( 'Full', n, m, d, n, df, n )
354*
355* Apply Q to D as D*QT = DF
356*
357 srnamt = 'ZGEMQRT'
358 CALL zgemqrt( 'R', 'C', n, m, k, nb2_ub, af, m, t2, nb2, df, n,
359 $ work, info )
360*
361* TEST 6
362* Compute |DF - D*(Q**T)| / ( eps * m * |D| )
363*
364 CALL zgemm( 'N', 'C', n, m, m, -cone, d, n, q, m, cone, df, n )
365 resid = zlange( '1', n, m, df, n, rwork )
366 IF( dnorm.GT.zero ) THEN
367 result( 6 ) = resid / ( eps * max( 1, m ) * dnorm )
368 ELSE
369 result( 6 ) = zero
370 END IF
371*
372* Deallocate all arrays
373*
374 DEALLOCATE ( a, af, q, r, rwork, work, t1, t2, diag,
375 $ c, d, cf, df )
376*
377 RETURN
378*
379* End of ZUNHR_COL02
380*
381 END
subroutine zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZGEMM
Definition zgemm.f:188
subroutine zgemqrt(side, trans, m, n, k, nb, v, ldv, t, ldt, c, ldc, work, info)
ZGEMQRT
Definition zgemqrt.f:168
subroutine zgetsqrhrt(m, n, mb1, nb1, nb2, a, lda, t, ldt, work, lwork, info)
ZGETSQRHRT
Definition zgetsqrhrt.f:179
subroutine zherk(uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
ZHERK
Definition zherk.f:173
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
Definition zlacpy.f:103
subroutine zlarnv(idist, iseed, n, x)
ZLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition zlarnv.f:99
subroutine zlaset(uplo, m, n, alpha, beta, a, lda)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition zlaset.f:106
subroutine zscal(n, za, zx, incx)
ZSCAL
Definition zscal.f:78
subroutine zunhr_col02(m, n, mb1, nb1, nb2, result)
ZUNHR_COL02