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

◆ slasd1()

subroutine slasd1 ( integer nl,
integer nr,
integer sqre,
real, dimension( * ) d,
real alpha,
real beta,
real, dimension( ldu, * ) u,
integer ldu,
real, dimension( ldvt, * ) vt,
integer ldvt,
integer, dimension( * ) idxq,
integer, dimension( * ) iwork,
real, dimension( * ) work,
integer info )

SLASD1 computes the SVD of an upper bidiagonal matrix B of the specified size. Used by sbdsdc.

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

Purpose:
!>
!> SLASD1 computes the SVD of an upper bidiagonal N-by-M matrix B,
!> where N = NL + NR + 1 and M = N + SQRE. SLASD1 is called from SLASD0.
!>
!> A related subroutine SLASD7 handles the case in which the singular
!> values (and the singular vectors in factored form) are desired.
!>
!> SLASD1 computes the SVD as follows:
!>
!>               ( D1(in)    0    0       0 )
!>   B = U(in) * (   Z1**T   a   Z2**T    b ) * VT(in)
!>               (   0       0   D2(in)   0 )
!>
!>     = U(out) * ( D(out) 0) * VT(out)
!>
!> where Z**T = (Z1**T a Z2**T b) = u**T VT**T, and u is a vector of dimension M
!> with ALPHA and BETA in the NL+1 and NL+2 th entries and zeros
!> elsewhere; and the entry b is empty if SQRE = 0.
!>
!> The left singular vectors of the original matrix are stored in U, and
!> the transpose of the right singular vectors are stored in VT, and the
!> singular values are in D.  The algorithm consists of three stages:
!>
!>    The first stage consists of deflating the size of the problem
!>    when there are multiple singular values or when there are zeros in
!>    the Z vector.  For each such occurrence the dimension of the
!>    secular equation problem is reduced by one.  This stage is
!>    performed by the routine SLASD2.
!>
!>    The second stage consists of calculating the updated
!>    singular values. This is done by finding the square roots of the
!>    roots of the secular equation via the routine SLASD4 (as called
!>    by SLASD3). This routine also calculates the singular vectors of
!>    the current problem.
!>
!>    The final stage consists of computing the updated singular vectors
!>    directly using the updated singular values.  The singular vectors
!>    for the current problem are multiplied with the singular vectors
!>    from the overall problem.
!> 
Parameters
[in]NL
!>          NL is INTEGER
!>         The row dimension of the upper block.  NL >= 1.
!> 
[in]NR
!>          NR is INTEGER
!>         The row dimension of the lower block.  NR >= 1.
!> 
[in]SQRE
!>          SQRE is INTEGER
!>         = 0: the lower block is an NR-by-NR square matrix.
!>         = 1: the lower block is an NR-by-(NR+1) rectangular matrix.
!>
!>         The bidiagonal matrix has row dimension N = NL + NR + 1,
!>         and column dimension M = N + SQRE.
!> 
[in,out]D
!>          D is REAL array, dimension (NL+NR+1).
!>         N = NL+NR+1
!>         On entry D(1:NL,1:NL) contains the singular values of the
!>         upper block; and D(NL+2:N) contains the singular values of
!>         the lower block. On exit D(1:N) contains the singular values
!>         of the modified matrix.
!> 
[in,out]ALPHA
!>          ALPHA is REAL
!>         Contains the diagonal element associated with the added row.
!> 
[in,out]BETA
!>          BETA is REAL
!>         Contains the off-diagonal element associated with the added
!>         row.
!> 
[in,out]U
!>          U is REAL array, dimension (LDU,N)
!>         On entry U(1:NL, 1:NL) contains the left singular vectors of
!>         the upper block; U(NL+2:N, NL+2:N) contains the left singular
!>         vectors of the lower block. On exit U contains the left
!>         singular vectors of the bidiagonal matrix.
!> 
[in]LDU
!>          LDU is INTEGER
!>         The leading dimension of the array U.  LDU >= max( 1, N ).
!> 
[in,out]VT
!>          VT is REAL array, dimension (LDVT,M)
!>         where M = N + SQRE.
!>         On entry VT(1:NL+1, 1:NL+1)**T contains the right singular
!>         vectors of the upper block; VT(NL+2:M, NL+2:M)**T contains
!>         the right singular vectors of the lower block. On exit
!>         VT**T contains the right singular vectors of the
!>         bidiagonal matrix.
!> 
[in]LDVT
!>          LDVT is INTEGER
!>         The leading dimension of the array VT.  LDVT >= max( 1, M ).
!> 
[in,out]IDXQ
!>          IDXQ is INTEGER array, dimension (N)
!>         This contains the permutation which will reintegrate the
!>         subproblem just solved back into sorted order, i.e.
!>         D( IDXQ( I = 1, N ) ) will be in ascending order.
!> 
[out]IWORK
!>          IWORK is INTEGER array, dimension (4*N)
!> 
[out]WORK
!>          WORK is REAL array, dimension (3*M**2+2*M)
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit.
!>          < 0:  if INFO = -i, the i-th argument had an illegal value.
!>          > 0:  if INFO = 1, a singular value did not converge
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Contributors:
Ming Gu and Huan Ren, Computer Science Division, University of California at Berkeley, USA

