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

CSYEQUB

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

Purpose:
 CSYEQUB 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 COMPLEX 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 REAL array, dimension (N)
          If INFO = 0, S contains the scale factors for A.
[out]SCOND
          SCOND is REAL
          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 REAL
          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 COMPLEX 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 138 of file csyequb.f.

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