127 INTEGER M, N, MB1, NB1, NB2
129 DOUBLE PRECISION RESULT(6)
135 COMPLEX*16 ,
ALLOCATABLE :: A(:,:), AF(:,:), Q(:,:), R(:,:),
136 $ WORK( : ), T1(:,:), T2(:,:), DIAG(:),
137 $ C(:,:), CF(:,:), D(:,:), DF(:,:)
138 DOUBLE PRECISION,
ALLOCATABLE :: RWORK(:)
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 ) )
149 INTEGER INFO, J, K, L, LWORK, NB2_UB, NRB
150 DOUBLE PRECISION ANORM, EPS, RESID, CNORM, DNORM
154 COMPLEX*16 WORKQUERY( 1 )
157 DOUBLE PRECISION DLAMCH, ZLANGE, ZLANSY
158 EXTERNAL dlamch, zlange, zlansy
165 INTRINSIC ceiling, dble, max, min
168 CHARACTER(LEN=32) SRNAMT
171 COMMON / srmnamc / srnamt
174 DATA iseed / 1988, 1989, 1990, 1991 /
180 eps = dlamch(
'Epsilon' )
186 ALLOCATE ( a(m,n), af(m,n), q(l,l), r(m,l), rwork(l),
193 CALL zlarnv( 2, iseed, m, a( 1, j ) )
198 CALL zlarnv( 2, iseed, m/2, a( m/4, j ) )
202 CALL zlacpy(
'Full', m, n, a, m, af, m )
206 nrb = max( 1, ceiling( dble( m - n ) / dble( mb1 - n ) ) )
208 ALLOCATE ( t1( nb1, n * nrb ) )
209 ALLOCATE ( t2( nb2, n ) )
210 ALLOCATE ( diag( n ) )
216 nb2_ub = min( nb2, n)
219 CALL zgetsqrhrt( m, n, mb1, nb1, nb2, af, m, t2, nb2,
220 $ workquery, -1, info )
222 lwork = int( workquery( 1 ) )
227 lwork = max( lwork, nb2_ub * n, nb2_ub * m )
229 ALLOCATE ( work( lwork ) )
238 srnamt =
'ZGETSQRHRT'
239 CALL zgetsqrhrt( m, n, mb1, nb1, nb2, af, m, t2, nb2,
240 $ work, lwork, info )
247 CALL zlaset(
'Full', m, m, czero, cone, q, m )
250 CALL zgemqrt(
'L',
'N', m, m, k, nb2_ub, af, m, t2, nb2, q, m,
255 CALL zlaset(
'Full', m, n, czero, czero, r, m )
257 CALL zlacpy(
'Upper', m, n, af, m, r, m )
262 CALL zgemm(
'C',
'N', m, n, m, -cone, q, m, a, m, cone, r, m )
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 )
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 ) )
283 CALL zlarnv( 2, iseed, m, c( 1, j ) )
285 cnorm = zlange(
'1', m, n, c, m, rwork )
286 CALL zlacpy(
'Full', m, n, c, m, cf, m )
291 CALL zgemqrt(
'L',
'N', m, n, k, nb2_ub, af, m, t2, nb2, cf, m,
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 )
307 CALL zlacpy(
'Full', m, n, c, m, cf, m )
312 CALL zgemqrt(
'L',
'C', m, n, k, nb2_ub, af, m, t2, nb2, cf, m,
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 )
329 CALL zlarnv( 2, iseed, n, d( 1, j ) )
331 dnorm = zlange(
'1', n, m, d, n, rwork )
332 CALL zlacpy(
'Full', n, m, d, n, df, n )
337 CALL zgemqrt(
'R',
'N', n, m, k, nb2_ub, af, m, t2, nb2, df, n,
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 )
353 CALL zlacpy(
'Full', n, m, d, n, df, n )
358 CALL zgemqrt(
'R',
'C', n, m, k, nb2_ub, af, m, t2, nb2, df, n,
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 )
374 DEALLOCATE ( a, af, q, r, rwork, work, t1, t2, diag,
subroutine zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZGEMM
subroutine zgemqrt(side, trans, m, n, k, nb, v, ldv, t, ldt, c, ldc, work, info)
ZGEMQRT
subroutine zgetsqrhrt(m, n, mb1, nb1, nb2, a, lda, t, ldt, work, lwork, info)
ZGETSQRHRT
subroutine zherk(uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
ZHERK
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
subroutine zlarnv(idist, iseed, n, x)
ZLARNV returns a vector of random numbers from a uniform or normal distribution.
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.
subroutine zscal(n, za, zx, incx)
ZSCAL
subroutine zunhr_col02(m, n, mb1, nb1, nb2, result)
ZUNHR_COL02