Definition at line 200 of file slasd1.f.

203*
204* -- LAPACK auxiliary routine --
205* -- LAPACK is a software package provided by Univ. of Tennessee, --
206* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
207*
208* .. Scalar Arguments ..
209 INTEGER INFO, LDU, LDVT, NL, NR, SQRE
210 REAL ALPHA, BETA
211* ..
212* .. Array Arguments ..
213 INTEGER IDXQ( * ), IWORK( * )
214 REAL D( * ), U( LDU, * ), VT( LDVT, * ), WORK( * )
215* ..
216*
217* =====================================================================
218*
219* .. Parameters ..
220*
221 REAL ONE, ZERO
222 parameter( one = 1.0e+0, zero = 0.0e+0 )
223* ..
224* .. Local Scalars ..
225 INTEGER COLTYP, I, IDX, IDXC, IDXP, IQ, ISIGMA, IU2,
226 $ IVT2, IZ, K, LDQ, LDU2, LDVT2, M, N, N1, N2
227 REAL ORGNRM
228* ..
229* .. External Subroutines ..
230 EXTERNAL slamrg, slascl, slasd2, slasd3,
231 $ xerbla
232* ..
233* .. Intrinsic Functions ..
234 INTRINSIC abs, max
235* ..
236* .. Executable Statements ..
237*
238* Test the input parameters.
239*
240 info = 0
241*
242 IF( nl.LT.1 ) THEN
243 info = -1
244 ELSE IF( nr.LT.1 ) THEN
245 info = -2
246 ELSE IF( ( sqre.LT.0 ) .OR. ( sqre.GT.1 ) ) THEN
247 info = -3
248 END IF
249 IF( info.NE.0 ) THEN
250 CALL xerbla( 'SLASD1', -info )
251 RETURN
252 END IF
253*
254 n = nl + nr + 1
255 m = n + sqre
256*
257* The following values are for bookkeeping purposes only. They are
258* integer pointers which indicate the portion of the workspace
259* used by a particular array in SLASD2 and SLASD3.
260*
261 ldu2 = n
262 ldvt2 = m
263*
264 iz = 1
265 isigma = iz + m
266 iu2 = isigma + n
267 ivt2 = iu2 + ldu2*n
268 iq = ivt2 + ldvt2*m
269*
270 idx = 1
271 idxc = idx + n
272 coltyp = idxc + n
273 idxp = coltyp + n
274*
275* Scale.
276*
277 orgnrm = max( abs( alpha ), abs( beta ) )
278 d( nl+1 ) = zero
279 DO 10 i = 1, n
280 IF( abs( d( i ) ).GT.orgnrm ) THEN
281 orgnrm = abs( d( i ) )
282 END IF
283 10 CONTINUE
284 CALL slascl( 'G', 0, 0, orgnrm, one, n, 1, d, n, info )
285 alpha = alpha / orgnrm
286 beta = beta / orgnrm
287*
288* Deflate singular values.
289*
290 CALL slasd2( nl, nr, sqre, k, d, work( iz ), alpha, beta, u,
291 $ ldu,
292 $ vt, ldvt, work( isigma ), work( iu2 ), ldu2,
293 $ work( ivt2 ), ldvt2, iwork( idxp ), iwork( idx ),
294 $ iwork( idxc ), idxq, iwork( coltyp ), info )
295*
296* Solve Secular Equation and update singular vectors.
297*
298 ldq = k
299 CALL slasd3( nl, nr, sqre, k, d, work( iq ), ldq,
300 $ work( isigma ),
301 $ u, ldu, work( iu2 ), ldu2, vt, ldvt, work( ivt2 ),
302 $ ldvt2, iwork( idxc ), iwork( coltyp ), work( iz ),
303 $ info )
304*
305* Report the possible convergence failure.
306*
307 IF( info.NE.0 ) THEN
308 RETURN
309 END IF
310*
311* Unscale.
312*
313 CALL slascl( 'G', 0, 0, one, orgnrm, n, 1, d, n, info )
314*
315* Prepare the IDXQ sorting permutation.
316*
317 n1 = k
318 n2 = n - k
319 CALL slamrg( n1, n2, d, 1, -1, idxq )
320*
321 RETURN
322*
323* End of SLASD1
324*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine slamrg(n1, n2, a, strd1, strd2, index)
SLAMRG creates a permutation list to merge the entries of two independently sorted sets into a single...
Definition slamrg.f:97
subroutine slascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition slascl.f:142
subroutine slasd2(nl, nr, sqre, k, d, z, alpha, beta, u, ldu, vt, ldvt, dsigma, u2, ldu2, vt2, ldvt2, idxp, idx, idxc, idxq, coltyp, info)
SLASD2 merges the two sets of singular values together into a single sorted set. Used by sbdsdc.
Definition slasd2.f:268
subroutine slasd3(nl, nr, sqre, k, d, q, ldq, dsigma, u, ldu, u2, ldu2, vt, ldvt, vt2, ldvt2, idxc, ctot, z, info)
SLASD3 finds all square roots of the roots of the secular equation, as defined by the values in D and...
Definition slasd3.f:216
Here is the call graph for this function:
Here is the caller graph for this function: