LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine dsyequb ( character  UPLO,
integer  N,
double precision, dimension( lda, * )  A,
integer  LDA,
double precision, dimension( * )  S,
double precision  SCOND,
double precision  AMAX,
double precision, dimension( * )  WORK,
integer  INFO 
)

DSYEQUB

Download DSYEQUB + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 DSYEQUB computes row and column scalings intended to equilibrate a
 symmetric matrix A and reduce its condition number
 (with respect to the two-norm).  S contains the scale factors,
 S(i) = 1/sqrt(A(i,i)), chosen so that the scaled matrix B with
 elements B(i,j) = S(i)*A(i,j)*S(j) has ones on the diagonal.  This
 choice of S puts the condition number of B within a factor N of the
 smallest possible condition number over all possible diagonal
 scalings.
Parameters
[in]UPLO
          UPLO is CHARACTER*1
          Specifies whether the details of the factorization are stored
          as an upper or lower triangular matrix.
          = 'U':  Upper triangular, form is A = U*D*U**T;
          = 'L':  Lower triangular, form is A = L*D*L**T.
[in]N
          N is INTEGER
          The order of the matrix A.  N >= 0.
[in]A
          A is DOUBLE PRECISION array, dimension (LDA,N)
          The N-by-N symmetric matrix whose scaling
          factors are to be computed.  Only the diagonal elements of A
          are referenced.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,N).
[out]S
          S is DOUBLE PRECISION array, dimension (N)
          If INFO = 0, S contains the scale factors for A.
[out]SCOND
          SCOND is DOUBLE PRECISION
          If INFO = 0, S contains the ratio of the smallest S(i) to
          the largest S(i).  If SCOND >= 0.1 and AMAX is neither too
          large nor too small, it is not worth scaling by S.
[out]AMAX
          AMAX is DOUBLE PRECISION
          Absolute value of largest matrix element.  If AMAX is very
          close to overflow or very close to underflow, the matrix
          should be scaled.
[out]WORK
          WORK is DOUBLE PRECISION array, dimension (3*N)
[out]INFO
          INFO is INTEGER
          = 0:  successful exit
          < 0:  if INFO = -i, the i-th argument had an illegal value
          > 0:  if INFO = i, the i-th diagonal element is nonpositive.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2011
References:
Livne, O.E. and Golub, G.H., "Scaling by Binormalization",
Numerical Algorithms, vol. 35, no. 1, pp. 97-120, January 2004.
DOI 10.1023/B:NUMA.0000016606.32820.69
Tech report version: http://ruready.utah.edu/archive/papers/bin.pdf

Definition at line 137 of file dsyequb.f.

