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

◆ dlags2()

subroutine dlags2 ( logical upper,
double precision a1,
double precision a2,
double precision a3,
double precision b1,
double precision b2,
double precision b3,
double precision csu,
double precision snu,
double precision csv,
double precision snv,
double precision csq,
double precision snq )

DLAGS2 computes 2-by-2 orthogonal matrices U, V, and Q, and applies them to matrices A and B such that the rows of the transformed A and B are parallel.

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

Purpose:
!>
!> DLAGS2 computes 2-by-2 orthogonal matrices U, V and Q, such
!> that if ( UPPER ) then
!>
!>           U**T *A*Q = U**T *( A1 A2 )*Q = ( x  0  )
!>                             ( 0  A3 )     ( x  x  )
!> and
!>           V**T*B*Q = V**T *( B1 B2 )*Q = ( x  0  )
!>                            ( 0  B3 )     ( x  x  )
!>
!> or if ( .NOT.UPPER ) then
!>
!>           U**T *A*Q = U**T *( A1 0  )*Q = ( x  x  )
!>                             ( A2 A3 )     ( 0  x  )
!> and
!>           V**T*B*Q = V**T*( B1 0  )*Q = ( x  x  )
!>                           ( B2 B3 )     ( 0  x  )
!>
!> The rows of the transformed A and B are parallel, where
!>
!>   U = (  CSU  SNU ), V = (  CSV SNV ), Q = (  CSQ   SNQ )
!>       ( -SNU  CSU )      ( -SNV CSV )      ( -SNQ   CSQ )
!>
!> Z**T denotes the transpose of Z.
!>
!> 
Parameters
[in]UPPER
!>          UPPER is LOGICAL
!>          = .TRUE.: the input matrices A and B are upper triangular.
!>          = .FALSE.: the input matrices A and B are lower triangular.
!> 
[in]A1
!>          A1 is DOUBLE PRECISION
!> 
[in]A2
!>          A2 is DOUBLE PRECISION
!> 
[in]A3
!>          A3 is DOUBLE PRECISION
!>          On entry, A1, A2 and A3 are elements of the input 2-by-2
!>          upper (lower) triangular matrix A.
!> 
[in]B1
!>          B1 is DOUBLE PRECISION
!> 
[in]B2
!>          B2 is DOUBLE PRECISION
!> 
[in]B3
!>          B3 is DOUBLE PRECISION
!>          On entry, B1, B2 and B3 are elements of the input 2-by-2
!>          upper (lower) triangular matrix B.
!> 
[out]CSU
!>          CSU is DOUBLE PRECISION
!> 
[out]SNU
!>          SNU is DOUBLE PRECISION
!>          The desired orthogonal matrix U.
!> 
[out]CSV
!>          CSV is DOUBLE PRECISION
!> 
[out]SNV
!>          SNV is DOUBLE PRECISION
!>          The desired orthogonal matrix V.
!> 
[out]CSQ
!>          CSQ is DOUBLE PRECISION
!> 
[out]SNQ
!>          SNQ is DOUBLE PRECISION
!>          The desired orthogonal matrix Q.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 148 of file dlags2.f.

151*
152* -- LAPACK auxiliary routine --
153* -- LAPACK is a software package provided by Univ. of Tennessee, --
154* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
155*
156* .. Scalar Arguments ..
157 LOGICAL UPPER
158 DOUBLE PRECISION A1, A2, A3, B1, B2, B3, CSQ, CSU, CSV, SNQ,
159 $ SNU, SNV
160* ..
161*
162* =====================================================================
163*
164* .. Parameters ..
165 DOUBLE PRECISION ZERO
166 parameter( zero = 0.0d+0 )
167* ..
168* .. Local Scalars ..
169 DOUBLE PRECISION A, AUA11, AUA12, AUA21, AUA22, AVB11, AVB12,
170 $ AVB21, AVB22, B, C, CSL, CSR, D, R, S1, S2,
171 $ SNL, SNR, UA11, UA11R, UA12, UA21, UA22, UA22R,
172 $ VB11, VB11R, VB12, VB21, VB22, VB22R
173* ..
174* .. External Subroutines ..
175 EXTERNAL dlartg, dlasv2
176* ..
177* .. Intrinsic Functions ..
178 INTRINSIC abs
179* ..
180* .. Executable Statements ..
181*
182 IF( upper ) THEN
183*
184* Input matrices A and B are upper triangular matrices
185*
186* Form matrix C = A*adj(B) = ( a b )
187* ( 0 d )
188*
189 a = a1*b3
190 d = a3*b1
191 b = a2*b1 - a1*b2
192*
193* The SVD of real 2-by-2 triangular C
194*
195* ( CSL -SNL )*( A B )*( CSR SNR ) = ( R 0 )
196* ( SNL CSL ) ( 0 D ) ( -SNR CSR ) ( 0 T )
197*
198 CALL dlasv2( a, b, d, s1, s2, snr, csr, snl, csl )
199*
200 IF( abs( csl ).GE.abs( snl ) .OR. abs( csr ).GE.abs( snr ) )
201 $ THEN
202*
203* Compute the (1,1) and (1,2) elements of U**T *A and V**T *B,
204* and (1,2) element of |U|**T *|A| and |V|**T *|B|.
205*
206 ua11r = csl*a1
207 ua12 = csl*a2 + snl*a3
208*
209 vb11r = csr*b1
210 vb12 = csr*b2 + snr*b3
211*
212 aua12 = abs( csl )*abs( a2 ) + abs( snl )*abs( a3 )
213 avb12 = abs( csr )*abs( b2 ) + abs( snr )*abs( b3 )
214*
215* zero (1,2) elements of U**T *A and V**T *B
216*
217 IF( ( abs( ua11r )+abs( ua12 ) ).NE.zero ) THEN
218 IF( aua12 / ( abs( ua11r )+abs( ua12 ) ).LE.avb12 /
219 $ ( abs( vb11r )+abs( vb12 ) ) ) THEN
220 CALL dlartg( -ua11r, ua12, csq, snq, r )
221 ELSE
222 CALL dlartg( -vb11r, vb12, csq, snq, r )
223 END IF
224 ELSE
225 CALL dlartg( -vb11r, vb12, csq, snq, r )
226 END IF
227*
228 csu = csl
229 snu = -snl
230 csv = csr
231 snv = -snr
232*
233 ELSE
234*
235* Compute the (2,1) and (2,2) elements of U**T *A and V**T *B,
236* and (2,2) element of |U|**T *|A| and |V|**T *|B|.
237*
238 ua21 = -snl*a1
239 ua22 = -snl*a2 + csl*a3
240*
241 vb21 = -snr*b1
242 vb22 = -snr*b2 + csr*b3
243*
244 aua22 = abs( snl )*abs( a2 ) + abs( csl )*abs( a3 )
245 avb22 = abs( snr )*abs( b2 ) + abs( csr )*abs( b3 )
246*
247* zero (2,2) elements of U**T*A and V**T*B, and then swap.
248*
249 IF( ( abs( ua21 )+abs( ua22 ) ).NE.zero ) THEN
250 IF( aua22 / ( abs( ua21 )+abs( ua22 ) ).LE.avb22 /
251 $ ( abs( vb21 )+abs( vb22 ) ) ) THEN
252 CALL dlartg( -ua21, ua22, csq, snq, r )
253 ELSE
254 CALL dlartg( -vb21, vb22, csq, snq, r )
255 END IF
256 ELSE
257 CALL dlartg( -vb21, vb22, csq, snq, r )
258 END IF
259*
260 csu = snl
261 snu = csl
262 csv = snr
263 snv = csr
264*
265 END IF
266*
267 ELSE
268*
269* Input matrices A and B are lower triangular matrices
270*
271* Form matrix C = A*adj(B) = ( a 0 )
272* ( c d )
273*
274 a = a1*b3
275 d = a3*b1
276 c = a2*b3 - a3*b2
277*
278* The SVD of real 2-by-2 triangular C
279*
280* ( CSL -SNL )*( A 0 )*( CSR SNR ) = ( R 0 )
281* ( SNL CSL ) ( C D ) ( -SNR CSR ) ( 0 T )
282*
283 CALL dlasv2( a, c, d, s1, s2, snr, csr, snl, csl )
284*
285 IF( abs( csr ).GE.abs( snr ) .OR. abs( csl ).GE.abs( snl ) )
286 $ THEN
287*
288* Compute the (2,1) and (2,2) elements of U**T *A and V**T *B,
289* and (2,1) element of |U|**T *|A| and |V|**T *|B|.
290*
291 ua21 = -snr*a1 + csr*a2
292 ua22r = csr*a3
293*
294 vb21 = -snl*b1 + csl*b2
295 vb22r = csl*b3
296*
297 aua21 = abs( snr )*abs( a1 ) + abs( csr )*abs( a2 )
298 avb21 = abs( snl )*abs( b1 ) + abs( csl )*abs( b2 )
299*
300* zero (2,1) elements of U**T *A and V**T *B.
301*
302 IF( ( abs( ua21 )+abs( ua22r ) ).NE.zero ) THEN
303 IF( aua21 / ( abs( ua21 )+abs( ua22r ) ).LE.avb21 /
304 $ ( abs( vb21 )+abs( vb22r ) ) ) THEN
305 CALL dlartg( ua22r, ua21, csq, snq, r )
306 ELSE
307 CALL dlartg( vb22r, vb21, csq, snq, r )
308 END IF
309 ELSE
310 CALL dlartg( vb22r, vb21, csq, snq, r )
311 END IF
312*
313 csu = csr
314 snu = -snr
315 csv = csl
316 snv = -snl
317*
318 ELSE
319*
320* Compute the (1,1) and (1,2) elements of U**T *A and V**T *B,
321* and (1,1) element of |U|**T *|A| and |V|**T *|B|.
322*
323 ua11 = csr*a1 + snr*a2
324 ua12 = snr*a3
325*
326 vb11 = csl*b1 + snl*b2
327 vb12 = snl*b3
328*
329 aua11 = abs( csr )*abs( a1 ) + abs( snr )*abs( a2 )
330 avb11 = abs( csl )*abs( b1 ) + abs( snl )*abs( b2 )
331*
332* zero (1,1) elements of U**T*A and V**T*B, and then swap.
333*
334 IF( ( abs( ua11 )+abs( ua12 ) ).NE.zero ) THEN
335 IF( aua11 / ( abs( ua11 )+abs( ua12 ) ).LE.avb11 /
336 $ ( abs( vb11 )+abs( vb12 ) ) ) THEN
337 CALL dlartg( ua12, ua11, csq, snq, r )
338 ELSE
339 CALL dlartg( vb12, vb11, csq, snq, r )
340 END IF
341 ELSE
342 CALL dlartg( vb12, vb11, csq, snq, r )
343 END IF
344*
345 csu = snr
346 snu = csr
347 csv = snl
348 snv = csl
349*
350 END IF
351*
352 END IF
353*
354 RETURN
355*
356* End of DLAGS2
357*
subroutine dlartg(f, g, c, s, r)
DLARTG generates a plane rotation with real cosine and real sine.
Definition dlartg.f90:111
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
Here is the call graph for this function:
Here is the caller graph for this function: