97 REAL FUNCTION cqrt12( M, N, A, LDA, S, WORK, LWORK,
106 INTEGER lda, lwork, m, n
109 REAL rwork( * ), s( * )
110 COMPLEX a( lda, * ), work( lwork )
117 parameter( zero = 0.0e0, one = 1.0e0 )
120 INTEGER i, info, iscl, j, mn
121 REAL anrm, bignum, nrmsvl, smlnum
135 INTRINSIC cmplx, max, min, real
143 IF( lwork.LT.m*n+2*min( m, n )+max( m, n ) )
THEN
144 CALL
xerbla(
'CQRT12', 7 )
154 nrmsvl =
snrm2( mn, s, 1 )
158 CALL
claset(
'Full', m, n, cmplx( zero ), cmplx( zero ), work, m )
160 DO 10 i = 1, min( j, m )
161 work( ( j-1 )*m+i ) = a( i, j )
168 bignum = one / smlnum
169 CALL
slabad( smlnum, bignum )
173 anrm =
clange(
'M', m, n, work, m, dummy )
175 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
179 CALL
clascl(
'G', 0, 0, anrm, smlnum, m, n, work, m, info )
181 ELSE IF( anrm.GT.bignum )
THEN
185 CALL
clascl(
'G', 0, 0, anrm, bignum, m, n, work, m, info )
189 IF( anrm.NE.zero )
THEN
193 CALL
cgebd2( m, n, work, m, rwork( 1 ), rwork( mn+1 ),
194 $ work( m*n+1 ), work( m*n+mn+1 ),
195 $ work( m*n+2*mn+1 ), info )
196 CALL
sbdsqr(
'Upper', mn, 0, 0, 0, rwork( 1 ), rwork( mn+1 ),
197 $ dummy, mn, dummy, 1, dummy, mn, rwork( 2*mn+1 ),
201 IF( anrm.GT.bignum )
THEN
202 CALL
slascl(
'G', 0, 0, bignum, anrm, mn, 1, rwork( 1 ),
205 IF( anrm.LT.smlnum )
THEN
206 CALL
slascl(
'G', 0, 0, smlnum, anrm, mn, 1, rwork( 1 ),
220 CALL
saxpy( mn, -one, s, 1, rwork( 1 ), 1 )
222 $ (
slamch(
'Epsilon' )*
REAL( MAX( M, N ) ) )