127 INTEGER M, N, MB1, NB1, NB2
129 DOUBLE PRECISION RESULT(6)
135 DOUBLE PRECISION,
ALLOCATABLE :: A(:,:), AF(:,:), Q(:,:), R(:,:),
136 $ RWORK(:), WORK( : ), T1(:,:), T2(:,:), DIAG(:),
137 $ C(:,:), CF(:,:), D(:,:), DF(:,:)
140 DOUBLE PRECISION ONE, ZERO
141 parameter( zero = 0.0d+0, one = 1.0d+0 )
145 INTEGER INFO, J, K, L, LWORK, NB2_UB, NRB
146 DOUBLE PRECISION ANORM, EPS, RESID, CNORM, DNORM
150 DOUBLE PRECISION WORKQUERY( 1 )
153 DOUBLE PRECISION DLAMCH, DLANGE, DLANSY
154 EXTERNAL dlamch, dlange, dlansy
161 INTRINSIC ceiling, dble, max, min
164 CHARACTER(LEN=32) SRNAMT
167 COMMON / srmnamc / srnamt
170 DATA iseed / 1988, 1989, 1990, 1991 /
176 eps = dlamch(
'Epsilon' )
182 ALLOCATE ( a(m,n), af(m,n), q(l,l), r(m,l), rwork(l),
189 CALL dlarnv( 2, iseed, m, a( 1, j ) )
194 CALL dlarnv( 2, iseed, m/2, a( m/4, j ) )
198 CALL dlacpy(
'Full', m, n, a, m, af, m )
202 nrb = max( 1, ceiling( dble( m - n ) / dble( mb1 - n ) ) )
204 ALLOCATE ( t1( nb1, n * nrb ) )
205 ALLOCATE ( t2( nb2, n ) )
206 ALLOCATE ( diag( n ) )
212 nb2_ub = min( nb2, n)
215 CALL dgetsqrhrt( m, n, mb1, nb1, nb2, af, m, t2, nb2,
216 $ workquery, -1, info )
218 lwork = int( workquery( 1 ) )
223 lwork = max( lwork, nb2_ub * n, nb2_ub * m )
225 ALLOCATE ( work( lwork ) )
234 srnamt =
'DGETSQRHRT'
235 CALL dgetsqrhrt( m, n, mb1, nb1, nb2, af, m, t2, nb2,
236 $ work, lwork, info )
243 CALL dlaset(
'Full', m, m, zero, one, q, m )
246 CALL dgemqrt(
'L',
'N', m, m, k, nb2_ub, af, m, t2, nb2, q, m,
251 CALL dlaset(
'Full', m, n, zero, zero, r, m )
253 CALL dlacpy(
'Upper', m, n, af, m, r, m )
258 CALL dgemm(
'T',
'N', m, n, m, -one, q, m, a, m, one, r, m )
260 anorm = dlange(
'1', m, n, a, m, rwork )
261 resid = dlange(
'1', m, n, r, m, rwork )
262 IF( anorm.GT.zero )
THEN
263 result( 1 ) = resid / ( eps * max( 1, m ) * anorm )
271 CALL dlaset(
'Full', m, m, zero, one, r, m )
272 CALL dsyrk(
'U',
'T', m, m, -one, q, m, one, r, m )
273 resid = dlansy(
'1',
'Upper', m, r, m, rwork )
274 result( 2 ) = resid / ( eps * max( 1, m ) )
279 CALL dlarnv( 2, iseed, m, c( 1, j ) )
281 cnorm = dlange(
'1', m, n, c, m, rwork )
282 CALL dlacpy(
'Full', m, n, c, m, cf, m )
287 CALL dgemqrt(
'L',
'N', m, n, k, nb2_ub, af, m, t2, nb2, cf, m,
293 CALL dgemm(
'N',
'N', m, n, m, -one, q, m, c, m, one, cf, m )
294 resid = dlange(
'1', m, n, cf, m, rwork )
295 IF( cnorm.GT.zero )
THEN
296 result( 3 ) = resid / ( eps * max( 1, m ) * cnorm )
303 CALL dlacpy(
'Full', m, n, c, m, cf, m )
308 CALL dgemqrt(
'L',
'T', m, n, k, nb2_ub, af, m, t2, nb2, cf, m,
314 CALL dgemm(
'T',
'N', m, n, m, -one, q, m, c, m, one, cf, m )
315 resid = dlange(
'1', m, n, cf, m, rwork )
316 IF( cnorm.GT.zero )
THEN
317 result( 4 ) = resid / ( eps * max( 1, m ) * cnorm )
325 CALL dlarnv( 2, iseed, n, d( 1, j ) )
327 dnorm = dlange(
'1', n, m, d, n, rwork )
328 CALL dlacpy(
'Full', n, m, d, n, df, n )
333 CALL dgemqrt(
'R',
'N', n, m, k, nb2_ub, af, m, t2, nb2, df, n,
339 CALL dgemm(
'N',
'N', n, m, m, -one, d, n, q, m, one, df, n )
340 resid = dlange(
'1', n, m, df, n, rwork )
341 IF( dnorm.GT.zero )
THEN
342 result( 5 ) = resid / ( eps * max( 1, m ) * dnorm )
349 CALL dlacpy(
'Full', n, m, d, n, df, n )
354 CALL dgemqrt(
'R',
'T', n, m, k, nb2_ub, af, m, t2, nb2, df, n,
360 CALL dgemm(
'N',
'T', n, m, m, -one, d, n, q, m, one, df, n )
361 resid = dlange(
'1', n, m, df, n, rwork )
362 IF( dnorm.GT.zero )
THEN
363 result( 6 ) = resid / ( eps * max( 1, m ) * dnorm )
370 DEALLOCATE ( a, af, q, r, rwork, work, t1, t2, diag,