LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine slalsa ( integer  ICOMPQ,
integer  SMLSIZ,
integer  N,
integer  NRHS,
real, dimension( ldb, * )  B,
integer  LDB,
real, dimension( ldbx, * )  BX,
integer  LDBX,
real, dimension( ldu, * )  U,
integer  LDU,
real, dimension( ldu, * )  VT,
integer, dimension( * )  K,
real, dimension( ldu, * )  DIFL,
real, dimension( ldu, * )  DIFR,
real, dimension( ldu, * )  Z,
real, dimension( ldu, * )  POLES,
integer, dimension( * )  GIVPTR,
integer, dimension( ldgcol, * )  GIVCOL,
integer  LDGCOL,
integer, dimension( ldgcol, * )  PERM,
real, dimension( ldu, * )  GIVNUM,
real, dimension( * )  C,
real, dimension( * )  S,
real, dimension( * )  WORK,
integer, dimension( * )  IWORK,
integer  INFO 
)

SLALSA computes the SVD of the coefficient matrix in compact form. Used by sgelsd.

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

Purpose:
 SLALSA 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, SLALSA applies the inverse of the left singular vector
 matrix of an upper bidiagonal matrix to the right hand side; and if
 ICOMPQ = 1, SLALSA applies the right singular vector matrix to the
 right hand side. The singular vector matrices were generated in
 compact form by SLALSA.
Parameters
[in]ICOMPQ
          ICOMPQ is INTEGER
         Specifies whether the left or the right singular vector
         matrix is involved.
         = 0: Left singular vector matrix
         = 1: Right singular vector matrix
[in]SMLSIZ
          SMLSIZ is INTEGER
         The maximum size of the subproblems at the bottom of the
         computation tree.
[in]N
          N is INTEGER
         The row and column dimensions of the upper bidiagonal matrix.
[in]NRHS
          NRHS is INTEGER
         The number of columns of B and BX. NRHS must be at least 1.
[in,out]B
          B is REAL array, dimension ( LDB, NRHS )
         On input, B contains the right hand sides of the least
         squares problem in rows 1 through M.
         On output, B contains the solution X in rows 1 through N.
[in]LDB
          LDB is INTEGER
         The leading dimension of B in the calling subprogram.
         LDB must be at least max(1,MAX( M, N ) ).
[out]BX
          BX is REAL array, dimension ( LDBX, NRHS )
         On exit, the result of applying the left or right singular
         vector matrix to B.
[in]LDBX
          LDBX is INTEGER
         The leading dimension of BX.
[in]U
          U is REAL array, dimension ( LDU, SMLSIZ ).
         On entry, U contains the left singular vector matrices of all
         subproblems at the bottom level.
[in]LDU
          LDU is INTEGER, LDU = > N.
         The leading dimension of arrays U, VT, DIFL, DIFR,
         POLES, GIVNUM, and Z.
[in]VT
          VT is REAL array, dimension ( LDU, SMLSIZ+1 ).
         On entry, VT**T contains the right singular vector matrices of
         all subproblems at the bottom level.
[in]K
          K is INTEGER array, dimension ( N ).
[in]DIFL
          DIFL is REAL array, dimension ( LDU, NLVL ).
         where NLVL = INT(log_2 (N/(SMLSIZ+1))) + 1.
[in]DIFR
          DIFR is REAL array, dimension ( LDU, 2 * NLVL ).
         On entry, DIFL(*, I) and DIFR(*, 2 * I -1) record
         distances between singular values on the I-th level and
         singular values on the (I -1)-th level, and DIFR(*, 2 * I)
         record the normalizing factors of the right singular vectors
         matrices of subproblems on I-th level.
[in]Z
          Z is REAL array, dimension ( LDU, NLVL ).
         On entry, Z(1, I) contains the components of the deflation-
         adjusted updating row vector for subproblems on the I-th
         level.
