LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ sppequ()

subroutine sppequ ( character uplo,
integer n,
real, dimension( * ) ap,
real, dimension( * ) s,
real scond,
real amax,
integer info )

SPPEQU

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

Purpose:
!>
!> SPPEQU computes row and column scalings intended to equilibrate a
!> symmetric 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 REAL array, dimension (N*(N+1)/2)
!>          The upper or lower triangle of the symmetric 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.

Definition at line 113 of file sppequ.f.

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