PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
cpoequ.f
Go to the documentation of this file.
1  SUBROUTINE cpoequ( N, A, LDA, S, SCOND, AMAX, INFO )
2 *
3 * -- LAPACK routine (version 3.2) --
4 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
5 * November 2006
6 *
7 * .. Scalar Arguments ..
8  INTEGER info, lda, n
9  REAL amax, scond
10 * ..
11 * .. Array Arguments ..
12  REAL s( * )
13  COMPLEX a( lda, * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * CPOEQU computes row and column scalings intended to equilibrate a
20 * Hermitian positive definite matrix A and reduce its condition number
21 * (with respect to the two-norm). S contains the scale factors,
22 * S(i) = 1/sqrt(A(i,i)), chosen so that the scaled matrix B with
23 * elements B(i,j) = S(i)*A(i,j)*S(j) has ones on the diagonal. This
24 * choice of S puts the condition number of B within a factor N of the
25 * smallest possible condition number over all possible diagonal
26 * scalings.
27 *
28 * Arguments
29 * =========
30 *
31 * N (input) INTEGER
32 * The order of the matrix A. N >= 0.
33 *
34 * A (input) COMPLEX array, dimension (LDA,N)
35 * The N-by-N Hermitian positive definite matrix whose scaling
36 * factors are to be computed. Only the diagonal elements of A
37 * are referenced.
38 *
39 * LDA (input) INTEGER
40 * The leading dimension of the array A. LDA >= max(1,N).
41 *
42 * S (output) REAL array, dimension (N)
43 * If INFO = 0, S contains the scale factors for A.
44 *
45 * SCOND (output) REAL
46 * If INFO = 0, S contains the ratio of the smallest S(i) to
47 * the largest S(i). If SCOND >= 0.1 and AMAX is neither too
48 * large nor too small, it is not worth scaling by S.
49 *
50 * AMAX (output) REAL
51 * Absolute value of largest matrix element. If AMAX is very
52 * close to overflow or very close to underflow, the matrix
53 * should be scaled.
54 *
55 * INFO (output) INTEGER
56 * = 0: successful exit
57 * < 0: if INFO = -i, the i-th argument had an illegal value
58 * > 0: if INFO = i, the i-th diagonal element is nonpositive.
59 *
60 * =====================================================================
61 *
62 * .. Parameters ..
63  REAL zero, one
64  parameter( zero = 0.0e+0, one = 1.0e+0 )
65 * ..
66 * .. Local Scalars ..
67  INTEGER i
68  REAL smin
69 * ..
70 * .. External Subroutines ..
71  EXTERNAL xerbla
72 * ..
73 * .. Intrinsic Functions ..
74  INTRINSIC max, min, REAL, sqrt
75 * ..
76 * .. Executable Statements ..
77 *
78 * Test the input parameters.
79 *
80  info = 0
81  IF( n.LT.0 ) THEN
82  info = -1
83  ELSE IF( lda.LT.max( 1, n ) ) THEN
84  info = -3
85  END IF
86  IF( info.NE.0 ) THEN
87  CALL xerbla( 'CPOEQU', -info )
88  return
89  END IF
90 *
91 * Quick return if possible
92 *
93  IF( n.EQ.0 ) THEN
94  scond = one
95  amax = zero
96  return
97  END IF
98 *
99 * Find the minimum and maximum diagonal elements.
100 *
101  s( 1 ) = REAL( A( 1, 1 ) )
102  smin = s( 1 )
103  amax = s( 1 )
104  DO 10 i = 2, n
105  s( i ) = REAL( A( I, I ) )
106  smin = min( smin, s( i ) )
107  amax = max( amax, s( i ) )
108  10 continue
109 *
110  IF( smin.LE.zero ) THEN
111 *
112 * Find the first non-positive diagonal element and return.
113 *
114  DO 20 i = 1, n
115  IF( s( i ).LE.zero ) THEN
116  info = i
117  return
118  END IF
119  20 continue
120  ELSE
121 *
122 * Set the scale factors to the reciprocals
123 * of the diagonal elements.
124 *
125  DO 30 i = 1, n
126  s( i ) = one / sqrt( s( i ) )
127  30 continue
128 *
129 * Compute SCOND = min(S(I)) / max(S(I))
130 *
131  scond = sqrt( smin ) / sqrt( amax )
132  END IF
133  return
134 *
135 * End of CPOEQU
136 *
137  END