LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine dlasd3 ( integer  NL,
integer  NR,
integer  SQRE,
integer  K,
double precision, dimension( * )  D,
double precision, dimension( ldq, * )  Q,
integer  LDQ,
double precision, dimension( * )  DSIGMA,
double precision, dimension( ldu, * )  U,
integer  LDU,
double precision, dimension( ldu2, * )  U2,
integer  LDU2,
double precision, dimension( ldvt, * )  VT,
integer  LDVT,
double precision, dimension( ldvt2, * )  VT2,
integer  LDVT2,
integer, dimension( * )  IDXC,
integer, dimension( * )  CTOT,
double precision, dimension( * )  Z,
integer  INFO 
)

DLASD3 finds all square roots of the roots of the secular equation, as defined by the values in D and Z, and then updates the singular vectors by matrix multiplication. Used by sbdsdc.

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

Purpose:
 DLASD3 finds all the square roots of the roots of the secular
 equation, as defined by the values in D and Z.  It makes the
 appropriate calls to DLASD4 and then updates the singular
 vectors by matrix multiplication.

 This code makes very mild assumptions about floating point
 arithmetic. It will work on machines with a guard digit in
 add/subtract, or on those binary machines without guard digits
 which subtract like the Cray XMP, Cray YMP, Cray C 90, or Cray 2.
 It could conceivably fail on hexadecimal or decimal machines
 without guard digits, but we know of none.

 DLASD3 is called from DLASD1.
Parameters
[in]NL
          NL is INTEGER
         The row dimension of the upper block.  NL >= 1.
[in]NR
          NR is INTEGER
         The row dimension of the lower block.  NR >= 1.
[in]SQRE
          SQRE is INTEGER
         = 0: the lower block is an NR-by-NR square matrix.
         = 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.
[in]K
          K is INTEGER
         The size of the secular equation, 1 =< K = < N.
[out]D
          D is DOUBLE PRECISION array, dimension(K)
         On exit the square roots of the roots of the secular equation,
         in ascending order.
[out]Q
          Q is DOUBLE PRECISION array,
                     dimension at least (LDQ,K).
[in]LDQ
          LDQ is INTEGER
         The leading dimension of the array Q.  LDQ >= K.
[in]DSIGMA
          DSIGMA is DOUBLE PRECISION array, dimension(K)
         The first K elements of this array contain the old roots
         of the deflated updating problem.  These are the poles
         of the secular equation.
[out]U
          U is DOUBLE PRECISION array, dimension (LDU, N)
         The last N - K columns of this matrix contain the deflated
         left singular vectors.
[in]LDU
          LDU is INTEGER
         The leading dimension of the array U.  LDU >= N.
[in,out]U2
          U2 is DOUBLE PRECISION array, dimension (LDU2, N)
         The first K columns of this matrix contain the non-deflated
         left singular vectors for the split problem.
[in]LDU2
          LDU2 is INTEGER
         The leading dimension of the array U2.  LDU2 >= N.
[out]VT
          VT is DOUBLE PRECISION array, dimension (LDVT, M)
         The last M - K columns of VT**T contain the deflated
         right singular vectors.
[in]LDVT
          LDVT is INTEGER
         The leading dimension of the array VT.  LDVT >= N.
[in,out]VT2
          VT2 is DOUBLE PRECISION array, dimension (LDVT2, N)
         The first K columns of VT2**T contain the non-deflated
         right singular vectors for the split problem.
[in]LDVT2
          LDVT2 is INTEGER
         The leading dimension of the array VT2.  LDVT2 >= N.
[in]IDXC
          IDXC is INTEGER array, dimension ( N )
         The permutation used to arrange the columns of U (and rows of
         VT) into three groups:  the first group contains non-zero
         entries only at and above (or before) NL +1; the second
         contains non-zero entries only at and below (or after) NL+2;
         and the third is dense. The first column of U and the row of
         VT are treated separately, however.

         The rows of the singular vectors found by DLASD4
         must be likewise permuted before the matrix multiplies can
         take place.
[in]CTOT
          CTOT is INTEGER array, dimension ( 4 )
         A count of the total number of the various types of columns
         in U (or rows in VT), as described in IDXC. The fourth column
         type is any column which has been deflated.
[in]Z
          Z is DOUBLE PRECISION array, dimension (K)
         The first K elements of this array contain the components
         of the deflation-adjusted updating row vector.
[out]INFO
          INFO is INTEGER
         = 0:  successful exit.
         < 0:  if INFO = -i, the i-th argument had an illegal value.
         > 0:  if INFO = 1, a singular value did not converge
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2015
Contributors:
Ming Gu and Huan Ren, Computer Science Division, University of California at Berkeley, USA

Definition at line 227 of file dlasd3.f.

227 *
228 * -- LAPACK auxiliary routine (version 3.6.0) --
229 * -- LAPACK is a software package provided by Univ. of Tennessee, --
230 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
231 * November 2015
232 *
233 * .. Scalar Arguments ..
234  INTEGER info, k, ldq, ldu, ldu2, ldvt, ldvt2, nl, nr,
235  $ sqre
236 * ..
237 * .. Array Arguments ..
238  INTEGER ctot( * ), idxc( * )
239  DOUBLE PRECISION d( * ), dsigma( * ), q( ldq, * ), u( ldu, * ),
240  $ u2( ldu2, * ), vt( ldvt, * ), vt2( ldvt2, * ),
241  $ z( * )
242 * ..
243 *
244 * =====================================================================
245 *
246 * .. Parameters ..
247  DOUBLE PRECISION one, zero, negone
248  parameter ( one = 1.0d+0, zero = 0.0d+0,
249  $ negone = -1.0d+0 )
250 * ..
251 * .. Local Scalars ..
252  INTEGER ctemp, i, j, jc, ktemp, m, n, nlp1, nlp2, nrp1
253  DOUBLE PRECISION rho, temp
254 * ..
255 * .. External Functions ..
256  DOUBLE PRECISION dlamc3, dnrm2
257  EXTERNAL dlamc3, dnrm2
258 * ..
259 * .. External Subroutines ..
260  EXTERNAL dcopy, dgemm, dlacpy, dlascl, dlasd4, xerbla
261 * ..
262 * .. Intrinsic Functions ..
263  INTRINSIC abs, sign, sqrt
264 * ..
265 * .. Executable Statements ..
266 *
267 * Test the input parameters.
268 *
269  info = 0
270 *
271  IF( nl.LT.1 ) THEN
272  info = -1
273  ELSE IF( nr.LT.1 ) THEN
274  info = -2
275  ELSE IF( ( sqre.NE.1 ) .AND. ( sqre.NE.0 ) ) THEN
276  info = -3
277  END IF
278 *
279  n = nl + nr + 1
280  m = n + sqre
281  nlp1 = nl + 1
282  nlp2 = nl + 2
283 *
284  IF( ( k.LT.1 ) .OR. ( k.GT.n ) ) THEN
285  info = -4
286  ELSE IF( ldq.LT.k ) THEN
287  info = -7
288  ELSE IF( ldu.LT.n ) THEN
289  info = -10
290  ELSE IF( ldu2.LT.n ) THEN
291  info = -12
292  ELSE IF( ldvt.LT.m ) THEN
293  info = -14
294  ELSE IF( ldvt2.LT.m ) THEN
295  info = -16
296  END IF
297  IF( info.NE.0 ) THEN
298  CALL xerbla( 'DLASD3', -info )
299  RETURN
300  END IF
301 *
302 * Quick return if possible
303 *
304  IF( k.EQ.1 ) THEN
305  d( 1 ) = abs( z( 1 ) )
306  CALL dcopy( m, vt2( 1, 1 ), ldvt2, vt( 1, 1 ), ldvt )
307  IF( z( 1 ).GT.zero ) THEN
308  CALL dcopy( n, u2( 1, 1 ), 1, u( 1, 1 ), 1 )
309  ELSE
310  DO 10 i = 1, n
311  u( i, 1 ) = -u2( i, 1 )
312  10 CONTINUE
313  END IF
314  RETURN
315  END IF
316 *
317 * Modify values DSIGMA(i) to make sure all DSIGMA(i)-DSIGMA(j) can
318 * be computed with high relative accuracy (barring over/underflow).
319 * This is a problem on machines without a guard digit in
320 * add/subtract (Cray XMP, Cray YMP, Cray C 90 and Cray 2).
321 * The following code replaces DSIGMA(I) by 2*DSIGMA(I)-DSIGMA(I),
322 * which on any of these machines zeros out the bottommost
323 * bit of DSIGMA(I) if it is 1; this makes the subsequent
324 * subtractions DSIGMA(I)-DSIGMA(J) unproblematic when cancellation
325 * occurs. On binary machines with a guard digit (almost all
326 * machines) it does not change DSIGMA(I) at all. On hexadecimal
327 * and decimal machines with a guard digit, it slightly
328 * changes the bottommost bits of DSIGMA(I). It does not account
329 * for hexadecimal or decimal machines without guard digits
330 * (we know of none). We use a subroutine call to compute
331 * 2*DSIGMA(I) to prevent optimizing compilers from eliminating
332 * this code.
333 *
334  DO 20 i = 1, k
335  dsigma( i ) = dlamc3( dsigma( i ), dsigma( i ) ) - dsigma( i )
336  20 CONTINUE
337 *
338 * Keep a copy of Z.
339 *
340  CALL dcopy( k, z, 1, q, 1 )
341 *
342 * Normalize Z.
343 *
344  rho = dnrm2( k, z, 1 )
345  CALL dlascl( 'G', 0, 0, rho, one, k, 1, z, k, info )
346  rho = rho*rho
347 *
348 * Find the new singular values.
349 *
350  DO 30 j = 1, k
351  CALL dlasd4( k, j, dsigma, z, u( 1, j ), rho, d( j ),
352  $ vt( 1, j ), info )
353 *
354 * If the zero finder fails, report the convergence failure.
355 *
356  IF( info.NE.0 ) THEN
357  RETURN
358  END IF
359  30 CONTINUE
360 *
361 * Compute updated Z.
362 *
363  DO 60 i = 1, k
364  z( i ) = u( i, k )*vt( i, k )
365  DO 40 j = 1, i - 1
366  z( i ) = z( i )*( u( i, j )*vt( i, j ) /
367  $ ( dsigma( i )-dsigma( j ) ) /
368  $ ( dsigma( i )+dsigma( j ) ) )
369  40 CONTINUE
370  DO 50 j = i, k - 1
371  z( i ) = z( i )*( u( i, j )*vt( i, j ) /
372  $ ( dsigma( i )-dsigma( j+1 ) ) /
373  $ ( dsigma( i )+dsigma( j+1 ) ) )
374  50 CONTINUE
375  z( i ) = sign( sqrt( abs( z( i ) ) ), q( i, 1 ) )
376  60 CONTINUE
377 *
378 * Compute left singular vectors of the modified diagonal matrix,
379 * and store related information for the right singular vectors.
380 *
381  DO 90 i = 1, k
382  vt( 1, i ) = z( 1 ) / u( 1, i ) / vt( 1, i )
383  u( 1, i ) = negone
384  DO 70 j = 2, k
385  vt( j, i ) = z( j ) / u( j, i ) / vt( j, i )
386  u( j, i ) = dsigma( j )*vt( j, i )
387  70 CONTINUE
388  temp = dnrm2( k, u( 1, i ), 1 )
389  q( 1, i ) = u( 1, i ) / temp
390  DO 80 j = 2, k
391  jc = idxc( j )
392  q( j, i ) = u( jc, i ) / temp
393  80 CONTINUE
394  90 CONTINUE
395 *
396 * Update the left singular vector matrix.
397 *
398  IF( k.EQ.2 ) THEN
399  CALL dgemm( 'N', 'N', n, k, k, one, u2, ldu2, q, ldq, zero, u,
400  $ ldu )
401  GO TO 100
402  END IF
403  IF( ctot( 1 ).GT.0 ) THEN
404  CALL dgemm( 'N', 'N', nl, k, ctot( 1 ), one, u2( 1, 2 ), ldu2,
405  $ q( 2, 1 ), ldq, zero, u( 1, 1 ), ldu )
406  IF( ctot( 3 ).GT.0 ) THEN
407  ktemp = 2 + ctot( 1 ) + ctot( 2 )
408  CALL dgemm( 'N', 'N', nl, k, ctot( 3 ), one, u2( 1, ktemp ),
409  $ ldu2, q( ktemp, 1 ), ldq, one, u( 1, 1 ), ldu )
410  END IF
411  ELSE IF( ctot( 3 ).GT.0 ) THEN
412  ktemp = 2 + ctot( 1 ) + ctot( 2 )
413  CALL dgemm( 'N', 'N', nl, k, ctot( 3 ), one, u2( 1, ktemp ),
414  $ ldu2, q( ktemp, 1 ), ldq, zero, u( 1, 1 ), ldu )
415  ELSE
416  CALL dlacpy( 'F', nl, k, u2, ldu2, u, ldu )
417  END IF
418  CALL dcopy( k, q( 1, 1 ), ldq, u( nlp1, 1 ), ldu )
419  ktemp = 2 + ctot( 1 )
420  ctemp = ctot( 2 ) + ctot( 3 )
421  CALL dgemm( 'N', 'N', nr, k, ctemp, one, u2( nlp2, ktemp ), ldu2,
422  $ q( ktemp, 1 ), ldq, zero, u( nlp2, 1 ), ldu )
423 *
424 * Generate the right singular vectors.
425 *
426  100 CONTINUE
427  DO 120 i = 1, k
428  temp = dnrm2( k, vt( 1, i ), 1 )
429  q( i, 1 ) = vt( 1, i ) / temp
430  DO 110 j = 2, k
431  jc = idxc( j )
432  q( i, j ) = vt( jc, i ) / temp
433  110 CONTINUE
434  120 CONTINUE
435 *
436 * Update the right singular vector matrix.
437 *
438  IF( k.EQ.2 ) THEN
439  CALL dgemm( 'N', 'N', k, m, k, one, q, ldq, vt2, ldvt2, zero,
440  $ vt, ldvt )
441  RETURN
442  END IF
443  ktemp = 1 + ctot( 1 )
444  CALL dgemm( 'N', 'N', k, nlp1, ktemp, one, q( 1, 1 ), ldq,
445  $ vt2( 1, 1 ), ldvt2, zero, vt( 1, 1 ), ldvt )
446  ktemp = 2 + ctot( 1 ) + ctot( 2 )
447  IF( ktemp.LE.ldvt2 )
448  $ CALL dgemm( 'N', 'N', k, nlp1, ctot( 3 ), one, q( 1, ktemp ),
449  $ ldq, vt2( ktemp, 1 ), ldvt2, one, vt( 1, 1 ),
450  $ ldvt )
451 *
452  ktemp = ctot( 1 ) + 1
453  nrp1 = nr + sqre
454  IF( ktemp.GT.1 ) THEN
455  DO 130 i = 1, k
456  q( i, ktemp ) = q( i, 1 )
457  130 CONTINUE
458  DO 140 i = nlp2, m
459  vt2( ktemp, i ) = vt2( 1, i )
460  140 CONTINUE
461  END IF
462  ctemp = 1 + ctot( 2 ) + ctot( 3 )
463  CALL dgemm( 'N', 'N', k, nrp1, ctemp, one, q( 1, ktemp ), ldq,
464  $ vt2( ktemp, nlp2 ), ldvt2, zero, vt( 1, nlp2 ), ldvt )
465 *
466  RETURN
467 *
468 * End of DLASD3
469 *
double precision function dlamc3(A, B)
DLAMC3
Definition: dlamch.f:169
subroutine dcopy(N, DX, INCX, DY, INCY)
DCOPY
Definition: dcopy.f:53
subroutine dlacpy(UPLO, M, N, A, LDA, B, LDB)
DLACPY copies all or part of one two-dimensional array to another.
Definition: dlacpy.f:105
subroutine dlascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
DLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition: dlascl.f:145
subroutine dgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
DGEMM
Definition: dgemm.f:189
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
double precision function dnrm2(N, X, INCX)
DNRM2
Definition: dnrm2.f:56
subroutine dlasd4(N, I, D, Z, DELTA, RHO, SIGMA, WORK, INFO)
DLASD4 computes the square root of the i-th updated eigenvalue of a positive symmetric rank-one modif...
Definition: dlasd4.f:155

Here is the call graph for this function:

Here is the caller graph for this function: