# ?lasd2

Merges the two sets of singular values together into a single sorted set. Used by ?bdsdc.

## Syntax

call slasd2( nl, nr, sqre, k, d, z, alpha, beta, u, ldu, vt, ldvt, dsigma, u2, ldu2, vt2, ldvt2, idxp, idx, idxp, idxq, coltyp, info )

call dlasd2( nl, nr, sqre, k, d, z, alpha, beta, u, ldu, vt, ldvt, dsigma, u2, ldu2, vt2, ldvt2, idxp, idx, idxp, idxq, coltyp, info )

## Description

The routine ?lasd2 merges the two sets of singular values together into a single sorted set. Then it tries to deflate the size of the problem. There are two ways in which deflation can occur: when two or more singular values are close together or if there is a tiny entry in the Z vector. For each such occurrence the order of the related secular equation problem is reduced by one.

The routine ?lasd2 is called from ?lasd1.

## Input Parameters

nl

  INTEGER. The row dimension of the upper block.

  `nl ≥ 1`.

nr

  INTEGER. The row dimension of the lower block.

  `nr ≥ 1`.

sqre

  INTEGER.

  If `sqre = 0`): the lower block is an nr-by-nr square matrix

  If `sqre = 1`): the lower block is an nr-by-(nr+1) rectangular matrix. The bidiagonal matrix has `n = nl + nr + 1` rows and `m = n + sqre ≥ n` columns.

d

  REAL for slasd2

  DOUBLE PRECISION for dlasd2

  Array, DIMENSION (n). On entry d contains the singular values of the two submatrices to be combined.

alpha

  REAL for slasd2

  DOUBLE PRECISION for dlasd2

  Contains the diagonal element associated with the added row.

beta

  REAL for slasd2

  DOUBLE PRECISION for dlasd2

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

u

  REAL for slasd2

  DOUBLE PRECISION for dlasd2

  Array, DIMENSION (ldu, n). On entry u contains the left singular vectors of two submatrices in the two square blocks with corners at (1,1), (nl, nl), and (nl+2, nl+2), (n,n).

ldu

  INTEGER. The leading dimension of the array u.

  `ldu ≥ n`.

ldu2

  INTEGER. The leading dimension of the output array u2. `ldu2 ≥ n`.

vt

  REAL for slasd2

  DOUBLE PRECISION for dlasd2

  Array, DIMENSION (ldvt, m). On entry, vt' contains the right singular vectors of two submatrices in the two square blocks with corners at (1,1), (nl+1, nl+1), and (nl+2, nl+2), (m, m).

ldvt

  INTEGER. The leading dimension of the array vt. `ldvt ≥ m`.

ldvt2

  INTEGER. The leading dimension of the output array vt2. `ldvt2 ≥ m`.

idxp

  INTEGER.

  Workspace array, DIMENSION (n). This will contain the permutation used to place deflated values of D at the end of the array. On output idxp(2:k) points to the nondeflated d-values and idxp(k+1:n) points to the deflated singular values.

idx

  INTEGER.

  Workspace array, DIMENSION (n). This will contain the permutation used to sort the contents of d into ascending order.

coltyp

  INTEGER.

  Workspace array, DIMENSION (n). As workspace, this array contains a label that indicates which of the following types a column in the u2 matrix or a row in the vt2 matrix is:

  1 : non-zero in the upper half only

  2 : non-zero in the lower half only

  3 : dense

  4 : deflated.

idxq

  INTEGER. Array, DIMENSION (n). This parameter contains the permutation that separately sorts the two sub-problems in D into ascending order. Note that entries in the first half of this permutation must first be moved one position backward; and entries in the second half must first have `nl+1` added to their values.

## Output Parameters

k

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

d

  On exit D contains the trailing (n-k) updated singular values (those which were deflated) sorted into increasing order.

u

  On exit u contains the trailing (n-k) updated left singular vectors (those which were deflated) in its last n-k columns.

z

  REAL for slasd2

  DOUBLE PRECISION for dlasd2

  Array, DIMENSION (n). On exit, z contains the updating row vector in the secular equation.

dsigma

  REAL for slasd2

  DOUBLE PRECISION for dlasd2

  Array, DIMENSION (n). Contains a copy of the diagonal elements (`k-1` singular values and one zero) in the secular equation.

u2

  REAL for slasd2

  DOUBLE PRECISION for dlasd2

  Array, DIMENSION (ldu2, n). Contains a copy of the first `k-1` left singular vectors which will be used by ?lasd3 in a matrix multiply (?gemm) to solve for the new left singular vectors. u2 is arranged into four blocks. The first block contains a column with 1 at `nl+1` and zero everywhere else; the second block contains non-zero entries only at and above nl; the third contains non-zero entries only below `nl+1`; and the fourth is dense.

vt

  On exit, vt' contains the trailing (n-k) updated right singular vectors (those which were deflated) in its last n-k columns. In case `sqre =1`, the last row of vt spans the right null space.

vt2

  REAL for slasd2

  DOUBLE PRECISION for dlasd2

  Array, DIMENSION (ldvt2, n). vt2' contains a copy of the first k right singular vectors which will be used by ?lasd3 in a matrix multiply (?gemm) to solve for the new right singular vectors. vt2 is arranged into three blocks. The first block contains a row that corresponds to the special 0 diagonal element in sigma; the second block contains non-zeros only at and before `nl +1`; the third block contains non-zeros only at and after `nl +2`.

idxc

  INTEGER. Array, DIMENSION (n). This will contain the permutation used to arrange the columns of the deflated u matrix into three groups: the first group contains non-zero entries only at and above nl, the second contains non-zero entries only below `nl+2`, and the third is dense.

coltyp

  On exit, it is an array of dimension 4, with coltyp(i) being the dimension of the i-th type columns.

info

  INTEGER.

  If `info = 0`): successful exit

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

Parent topic: Auxiliary Routines