LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dlasv2.f
Go to the documentation of this file.
1*> \brief \b DLASV2 computes the singular value decomposition of a 2-by-2 triangular matrix.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DLASV2 + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlasv2.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlasv2.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlasv2.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DLASV2( F, G, H, SSMIN, SSMAX, SNR, CSR, SNL, CSL )
20*
21* .. Scalar Arguments ..
22* DOUBLE PRECISION CSL, CSR, F, G, H, SNL, SNR, SSMAX, SSMIN
23* ..
24*
25*
26*> \par Purpose:
27* =============
28*>
29*> \verbatim
30*>
31*> DLASV2 computes the singular value decomposition of a 2-by-2
32*> triangular matrix
33*> [ F G ]
34*> [ 0 H ].
35*> On return, abs(SSMAX) is the larger singular value, abs(SSMIN) is the
36*> smaller singular value, and (CSL,SNL) and (CSR,SNR) are the left and
37*> right singular vectors for abs(SSMAX), giving the decomposition
38*>
39*> [ CSL SNL ] [ F G ] [ CSR -SNR ] = [ SSMAX 0 ]
40*> [-SNL CSL ] [ 0 H ] [ SNR CSR ] [ 0 SSMIN ].
41*> \endverbatim
42*
43* Arguments:
44* ==========
45*
46*> \param[in] F
47*> \verbatim
48*> F is DOUBLE PRECISION
49*> The (1,1) element of the 2-by-2 matrix.
50*> \endverbatim
51*>
52*> \param[in] G
53*> \verbatim
54*> G is DOUBLE PRECISION
55*> The (1,2) element of the 2-by-2 matrix.
56*> \endverbatim
57*>
58*> \param[in] H
59*> \verbatim
60*> H is DOUBLE PRECISION
61*> The (2,2) element of the 2-by-2 matrix.
62*> \endverbatim
63*>
64*> \param[out] SSMIN
65*> \verbatim
66*> SSMIN is DOUBLE PRECISION
67*> abs(SSMIN) is the smaller singular value.
68*> \endverbatim
69*>
70*> \param[out] SSMAX
71*> \verbatim
72*> SSMAX is DOUBLE PRECISION
73*> abs(SSMAX) is the larger singular value.
74*> \endverbatim
75*>
76*> \param[out] SNL
77*> \verbatim
78*> SNL is DOUBLE PRECISION
79*> \endverbatim
80*>
81*> \param[out] CSL
82*> \verbatim
83*> CSL is DOUBLE PRECISION
84*> The vector (CSL, SNL) is a unit left singular vector for the
85*> singular value abs(SSMAX).
86*> \endverbatim
87*>
88*> \param[out] SNR
89*> \verbatim
90*> SNR is DOUBLE PRECISION
91*> \endverbatim
92*>
93*> \param[out] CSR
94*> \verbatim
95*> CSR is DOUBLE PRECISION
96*> The vector (CSR, SNR) is a unit right singular vector for the
97*> singular value abs(SSMAX).
98*> \endverbatim
99*
100* Authors:
101* ========
102*
103*> \author Univ. of Tennessee
104*> \author Univ. of California Berkeley
105*> \author Univ. of Colorado Denver
106*> \author NAG Ltd.
107*
108*> \ingroup lasv2
109*
110*> \par Further Details:
111* =====================
112*>
113*> \verbatim
114*>
115*> Any input parameter may be aliased with any output parameter.
116*>
117*> Barring over/underflow and assuming a guard digit in subtraction, all
118*> output quantities are correct to within a few units in the last
119*> place (ulps).
120*>
121*> In IEEE arithmetic, the code works correctly if one matrix element is
122*> infinite.
123*>
124*> Overflow will not occur unless the largest singular value itself
125*> overflows or is within a few ulps of overflow.
126*>
127*> Underflow is harmless if underflow is gradual. Otherwise, results
128*> may correspond to a matrix modified by perturbations of size near
129*> the underflow threshold.
130*> \endverbatim
131*>
132* =====================================================================
133 SUBROUTINE dlasv2( F, G, H, SSMIN, SSMAX, SNR, CSR, SNL, CSL )
134*
135* -- LAPACK auxiliary routine --
136* -- LAPACK is a software package provided by Univ. of Tennessee, --
137* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
138*
139* .. Scalar Arguments ..
140 DOUBLE PRECISION CSL, CSR, F, G, H, SNL, SNR, SSMAX, SSMIN
141* ..
142*
143* =====================================================================
144*
145* .. Parameters ..
146 DOUBLE PRECISION ZERO
147 parameter( zero = 0.0d0 )
148 DOUBLE PRECISION HALF
149 parameter( half = 0.5d0 )
150 DOUBLE PRECISION ONE
151 parameter( one = 1.0d0 )
152 DOUBLE PRECISION TWO
153 parameter( two = 2.0d0 )
154 DOUBLE PRECISION FOUR
155 parameter( four = 4.0d0 )
156* ..
157* .. Local Scalars ..
158 LOGICAL GASMAL, SWAP
159 INTEGER PMAX
160 DOUBLE PRECISION A, CLT, CRT, D, FA, FT, GA, GT, HA, HT, L, M,
161 $ MM, R, S, SLT, SRT, T, TEMP, TSIGN, TT
162* ..
163* .. Intrinsic Functions ..
164 INTRINSIC abs, sign, sqrt
165* ..
166* .. External Functions ..
167 DOUBLE PRECISION DLAMCH
168 EXTERNAL dlamch
169* ..
170* .. Executable Statements ..
171*
172 ft = f
173 fa = abs( ft )
174 ht = h
175 ha = abs( h )
176*
177* PMAX points to the maximum absolute element of matrix
178* PMAX = 1 if F largest in absolute values
179* PMAX = 2 if G largest in absolute values
180* PMAX = 3 if H largest in absolute values
181*
182 pmax = 1
183 swap = ( ha.GT.fa )
184 IF( swap ) THEN
185 pmax = 3
186 temp = ft
187 ft = ht
188 ht = temp
189 temp = fa
190 fa = ha
191 ha = temp
192*
193* Now FA .ge. HA
194*
195 END IF
196 gt = g
197 ga = abs( gt )
198 IF( ga.EQ.zero ) THEN
199*
200* Diagonal matrix
201*
202 ssmin = ha
203 ssmax = fa
204 clt = one
205 crt = one
206 slt = zero
207 srt = zero
208 ELSE
209 gasmal = .true.
210 IF( ga.GT.fa ) THEN
211 pmax = 2
212 IF( ( fa / ga ).LT.dlamch( 'EPS' ) ) THEN
213*
214* Case of very large GA
215*
216 gasmal = .false.
217 ssmax = ga
218 IF( ha.GT.one ) THEN
219 ssmin = fa / ( ga / ha )
220 ELSE
221 ssmin = ( fa / ga )*ha
222 END IF
223 clt = one
224 slt = ht / gt
225 srt = one
226 crt = ft / gt
227 END IF
228 END IF
229 IF( gasmal ) THEN
230*
231* Normal case
232*
233 d = fa - ha
234 IF( d.EQ.fa ) THEN
235*
236* Copes with infinite F or H
237*
238 l = one
239 ELSE
240 l = d / fa
241 END IF
242*
243* Note that 0 .le. L .le. 1
244*
245 m = gt / ft
246*
247* Note that abs(M) .le. 1/macheps
248*
249 t = two - l
250*
251* Note that T .ge. 1
252*
253 mm = m*m
254 tt = t*t
255 s = sqrt( tt+mm )
256*
257* Note that 1 .le. S .le. 1 + 1/macheps
258*
259 IF( l.EQ.zero ) THEN
260 r = abs( m )
261 ELSE
262 r = sqrt( l*l+mm )
263 END IF
264*
265* Note that 0 .le. R .le. 1 + 1/macheps
266*
267 a = half*( s+r )
268*
269* Note that 1 .le. A .le. 1 + abs(M)
270*
271 ssmin = ha / a
272 ssmax = fa*a
273 IF( mm.EQ.zero ) THEN
274*
275* Note that M is very tiny
276*
277 IF( l.EQ.zero ) THEN
278 t = sign( two, ft )*sign( one, gt )
279 ELSE
280 t = gt / sign( d, ft ) + m / t
281 END IF
282 ELSE
283 t = ( m / ( s+t )+m / ( r+l ) )*( one+a )
284 END IF
285 l = sqrt( t*t+four )
286 crt = two / l
287 srt = t / l
288 clt = ( crt+srt*m ) / a
289 slt = ( ht / ft )*srt / a
290 END IF
291 END IF
292 IF( swap ) THEN
293 csl = srt
294 snl = crt
295 csr = slt
296 snr = clt
297 ELSE
298 csl = clt
299 snl = slt
300 csr = crt
301 snr = srt
302 END IF
303*
304* Correct signs of SSMAX and SSMIN
305*
306 IF( pmax.EQ.1 )
307 $ tsign = sign( one, csr )*sign( one, csl )*sign( one, f )
308 IF( pmax.EQ.2 )
309 $ tsign = sign( one, snr )*sign( one, csl )*sign( one, g )
310 IF( pmax.EQ.3 )
311 $ tsign = sign( one, snr )*sign( one, snl )*sign( one, h )
312 ssmax = sign( ssmax, tsign )
313 ssmin = sign( ssmin, tsign*sign( one, f )*sign( one, h ) )
314 RETURN
315*
316* End of DLASV2
317*
318 END
subroutine dlasv2(f, g, h, ssmin, ssmax, snr, csr, snl, csl)
DLASV2 computes the singular value decomposition of a 2-by-2 triangular matrix.
Definition dlasv2.f:134