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