137 *
138 * -- LAPACK computational routine (version 3.4.0) --
139 * -- LAPACK is a software package provided by Univ. of Tennessee, --
140 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
141 * November 2011
142 *
143 * .. Scalar Arguments ..
144  INTEGER info, lda, n
145  DOUBLE PRECISION amax, scond
146  CHARACTER uplo
147 * ..
148 * .. Array Arguments ..
149  DOUBLE PRECISION a( lda, * ), s( * ), work( * )
150 * ..
151 *
152 * =====================================================================
153 *
154 * .. Parameters ..
155  DOUBLE PRECISION one, zero
156  parameter ( one = 1.0d+0, zero = 0.0d+0 )
157  INTEGER max_iter
158  parameter ( max_iter = 100 )
159 * ..
160 * .. Local Scalars ..
161  INTEGER i, j, iter
162  DOUBLE PRECISION avg, std, tol, c0, c1, c2, t, u, si, d, base,
163  $ smin, smax, smlnum, bignum, scale, sumsq
164  LOGICAL up
165 * ..
166 * .. External Functions ..
167  DOUBLE PRECISION dlamch
168  LOGICAL lsame
169  EXTERNAL dlamch, lsame
170 * ..
171 * .. External Subroutines ..
172  EXTERNAL dlassq
173 * ..
174 * .. Intrinsic Functions ..
175  INTRINSIC abs, int, log, max, min, sqrt
176 * ..
177 * .. Executable Statements ..
178 *
179 * Test input parameters.
180 *
181  info = 0
182  IF ( .NOT. ( lsame( uplo, 'U' ) .OR. lsame( uplo, 'L' ) ) ) THEN
183  info = -1
184  ELSE IF ( n .LT. 0 ) THEN
185  info = -2
186  ELSE IF ( lda .LT. max( 1, n ) ) THEN
187  info = -4
188  END IF
189  IF ( info .NE. 0 ) THEN
190  CALL xerbla( 'DSYEQUB', -info )
191  RETURN
192  END IF
193 
194  up = lsame( uplo, 'U' )
195  amax = zero
196 *
197 * Quick return if possible.
198 *
199  IF ( n .EQ. 0 ) THEN
200  scond = one
201  RETURN
202  END IF
203 
204  DO i = 1, n
205  s( i ) = zero
206  END DO
207 
208  amax = zero
209  IF ( up ) THEN
210  DO j = 1, n
211  DO i = 1, j-1
212  s( i ) = max( s( i ), abs( a( i, j ) ) )
213  s( j ) = max( s( j ), abs( a( i, j ) ) )
214  amax = max( amax, abs( a(i, j) ) )
215  END DO
216  s( j ) = max( s( j ), abs( a( j, j ) ) )
217  amax = max( amax, abs( a( j, j ) ) )
218  END DO
219  ELSE
220  DO j = 1, n
221  s( j ) = max( s( j ), abs( a( j, j ) ) )
222  amax = max( amax, abs( a( j, j ) ) )
223  DO i = j+1, n
224  s( i ) = max( s( i ), abs( a( i, j ) ) )
225  s( j ) = max( s( j ), abs( a( i, j ) ) )
226  amax = max( amax, abs( a( i, j ) ) )
227  END DO
228  END DO
229  END IF
230  DO j = 1, n
231  s( j ) = 1.0d+0 / s( j )
232  END DO
233 
234  tol = one / sqrt(2.0d0 * n)
235 
236  DO iter = 1, max_iter
237  scale = 0.0d+0
238  sumsq = 0.0d+0
239 * BETA = |A|S
240  DO i = 1, n
241  work(i) = zero
242  END DO
243  IF ( up ) THEN
244  DO j = 1, n
245  DO i = 1, j-1
246  t = abs( a( i, j ) )
247  work( i ) = work( i ) + abs( a( i, j ) ) * s( j )
248  work( j ) = work( j ) + abs( a( i, j ) ) * s( i )
249  END DO
250  work( j ) = work( j ) + abs( a( j, j ) ) * s( j )
251  END DO
252  ELSE
253  DO j = 1, n
254  work( j ) = work( j ) + abs( a( j, j ) ) * s( j )
255  DO i = j+1, n
256  t = abs( a( i, j ) )
257  work( i ) = work( i ) + abs( a( i, j ) ) * s( j )
258  work( j ) = work( j ) + abs( a( i, j ) ) * s( i )
259  END DO
260  END DO
261  END IF
262 
263 * avg = s^T beta / n
264  avg = 0.0d+0
265  DO i = 1, n
266  avg = avg + s( i )*work( i )
267  END DO
268  avg = avg / n
269 
270  std = 0.0d+0
271  DO i = 2*n+1, 3*n
272  work( i ) = s( i-2*n ) * work( i-2*n ) - avg
273  END DO
274  CALL dlassq( n, work( 2*n+1 ), 1, scale, sumsq )
275  std = scale * sqrt( sumsq / n )
276 
277  IF ( std .LT. tol * avg ) GOTO 999
278 
279  DO i = 1, n
280  t = abs( a( i, i ) )
281  si = s( i )
282  c2 = ( n-1 ) * t
283  c1 = ( n-2 ) * ( work( i ) - t*si )
284  c0 = -(t*si)*si + 2*work( i )*si - n*avg
285  d = c1*c1 - 4*c0*c2
286 
287  IF ( d .LE. 0 ) THEN
288  info = -1
289  RETURN
290  END IF
291  si = -2*c0 / ( c1 + sqrt( d ) )
292 
293  d = si - s( i )
294  u = zero
295  IF ( up ) THEN
296  DO j = 1, i
297  t = abs( a( j, i ) )
298  u = u + s( j )*t
299  work( j ) = work( j ) + d*t
300  END DO
301  DO j = i+1,n
302  t = abs( a( i, j ) )
303  u = u + s( j )*t
304  work( j ) = work( j ) + d*t
305  END DO
306  ELSE
307  DO j = 1, i
308  t = abs( a( i, j ) )
309  u = u + s( j )*t
310  work( j ) = work( j ) + d*t
311  END DO
312  DO j = i+1,n
313  t = abs( a( j, i ) )
314  u = u + s( j )*t
315  work( j ) = work( j ) + d*t
316  END DO
317  END IF
318 
319  avg = avg + ( u + work( i ) ) * d / n
320  s( i ) = si
321 
322  END DO
323 
324  END DO
325 
326  999 CONTINUE
327 
328  smlnum = dlamch( 'SAFEMIN' )
329  bignum = one / smlnum
330  smin = bignum
331  smax = zero
332  t = one / sqrt(avg)
333  base = dlamch( 'B' )
334  u = one / log( base )
335  DO i = 1, n
336  s( i ) = base ** int( u * log( s( i ) * t ) )
337  smin = min( smin, s( i ) )
338  smax = max( smax, s( i ) )
339  END DO
340  scond = max( smin, smlnum ) / min( smax, bignum )
341 *
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:65
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine dlassq(N, X, INCX, SCALE, SUMSQ)
DLASSQ updates a sum of squares represented in scaled form.
Definition: dlassq.f:105
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55

Here is the call graph for this function:

Here is the caller graph for this function: