Statistiques
| Révision :

root / src / lapack / double / dlasq1.f @ 10

Historique | Voir | Annoter | Télécharger (4,7 ko)

1 1 pfleura2
      SUBROUTINE DLASQ1( N, D, E, WORK, INFO )
2 1 pfleura2
*
3 1 pfleura2
*  -- LAPACK routine (version 3.2)                                    --
4 1 pfleura2
*
5 1 pfleura2
*  -- Contributed by Osni Marques of the Lawrence Berkeley National   --
6 1 pfleura2
*  -- Laboratory and Beresford Parlett of the Univ. of California at  --
7 1 pfleura2
*  -- Berkeley                                                        --
8 1 pfleura2
*  -- November 2008                                                   --
9 1 pfleura2
*
10 1 pfleura2
*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
11 1 pfleura2
*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
12 1 pfleura2
*
13 1 pfleura2
*     .. Scalar Arguments ..
14 1 pfleura2
      INTEGER            INFO, N
15 1 pfleura2
*     ..
16 1 pfleura2
*     .. Array Arguments ..
17 1 pfleura2
      DOUBLE PRECISION   D( * ), E( * ), WORK( * )
18 1 pfleura2
*     ..
19 1 pfleura2
*
20 1 pfleura2
*  Purpose
21 1 pfleura2
*  =======
22 1 pfleura2
*
23 1 pfleura2
*  DLASQ1 computes the singular values of a real N-by-N bidiagonal
24 1 pfleura2
*  matrix with diagonal D and off-diagonal E. The singular values
25 1 pfleura2
*  are computed to high relative accuracy, in the absence of
26 1 pfleura2
*  denormalization, underflow and overflow. The algorithm was first
27 1 pfleura2
*  presented in
28 1 pfleura2
*
29 1 pfleura2
*  "Accurate singular values and differential qd algorithms" by K. V.
30 1 pfleura2
*  Fernando and B. N. Parlett, Numer. Math., Vol-67, No. 2, pp. 191-230,
31 1 pfleura2
*  1994,
32 1 pfleura2
*
33 1 pfleura2
*  and the present implementation is described in "An implementation of
34 1 pfleura2
*  the dqds Algorithm (Positive Case)", LAPACK Working Note.
35 1 pfleura2
*
36 1 pfleura2
*  Arguments
37 1 pfleura2
*  =========
38 1 pfleura2
*
39 1 pfleura2
*  N     (input) INTEGER
40 1 pfleura2
*        The number of rows and columns in the matrix. N >= 0.
41 1 pfleura2
*
42 1 pfleura2
*  D     (input/output) DOUBLE PRECISION array, dimension (N)
43 1 pfleura2
*        On entry, D contains the diagonal elements of the
44 1 pfleura2
*        bidiagonal matrix whose SVD is desired. On normal exit,
45 1 pfleura2
*        D contains the singular values in decreasing order.
46 1 pfleura2
*
47 1 pfleura2
*  E     (input/output) DOUBLE PRECISION array, dimension (N)
48 1 pfleura2
*        On entry, elements E(1:N-1) contain the off-diagonal elements
49 1 pfleura2
*        of the bidiagonal matrix whose SVD is desired.
50 1 pfleura2
*        On exit, E is overwritten.
51 1 pfleura2
*
52 1 pfleura2
*  WORK  (workspace) DOUBLE PRECISION array, dimension (4*N)
53 1 pfleura2
*
54 1 pfleura2
*  INFO  (output) INTEGER
55 1 pfleura2
*        = 0: successful exit
56 1 pfleura2
*        < 0: if INFO = -i, the i-th argument had an illegal value
57 1 pfleura2
*        > 0: the algorithm failed
58 1 pfleura2
*             = 1, a split was marked by a positive value in E
59 1 pfleura2
*             = 2, current block of Z not diagonalized after 30*N
60 1 pfleura2
*                  iterations (in inner while loop)
61 1 pfleura2
*             = 3, termination criterion of outer while loop not met
62 1 pfleura2
*                  (program created more than N unreduced blocks)
63 1 pfleura2
*
64 1 pfleura2
*  =====================================================================
65 1 pfleura2
*
66 1 pfleura2
*     .. Parameters ..
67 1 pfleura2
      DOUBLE PRECISION   ZERO
68 1 pfleura2
      PARAMETER          ( ZERO = 0.0D0 )
69 1 pfleura2
*     ..
70 1 pfleura2
*     .. Local Scalars ..
71 1 pfleura2
      INTEGER            I, IINFO
72 1 pfleura2
      DOUBLE PRECISION   EPS, SCALE, SAFMIN, SIGMN, SIGMX
73 1 pfleura2
*     ..
74 1 pfleura2
*     .. External Subroutines ..
75 1 pfleura2
      EXTERNAL           DCOPY, DLAS2, DLASCL, DLASQ2, DLASRT, XERBLA
76 1 pfleura2
*     ..
77 1 pfleura2
*     .. External Functions ..
78 1 pfleura2
      DOUBLE PRECISION   DLAMCH
79 1 pfleura2
      EXTERNAL           DLAMCH
80 1 pfleura2
*     ..
81 1 pfleura2
*     .. Intrinsic Functions ..
82 1 pfleura2
      INTRINSIC          ABS, MAX, SQRT
83 1 pfleura2
*     ..
84 1 pfleura2
*     .. Executable Statements ..
85 1 pfleura2
*
86 1 pfleura2
      INFO = 0
87 1 pfleura2
      IF( N.LT.0 ) THEN
88 1 pfleura2
         INFO = -2
89 1 pfleura2
         CALL XERBLA( 'DLASQ1', -INFO )
90 1 pfleura2
         RETURN
91 1 pfleura2
      ELSE IF( N.EQ.0 ) THEN
92 1 pfleura2
         RETURN
93 1 pfleura2
      ELSE IF( N.EQ.1 ) THEN
94 1 pfleura2
         D( 1 ) = ABS( D( 1 ) )
95 1 pfleura2
         RETURN
96 1 pfleura2
      ELSE IF( N.EQ.2 ) THEN
97 1 pfleura2
         CALL DLAS2( D( 1 ), E( 1 ), D( 2 ), SIGMN, SIGMX )
98 1 pfleura2
         D( 1 ) = SIGMX
99 1 pfleura2
         D( 2 ) = SIGMN
100 1 pfleura2
         RETURN
101 1 pfleura2
      END IF
102 1 pfleura2
*
103 1 pfleura2
*     Estimate the largest singular value.
104 1 pfleura2
*
105 1 pfleura2
      SIGMX = ZERO
106 1 pfleura2
      DO 10 I = 1, N - 1
107 1 pfleura2
         D( I ) = ABS( D( I ) )
108 1 pfleura2
         SIGMX = MAX( SIGMX, ABS( E( I ) ) )
109 1 pfleura2
   10 CONTINUE
110 1 pfleura2
      D( N ) = ABS( D( N ) )
111 1 pfleura2
*
112 1 pfleura2
*     Early return if SIGMX is zero (matrix is already diagonal).
113 1 pfleura2
*
114 1 pfleura2
      IF( SIGMX.EQ.ZERO ) THEN
115 1 pfleura2
         CALL DLASRT( 'D', N, D, IINFO )
116 1 pfleura2
         RETURN
117 1 pfleura2
      END IF
118 1 pfleura2
*
119 1 pfleura2
      DO 20 I = 1, N
120 1 pfleura2
         SIGMX = MAX( SIGMX, D( I ) )
121 1 pfleura2
   20 CONTINUE
122 1 pfleura2
*
123 1 pfleura2
*     Copy D and E into WORK (in the Z format) and scale (squaring the
124 1 pfleura2
*     input data makes scaling by a power of the radix pointless).
125 1 pfleura2
*
126 1 pfleura2
      EPS = DLAMCH( 'Precision' )
127 1 pfleura2
      SAFMIN = DLAMCH( 'Safe minimum' )
128 1 pfleura2
      SCALE = SQRT( EPS / SAFMIN )
129 1 pfleura2
      CALL DCOPY( N, D, 1, WORK( 1 ), 2 )
130 1 pfleura2
      CALL DCOPY( N-1, E, 1, WORK( 2 ), 2 )
131 1 pfleura2
      CALL DLASCL( 'G', 0, 0, SIGMX, SCALE, 2*N-1, 1, WORK, 2*N-1,
132 1 pfleura2
     $             IINFO )
133 1 pfleura2
*
134 1 pfleura2
*     Compute the q's and e's.
135 1 pfleura2
*
136 1 pfleura2
      DO 30 I = 1, 2*N - 1
137 1 pfleura2
         WORK( I ) = WORK( I )**2
138 1 pfleura2
   30 CONTINUE
139 1 pfleura2
      WORK( 2*N ) = ZERO
140 1 pfleura2
*
141 1 pfleura2
      CALL DLASQ2( N, WORK, INFO )
142 1 pfleura2
*
143 1 pfleura2
      IF( INFO.EQ.0 ) THEN
144 1 pfleura2
         DO 40 I = 1, N
145 1 pfleura2
            D( I ) = SQRT( WORK( I ) )
146 1 pfleura2
   40    CONTINUE
147 1 pfleura2
         CALL DLASCL( 'G', 0, 0, SCALE, SIGMX, N, 1, D, N, IINFO )
148 1 pfleura2
      END IF
149 1 pfleura2
*
150 1 pfleura2
      RETURN
151 1 pfleura2
*
152 1 pfleura2
*     End of DLASQ1
153 1 pfleura2
*
154 1 pfleura2
      END