LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dlaic1.f
Go to the documentation of this file.
1*> \brief \b DLAIC1 applies one step of incremental condition estimation.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DLAIC1 + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaic1.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaic1.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaic1.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DLAIC1( JOB, J, X, SEST, W, GAMMA, SESTPR, S, C )
20*
21* .. Scalar Arguments ..
22* INTEGER J, JOB
23* DOUBLE PRECISION C, GAMMA, S, SEST, SESTPR
24* ..
25* .. Array Arguments ..
26* DOUBLE PRECISION W( J ), X( J )
27* ..
28*
29*
30*> \par Purpose:
31* =============
32*>
33*> \verbatim
34*>
35*> DLAIC1 applies one step of incremental condition estimation in
36*> its simplest version:
37*>
38*> Let x, twonorm(x) = 1, be an approximate singular vector of an j-by-j
39*> lower triangular matrix L, such that
40*> twonorm(L*x) = sest
41*> Then DLAIC1 computes sestpr, s, c such that
42*> the vector
43*> [ s*x ]
44*> xhat = [ c ]
45*> is an approximate singular vector of
46*> [ L 0 ]
47*> Lhat = [ w**T gamma ]
48*> in the sense that
49*> twonorm(Lhat*xhat) = sestpr.
50*>
51*> Depending on JOB, an estimate for the largest or smallest singular
52*> value is computed.
53*>
54*> Note that [s c]**T and sestpr**2 is an eigenpair of the system
55*>
56*> diag(sest*sest, 0) + [alpha gamma] * [ alpha ]
57*> [ gamma ]
58*>
59*> where alpha = x**T*w.
60*> \endverbatim
61*
62* Arguments:
63* ==========
64*
65*> \param[in] JOB
66*> \verbatim
67*> JOB is INTEGER
68*> = 1: an estimate for the largest singular value is computed.
69*> = 2: an estimate for the smallest singular value is computed.
70*> \endverbatim
71*>
72*> \param[in] J
73*> \verbatim
74*> J is INTEGER
75*> Length of X and W
76*> \endverbatim
77*>
78*> \param[in] X
79*> \verbatim
80*> X is DOUBLE PRECISION array, dimension (J)
81*> The j-vector x.
82*> \endverbatim
83*>
84*> \param[in] SEST
85*> \verbatim
86*> SEST is DOUBLE PRECISION
87*> Estimated singular value of j by j matrix L
88*> \endverbatim
89*>
90*> \param[in] W
91*> \verbatim
92*> W is DOUBLE PRECISION array, dimension (J)
93*> The j-vector w.
94*> \endverbatim
95*>
96*> \param[in] GAMMA
97*> \verbatim
98*> GAMMA is DOUBLE PRECISION
99*> The diagonal element gamma.
100*> \endverbatim
101*>
102*> \param[out] SESTPR
103*> \verbatim
104*> SESTPR is DOUBLE PRECISION
105*> Estimated singular value of (j+1) by (j+1) matrix Lhat.
106*> \endverbatim
107*>
108*> \param[out] S
109*> \verbatim
110*> S is DOUBLE PRECISION
111*> Sine needed in forming xhat.
112*> \endverbatim
113*>
114*> \param[out] C
115*> \verbatim
116*> C is DOUBLE PRECISION
117*> Cosine needed in forming xhat.
118*> \endverbatim
119*
120* Authors:
121* ========
122*
123*> \author Univ. of Tennessee
124*> \author Univ. of California Berkeley
125*> \author Univ. of Colorado Denver
126*> \author NAG Ltd.
127*
128*> \ingroup laic1
129*
130* =====================================================================
131 SUBROUTINE dlaic1( JOB, J, X, SEST, W, GAMMA, SESTPR, S, C )
132*
133* -- LAPACK auxiliary routine --
134* -- LAPACK is a software package provided by Univ. of Tennessee, --
135* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
136*
137* .. Scalar Arguments ..
138 INTEGER J, JOB
139 DOUBLE PRECISION C, GAMMA, S, SEST, SESTPR
140* ..
141* .. Array Arguments ..
142 DOUBLE PRECISION W( J ), X( J )
143* ..
144*
145* =====================================================================
146*
147* .. Parameters ..
148 DOUBLE PRECISION ZERO, ONE, TWO
149 parameter( zero = 0.0d0, one = 1.0d0, two = 2.0d0 )
150 DOUBLE PRECISION HALF, FOUR
151 parameter( half = 0.5d0, four = 4.0d0 )
152* ..
153* .. Local Scalars ..
154 DOUBLE PRECISION ABSALP, ABSEST, ABSGAM, ALPHA, B, COSINE, EPS,
155 $ NORMA, S1, S2, SINE, T, TEST, TMP, ZETA1, ZETA2
156* ..
157* .. Intrinsic Functions ..
158 INTRINSIC abs, max, sign, sqrt
159* ..
160* .. External Functions ..
161 DOUBLE PRECISION DDOT, DLAMCH
162 EXTERNAL ddot, dlamch
163* ..
164* .. Executable Statements ..
165*
166 eps = dlamch( 'Epsilon' )
167 alpha = ddot( j, x, 1, w, 1 )
168*
169 absalp = abs( alpha )
170 absgam = abs( gamma )
171 absest = abs( sest )
172*
173 IF( job.EQ.1 ) THEN
174*
175* Estimating largest singular value
176*
177* special cases
178*
179 IF( sest.EQ.zero ) THEN
180 s1 = max( absgam, absalp )
181 IF( s1.EQ.zero ) THEN
182 s = zero
183 c = one
184 sestpr = zero
185 ELSE
186 s = alpha / s1
187 c = gamma / s1
188 tmp = sqrt( s*s+c*c )
189 s = s / tmp
190 c = c / tmp
191 sestpr = s1*tmp
192 END IF
193 RETURN
194 ELSE IF( absgam.LE.eps*absest ) THEN
195 s = one
196 c = zero
197 tmp = max( absest, absalp )
198 s1 = absest / tmp
199 s2 = absalp / tmp
200 sestpr = tmp*sqrt( s1*s1+s2*s2 )
201 RETURN
202 ELSE IF( absalp.LE.eps*absest ) THEN
203 s1 = absgam
204 s2 = absest
205 IF( s1.LE.s2 ) THEN
206 s = one
207 c = zero
208 sestpr = s2
209 ELSE
210 s = zero
211 c = one
212 sestpr = s1
213 END IF
214 RETURN
215 ELSE IF( absest.LE.eps*absalp .OR. absest.LE.eps*absgam ) THEN
216 s1 = absgam
217 s2 = absalp
218 IF( s1.LE.s2 ) THEN
219 tmp = s1 / s2
220 s = sqrt( one+tmp*tmp )
221 sestpr = s2*s
222 c = ( gamma / s2 ) / s
223 s = sign( one, alpha ) / s
224 ELSE
225 tmp = s2 / s1
226 c = sqrt( one+tmp*tmp )
227 sestpr = s1*c
228 s = ( alpha / s1 ) / c
229 c = sign( one, gamma ) / c
230 END IF
231 RETURN
232 ELSE
233*
234* normal case
235*
236 zeta1 = alpha / absest
237 zeta2 = gamma / absest
238*
239 b = ( one-zeta1*zeta1-zeta2*zeta2 )*half
240 c = zeta1*zeta1
241 IF( b.GT.zero ) THEN
242 t = c / ( b+sqrt( b*b+c ) )
243 ELSE
244 t = sqrt( b*b+c ) - b
245 END IF
246*
247 sine = -zeta1 / t
248 cosine = -zeta2 / ( one+t )
249 tmp = sqrt( sine*sine+cosine*cosine )
250 s = sine / tmp
251 c = cosine / tmp
252 sestpr = sqrt( t+one )*absest
253 RETURN
254 END IF
255*
256 ELSE IF( job.EQ.2 ) THEN
257*
258* Estimating smallest singular value
259*
260* special cases
261*
262 IF( sest.EQ.zero ) THEN
263 sestpr = zero
264 IF( max( absgam, absalp ).EQ.zero ) THEN
265 sine = one
266 cosine = zero
267 ELSE
268 sine = -gamma
269 cosine = alpha
270 END IF
271 s1 = max( abs( sine ), abs( cosine ) )
272 s = sine / s1
273 c = cosine / s1
274 tmp = sqrt( s*s+c*c )
275 s = s / tmp
276 c = c / tmp
277 RETURN
278 ELSE IF( absgam.LE.eps*absest ) THEN
279 s = zero
280 c = one
281 sestpr = absgam
282 RETURN
283 ELSE IF( absalp.LE.eps*absest ) THEN
284 s1 = absgam
285 s2 = absest
286 IF( s1.LE.s2 ) THEN
287 s = zero
288 c = one
289 sestpr = s1
290 ELSE
291 s = one
292 c = zero
293 sestpr = s2
294 END IF
295 RETURN
296 ELSE IF( absest.LE.eps*absalp .OR. absest.LE.eps*absgam ) THEN
297 s1 = absgam
298 s2 = absalp
299 IF( s1.LE.s2 ) THEN
300 tmp = s1 / s2
301 c = sqrt( one+tmp*tmp )
302 sestpr = absest*( tmp / c )
303 s = -( gamma / s2 ) / c
304 c = sign( one, alpha ) / c
305 ELSE
306 tmp = s2 / s1
307 s = sqrt( one+tmp*tmp )
308 sestpr = absest / s
309 c = ( alpha / s1 ) / s
310 s = -sign( one, gamma ) / s
311 END IF
312 RETURN
313 ELSE
314*
315* normal case
316*
317 zeta1 = alpha / absest
318 zeta2 = gamma / absest
319*
320 norma = max( one+zeta1*zeta1+abs( zeta1*zeta2 ),
321 $ abs( zeta1*zeta2 )+zeta2*zeta2 )
322*
323* See if root is closer to zero or to ONE
324*
325 test = one + two*( zeta1-zeta2 )*( zeta1+zeta2 )
326 IF( test.GE.zero ) THEN
327*
328* root is close to zero, compute directly
329*
330 b = ( zeta1*zeta1+zeta2*zeta2+one )*half
331 c = zeta2*zeta2
332 t = c / ( b+sqrt( abs( b*b-c ) ) )
333 sine = zeta1 / ( one-t )
334 cosine = -zeta2 / t
335 sestpr = sqrt( t+four*eps*eps*norma )*absest
336 ELSE
337*
338* root is closer to ONE, shift by that amount
339*
340 b = ( zeta2*zeta2+zeta1*zeta1-one )*half
341 c = zeta1*zeta1
342 IF( b.GE.zero ) THEN
343 t = -c / ( b+sqrt( b*b+c ) )
344 ELSE
345 t = b - sqrt( b*b+c )
346 END IF
347 sine = -zeta1 / t
348 cosine = -zeta2 / ( one+t )
349 sestpr = sqrt( one+t+four*eps*eps*norma )*absest
350 END IF
351 tmp = sqrt( sine*sine+cosine*cosine )
352 s = sine / tmp
353 c = cosine / tmp
354 RETURN
355*
356 END IF
357 END IF
358 RETURN
359*
360* End of DLAIC1
361*
362 END
subroutine dlaic1(job, j, x, sest, w, gamma, sestpr, s, c)
DLAIC1 applies one step of incremental condition estimation.
Definition dlaic1.f:132