LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ dlalsa()

subroutine dlalsa ( integer  ICOMPQ,
integer  SMLSIZ,
integer  N,
integer  NRHS,
double precision, dimension( ldb, * )  B,
integer  LDB,
double precision, dimension( ldbx, * )  BX,
integer  LDBX,
double precision, dimension( ldu, * )  U,
integer  LDU,
double precision, dimension( ldu, * )  VT,
integer, dimension( * )  K,
double precision, dimension( ldu, * )  DIFL,
double precision, dimension( ldu, * )  DIFR,
double precision, dimension( ldu, * )  Z,
double precision, dimension( ldu, * )  POLES,
integer, dimension( * )  GIVPTR,
integer, dimension( ldgcol, * )  GIVCOL,
integer  LDGCOL,
integer, dimension( ldgcol, * )  PERM,
double precision, dimension( ldu, * )  GIVNUM,
double precision, dimension( * )  C,
double precision, dimension( * )  S,
double precision, dimension( * )  WORK,
integer, dimension( * )  IWORK,
integer  INFO 
)

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

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

Purpose:
 DLALSA 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, DLALSA applies the inverse of the left singular vector
 matrix of an upper bidiagonal matrix to the right hand side; and if
 ICOMPQ = 1, DLALSA applies the right singular vector matrix to the
 right hand side. The singular vector matrices were generated in
 compact form by DLALSA.
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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION array, dimension ( LDU, NLVL ).
         where NLVL = INT(log_2 (N/(SMLSIZ+1))) + 1.
[in]DIFR
          DIFR is DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION array, dimension (N)
[out]IWORK
          IWORK is INTEGER array, dimension (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
June 2017
Contributors:
Ming Gu and Ren-Cang Li, Computer Science Division, University of California at Berkeley, USA
Osni Marques, LBNL/NERSC, USA

Definition at line 269 of file dlalsa.f.

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