97
98
99
100
101
102
103 INTEGER LDA, LWORK, M, N
104
105
106 REAL RWORK( * ), S( * )
107 COMPLEX A( LDA, * ), WORK( LWORK )
108
109
110
111
112
113 REAL ZERO, ONE
114 parameter( zero = 0.0e0, one = 1.0e0 )
115
116
117 INTEGER I, INFO, ISCL, J, MN
118 REAL ANRM, BIGNUM, NRMSVL, SMLNUM
119
120
121 REAL DUMMY( 1 )
122
123
124 REAL CLANGE, SASUM, SLAMCH, SNRM2
126
127
130
131
132 INTRINSIC cmplx, max, min, real
133
134
135
137
138
139
140 IF( lwork.LT.m*n+2*min( m, n )+max( m, n ) ) THEN
141 CALL xerbla(
'CQRT12', 7 )
142 RETURN
143 END IF
144
145
146
147 mn = min( m, n )
148 IF( mn.LE.zero )
149 $ RETURN
150
151 nrmsvl =
snrm2( mn, s, 1 )
152
153
154
155 CALL claset(
'Full', m, n, cmplx( zero ), cmplx( zero ), work, m )
156 DO j = 1, n
157 DO i = 1, min( j, m )
158 work( ( j-1 )*m+i ) = a( i, j )
159 END DO
160 END DO
161
162
163
165 bignum = one / smlnum
166
167
168
169 anrm =
clange(
'M', m, n, work, m, dummy )
170 iscl = 0
171 IF( anrm.GT.zero .AND. anrm.LT.smlnum ) THEN
172
173
174
175 CALL clascl(
'G', 0, 0, anrm, smlnum, m, n, work, m, info )
176 iscl = 1
177 ELSE IF( anrm.GT.bignum ) THEN
178
179
180
181 CALL clascl(
'G', 0, 0, anrm, bignum, m, n, work, m, info )
182 iscl = 1
183 END IF
184
185 IF( anrm.NE.zero ) THEN
186
187
188
189 CALL cgebd2( m, n, work, m, rwork( 1 ), rwork( mn+1 ),
190 $ work( m*n+1 ), work( m*n+mn+1 ),
191 $ work( m*n+2*mn+1 ), info )
192 CALL sbdsqr(
'Upper', mn, 0, 0, 0, rwork( 1 ), rwork( mn+1 ),
193 $ dummy, mn, dummy, 1, dummy, mn, rwork( 2*mn+1 ),
194 $ info )
195
196 IF( iscl.EQ.1 ) THEN
197 IF( anrm.GT.bignum ) THEN
198 CALL slascl(
'G', 0, 0, bignum, anrm, mn, 1, rwork( 1 ),
199 $ mn, info )
200 END IF
201 IF( anrm.LT.smlnum ) THEN
202 CALL slascl(
'G', 0, 0, smlnum, anrm, mn, 1, rwork( 1 ),
203 $ mn, info )
204 END IF
205 END IF
206
207 ELSE
208
209 DO i = 1, mn
210 rwork( i ) = zero
211 END DO
212 END IF
213
214
215
216 CALL saxpy( mn, -one, s, 1, rwork( 1 ), 1 )
218 $ (
slamch(
'Epsilon' )*real( max( m, n ) ) )
219 IF( nrmsvl.NE.zero )
221
222 RETURN
223
224
225
subroutine xerbla(srname, info)
real function cqrt12(m, n, a, lda, s, work, lwork, rwork)
CQRT12
real function sasum(n, sx, incx)
SASUM
subroutine saxpy(n, sa, sx, incx, sy, incy)
SAXPY
subroutine sbdsqr(uplo, n, ncvt, nru, ncc, d, e, vt, ldvt, u, ldu, c, ldc, work, info)
SBDSQR
subroutine cgebd2(m, n, a, lda, d, e, tauq, taup, work, info)
CGEBD2 reduces a general matrix to bidiagonal form using an unblocked algorithm.
real function slamch(cmach)
SLAMCH
real function clange(norm, m, n, a, lda, work)
CLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
subroutine clascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
CLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine slascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
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.
real(wp) function snrm2(n, x, incx)
SNRM2