[in]POLES
          POLES is REAL array, dimension ( LDU, 2 * NLVL ).
         On entry, POLES(*, 2 * I -1: 2 * I) contains the new and old
         singular values involved in the secular equations on the I-th
         level.
[in]GIVPTR
          GIVPTR is INTEGER array, dimension ( N ).
         On entry, GIVPTR( I ) records the number of Givens
         rotations performed on the I-th problem on the computation
         tree.
[in]GIVCOL
          GIVCOL is INTEGER array, dimension ( LDGCOL, 2 * NLVL ).
         On entry, for each I, GIVCOL(*, 2 * I - 1: 2 * I) records the
         locations of Givens rotations performed on the I-th level on
         the computation tree.
[in]LDGCOL
          LDGCOL is INTEGER, LDGCOL = > N.
         The leading dimension of arrays GIVCOL and PERM.
[in]PERM
          PERM is INTEGER array, dimension ( LDGCOL, NLVL ).
         On entry, PERM(*, I) records permutations done on the I-th
         level of the computation tree.
[in]GIVNUM
          GIVNUM is REAL array, dimension ( LDU, 2 * NLVL ).
         On entry, GIVNUM(*, 2 *I -1 : 2 * I) records the C- and S-
         values of Givens rotations performed on the I-th level on the
         computation tree.
[in]C
          C is REAL 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.
[in]S
          S is REAL 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.
[out]WORK
          WORK is REAL array.
         The dimension must be at least N.
[out]IWORK
          IWORK is INTEGER array.
         The dimension must be at least 3 * N
[out]INFO
          INFO is INTEGER
          = 0:  successful exit.
          < 0:  if INFO = -i, the i-th argument had an illegal value.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
September 2012
Contributors:
Ming Gu and Ren-Cang Li, Computer Science Division, University of California at Berkeley, USA
Osni Marques, LBNL/NERSC, USA

Definition at line 271 of file slalsa.f.

271 *
272 * -- LAPACK computational routine (version 3.4.2) --
273 * -- LAPACK is a software package provided by Univ. of Tennessee, --
274 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
275 * September 2012
276 *
277 * .. Scalar Arguments ..
278  INTEGER icompq, info, ldb, ldbx, ldgcol, ldu, n, nrhs,
279  $ smlsiz
280 * ..
281 * .. Array Arguments ..
282  INTEGER givcol( ldgcol, * ), givptr( * ), iwork( * ),
283  $ k( * ), perm( ldgcol, * )
284  REAL b( ldb, * ), bx( ldbx, * ), c( * ),
285  $ difl( ldu, * ), difr( ldu, * ),
286  $ givnum( ldu, * ), poles( ldu, * ), s( * ),
287  $ u( ldu, * ), vt( ldu, * ), work( * ),
288  $ z( ldu, * )
289 * ..
290 *
291 * =====================================================================
292 *
293 * .. Parameters ..
294  REAL zero, one
295  parameter ( zero = 0.0e0, one = 1.0e0 )
296 * ..
297 * .. Local Scalars ..
298  INTEGER i, i1, ic, im1, inode, j, lf, ll, lvl, lvl2,
299  $ nd, ndb1, ndiml, ndimr, nl, nlf, nlp1, nlvl,
300  $ nr, nrf, nrp1, sqre
301 * ..
302 * .. External Subroutines ..
303  EXTERNAL scopy, sgemm, slals0, slasdt, xerbla
304 * ..
305 * .. Executable Statements ..
306 *
307 * Test the input parameters.
308 *
309  info = 0
310 *
311  IF( ( icompq.LT.0 ) .OR. ( icompq.GT.1 ) ) THEN
312  info = -1
313  ELSE IF( smlsiz.LT.3 ) THEN
314  info = -2
315  ELSE IF( n.LT.smlsiz ) THEN
316  info = -3
317  ELSE IF( nrhs.LT.1 ) THEN
318  info = -4
319  ELSE IF( ldb.LT.n ) THEN
320  info = -6
321  ELSE IF( ldbx.LT.n ) THEN
322  info = -8
323  ELSE IF( ldu.LT.n ) THEN
324  info = -10
325  ELSE IF( ldgcol.LT.n ) THEN
326  info = -19
327  END IF
328  IF( info.NE.0 ) THEN
329  CALL xerbla( 'SLALSA', -info )
330  RETURN
331  END IF
332 *
333 * Book-keeping and setting up the computation tree.
334 *
335  inode = 1
336  ndiml = inode + n
337  ndimr = ndiml + n
338 *
339  CALL slasdt( n, nlvl, nd, iwork( inode ), iwork( ndiml ),
340  $ iwork( ndimr ), smlsiz )
341 *
342 * The following code applies back the left singular vector factors.
343 * For applying back the right singular vector factors, go to 50.
344 *
345  IF( icompq.EQ.1 ) THEN
346  GO TO 50
347  END IF
348 *
349 * The nodes on the bottom level of the tree were solved
350 * by SLASDQ. The corresponding left and right singular vector
351 * matrices are in explicit form. First apply back the left
352 * singular vector matrices.
353 *
354  ndb1 = ( nd+1 ) / 2
355  DO 10 i = ndb1, nd
356 *
357 * IC : center row of each node
358 * NL : number of rows of left subproblem
359 * NR : number of rows of right subproblem
360 * NLF: starting row of the left subproblem
361 * NRF: starting row of the right subproblem
362 *
363  i1 = i - 1
364  ic = iwork( inode+i1 )
365  nl = iwork( ndiml+i1 )
366  nr = iwork( ndimr+i1 )
367  nlf = ic - nl
368  nrf = ic + 1
369  CALL sgemm( 'T', 'N', nl, nrhs, nl, one, u( nlf, 1 ), ldu,
370  $ b( nlf, 1 ), ldb, zero, bx( nlf, 1 ), ldbx )
371  CALL sgemm( 'T', 'N', nr, nrhs, nr, one, u( nrf, 1 ), ldu,
372  $ b( nrf, 1 ), ldb, zero, bx( nrf, 1 ), ldbx )
373  10 CONTINUE
374 *
375 * Next copy the rows of B that correspond to unchanged rows
376 * in the bidiagonal matrix to BX.
377 *
378  DO 20 i = 1, nd
379  ic = iwork( inode+i-1 )
380  CALL scopy( nrhs, b( ic, 1 ), ldb, bx( ic, 1 ), ldbx )
381  20 CONTINUE
382 *
383 * Finally go through the left singular vector matrices of all
384 * the other subproblems bottom-up on the tree.
385 *
386  j = 2**nlvl
387  sqre = 0
388 *
389  DO 40 lvl = nlvl, 1, -1
390  lvl2 = 2*lvl - 1
391 *
392 * find the first node LF and last node LL on
393 * the current level LVL
394 *
395  IF( lvl.EQ.1 ) THEN
396  lf = 1
397  ll = 1
398  ELSE
399  lf = 2**( lvl-1 )
400  ll = 2*lf - 1
401  END IF
402  DO 30 i = lf, ll
403  im1 = i - 1
404  ic = iwork( inode+im1 )
405  nl = iwork( ndiml+im1 )
406  nr = iwork( ndimr+im1 )
407  nlf = ic - nl
408  nrf = ic + 1
409  j = j - 1
410  CALL slals0( icompq, nl, nr, sqre, nrhs, bx( nlf, 1 ), ldbx,
411  $ b( nlf, 1 ), ldb, perm( nlf, lvl ),
412  $ givptr( j ), givcol( nlf, lvl2 ), ldgcol,
413  $ givnum( nlf, lvl2 ), ldu, poles( nlf, lvl2 ),
414  $ difl( nlf, lvl ), difr( nlf, lvl2 ),
415  $ z( nlf, lvl ), k( j ), c( j ), s( j ), work,
416  $ info )
417  30 CONTINUE
418  40 CONTINUE
419  GO TO 90
420 *
421 * ICOMPQ = 1: applying back the right singular vector factors.
422 *
423  50 CONTINUE
424 *
425 * First now go through the right singular vector matrices of all
426 * the tree nodes top-down.
427 *
428  j = 0
429  DO 70 lvl = 1, nlvl
430  lvl2 = 2*lvl - 1
431 *
432 * Find the first node LF and last node LL on
433 * the current level LVL.
434 *
435  IF( lvl.EQ.1 ) THEN
436  lf = 1
437  ll = 1
438  ELSE
439  lf = 2**( lvl-1 )
440  ll = 2*lf - 1
441  END IF
442  DO 60 i = ll, lf, -1
443  im1 = i - 1
444  ic = iwork( inode+im1 )
445  nl = iwork( ndiml+im1 )
446  nr = iwork( ndimr+im1 )
447  nlf = ic - nl
448  nrf = ic + 1
449  IF( i.EQ.ll ) THEN
450  sqre = 0
451  ELSE
452  sqre = 1
453  END IF
454  j = j + 1
455  CALL slals0( icompq, nl, nr, sqre, nrhs, b( nlf, 1 ), ldb,
456  $ bx( nlf, 1 ), ldbx, perm( nlf, lvl ),
457  $ givptr( j ), givcol( nlf, lvl2 ), ldgcol,
458  $ givnum( nlf, lvl2 ), ldu, poles( nlf, lvl2 ),
459  $ difl( nlf, lvl ), difr( nlf, lvl2 ),
460  $ z( nlf, lvl ), k( j ), c( j ), s( j ), work,
461  $ info )
462  60 CONTINUE
463  70 CONTINUE
464 *
465 * The nodes on the bottom level of the tree were solved
466 * by SLASDQ. The corresponding right singular vector
467 * matrices are in explicit form. Apply them back.
468 *
469  ndb1 = ( nd+1 ) / 2
470  DO 80 i = ndb1, nd
471  i1 = i - 1
472  ic = iwork( inode+i1 )
473  nl = iwork( ndiml+i1 )
474  nr = iwork( ndimr+i1 )
475  nlp1 = nl + 1
476  IF( i.EQ.nd ) THEN
477  nrp1 = nr
478  ELSE
479  nrp1 = nr + 1
480  END IF
481  nlf = ic - nl
482  nrf = ic + 1
483  CALL sgemm( 'T', 'N', nlp1, nrhs, nlp1, one, vt( nlf, 1 ), ldu,
484  $ b( nlf, 1 ), ldb, zero, bx( nlf, 1 ), ldbx )
485  CALL sgemm( 'T', 'N', nrp1, nrhs, nrp1, one, vt( nrf, 1 ), ldu,
486  $ b( nrf, 1 ), ldb, zero, bx( nrf, 1 ), ldbx )
487  80 CONTINUE
488 *
489  90 CONTINUE
490 *
491  RETURN
492 *
493 * End of SLALSA
494 *
subroutine slals0(ICOMPQ, NL, NR, SQRE, NRHS, B, LDB, BX, LDBX, PERM, GIVPTR, GIVCOL, LDGCOL, GIVNUM, LDGNUM, POLES, DIFL, DIFR, Z, K, C, S, WORK, INFO)
SLALS0 applies back multiplying factors in solving the least squares problem using divide and conquer...
Definition: slals0.f:270
subroutine slasdt(N, LVL, ND, INODE, NDIML, NDIMR, MSUB)
SLASDT creates a tree of subproblems for bidiagonal divide and conquer. Used by sbdsdc.
Definition: slasdt.f:107
subroutine sgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
SGEMM
Definition: sgemm.f:189
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine scopy(N, SX, INCX, SY, INCY)
SCOPY
Definition: scopy.f:53

Here is the call graph for this function:

Here is the caller graph for this function: