LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ zlalsa()

subroutine zlalsa ( integer  ICOMPQ,
integer  SMLSIZ,
integer  N,
integer  NRHS,
complex*16, dimension( ldb, * )  B,
integer  LDB,
complex*16, 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( * )  RWORK,
integer, dimension( * )  IWORK,
integer  INFO 
)

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

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

Purpose:
 ZLALSA 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, ZLALSA applies the inverse of the left singular vector
 matrix of an upper bidiagonal matrix to the right hand side; and if
 ICOMPQ = 1, ZLALSA applies the right singular vector matrix to the
 right hand side. The singular vector matrices were generated in
 compact form by ZLALSA.
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 COMPLEX*16 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 COMPLEX*16 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**H 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]RWORK
          RWORK is DOUBLE PRECISION array, dimension at least
         MAX( (SMLSZ+1)*NRHS*3, N*(1+NRHS) + 2*NRHS ).
[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 zlalsa.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 c( * ), difl( ldu, * ), difr( ldu, * ),
283  $ givnum( ldu, * ), poles( ldu, * ), rwork( * ),
284  $ s( * ), u( ldu, * ), vt( ldu, * ), z( ldu, * )
285  COMPLEX*16 b( ldb, * ), bx( ldbx, * )
286 * ..
287 *
288 * =====================================================================
289 *
290 * .. Parameters ..
291  DOUBLE PRECISION zero, one
292  parameter( zero = 0.0d0, one = 1.0d0 )
293 * ..
294 * .. Local Scalars ..
295  INTEGER i, i1, ic, im1, inode, j, jcol, jimag, jreal,
296  $ jrow, lf, ll, lvl, lvl2, nd, ndb1, ndiml,
297  $ ndimr, nl, nlf, nlp1, nlvl, nr, nrf, nrp1, sqre
298 * ..
299 * .. External Subroutines ..
300  EXTERNAL dgemm, dlasdt, xerbla, zcopy, zlals0
301 * ..
302 * .. Intrinsic Functions ..
303  INTRINSIC dble, dcmplx, dimag
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( 'ZLALSA', -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 dlasdt( 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 170.
344 *
345  IF( icompq.EQ.1 ) THEN
346  GO TO 170
347  END IF
348 *
349 * The nodes on the bottom level of the tree were solved
350 * by DLASDQ. 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 130 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 *
370 * Since B and BX are complex, the following call to DGEMM
371 * is performed in two steps (real and imaginary parts).
372 *
373 * CALL DGEMM( 'T', 'N', NL, NRHS, NL, ONE, U( NLF, 1 ), LDU,
374 * $ B( NLF, 1 ), LDB, ZERO, BX( NLF, 1 ), LDBX )
375 *
376  j = nl*nrhs*2
377  DO 20 jcol = 1, nrhs
378  DO 10 jrow = nlf, nlf + nl - 1
379  j = j + 1
380  rwork( j ) = dble( b( jrow, jcol ) )
381  10 CONTINUE
382  20 CONTINUE
383  CALL dgemm( 'T', 'N', nl, nrhs, nl, one, u( nlf, 1 ), ldu,
384  $ rwork( 1+nl*nrhs*2 ), nl, zero, rwork( 1 ), nl )
385  j = nl*nrhs*2
386  DO 40 jcol = 1, nrhs
387  DO 30 jrow = nlf, nlf + nl - 1
388  j = j + 1
389  rwork( j ) = dimag( b( jrow, jcol ) )
390  30 CONTINUE
391  40 CONTINUE
392  CALL dgemm( 'T', 'N', nl, nrhs, nl, one, u( nlf, 1 ), ldu,
393  $ rwork( 1+nl*nrhs*2 ), nl, zero, rwork( 1+nl*nrhs ),
394  $ nl )
395  jreal = 0
396  jimag = nl*nrhs
397  DO 60 jcol = 1, nrhs
398  DO 50 jrow = nlf, nlf + nl - 1
399  jreal = jreal + 1
400  jimag = jimag + 1
401  bx( jrow, jcol ) = dcmplx( rwork( jreal ),
402  $ rwork( jimag ) )
403  50 CONTINUE
404  60 CONTINUE
405 *
406 * Since B and BX are complex, the following call to DGEMM
407 * is performed in two steps (real and imaginary parts).
408 *
409 * CALL DGEMM( 'T', 'N', NR, NRHS, NR, ONE, U( NRF, 1 ), LDU,
410 * $ B( NRF, 1 ), LDB, ZERO, BX( NRF, 1 ), LDBX )
411 *
412  j = nr*nrhs*2
413  DO 80 jcol = 1, nrhs
414  DO 70 jrow = nrf, nrf + nr - 1
415  j = j + 1
416  rwork( j ) = dble( b( jrow, jcol ) )
417  70 CONTINUE
418  80 CONTINUE
419  CALL dgemm( 'T', 'N', nr, nrhs, nr, one, u( nrf, 1 ), ldu,
420  $ rwork( 1+nr*nrhs*2 ), nr, zero, rwork( 1 ), nr )
421  j = nr*nrhs*2
422  DO 100 jcol = 1, nrhs
423  DO 90 jrow = nrf, nrf + nr - 1
424  j = j + 1
425  rwork( j ) = dimag( b( jrow, jcol ) )
426  90 CONTINUE
427  100 CONTINUE
428  CALL dgemm( 'T', 'N', nr, nrhs, nr, one, u( nrf, 1 ), ldu,
429  $ rwork( 1+nr*nrhs*2 ), nr, zero, rwork( 1+nr*nrhs ),
430  $ nr )
431  jreal = 0
432  jimag = nr*nrhs
433  DO 120 jcol = 1, nrhs
434  DO 110 jrow = nrf, nrf + nr - 1
435  jreal = jreal + 1
436  jimag = jimag + 1
437  bx( jrow, jcol ) = dcmplx( rwork( jreal ),
438  $ rwork( jimag ) )
439  110 CONTINUE
440  120 CONTINUE
441 *
442  130 CONTINUE
443 *
444 * Next copy the rows of B that correspond to unchanged rows
445 * in the bidiagonal matrix to BX.
446 *
447  DO 140 i = 1, nd
448  ic = iwork( inode+i-1 )
449  CALL zcopy( nrhs, b( ic, 1 ), ldb, bx( ic, 1 ), ldbx )
450  140 CONTINUE
451 *
452 * Finally go through the left singular vector matrices of all
453 * the other subproblems bottom-up on the tree.
454 *
455  j = 2**nlvl
456  sqre = 0
457 *
458  DO 160 lvl = nlvl, 1, -1
459  lvl2 = 2*lvl - 1
460 *
461 * find the first node LF and last node LL on
462 * the current level LVL
463 *
464  IF( lvl.EQ.1 ) THEN
465  lf = 1
466  ll = 1
467  ELSE
468  lf = 2**( lvl-1 )
469  ll = 2*lf - 1
470  END IF
471  DO 150 i = lf, ll
472  im1 = i - 1
473  ic = iwork( inode+im1 )
474  nl = iwork( ndiml+im1 )
475  nr = iwork( ndimr+im1 )
476  nlf = ic - nl
477  nrf = ic + 1
478  j = j - 1
479  CALL zlals0( icompq, nl, nr, sqre, nrhs, bx( nlf, 1 ), ldbx,
480  $ b( nlf, 1 ), ldb, perm( nlf, lvl ),
481  $ givptr( j ), givcol( nlf, lvl2 ), ldgcol,
482  $ givnum( nlf, lvl2 ), ldu, poles( nlf, lvl2 ),
483  $ difl( nlf, lvl ), difr( nlf, lvl2 ),
484  $ z( nlf, lvl ), k( j ), c( j ), s( j ), rwork,
485  $ info )
486  150 CONTINUE
487  160 CONTINUE
488  GO TO 330
489 *
490 * ICOMPQ = 1: applying back the right singular vector factors.
491 *
492  170 CONTINUE
493 *
494 * First now go through the right singular vector matrices of all
495 * the tree nodes top-down.
496 *
497  j = 0
498  DO 190 lvl = 1, nlvl
499  lvl2 = 2*lvl - 1
500 *
501 * Find the first node LF and last node LL on
502 * the current level LVL.
503 *
504  IF( lvl.EQ.1 ) THEN
505  lf = 1
506  ll = 1
507  ELSE
508  lf = 2**( lvl-1 )
509  ll = 2*lf - 1
510  END IF
511  DO 180 i = ll, lf, -1
512  im1 = i - 1
513  ic = iwork( inode+im1 )
514  nl = iwork( ndiml+im1 )
515  nr = iwork( ndimr+im1 )
516  nlf = ic - nl
517  nrf = ic + 1
518  IF( i.EQ.ll ) THEN
519  sqre = 0
520  ELSE
521  sqre = 1
522  END IF
523  j = j + 1
524  CALL zlals0( icompq, nl, nr, sqre, nrhs, b( nlf, 1 ), ldb,
525  $ bx( nlf, 1 ), ldbx, perm( nlf, lvl ),
526  $ givptr( j ), givcol( nlf, lvl2 ), ldgcol,
527  $ givnum( nlf, lvl2 ), ldu, poles( nlf, lvl2 ),
528  $ difl( nlf, lvl ), difr( nlf, lvl2 ),
529  $ z( nlf, lvl ), k( j ), c( j ), s( j ), rwork,
530  $ info )
531  180 CONTINUE
532  190 CONTINUE
533 *
534 * The nodes on the bottom level of the tree were solved
535 * by DLASDQ. The corresponding right singular vector
536 * matrices are in explicit form. Apply them back.
537 *
538  ndb1 = ( nd+1 ) / 2
539  DO 320 i = ndb1, nd
540  i1 = i - 1
541  ic = iwork( inode+i1 )
542  nl = iwork( ndiml+i1 )
543  nr = iwork( ndimr+i1 )
544  nlp1 = nl + 1
545  IF( i.EQ.nd ) THEN
546  nrp1 = nr
547  ELSE
548  nrp1 = nr + 1
549  END IF
550  nlf = ic - nl
551  nrf = ic + 1
552 *
553 * Since B and BX are complex, the following call to DGEMM is
554 * performed in two steps (real and imaginary parts).
555 *
556 * CALL DGEMM( 'T', 'N', NLP1, NRHS, NLP1, ONE, VT( NLF, 1 ), LDU,
557 * $ B( NLF, 1 ), LDB, ZERO, BX( NLF, 1 ), LDBX )
558 *
559  j = nlp1*nrhs*2
560  DO 210 jcol = 1, nrhs
561  DO 200 jrow = nlf, nlf + nlp1 - 1
562  j = j + 1
563  rwork( j ) = dble( b( jrow, jcol ) )
564  200 CONTINUE
565  210 CONTINUE
566  CALL dgemm( 'T', 'N', nlp1, nrhs, nlp1, one, vt( nlf, 1 ), ldu,
567  $ rwork( 1+nlp1*nrhs*2 ), nlp1, zero, rwork( 1 ),
568  $ nlp1 )
569  j = nlp1*nrhs*2
570  DO 230 jcol = 1, nrhs
571  DO 220 jrow = nlf, nlf + nlp1 - 1
572  j = j + 1
573  rwork( j ) = dimag( b( jrow, jcol ) )
574  220 CONTINUE
575  230 CONTINUE
576  CALL dgemm( 'T', 'N', nlp1, nrhs, nlp1, one, vt( nlf, 1 ), ldu,
577  $ rwork( 1+nlp1*nrhs*2 ), nlp1, zero,
578  $ rwork( 1+nlp1*nrhs ), nlp1 )
579  jreal = 0
580  jimag = nlp1*nrhs
581  DO 250 jcol = 1, nrhs
582  DO 240 jrow = nlf, nlf + nlp1 - 1
583  jreal = jreal + 1
584  jimag = jimag + 1
585  bx( jrow, jcol ) = dcmplx( rwork( jreal ),
586  $ rwork( jimag ) )
587  240 CONTINUE
588  250 CONTINUE
589 *
590 * Since B and BX are complex, the following call to DGEMM is
591 * performed in two steps (real and imaginary parts).
592 *
593 * CALL DGEMM( 'T', 'N', NRP1, NRHS, NRP1, ONE, VT( NRF, 1 ), LDU,
594 * $ B( NRF, 1 ), LDB, ZERO, BX( NRF, 1 ), LDBX )
595 *
596  j = nrp1*nrhs*2
597  DO 270 jcol = 1, nrhs
598  DO 260 jrow = nrf, nrf + nrp1 - 1
599  j = j + 1
600  rwork( j ) = dble( b( jrow, jcol ) )
601  260 CONTINUE
602  270 CONTINUE
603  CALL dgemm( 'T', 'N', nrp1, nrhs, nrp1, one, vt( nrf, 1 ), ldu,
604  $ rwork( 1+nrp1*nrhs*2 ), nrp1, zero, rwork( 1 ),
605  $ nrp1 )
606  j = nrp1*nrhs*2
607  DO 290 jcol = 1, nrhs
608  DO 280 jrow = nrf, nrf + nrp1 - 1
609  j = j + 1
610  rwork( j ) = dimag( b( jrow, jcol ) )
611  280 CONTINUE
612  290 CONTINUE
613  CALL dgemm( 'T', 'N', nrp1, nrhs, nrp1, one, vt( nrf, 1 ), ldu,
614  $ rwork( 1+nrp1*nrhs*2 ), nrp1, zero,
615  $ rwork( 1+nrp1*nrhs ), nrp1 )
616  jreal = 0
617  jimag = nrp1*nrhs
618  DO 310 jcol = 1, nrhs
619  DO 300 jrow = nrf, nrf + nrp1 - 1
620  jreal = jreal + 1
621  jimag = jimag + 1
622  bx( jrow, jcol ) = dcmplx( rwork( jreal ),
623  $ rwork( jimag ) )
624  300 CONTINUE
625  310 CONTINUE
626 *
627  320 CONTINUE
628 *
629  330 CONTINUE
630 *
631  RETURN
632 *
633 * End of ZLALSA
634 *
subroutine zcopy(N, ZX, INCX, ZY, INCY)
ZCOPY
Definition: zcopy.f:83
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 zlals0(ICOMPQ, NL, NR, SQRE, NRHS, B, LDB, BX, LDBX, PERM, GIVPTR, GIVCOL, LDGCOL, GIVNUM, LDGNUM, POLES, DIFL, DIFR, Z, K, C, S, RWORK, INFO)
ZLALS0 applies back multiplying factors in solving the least squares problem using divide and conquer...
Definition: zlals0.f:272
Here is the call graph for this function:
Here is the caller graph for this function: