LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ spoequ()

subroutine spoequ ( integer  N,
real, dimension( lda, * )  A,
integer  LDA,
real, dimension( * )  S,
real  SCOND,
real  AMAX,
integer  INFO 
)

SPOEQU

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

Purpose:
 SPOEQU computes row and column scalings intended to equilibrate a
 symmetric positive definite 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]N
          N is INTEGER
          The order of the matrix A.  N >= 0.
[in]A
          A is REAL array, dimension (LDA,N)
          The N-by-N symmetric positive definite 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]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
December 2016

Definition at line 114 of file spoequ.f.

114 *
115 * -- LAPACK computational routine (version 3.7.0) --
116 * -- LAPACK is a software package provided by Univ. of Tennessee, --
117 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
118 * December 2016
119 *
120 * .. Scalar Arguments ..
121  INTEGER info, lda, n
122  REAL amax, scond
123 * ..
124 * .. Array Arguments ..
125  REAL a( lda, * ), s( * )
126 * ..
127 *
128 * =====================================================================
129 *
130 * .. Parameters ..
131  REAL zero, one
132  parameter( zero = 0.0e+0, one = 1.0e+0 )
133 * ..
134 * .. Local Scalars ..
135  INTEGER i
136  REAL smin
137 * ..
138 * .. External Subroutines ..
139  EXTERNAL xerbla
140 * ..
141 * .. Intrinsic Functions ..
142  INTRINSIC max, min, sqrt
143 * ..
144 * .. Executable Statements ..
145 *
146 * Test the input parameters.
147 *
148  info = 0
149  IF( n.LT.0 ) THEN
150  info = -1
151  ELSE IF( lda.LT.max( 1, n ) ) THEN
152  info = -3
153  END IF
154  IF( info.NE.0 ) THEN
155  CALL xerbla( 'SPOEQU', -info )
156  RETURN
157  END IF
158 *
159 * Quick return if possible
160 *
161  IF( n.EQ.0 ) THEN
162  scond = one
163  amax = zero
164  RETURN
165  END IF
166 *
167 * Find the minimum and maximum diagonal elements.
168 *
169  s( 1 ) = a( 1, 1 )
170  smin = s( 1 )
171  amax = s( 1 )
172  DO 10 i = 2, n
173  s( i ) = a( i, i )
174  smin = min( smin, s( i ) )
175  amax = max( amax, s( i ) )
176  10 CONTINUE
177 *
178  IF( smin.LE.zero ) THEN
179 *
180 * Find the first non-positive diagonal element and return.
181 *
182  DO 20 i = 1, n
183  IF( s( i ).LE.zero ) THEN
184  info = i
185  RETURN
186  END IF
187  20 CONTINUE
188  ELSE
189 *
190 * Set the scale factors to the reciprocals
191 * of the diagonal elements.
192 *
193  DO 30 i = 1, n
194  s( i ) = one / sqrt( s( i ) )
195  30 CONTINUE
196 *
197 * Compute SCOND = min(S(I)) / max(S(I))
198 *
199  scond = sqrt( smin ) / sqrt( amax )
200  END IF
201  RETURN
202 *
203 * End of SPOEQU
204 *
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
Here is the call graph for this function:
Here is the caller graph for this function: