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

◆ slasv2()

subroutine slasv2 ( real f,
real g,
real h,
real ssmin,
real ssmax,
real snr,
real csr,
real snl,
real csl )

SLASV2 computes the singular value decomposition of a 2-by-2 triangular matrix.

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

Purpose:
!>
!> SLASV2 computes the singular value decomposition of a 2-by-2
!> triangular matrix
!>    [  F   G  ]
!>    [  0   H  ].
!> On return, abs(SSMAX) is the larger singular value, abs(SSMIN) is the
!> smaller singular value, and (CSL,SNL) and (CSR,SNR) are the left and
!> right singular vectors for abs(SSMAX), giving the decomposition
!>
!>    [ CSL  SNL ] [  F   G  ] [ CSR -SNR ]  =  [ SSMAX   0   ]
!>    [-SNL  CSL ] [  0   H  ] [ SNR  CSR ]     [  0    SSMIN ].
!> 
Parameters
[in]F
!>          F is REAL
!>          The (1,1) element of the 2-by-2 matrix.
!> 
[in]G
!>          G is REAL
!>          The (1,2) element of the 2-by-2 matrix.
!> 
[in]H
!>          H is REAL
!>          The (2,2) element of the 2-by-2 matrix.
!> 
[out]SSMIN
!>          SSMIN is REAL
!>          abs(SSMIN) is the smaller singular value.
!> 
[out]SSMAX
!>          SSMAX is REAL
!>          abs(SSMAX) is the larger singular value.
!> 
[out]SNL
!>          SNL is REAL
!> 
[out]CSL
!>          CSL is REAL
!>          The vector (CSL, SNL) is a unit left singular vector for the
!>          singular value abs(SSMAX).
!> 
[out]SNR
!>          SNR is REAL
!> 
[out]CSR
!>          CSR is REAL
!>          The vector (CSR, SNR) is a unit right singular vector for the
!>          singular value abs(SSMAX).
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
!>
!>  Any input parameter may be aliased with any output parameter.
!>
!>  Barring over/underflow and assuming a guard digit in subtraction, all
!>  output quantities are correct to within a few units in the last
!>  place (ulps).
!>
!>  In IEEE arithmetic, the code works correctly if one matrix element is
!>  infinite.
!>
!>  Overflow will not occur unless the largest singular value itself
!>  overflows or is within a few ulps of overflow.
!>
!>  Underflow is harmless if underflow is gradual. Otherwise, results
!>  may correspond to a matrix modified by perturbations of size near
!>  the underflow threshold.
!> 

Definition at line 133 of file slasv2.f.

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 REAL CSL, CSR, F, G, H, SNL, SNR, SSMAX, SSMIN
141* ..
142*
143* =====================================================================
144*
145* .. Parameters ..
146 REAL ZERO
147 parameter( zero = 0.0e0 )
148 REAL HALF
149 parameter( half = 0.5e0 )
150 REAL ONE
151 parameter( one = 1.0e0 )
152 REAL TWO
153 parameter( two = 2.0e0 )
154 REAL FOUR
155 parameter( four = 4.0e0 )
156* ..
157* .. Local Scalars ..
158 LOGICAL GASMAL, SWAP
159 INTEGER PMAX
160 REAL 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 REAL SLAMCH
168 EXTERNAL slamch
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.slamch( '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 SLASV2
317*
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
Here is the caller graph for this function: