LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dlasd6.f
Go to the documentation of this file.
1*> \brief \b DLASD6 computes the SVD of an updated upper bidiagonal matrix obtained by merging two smaller ones by appending a row. Used by sbdsdc.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DLASD6 + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlasd6.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlasd6.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlasd6.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DLASD6( ICOMPQ, NL, NR, SQRE, D, VF, VL, ALPHA, BETA,
20* IDXQ, PERM, GIVPTR, GIVCOL, LDGCOL, GIVNUM,
21* LDGNUM, POLES, DIFL, DIFR, Z, K, C, S, WORK,
22* IWORK, INFO )
23*
24* .. Scalar Arguments ..
25* INTEGER GIVPTR, ICOMPQ, INFO, K, LDGCOL, LDGNUM, NL,
26* $ NR, SQRE
27* DOUBLE PRECISION ALPHA, BETA, C, S
28* ..
29* .. Array Arguments ..
30* INTEGER GIVCOL( LDGCOL, * ), IDXQ( * ), IWORK( * ),
31* $ PERM( * )
32* DOUBLE PRECISION D( * ), DIFL( * ), DIFR( * ),
33* $ GIVNUM( LDGNUM, * ), POLES( LDGNUM, * ),
34* $ VF( * ), VL( * ), WORK( * ), Z( * )
35* ..
36*
37*
38*> \par Purpose:
39* =============
40*>
41*> \verbatim
42*>
43*> DLASD6 computes the SVD of an updated upper bidiagonal matrix B
44*> obtained by merging two smaller ones by appending a row. This
45*> routine is used only for the problem which requires all singular
46*> values and optionally singular vector matrices in factored form.
47*> B is an N-by-M matrix with N = NL + NR + 1 and M = N + SQRE.
48*> A related subroutine, DLASD1, handles the case in which all singular
49*> values and singular vectors of the bidiagonal matrix are desired.
50*>
51*> DLASD6 computes the SVD as follows:
52*>
53*> ( D1(in) 0 0 0 )
54*> B = U(in) * ( Z1**T a Z2**T b ) * VT(in)
55*> ( 0 0 D2(in) 0 )
56*>
57*> = U(out) * ( D(out) 0) * VT(out)
58*>
59*> where Z**T = (Z1**T a Z2**T b) = u**T VT**T, and u is a vector of dimension M
60*> with ALPHA and BETA in the NL+1 and NL+2 th entries and zeros
61*> elsewhere; and the entry b is empty if SQRE = 0.
62*>
63*> The singular values of B can be computed using D1, D2, the first
64*> components of all the right singular vectors of the lower block, and
65*> the last components of all the right singular vectors of the upper
66*> block. These components are stored and updated in VF and VL,
67*> respectively, in DLASD6. Hence U and VT are not explicitly
68*> referenced.
69*>
70*> The singular values are stored in D. The algorithm consists of two
71*> stages:
72*>
73*> The first stage consists of deflating the size of the problem
74*> when there are multiple singular values or if there is a zero
75*> in the Z vector. For each such occurrence the dimension of the
76*> secular equation problem is reduced by one. This stage is
77*> performed by the routine DLASD7.
78*>
79*> The second stage consists of calculating the updated
80*> singular values. This is done by finding the roots of the
81*> secular equation via the routine DLASD4 (as called by DLASD8).
82*> This routine also updates VF and VL and computes the distances
83*> between the updated singular values and the old singular
84*> values.
85*>
86*> DLASD6 is called from DLASDA.
87*> \endverbatim
88*
89* Arguments:
90* ==========
91*
92*> \param[in] ICOMPQ
93*> \verbatim
94*> ICOMPQ is INTEGER
95*> Specifies whether singular vectors are to be computed in
96*> factored form:
97*> = 0: Compute singular values only.
98*> = 1: Compute singular vectors in factored form as well.
99*> \endverbatim
100*>
101*> \param[in] NL
102*> \verbatim
103*> NL is INTEGER
104*> The row dimension of the upper block. NL >= 1.
105*> \endverbatim
106*>
107*> \param[in] NR
108*> \verbatim
109*> NR is INTEGER
110*> The row dimension of the lower block. NR >= 1.
111*> \endverbatim
112*>
113*> \param[in] SQRE
114*> \verbatim
115*> SQRE is INTEGER
116*> = 0: the lower block is an NR-by-NR square matrix.
117*> = 1: the lower block is an NR-by-(NR+1) rectangular matrix.
118*>
119*> The bidiagonal matrix has row dimension N = NL + NR + 1,
120*> and column dimension M = N + SQRE.
121*> \endverbatim
122*>
123*> \param[in,out] D
124*> \verbatim
125*> D is DOUBLE PRECISION array, dimension ( NL+NR+1 ).
126*> On entry D(1:NL,1:NL) contains the singular values of the
127*> upper block, and D(NL+2:N) contains the singular values
128*> of the lower block. On exit D(1:N) contains the singular
129*> values of the modified matrix.
130*> \endverbatim
131*>
132*> \param[in,out] VF
133*> \verbatim
134*> VF is DOUBLE PRECISION array, dimension ( M )
135*> On entry, VF(1:NL+1) contains the first components of all
136*> right singular vectors of the upper block; and VF(NL+2:M)
137*> contains the first components of all right singular vectors
138*> of the lower block. On exit, VF contains the first components
139*> of all right singular vectors of the bidiagonal matrix.
140*> \endverbatim
141*>
142*> \param[in,out] VL
143*> \verbatim
144*> VL is DOUBLE PRECISION array, dimension ( M )
145*> On entry, VL(1:NL+1) contains the last components of all
146*> right singular vectors of the upper block; and VL(NL+2:M)
147*> contains the last components of all right singular vectors of
148*> the lower block. On exit, VL contains the last components of
149*> all right singular vectors of the bidiagonal matrix.
150*> \endverbatim
151*>
152*> \param[in,out] ALPHA
153*> \verbatim
154*> ALPHA is DOUBLE PRECISION
155*> Contains the diagonal element associated with the added row.
156*> \endverbatim
157*>
158*> \param[in,out] BETA
159*> \verbatim
160*> BETA is DOUBLE PRECISION
161*> Contains the off-diagonal element associated with the added
162*> row.
163*> \endverbatim
164*>
165*> \param[in,out] IDXQ
166*> \verbatim
167*> IDXQ is INTEGER array, dimension ( N )
168*> This contains the permutation which will reintegrate the
169*> subproblem just solved back into sorted order, i.e.
170*> D( IDXQ( I = 1, N ) ) will be in ascending order.
171*> \endverbatim
172*>
173*> \param[out] PERM
174*> \verbatim
175*> PERM is INTEGER array, dimension ( N )
176*> The permutations (from deflation and sorting) to be applied
177*> to each block. Not referenced if ICOMPQ = 0.
178*> \endverbatim
179*>
180*> \param[out] GIVPTR
181*> \verbatim
182*> GIVPTR is INTEGER
183*> The number of Givens rotations which took place in this
184*> subproblem. Not referenced if ICOMPQ = 0.
185*> \endverbatim
186*>
187*> \param[out] GIVCOL
188*> \verbatim
189*> GIVCOL is INTEGER array, dimension ( LDGCOL, 2 )
190*> Each pair of numbers indicates a pair of columns to take place
191*> in a Givens rotation. Not referenced if ICOMPQ = 0.
192*> \endverbatim
193*>
194*> \param[in] LDGCOL
195*> \verbatim
196*> LDGCOL is INTEGER
197*> leading dimension of GIVCOL, must be at least N.
198*> \endverbatim
199*>
200*> \param[out] GIVNUM
201*> \verbatim
202*> GIVNUM is DOUBLE PRECISION array, dimension ( LDGNUM, 2 )
203*> Each number indicates the C or S value to be used in the
204*> corresponding Givens rotation. Not referenced if ICOMPQ = 0.
205*> \endverbatim
206*>
207*> \param[in] LDGNUM
208*> \verbatim
209*> LDGNUM is INTEGER
210*> The leading dimension of GIVNUM and POLES, must be at least N.
211*> \endverbatim
212*>
213*> \param[out] POLES
214*> \verbatim
215*> POLES is DOUBLE PRECISION array, dimension ( LDGNUM, 2 )
216*> On exit, POLES(1,*) is an array containing the new singular
217*> values obtained from solving the secular equation, and
218*> POLES(2,*) is an array containing the poles in the secular
219*> equation. Not referenced if ICOMPQ = 0.
220*> \endverbatim
221*>
222*> \param[out] DIFL
223*> \verbatim
224*> DIFL is DOUBLE PRECISION array, dimension ( N )
225*> On exit, DIFL(I) is the distance between I-th updated
226*> (undeflated) singular value and the I-th (undeflated) old
227*> singular value.
228*> \endverbatim
229*>
230*> \param[out] DIFR
231*> \verbatim
232*> DIFR is DOUBLE PRECISION array,
233*> dimension ( LDDIFR, 2 ) if ICOMPQ = 1 and
234*> dimension ( K ) if ICOMPQ = 0.
235*> On exit, DIFR(I,1) = D(I) - DSIGMA(I+1), DIFR(K,1) is not
236*> defined and will not be referenced.
237*>
238*> If ICOMPQ = 1, DIFR(1:K,2) is an array containing the
239*> normalizing factors for the right singular vector matrix.
240*>
241*> See DLASD8 for details on DIFL and DIFR.
242*> \endverbatim
243*>
244*> \param[out] Z
245*> \verbatim
246*> Z is DOUBLE PRECISION array, dimension ( M )
247*> The first elements of this array contain the components
248*> of the deflation-adjusted updating row vector.
249*> \endverbatim
250*>
251*> \param[out] K
252*> \verbatim
253*> K is INTEGER
254*> Contains the dimension of the non-deflated matrix,
255*> This is the order of the related secular equation. 1 <= K <=N.
256*> \endverbatim
257*>
258*> \param[out] C
259*> \verbatim
260*> C is DOUBLE PRECISION
261*> C contains garbage if SQRE =0 and the C-value of a Givens
262*> rotation related to the right null space if SQRE = 1.
263*> \endverbatim
264*>
265*> \param[out] S
266*> \verbatim
267*> S is DOUBLE PRECISION
268*> S contains garbage if SQRE =0 and the S-value of a Givens
269*> rotation related to the right null space if SQRE = 1.
270*> \endverbatim
271*>
272*> \param[out] WORK
273*> \verbatim
274*> WORK is DOUBLE PRECISION array, dimension ( 4 * M )
275*> \endverbatim
276*>
277*> \param[out] IWORK
278*> \verbatim
279*> IWORK is INTEGER array, dimension ( 3 * N )
280*> \endverbatim
281*>
282*> \param[out] INFO
283*> \verbatim
284*> INFO is INTEGER
285*> = 0: successful exit.
286*> < 0: if INFO = -i, the i-th argument had an illegal value.
287*> > 0: if INFO = 1, a singular value did not converge
288*> \endverbatim
289*
290* Authors:
291* ========
292*
293*> \author Univ. of Tennessee
294*> \author Univ. of California Berkeley
295*> \author Univ. of Colorado Denver
296*> \author NAG Ltd.
297*
298*> \ingroup lasd6
299*
300*> \par Contributors:
301* ==================
302*>
303*> Ming Gu and Huan Ren, Computer Science Division, University of
304*> California at Berkeley, USA
305*>
306* =====================================================================
307 SUBROUTINE dlasd6( ICOMPQ, NL, NR, SQRE, D, VF, VL, ALPHA,
308 $ BETA,
309 $ IDXQ, PERM, GIVPTR, GIVCOL, LDGCOL, GIVNUM,
310 $ LDGNUM, POLES, DIFL, DIFR, Z, K, C, S, WORK,
311 $ IWORK, INFO )
312*
313* -- LAPACK auxiliary routine --
314* -- LAPACK is a software package provided by Univ. of Tennessee, --
315* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
316*
317* .. Scalar Arguments ..
318 INTEGER GIVPTR, ICOMPQ, INFO, K, LDGCOL, LDGNUM, NL,
319 $ NR, SQRE
320 DOUBLE PRECISION ALPHA, BETA, C, S
321* ..
322* .. Array Arguments ..
323 INTEGER GIVCOL( LDGCOL, * ), IDXQ( * ), IWORK( * ),
324 $ perm( * )
325 DOUBLE PRECISION D( * ), DIFL( * ), DIFR( * ),
326 $ GIVNUM( LDGNUM, * ), POLES( LDGNUM, * ),
327 $ vf( * ), vl( * ), work( * ), z( * )
328* ..
329*
330* =====================================================================
331*
332* .. Parameters ..
333 DOUBLE PRECISION ONE, ZERO
334 PARAMETER ( ONE = 1.0d+0, zero = 0.0d+0 )
335* ..
336* .. Local Scalars ..
337 INTEGER I, IDX, IDXC, IDXP, ISIGMA, IVFW, IVLW, IW, M,
338 $ n, n1, n2
339 DOUBLE PRECISION ORGNRM
340* ..
341* .. External Subroutines ..
342 EXTERNAL dcopy, dlamrg, dlascl, dlasd7, dlasd8,
343 $ xerbla
344* ..
345* .. Intrinsic Functions ..
346 INTRINSIC abs, max
347* ..
348* .. Executable Statements ..
349*
350* Test the input parameters.
351*
352 info = 0
353 n = nl + nr + 1
354 m = n + sqre
355*
356 IF( ( icompq.LT.0 ) .OR. ( icompq.GT.1 ) ) THEN
357 info = -1
358 ELSE IF( nl.LT.1 ) THEN
359 info = -2
360 ELSE IF( nr.LT.1 ) THEN
361 info = -3
362 ELSE IF( ( sqre.LT.0 ) .OR. ( sqre.GT.1 ) ) THEN
363 info = -4
364 ELSE IF( ldgcol.LT.n ) THEN
365 info = -14
366 ELSE IF( ldgnum.LT.n ) THEN
367 info = -16
368 END IF
369 IF( info.NE.0 ) THEN
370 CALL xerbla( 'DLASD6', -info )
371 RETURN
372 END IF
373*
374* The following values are for bookkeeping purposes only. They are
375* integer pointers which indicate the portion of the workspace
376* used by a particular array in DLASD7 and DLASD8.
377*
378 isigma = 1
379 iw = isigma + n
380 ivfw = iw + m
381 ivlw = ivfw + m
382*
383 idx = 1
384 idxc = idx + n
385 idxp = idxc + n
386*
387* Scale.
388*
389 orgnrm = max( abs( alpha ), abs( beta ) )
390 d( nl+1 ) = zero
391 DO 10 i = 1, n
392 IF( abs( d( i ) ).GT.orgnrm ) THEN
393 orgnrm = abs( d( i ) )
394 END IF
395 10 CONTINUE
396 CALL dlascl( 'G', 0, 0, orgnrm, one, n, 1, d, n, info )
397 alpha = alpha / orgnrm
398 beta = beta / orgnrm
399*
400* Sort and Deflate singular values.
401*
402 CALL dlasd7( icompq, nl, nr, sqre, k, d, z, work( iw ), vf,
403 $ work( ivfw ), vl, work( ivlw ), alpha, beta,
404 $ work( isigma ), iwork( idx ), iwork( idxp ), idxq,
405 $ perm, givptr, givcol, ldgcol, givnum, ldgnum, c, s,
406 $ info )
407*
408* Solve Secular Equation, compute DIFL, DIFR, and update VF, VL.
409*
410 CALL dlasd8( icompq, k, d, z, vf, vl, difl, difr, ldgnum,
411 $ work( isigma ), work( iw ), info )
412*
413* Report the possible convergence failure.
414*
415 IF( info.NE.0 ) THEN
416 RETURN
417 END IF
418*
419* Save the poles if ICOMPQ = 1.
420*
421 IF( icompq.EQ.1 ) THEN
422 CALL dcopy( k, d, 1, poles( 1, 1 ), 1 )
423 CALL dcopy( k, work( isigma ), 1, poles( 1, 2 ), 1 )
424 END IF
425*
426* Unscale.
427*
428 CALL dlascl( 'G', 0, 0, one, orgnrm, n, 1, d, n, info )
429*
430* Prepare the IDXQ sorting permutation.
431*
432 n1 = k
433 n2 = n - k
434 CALL dlamrg( n1, n2, d, 1, -1, idxq )
435*
436 RETURN
437*
438* End of DLASD6
439*
440 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine dcopy(n, dx, incx, dy, incy)
DCOPY
Definition dcopy.f:82
subroutine dlamrg(n1, n2, a, dtrd1, dtrd2, index)
DLAMRG creates a permutation list to merge the entries of two independently sorted sets into a single...
Definition dlamrg.f:97
subroutine dlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
DLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition dlascl.f:142
subroutine dlasd6(icompq, nl, nr, sqre, d, vf, vl, alpha, beta, idxq, perm, givptr, givcol, ldgcol, givnum, ldgnum, poles, difl, difr, z, k, c, s, work, iwork, info)
DLASD6 computes the SVD of an updated upper bidiagonal matrix obtained by merging two smaller ones by...
Definition dlasd6.f:312
subroutine dlasd7(icompq, nl, nr, sqre, k, d, z, zw, vf, vfw, vl, vlw, alpha, beta, dsigma, idx, idxp, idxq, perm, givptr, givcol, ldgcol, givnum, ldgnum, c, s, info)
DLASD7 merges the two sets of singular values together into a single sorted set. Then it tries to def...
Definition dlasd7.f:279
subroutine dlasd8(icompq, k, d, z, vf, vl, difl, difr, lddifr, dsigma, work, info)
DLASD8 finds the square roots of the roots of the secular equation, and stores, for each element in D...
Definition dlasd8.f:162