126 INTEGER M, N, MB1, NB1, NB2
134 COMPLEX ,
ALLOCATABLE :: A(:,:), AF(:,:), Q(:,:), R(:,:),
135 $ WORK( : ), T1(:,:), T2(:,:), DIAG(:),
136 $ C(:,:), CF(:,:), D(:,:), DF(:,:)
137 REAL ,
ALLOCATABLE :: RWORK(:)
141 parameter( zero = 0.0e+0 )
143 parameter( cone = ( 1.0e+0, 0.0e+0 ),
144 $ czero = ( 0.0e+0, 0.0e+0 ) )
148 INTEGER INFO, I, J, K, L, LWORK, NB1_UB, NB2_UB, NRB
149 REAL ANORM, EPS, RESID, CNORM, DNORM
153 COMPLEX WORKQUERY( 1 )
156 REAL SLAMCH, CLANGE, CLANSY
157 EXTERNAL slamch, clange, clansy
164 INTRINSIC ceiling, real, max, min
167 CHARACTER(LEN=32) SRNAMT
170 COMMON / srmnamc / srnamt
173 DATA iseed / 1988, 1989, 1990, 1991 /
179 eps = slamch(
'Epsilon' )
185 ALLOCATE ( a(m,n), af(m,n), q(l,l), r(m,l), rwork(l),
192 CALL clarnv( 2, iseed, m, a( 1, j ) )
197 CALL clarnv( 2, iseed, m/2, a( m/4, j ) )
201 CALL clacpy(
'Full', m, n, a, m, af, m )
205 nrb = max( 1, ceiling( real( m - n ) / real( mb1 - n ) ) )
207 ALLOCATE ( t1( nb1, n * nrb ) )
208 ALLOCATE ( t2( nb2, n ) )
209 ALLOCATE ( diag( n ) )
215 nb1_ub = min( nb1, n)
219 nb2_ub = min( nb2, n)
221 CALL clatsqr( m, n, mb1, nb1_ub, af, m, t1, nb1,
222 $ workquery, -1, info )
223 lwork = int( workquery( 1 ) )
224 CALL cungtsqr( m, n, mb1, nb1, af, m, t1, nb1, workquery, -1,
227 lwork = max( lwork, int( workquery( 1 ) ) )
232 lwork = max( lwork, nb2_ub * n, nb2_ub * m )
234 ALLOCATE ( work( lwork ) )
244 CALL clatsqr( m, n, mb1, nb1_ub, af, m, t1, nb1, work, lwork,
250 CALL clacpy(
'U', n, n, af, m, r, m )
255 CALL cungtsqr( m, n, mb1, nb1, af, m, t1, nb1, work, lwork,
262 CALL cunhr_col( m, n, nb2, af, m, t2, nb2, diag, info )
272 CALL clacpy(
'U', n, n, r, m, af, m )
275 IF( diag( i ).EQ.-cone )
THEN
276 CALL cscal( n+1-i, -cone, af( i, i ), m )
285 CALL claset(
'Full', m, m, czero, cone, q, m )
288 CALL cgemqrt(
'L',
'N', m, m, k, nb2_ub, af, m, t2, nb2, q, m,
293 CALL claset(
'Full', m, n, czero, czero, r, m )
295 CALL clacpy(
'Upper', m, n, af, m, r, m )
300 CALL cgemm(
'C',
'N', m, n, m, -cone, q, m, a, m, cone, r, m )
302 anorm = clange(
'1', m, n, a, m, rwork )
303 resid = clange(
'1', m, n, r, m, rwork )
304 IF( anorm.GT.zero )
THEN
305 result( 1 ) = resid / ( eps * max( 1, m ) * anorm )
313 CALL claset(
'Full', m, m, czero, cone, r, m )
314 CALL cherk(
'U',
'C', m, m, real(-cone), q, m, real(cone), r, m )
315 resid = clansy(
'1',
'Upper', m, r, m, rwork )
316 result( 2 ) = resid / ( eps * max( 1, m ) )
321 CALL clarnv( 2, iseed, m, c( 1, j ) )
323 cnorm = clange(
'1', m, n, c, m, rwork )
324 CALL clacpy(
'Full', m, n, c, m, cf, m )
329 CALL cgemqrt(
'L',
'N', m, n, k, nb2_ub, af, m, t2, nb2, cf, m,
335 CALL cgemm(
'N',
'N', m, n, m, -cone, q, m, c, m, cone, cf, m )
336 resid = clange(
'1', m, n, cf, m, rwork )
337 IF( cnorm.GT.zero )
THEN
338 result( 3 ) = resid / ( eps * max( 1, m ) * cnorm )
345 CALL clacpy(
'Full', m, n, c, m, cf, m )
350 CALL cgemqrt(
'L',
'C', m, n, k, nb2_ub, af, m, t2, nb2, cf, m,
356 CALL cgemm(
'C',
'N', m, n, m, -cone, q, m, c, m, cone, cf, m )
357 resid = clange(
'1', m, n, cf, m, rwork )
358 IF( cnorm.GT.zero )
THEN
359 result( 4 ) = resid / ( eps * max( 1, m ) * cnorm )
367 CALL clarnv( 2, iseed, n, d( 1, j ) )
369 dnorm = clange(
'1', n, m, d, n, rwork )
370 CALL clacpy(
'Full', n, m, d, n, df, n )
375 CALL cgemqrt(
'R',
'N', n, m, k, nb2_ub, af, m, t2, nb2, df, n,
381 CALL cgemm(
'N',
'N', n, m, m, -cone, d, n, q, m, cone, df, n )
382 resid = clange(
'1', n, m, df, n, rwork )
383 IF( dnorm.GT.zero )
THEN
384 result( 5 ) = resid / ( eps * max( 1, m ) * dnorm )
391 CALL clacpy(
'Full', n, m, d, n, df, n )
396 CALL cgemqrt(
'R',
'C', n, m, k, nb2_ub, af, m, t2, nb2, df, n,
402 CALL cgemm(
'N',
'C', n, m, m, -cone, d, n, q, m, cone, df, n )
403 resid = clange(
'1', n, m, df, n, rwork )
404 IF( dnorm.GT.zero )
THEN
405 result( 6 ) = resid / ( eps * max( 1, m ) * dnorm )
412 DEALLOCATE ( a, af, q, r, rwork, work, t1, t2, diag,
subroutine cunhr_col01(m, n, mb1, nb1, nb2, result)
CUNHR_COL01
subroutine cgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
CGEMM
subroutine cgemqrt(side, trans, m, n, k, nb, v, ldv, t, ldt, c, ldc, work, info)
CGEMQRT
subroutine cherk(uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
CHERK
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
subroutine clarnv(idist, iseed, n, x)
CLARNV returns a vector of random numbers from a uniform or normal distribution.
subroutine claset(uplo, m, n, alpha, beta, a, lda)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine clatsqr(m, n, mb, nb, a, lda, t, ldt, work, lwork, info)
CLATSQR
subroutine cscal(n, ca, cx, incx)
CSCAL
subroutine cungtsqr(m, n, mb, nb, a, lda, t, ldt, work, lwork, info)
CUNGTSQR
subroutine cunhr_col(m, n, nb, a, lda, t, ldt, d, info)
CUNHR_COL