LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine cppequ ( character  UPLO,
integer  N,
complex, dimension( * )  AP,
real, dimension( * )  S,
real  SCOND,
real  AMAX,
integer  INFO 
)

CPPEQU

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

Purpose:
 CPPEQU computes row and column scalings intended to equilibrate a
 Hermitian positive definite matrix A in packed storage 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
          = 'U':  Upper triangle of A is stored;
          = 'L':  Lower triangle of A is stored.
[in]N
          N is INTEGER
          The order of the matrix A.  N >= 0.
[in]AP
          AP is COMPLEX array, dimension (N*(N+1)/2)
          The upper or lower triangle of the Hermitian matrix A, packed
          columnwise in a linear array.  The j-th column of A is stored
          in the array AP as follows:
          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=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
November 2011

Definition at line 119 of file cppequ.f.

119 *
120 * -- LAPACK computational routine (version 3.4.0) --
121 * -- LAPACK is a software package provided by Univ. of Tennessee, --
122 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
123 * November 2011
124 *
125 * .. Scalar Arguments ..
126  CHARACTER uplo
127  INTEGER info, n
128  REAL amax, scond
129 * ..
130 * .. Array Arguments ..
131  REAL s( * )
132  COMPLEX ap( * )
133 * ..
134 *
135 * =====================================================================
136 *
137 * .. Parameters ..
138  REAL one, zero
139  parameter ( one = 1.0e+0, zero = 0.0e+0 )
140 * ..
141 * .. Local Scalars ..
142  LOGICAL upper
143  INTEGER i, jj
144  REAL smin
145 * ..
146 * .. External Functions ..
147  LOGICAL lsame
148  EXTERNAL lsame
149 * ..
150 * .. External Subroutines ..
151  EXTERNAL xerbla
152 * ..
153 * .. Intrinsic Functions ..
154  INTRINSIC max, min, REAL, sqrt
155 * ..
156 * .. Executable Statements ..
157 *
158 * Test the input parameters.
159 *
160  info = 0
161  upper = lsame( uplo, 'U' )
162  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
163  info = -1
164  ELSE IF( n.LT.0 ) THEN
165  info = -2
166  END IF
167  IF( info.NE.0 ) THEN
168  CALL xerbla( 'CPPEQU', -info )
169  RETURN
170  END IF
171 *
172 * Quick return if possible
173 *
174  IF( n.EQ.0 ) THEN
175  scond = one
176  amax = zero
177  RETURN
178  END IF
179 *
180 * Initialize SMIN and AMAX.
181 *
182  s( 1 ) = REAL( AP( 1 ) )
183  smin = s( 1 )
184  amax = s( 1 )
185 *
186  IF( upper ) THEN
187 *
188 * UPLO = 'U': Upper triangle of A is stored.
189 * Find the minimum and maximum diagonal elements.
190 *
191  jj = 1
192  DO 10 i = 2, n
193  jj = jj + i
194  s( i ) = REAL( AP( JJ ) )
195  smin = min( smin, s( i ) )
196  amax = max( amax, s( i ) )
197  10 CONTINUE
198 *
199  ELSE
200 *
201 * UPLO = 'L': Lower triangle of A is stored.
202 * Find the minimum and maximum diagonal elements.
203 *
204  jj = 1
205  DO 20 i = 2, n
206  jj = jj + n - i + 2
207  s( i ) = REAL( AP( JJ ) )
208  smin = min( smin, s( i ) )
209  amax = max( amax, s( i ) )
210  20 CONTINUE
211  END IF
212 *
213  IF( smin.LE.zero ) THEN
214 *
215 * Find the first non-positive diagonal element and return.
216 *
217  DO 30 i = 1, n
218  IF( s( i ).LE.zero ) THEN
219  info = i
220  RETURN
221  END IF
222  30 CONTINUE
223  ELSE
224 *
225 * Set the scale factors to the reciprocals
226 * of the diagonal elements.
227 *
228  DO 40 i = 1, n
229  s( i ) = one / sqrt( s( i ) )
230  40 CONTINUE
231 *
232 * Compute SCOND = min(S(I)) / max(S(I))
233 *
234  scond = sqrt( smin ) / sqrt( amax )
235  END IF
236  RETURN
237 *
238 * End of CPPEQU
239 *
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
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: