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

◆ slaneg()

integer function slaneg ( integer n,
real, dimension( * ) d,
real, dimension( * ) lld,
real sigma,
real pivmin,
integer r )

SLANEG computes the Sturm count.

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

Purpose:
!>
!> SLANEG computes the Sturm count, the number of negative pivots
!> encountered while factoring tridiagonal T - sigma I = L D L^T.
!> This implementation works directly on the factors without forming
!> the tridiagonal matrix T.  The Sturm count is also the number of
!> eigenvalues of T less than sigma.
!>
!> This routine is called from SLARRB.
!>
!> The current routine does not use the PIVMIN parameter but rather
!> requires IEEE-754 propagation of Infinities and NaNs.  This
!> routine also has no input range restrictions but does require
!> default exception handling such that x/0 produces Inf when x is
!> non-zero, and Inf/Inf produces NaN.  For more information, see:
!>
!>   Marques, Riedy, and Voemel,  SIAM Journal on
!>   Scientific Computing, v28, n5, 2006.  DOI 10.1137/050641624
!>   (Tech report version in LAWN 172 with the same title.)
!> 
Parameters
[in]N
!>          N is INTEGER
!>          The order of the matrix.
!> 
[in]D
!>          D is REAL array, dimension (N)
!>          The N diagonal elements of the diagonal matrix D.
!> 
[in]LLD
!>          LLD is REAL array, dimension (N-1)
!>          The (N-1) elements L(i)*L(i)*D(i).
!> 
[in]SIGMA
!>          SIGMA is REAL
!>          Shift amount in T - sigma I = L D L^T.
!> 
[in]PIVMIN
!>          PIVMIN is REAL
!>          The minimum pivot in the Sturm sequence.  May be used
!>          when zero pivots are encountered on non-IEEE-754
!>          architectures.
!> 
[in]R
!>          R is INTEGER
!>          The twist index for the twisted factorization that is used
!>          for the negcount.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Contributors:
Osni Marques, LBNL/NERSC, USA
Christof Voemel, University of California, Berkeley, USA
Jason Riedy, University of California, Berkeley, USA

Definition at line 115 of file slaneg.f.

116*
117* -- LAPACK auxiliary routine --
118* -- LAPACK is a software package provided by Univ. of Tennessee, --
119* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
120*
121* .. Scalar Arguments ..
122 INTEGER N, R
123 REAL PIVMIN, SIGMA
124* ..
125* .. Array Arguments ..
126 REAL D( * ), LLD( * )
127* ..
128*
129* =====================================================================
130*
131* .. Parameters ..
132 REAL ZERO, ONE
133 parameter( zero = 0.0e0, one = 1.0e0 )
134* Some architectures propagate Infinities and NaNs very slowly, so
135* the code computes counts in BLKLEN chunks. Then a NaN can
136* propagate at most BLKLEN columns before being detected. This is
137* not a general tuning parameter; it needs only to be just large
138* enough that the overhead is tiny in common cases.
139 INTEGER BLKLEN
140 parameter( blklen = 128 )
141* ..
142* .. Local Scalars ..
143 INTEGER BJ, J, NEG1, NEG2, NEGCNT
144 REAL BSAV, DMINUS, DPLUS, GAMMA, P, T, TMP
145 LOGICAL SAWNAN
146* ..
147* .. Intrinsic Functions ..
148 INTRINSIC min, max
149* ..
150* .. External Functions ..
151 LOGICAL SISNAN
152 EXTERNAL sisnan
153* ..
154* .. Executable Statements ..
155
156 negcnt = 0
157
158* I) upper part: L D L^T - SIGMA I = L+ D+ L+^T
159 t = -sigma
160 DO 210 bj = 1, r-1, blklen
161 neg1 = 0
162 bsav = t
163 DO 21 j = bj, min(bj+blklen-1, r-1)
164 dplus = d( j ) + t
165 IF( dplus.LT.zero ) neg1 = neg1 + 1
166 tmp = t / dplus
167 t = tmp * lld( j ) - sigma
168 21 CONTINUE
169 sawnan = sisnan( t )
170* Run a slower version of the above loop if a NaN is detected.
171* A NaN should occur only with a zero pivot after an infinite
172* pivot. In that case, substituting 1 for T/DPLUS is the
173* correct limit.
174 IF( sawnan ) THEN
175 neg1 = 0
176 t = bsav
177 DO 22 j = bj, min(bj+blklen-1, r-1)
178 dplus = d( j ) + t
179 IF( dplus.LT.zero ) neg1 = neg1 + 1
180 tmp = t / dplus
181 IF (sisnan(tmp)) tmp = one
182 t = tmp * lld(j) - sigma
183 22 CONTINUE
184 END IF
185 negcnt = negcnt + neg1
186 210 CONTINUE
187*
188* II) lower part: L D L^T - SIGMA I = U- D- U-^T
189 p = d( n ) - sigma
190 DO 230 bj = n-1, r, -blklen
191 neg2 = 0
192 bsav = p
193 DO 23 j = bj, max(bj-blklen+1, r), -1
194 dminus = lld( j ) + p
195 IF( dminus.LT.zero ) neg2 = neg2 + 1
196 tmp = p / dminus
197 p = tmp * d( j ) - sigma
198 23 CONTINUE
199 sawnan = sisnan( p )
200* As above, run a slower version that substitutes 1 for Inf/Inf.
201*
202 IF( sawnan ) THEN
203 neg2 = 0
204 p = bsav
205 DO 24 j = bj, max(bj-blklen+1, r), -1
206 dminus = lld( j ) + p
207 IF( dminus.LT.zero ) neg2 = neg2 + 1
208 tmp = p / dminus
209 IF (sisnan(tmp)) tmp = one
210 p = tmp * d(j) - sigma
211 24 CONTINUE
212 END IF
213 negcnt = negcnt + neg2
214 230 CONTINUE
215*
216* III) Twist index
217* T was shifted by SIGMA initially.
218 gamma = (t + sigma) + p
219 IF( gamma.LT.zero ) negcnt = negcnt+1
220
221 slaneg = negcnt
logical function sisnan(sin)
SISNAN tests input for NaN.
Definition sisnan.f:57
integer function slaneg(n, d, lld, sigma, pivmin, r)
SLANEG computes the Sturm count.
Definition slaneg.f:116
Here is the call graph for this function:
Here is the caller graph for this function: