# ?lasd6

Computes the SVD of an updated upper bidiagonal matrix obtained by merging two smaller ones by appending a row. Used by ?bdsdc.

## Syntax

call slasd6( 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 )

call 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 )

## Description

The routine ?lasd6 computes the SVD of an updated upper bidiagonal matrix B obtained by merging two smaller ones by appending a row. This routine is used only for the problem which requires all singular values and optionally singular vector matrices in factored form. B is an n-by-m matrix with `n = nl + nr + 1` and `m = n + sqre`. A related subroutine, ?lasd1, handles the case in which all singular values and singular vectors of the bidiagonal matrix are desired. ?lasd6 computes the SVD as follows:

`= U(out)*(D(out)*VT(out)`

where `Z' = (Z1' a Z2' b) = u'*VT'`, 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 singular values of B can be computed using D1, D2, the first components of all the right singular vectors of the lower block, and the last components of all the right singular vectors of the upper block. These components are stored and updated in vf and vl, respectively, in ?lasd6. Hence U and VT are not explicitly referenced.

The singular values are stored in D. The algorithm consists of two stages:

1. The first stage consists of deflating the size of the problem when there are multiple singular values or if there is a zero 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 ?lasd7.

2. The second stage consists of calculating the updated singular values. This is done by finding the roots of the secular equation via the routine ?lasd4 (as called by ?lasd8). This routine also updates vf and vl and computes the distances between the updated singular values and the old singular values. ?lasd6 is called from ?lasda.

## Input Parameters

icompq

  INTEGER. Specifies whether singular vectors are to be computed in factored form:

  = 0: Compute singular values only

  = 1: Compute singular vectors in factored form as well.

nl

  INTEGER. The row dimension of the upper block.

  `nl ≥ 1`.

nr

  INTEGER. The row dimension of the lower block.

  `nr ≥ 1`.

sqre

  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`.

d

  REAL for slasd6

  DOUBLE PRECISION for dlasd6

  Array, dimension ( 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.

vf

  REAL for slasd6

  DOUBLE PRECISION for dlasd6

  Array, dimension ( m ).

  On entry, vf(1:nl+1) contains the first components of all right singular vectors of the upper block; and vf(nl+2:m)

  contains the first components of all right singular vectors of the lower block.

vl

  REAL for slasd6

  DOUBLE PRECISION for dlasd6

  Array, dimension ( m ).

  On entry, vl(1:nl+1) contains the last components of all right singular vectors of the upper block; and vl(nl+2:m) contains the last components of all right singular vectors of the lower block.

alpha

  REAL for slasd6

  DOUBLE PRECISION for dlasd6

  Contains the diagonal element associated with the added row.

beta

  REAL for slasd6

  DOUBLE PRECISION for dlasd6

  Contains the off-diagonal element associated with the added row.

ldgcol

  INTEGER.The leading dimension of the output array givcol, must be at least n.

ldgnum

  INTEGER.

  The leading dimension of the output arrays givnum and poles, must be at least n.

work

  REAL for slasd6

  DOUBLE PRECISION for dlasd6

  Workspace array, dimension ( 4m ).

iwork

  INTEGER.

  Workspace array, dimension ( 3n ).

## Output Parameters

d

  On exit d(1:n) contains the singular values of the modified matrix.

vf

  On exit, vf contains the first components of all right singular vectors of the bidiagonal matrix.

vl

  On exit, vl contains the last components of all right singular vectors of the bidiagonal matrix.

alpha

  On exit, the diagonal element associated with the added row deflated by `max(abs(alpha), abs(beta), abs(D(I)))`, `I = 1,n`.

beta

  On exit, the off-diagonal element associated with the added row deflated by `max(abs(alpha), abs(beta), abs(D(I)))`, `I = 1,n`.

idxq

  INTEGER.

  Array, dimension (n). This contains the permutation which will reintegrate the subproblem just solved back into sorted order, that is, `d( idxq( i = 1, n ) )` will be in ascending order.

perm

  INTEGER.

  Array, dimension (n). The permutations (from deflation and sorting) to be applied to each block. Not referenced if `icompq = 0`.

givptr

  INTEGER. The number of Givens rotations which took place in this subproblem. Not referenced if `icompq = 0`.

givcol

  INTEGER.

  Array, dimension ( ldgcol, 2 ). Each pair of numbers indicates a pair of columns to take place in a Givens rotation. Not referenced if `icompq = 0`.

givnum

  REAL for slasd6

  DOUBLE PRECISION for dlasd6

  Array, dimension ( ldgnum, 2 ). Each number indicates the C or S value to be used in the corresponding Givens rotation. Not referenced if `icompq = 0`.

poles

  REAL for slasd6

  DOUBLE PRECISION for dlasd6

  Array, dimension ( ldgnum, 2 ). On exit, poles(1,*) is an array containing the new singular values obtained from solving the secular equation, and poles(2,*) is an array containing the poles in the secular equation. Not referenced if `icompq = 0`.

difl

  REAL for slasd6

  DOUBLE PRECISION for dlasd6

  Array, dimension (n). On exit, difl(i) is the distance between i-th updated (undeflated) singular value and the i-th (undeflated) old singular value.

difr

  REAL for slasd6

  DOUBLE PRECISION for dlasd6

  Array, dimension (ldgnum, 2 ) if `icompq = 1` and dimension (n) if `icompq = 0`.

  On exit, difr(i, 1) is the distance between i-th updated (undeflated) singular value and the i+1-th (undeflated) old singular value. If `icompq = 1, difr(1: k, 2)` is an array containing the normalizing factors for the right singular vector matrix.

  See ?lasd8 for details on difl and difr.

z

  REAL for slasd6

  DOUBLE PRECISION for dlasd6

  Array, dimension ( m ).

  The first elements of this array contain the components of the deflation-adjusted updating row vector.

k

  INTEGER. Contains the dimension of the non-deflated matrix. This is the order of the related secular equation. `1 ≤ k ≤ n`.

c

  REAL for slasd6

  DOUBLE PRECISION for dlasd6

  c contains garbage if `sqre =0` and the C-value of a Givens rotation related to the right null space if `sqre = 1`.

s

  REAL for slasd6

  DOUBLE PRECISION for dlasd6

  s contains garbage if `sqre =0` and the S-value of a Givens rotation related to the right null space if `sqre = 1`.

info

  INTEGER.

  = 0: successful exit.

  < 0: if `info = -i`, the i-th argument had an illegal value.

  > 0: if `info = 1`, an singular value did not converge

Parent topic: Auxiliary Routines