LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
sppequ.f
Go to the documentation of this file.
1*> \brief \b SPPEQU
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SPPEQU + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sppequ.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sppequ.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sppequ.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SPPEQU( UPLO, N, AP, S, SCOND, AMAX, INFO )
20*
21* .. Scalar Arguments ..
22* CHARACTER UPLO
23* INTEGER INFO, N
24* REAL AMAX, SCOND
25* ..
26* .. Array Arguments ..
27* REAL AP( * ), S( * )
28* ..
29*
30*
31*> \par Purpose:
32* =============
33*>
34*> \verbatim
35*>
36*> SPPEQU computes row and column scalings intended to equilibrate a
37*> symmetric positive definite matrix A in packed storage and reduce
38*> its condition number (with respect to the two-norm). S contains the
39*> scale factors, S(i)=1/sqrt(A(i,i)), chosen so that the scaled matrix
40*> B with elements B(i,j)=S(i)*A(i,j)*S(j) has ones on the diagonal.
41*> This choice of S puts the condition number of B within a factor N of
42*> the smallest possible condition number over all possible diagonal
43*> scalings.
44*> \endverbatim
45*
46* Arguments:
47* ==========
48*
49*> \param[in] UPLO
50*> \verbatim
51*> UPLO is CHARACTER*1
52*> = 'U': Upper triangle of A is stored;
53*> = 'L': Lower triangle of A is stored.
54*> \endverbatim
55*>
56*> \param[in] N
57*> \verbatim
58*> N is INTEGER
59*> The order of the matrix A. N >= 0.
60*> \endverbatim
61*>
62*> \param[in] AP
63*> \verbatim
64*> AP is REAL array, dimension (N*(N+1)/2)
65*> The upper or lower triangle of the symmetric matrix A, packed
66*> columnwise in a linear array. The j-th column of A is stored
67*> in the array AP as follows:
68*> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
69*> if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
70*> \endverbatim
71*>
72*> \param[out] S
73*> \verbatim
74*> S is REAL array, dimension (N)
75*> If INFO = 0, S contains the scale factors for A.
76*> \endverbatim
77*>
78*> \param[out] SCOND
79*> \verbatim
80*> SCOND is REAL
81*> If INFO = 0, S contains the ratio of the smallest S(i) to
82*> the largest S(i). If SCOND >= 0.1 and AMAX is neither too
83*> large nor too small, it is not worth scaling by S.
84*> \endverbatim
85*>
86*> \param[out] AMAX
87*> \verbatim
88*> AMAX is REAL
89*> Absolute value of largest matrix element. If AMAX is very
90*> close to overflow or very close to underflow, the matrix
91*> should be scaled.
92*> \endverbatim
93*>
94*> \param[out] INFO
95*> \verbatim
96*> INFO is INTEGER
97*> = 0: successful exit
98*> < 0: if INFO = -i, the i-th argument had an illegal value
99*> > 0: if INFO = i, the i-th diagonal element is nonpositive.
100*> \endverbatim
101*
102* Authors:
103* ========
104*
105*> \author Univ. of Tennessee
106*> \author Univ. of California Berkeley
107*> \author Univ. of Colorado Denver
108*> \author NAG Ltd.
109*
110*> \ingroup ppequ
111*
112* =====================================================================
113 SUBROUTINE sppequ( UPLO, N, AP, S, SCOND, AMAX, INFO )
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*
233 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sppequ(uplo, n, ap, s, scond, amax, info)
SPPEQU
Definition sppequ.f:114