# ?lalsa

Computes the SVD of the coefficient matrix in compact form. Used by ?gelsd.

## Syntax

call slalsa( icompq, smlsiz, n, nrhs, b, ldb, bx, ldbx, u, ldu, vt, k, difl, difr, z, poles, givptr, givcol, ldgcol, perm, givnum, c, s, work, iwork, info )

call dlalsa( icompq, smlsiz, n, nrhs, b, ldb, bx, ldbx, u, ldu, vt, k, difl, difr, z, poles, givptr, givcol, ldgcol, perm, givnum, c, s, work, iwork, info )

call clalsa( icompq, smlsiz, n, nrhs, b, ldb, bx, ldbx, u, ldu, vt, k, difl, difr, z, poles, givptr, givcol, ldgcol, perm, givnum, c, s, rwork, iwork, info )

call zlalsa( icompq, smlsiz, n, nrhs, b, ldb, bx, ldbx, u, ldu, vt, k, difl, difr, z, poles, givptr, givcol, ldgcol, perm, givnum, c, s, rwork, iwork, info )

## Description

The routine is an itermediate step in solving the least squares problem by computing the SVD of the coefficient matrix in compact form. The singular vectors are computed as products of simple orthorgonal matrices.

If `icompq = 0`, ?lalsa applies the inverse of the left singular vector matrix of an upper bidiagonal matrix to the right hand side; and if `icompq = 1`, the routine applies the right singular vector matrix to the right hand side. The singular vector matrices were generated in the compact form by ?lalsa.

## Input Parameters

icompq

  INTEGER. Specifies whether the left or the right singular vector matrix is involved. If `icompq = 0`: left singular vector matrix is used

  If `icompq = 1`: right singular vector matrix is used.

smlsiz

  INTEGER. The maximum size of the subproblems at the bottom of the computation tree.

n

  INTEGER. The row and column dimensions of the upper bidiagonal matrix.

nrhs

  INTEGER. The number of columns of b and bx. Must be at least 1.

b

  REAL for slalsa

  DOUBLE PRECISION for dlalsa

  COMPLEX for clalsa

  COMPLEX*16 for zlalsa

  Array, DIMENSION (ldb, nrhs). Contains the right hand sides of the least squares problem in rows 1 through m.

ldb

  INTEGER. The leading dimension of b in the calling subprogram. Must be at least `max(1,max( m, n ))`.

ldbx

  INTEGER. The leading dimension of the output array bx.

u

  REAL for slalsa/clalsa

  DOUBLE PRECISION for dlalsa/zlalsa

  Array, DIMENSION (ldu, smlsiz). On entry, u contains the left singular vector matrices of all subproblems at the bottom level.

ldu

  INTEGER, `ldu ≥ n`. The leading dimension of arrays u, vt, difl, difr, poles, givnum, and z.

vt

  REAL for slalsa/clalsa

  DOUBLE PRECISION for dlalsa/zlalsa

  Array, DIMENSION `(ldu, smlsiz +1)`. On entry, contains the right singular vector matrices of all subproblems at the bottom level.

k

  INTEGER array, DIMENSION ( n ).

difl

  REAL for slalsa/clalsa

  DOUBLE PRECISION for dlalsa/zlalsa

  Array, DIMENSION (ldu, nlvl), where `nlvl = int(log2(n /(smlsiz+1))) + 1`.

difr

  REAL for slalsa/clalsa

  DOUBLE PRECISION for dlalsa/zlalsa

  Array, DIMENSION `(ldu, 2*nlvl)`. On entry, difl(*, i) and difr(*, 2i -1) record distances between singular values on the i-th level and singular values on the (i -1)-th level, and difr(*, 2i) record the normalizing factors of the right singular vectors matrices of subproblems on i-th level.

z

  REAL for slalsa/clalsa

  DOUBLE PRECISION for dlalsa/zlalsa

  Array, DIMENSION (ldu, nlvl . On entry, z(1, i) contains the components of the deflation- adjusted updating the row vector for subproblems on the i-th level.

poles

  REAL for slalsa/clalsa

  DOUBLE PRECISION for dlalsa/zlalsa

  Array, DIMENSION (ldu, 2*nlvl).

  On entry, poles(*, 2i-1: 2i) contains the new and old singular values involved in the secular equations on the i-th level.

givptr

  INTEGER. Array, DIMENSION ( n ).

  On entry, givptr( i ) records the number of Givens rotations performed on the i-th problem on the computation tree.

givcol

  INTEGER. Array, DIMENSION ( ldgcol, 2*nlvl ). On entry, for each i, givcol(*, 2i-1: 2i) records the locations of Givens rotations performed on the i-th level on the computation tree.

ldgcol

  INTEGER, `ldgcol ≥ n`. The leading dimension of arrays givcol and perm.

perm

  INTEGER. Array, DIMENSION ( ldgcol, nlvl ). On entry, perm(*, i) records permutations done on the i-th level of the computation tree.

givnum

  REAL for slalsa/clalsa

  DOUBLE PRECISION for dlalsa/zlalsa

  Array, DIMENSION (ldu, 2*nlvl). On entry, givnum(*, 2i-1 : 2i) records the c and s values of Givens rotations performed on the i-th level on the computation tree.

c

  REAL for slalsa/clalsa

  DOUBLE PRECISION for dlalsa/zlalsa

  Array, DIMENSION ( n ). On entry, if the i-th subproblem is not square, c( i ) contains the c value of a Givens rotation related to the right null space of the i-th subproblem.

s

  REAL for slalsa/clalsa

  DOUBLE PRECISION for dlalsa/zlalsa

  Array, DIMENSION ( n ). On entry, if the i-th subproblem is not square, s( i ) contains the s-value of a Givens rotation related to the right null space of the i-th subproblem.

work

  REAL for slalsa

  DOUBLE PRECISION for dlalsa

  Workspace array, DIMENSION at least (n). Used with real flavors only.

rwork

  REAL for clalsa

  DOUBLE PRECISION for zlalsa

  Workspace array, DIMENSION at least `max(n, (smlsz+1)*nrhs*3)`. Used with complex flavors only.

iwork

  INTEGER.

  Workspace array, DIMENSION at least (3n).

## Output Parameters

b

  On exit, contains the solution X in rows 1 through n.

bx

  REAL for slalsa

  DOUBLE PRECISION for dlalsa

  COMPLEX for clalsa

  COMPLEX*16 for zlalsa

  Array, DIMENSION (ldbx, nrhs). On exit, the result of applying the left or right singular vector matrix to b.

info

  INTEGER. If `info = 0`: successful exit

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

Parent topic: Auxiliary Routines