208 SUBROUTINE zgsvts( M, P, N, A, AF, LDA, B, BF, LDB, U, LDU, V,
209 $ ldv, q, ldq, alpha, beta, r, ldr, iwork, work,
210 $ lwork, rwork, result )
218 INTEGER lda, ldb, ldq, ldr, ldu, ldv, lwork, m, n, p
222 DOUBLE PRECISION alpha( * ), beta( * ), result( 6 ), rwork( * )
223 COMPLEX*16 a( lda, * ), af( lda, * ), b( ldb, * ),
224 $ bf( ldb, * ), q( ldq, * ), r( ldr, * ),
225 $ u( ldu, * ), v( ldv, * ), work( lwork )
231 DOUBLE PRECISION zero, one
232 parameter( zero = 0.0d+0, one = 1.0d+0 )
233 COMPLEX*16 czero, cone
234 parameter( czero = ( 0.0d+0, 0.0d+0 ),
235 $ cone = ( 1.0d+0, 0.0d+0 ) )
238 INTEGER i, info, j, k, l
239 DOUBLE PRECISION anorm, bnorm, resid, temp, ulp, ulpinv, unfl
249 INTRINSIC dble, max, min
253 ulp =
dlamch(
'Precision' )
255 unfl =
dlamch(
'Safe minimum' )
259 CALL
zlacpy(
'Full', m, n, a, lda, af, lda )
260 CALL
zlacpy(
'Full', p, n, b, ldb, bf, ldb )
262 anorm = max(
zlange(
'1', m, n, a, lda, rwork ), unfl )
263 bnorm = max(
zlange(
'1', p, n, b, ldb, rwork ), unfl )
267 CALL
zggsvd(
'U',
'V',
'Q', m, n, p, k, l, af, lda, bf, ldb,
268 $ alpha, beta, u, ldu, v, ldv, q, ldq, work, rwork,
273 DO 20 i = 1, min( k+l, m )
275 r( i, j ) = af( i, n-k-l+j )
279 IF( m-k-l.LT.0 )
THEN
280 DO 40 i = m + 1, k + l
282 r( i, j ) = bf( i-k, n-k-l+j )
289 CALL
zgemm(
'No transpose',
'No transpose', m, n, n, cone, a, lda,
290 $ q, ldq, czero, work, lda )
292 CALL
zgemm(
'Conjugate transpose',
'No transpose', m, n, m, cone,
293 $ u, ldu, work, lda, czero, a, lda )
297 a( i, n-k-l+j ) = a( i, n-k-l+j ) - r( i, j )
301 DO 80 i = k + 1, min( k+l, m )
303 a( i, n-k-l+j ) = a( i, n-k-l+j ) - alpha( i )*r( i, j )
309 resid =
zlange(
'1', m, n, a, lda, rwork )
310 IF( anorm.GT.zero )
THEN
311 result( 1 ) = ( ( resid / dble( max( 1, m, n ) ) ) / anorm ) /
319 CALL
zgemm(
'No transpose',
'No transpose', p, n, n, cone, b, ldb,
320 $ q, ldq, czero, work, ldb )
322 CALL
zgemm(
'Conjugate transpose',
'No transpose', p, n, p, cone,
323 $ v, ldv, work, ldb, czero, b, ldb )
327 b( i, n-l+j ) = b( i, n-l+j ) - beta( k+i )*r( k+i, k+j )
333 resid =
zlange(
'1', p, n, b, ldb, rwork )
334 IF( bnorm.GT.zero )
THEN
335 result( 2 ) = ( ( resid / dble( max( 1, p, n ) ) ) / bnorm ) /
343 CALL
zlaset(
'Full', m, m, czero, cone, work, ldq )
344 CALL
zherk(
'Upper',
'Conjugate transpose', m, m, -one, u, ldu,
349 resid =
zlanhe(
'1',
'Upper', m, work, ldu, rwork )
350 result( 3 ) = ( resid / dble( max( 1, m ) ) ) / ulp
354 CALL
zlaset(
'Full', p, p, czero, cone, work, ldv )
355 CALL
zherk(
'Upper',
'Conjugate transpose', p, p, -one, v, ldv,
360 resid =
zlanhe(
'1',
'Upper', p, work, ldv, rwork )
361 result( 4 ) = ( resid / dble( max( 1, p ) ) ) / ulp
365 CALL
zlaset(
'Full', n, n, czero, cone, work, ldq )
366 CALL
zherk(
'Upper',
'Conjugate transpose', n, n, -one, q, ldq,
371 resid =
zlanhe(
'1',
'Upper', n, work, ldq, rwork )
372 result( 5 ) = ( resid / dble( max( 1, n ) ) ) / ulp
376 CALL
dcopy( n, alpha, 1, rwork, 1 )
377 DO 110 i = k + 1, min( k+l, m )
381 rwork( i ) = rwork( j )
387 DO 120 i = k + 1, min( k+l, m ) - 1
388 IF( rwork( i ).LT.rwork( i+1 ) )
389 $ result( 6 ) = ulpinv