Statistiques
| Révision :

root / src / lapack / double / dgebrd.f @ 2

Historique | Voir | Annoter | Télécharger (9,05 ko)

1 1 pfleura2
      SUBROUTINE DGEBRD( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK,
2 1 pfleura2
     $                   INFO )
3 1 pfleura2
*
4 1 pfleura2
*  -- LAPACK routine (version 3.2) --
5 1 pfleura2
*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
6 1 pfleura2
*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
7 1 pfleura2
*     November 2006
8 1 pfleura2
*
9 1 pfleura2
*     .. Scalar Arguments ..
10 1 pfleura2
      INTEGER            INFO, LDA, LWORK, M, N
11 1 pfleura2
*     ..
12 1 pfleura2
*     .. Array Arguments ..
13 1 pfleura2
      DOUBLE PRECISION   A( LDA, * ), D( * ), E( * ), TAUP( * ),
14 1 pfleura2
     $                   TAUQ( * ), WORK( * )
15 1 pfleura2
*     ..
16 1 pfleura2
*
17 1 pfleura2
*  Purpose
18 1 pfleura2
*  =======
19 1 pfleura2
*
20 1 pfleura2
*  DGEBRD reduces a general real M-by-N matrix A to upper or lower
21 1 pfleura2
*  bidiagonal form B by an orthogonal transformation: Q**T * A * P = B.
22 1 pfleura2
*
23 1 pfleura2
*  If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal.
24 1 pfleura2
*
25 1 pfleura2
*  Arguments
26 1 pfleura2
*  =========
27 1 pfleura2
*
28 1 pfleura2
*  M       (input) INTEGER
29 1 pfleura2
*          The number of rows in the matrix A.  M >= 0.
30 1 pfleura2
*
31 1 pfleura2
*  N       (input) INTEGER
32 1 pfleura2
*          The number of columns in the matrix A.  N >= 0.
33 1 pfleura2
*
34 1 pfleura2
*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
35 1 pfleura2
*          On entry, the M-by-N general matrix to be reduced.
36 1 pfleura2
*          On exit,
37 1 pfleura2
*          if m >= n, the diagonal and the first superdiagonal are
38 1 pfleura2
*            overwritten with the upper bidiagonal matrix B; the
39 1 pfleura2
*            elements below the diagonal, with the array TAUQ, represent
40 1 pfleura2
*            the orthogonal matrix Q as a product of elementary
41 1 pfleura2
*            reflectors, and the elements above the first superdiagonal,
42 1 pfleura2
*            with the array TAUP, represent the orthogonal matrix P as
43 1 pfleura2
*            a product of elementary reflectors;
44 1 pfleura2
*          if m < n, the diagonal and the first subdiagonal are
45 1 pfleura2
*            overwritten with the lower bidiagonal matrix B; the
46 1 pfleura2
*            elements below the first subdiagonal, with the array TAUQ,
47 1 pfleura2
*            represent the orthogonal matrix Q as a product of
48 1 pfleura2
*            elementary reflectors, and the elements above the diagonal,
49 1 pfleura2
*            with the array TAUP, represent the orthogonal matrix P as
50 1 pfleura2
*            a product of elementary reflectors.
51 1 pfleura2
*          See Further Details.
52 1 pfleura2
*
53 1 pfleura2
*  LDA     (input) INTEGER
54 1 pfleura2
*          The leading dimension of the array A.  LDA >= max(1,M).
55 1 pfleura2
*
56 1 pfleura2
*  D       (output) DOUBLE PRECISION array, dimension (min(M,N))
57 1 pfleura2
*          The diagonal elements of the bidiagonal matrix B:
58 1 pfleura2
*          D(i) = A(i,i).
59 1 pfleura2
*
60 1 pfleura2
*  E       (output) DOUBLE PRECISION array, dimension (min(M,N)-1)
61 1 pfleura2
*          The off-diagonal elements of the bidiagonal matrix B:
62 1 pfleura2
*          if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1;
63 1 pfleura2
*          if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1.
64 1 pfleura2
*
65 1 pfleura2
*  TAUQ    (output) DOUBLE PRECISION array dimension (min(M,N))
66 1 pfleura2
*          The scalar factors of the elementary reflectors which
67 1 pfleura2
*          represent the orthogonal matrix Q. See Further Details.
68 1 pfleura2
*
69 1 pfleura2
*  TAUP    (output) DOUBLE PRECISION array, dimension (min(M,N))
70 1 pfleura2
*          The scalar factors of the elementary reflectors which
71 1 pfleura2
*          represent the orthogonal matrix P. See Further Details.
72 1 pfleura2
*
73 1 pfleura2
*  WORK    (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
74 1 pfleura2
*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
75 1 pfleura2
*
76 1 pfleura2
*  LWORK   (input) INTEGER
77 1 pfleura2
*          The length of the array WORK.  LWORK >= max(1,M,N).
78 1 pfleura2
*          For optimum performance LWORK >= (M+N)*NB, where NB
79 1 pfleura2
*          is the optimal blocksize.
80 1 pfleura2
*
81 1 pfleura2
*          If LWORK = -1, then a workspace query is assumed; the routine
82 1 pfleura2
*          only calculates the optimal size of the WORK array, returns
83 1 pfleura2
*          this value as the first entry of the WORK array, and no error
84 1 pfleura2
*          message related to LWORK is issued by XERBLA.
85 1 pfleura2
*
86 1 pfleura2
*  INFO    (output) INTEGER
87 1 pfleura2
*          = 0:  successful exit
88 1 pfleura2
*          < 0:  if INFO = -i, the i-th argument had an illegal value.
89 1 pfleura2
*
90 1 pfleura2
*  Further Details
91 1 pfleura2
*  ===============
92 1 pfleura2
*
93 1 pfleura2
*  The matrices Q and P are represented as products of elementary
94 1 pfleura2
*  reflectors:
95 1 pfleura2
*
96 1 pfleura2
*  If m >= n,
97 1 pfleura2
*
98 1 pfleura2
*     Q = H(1) H(2) . . . H(n)  and  P = G(1) G(2) . . . G(n-1)
99 1 pfleura2
*
100 1 pfleura2
*  Each H(i) and G(i) has the form:
101 1 pfleura2
*
102 1 pfleura2
*     H(i) = I - tauq * v * v'  and G(i) = I - taup * u * u'
103 1 pfleura2
*
104 1 pfleura2
*  where tauq and taup are real scalars, and v and u are real vectors;
105 1 pfleura2
*  v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i);
106 1 pfleura2
*  u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n);
107 1 pfleura2
*  tauq is stored in TAUQ(i) and taup in TAUP(i).
108 1 pfleura2
*
109 1 pfleura2
*  If m < n,
110 1 pfleura2
*
111 1 pfleura2
*     Q = H(1) H(2) . . . H(m-1)  and  P = G(1) G(2) . . . G(m)
112 1 pfleura2
*
113 1 pfleura2
*  Each H(i) and G(i) has the form:
114 1 pfleura2
*
115 1 pfleura2
*     H(i) = I - tauq * v * v'  and G(i) = I - taup * u * u'
116 1 pfleura2
*
117 1 pfleura2
*  where tauq and taup are real scalars, and v and u are real vectors;
118 1 pfleura2
*  v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i);
119 1 pfleura2
*  u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n);
120 1 pfleura2
*  tauq is stored in TAUQ(i) and taup in TAUP(i).
121 1 pfleura2
*
122 1 pfleura2
*  The contents of A on exit are illustrated by the following examples:
123 1 pfleura2
*
124 1 pfleura2
*  m = 6 and n = 5 (m > n):          m = 5 and n = 6 (m < n):
125 1 pfleura2
*
126 1 pfleura2
*    (  d   e   u1  u1  u1 )           (  d   u1  u1  u1  u1  u1 )
127 1 pfleura2
*    (  v1  d   e   u2  u2 )           (  e   d   u2  u2  u2  u2 )
128 1 pfleura2
*    (  v1  v2  d   e   u3 )           (  v1  e   d   u3  u3  u3 )
129 1 pfleura2
*    (  v1  v2  v3  d   e  )           (  v1  v2  e   d   u4  u4 )
130 1 pfleura2
*    (  v1  v2  v3  v4  d  )           (  v1  v2  v3  e   d   u5 )
131 1 pfleura2
*    (  v1  v2  v3  v4  v5 )
132 1 pfleura2
*
133 1 pfleura2
*  where d and e denote diagonal and off-diagonal elements of B, vi
134 1 pfleura2
*  denotes an element of the vector defining H(i), and ui an element of
135 1 pfleura2
*  the vector defining G(i).
136 1 pfleura2
*
137 1 pfleura2
*  =====================================================================
138 1 pfleura2
*
139 1 pfleura2
*     .. Parameters ..
140 1 pfleura2
      DOUBLE PRECISION   ONE
141 1 pfleura2
      PARAMETER          ( ONE = 1.0D+0 )
142 1 pfleura2
*     ..
143 1 pfleura2
*     .. Local Scalars ..
144 1 pfleura2
      LOGICAL            LQUERY
145 1 pfleura2
      INTEGER            I, IINFO, J, LDWRKX, LDWRKY, LWKOPT, MINMN, NB,
146 1 pfleura2
     $                   NBMIN, NX
147 1 pfleura2
      DOUBLE PRECISION   WS
148 1 pfleura2
*     ..
149 1 pfleura2
*     .. External Subroutines ..
150 1 pfleura2
      EXTERNAL           DGEBD2, DGEMM, DLABRD, XERBLA
151 1 pfleura2
*     ..
152 1 pfleura2
*     .. Intrinsic Functions ..
153 1 pfleura2
      INTRINSIC          DBLE, MAX, MIN
154 1 pfleura2
*     ..
155 1 pfleura2
*     .. External Functions ..
156 1 pfleura2
      INTEGER            ILAENV
157 1 pfleura2
      EXTERNAL           ILAENV
158 1 pfleura2
*     ..
159 1 pfleura2
*     .. Executable Statements ..
160 1 pfleura2
*
161 1 pfleura2
*     Test the input parameters
162 1 pfleura2
*
163 1 pfleura2
      INFO = 0
164 1 pfleura2
      NB = MAX( 1, ILAENV( 1, 'DGEBRD', ' ', M, N, -1, -1 ) )
165 1 pfleura2
      LWKOPT = ( M+N )*NB
166 1 pfleura2
      WORK( 1 ) = DBLE( LWKOPT )
167 1 pfleura2
      LQUERY = ( LWORK.EQ.-1 )
168 1 pfleura2
      IF( M.LT.0 ) THEN
169 1 pfleura2
         INFO = -1
170 1 pfleura2
      ELSE IF( N.LT.0 ) THEN
171 1 pfleura2
         INFO = -2
172 1 pfleura2
      ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
173 1 pfleura2
         INFO = -4
174 1 pfleura2
      ELSE IF( LWORK.LT.MAX( 1, M, N ) .AND. .NOT.LQUERY ) THEN
175 1 pfleura2
         INFO = -10
176 1 pfleura2
      END IF
177 1 pfleura2
      IF( INFO.LT.0 ) THEN
178 1 pfleura2
         CALL XERBLA( 'DGEBRD', -INFO )
179 1 pfleura2
         RETURN
180 1 pfleura2
      ELSE IF( LQUERY ) THEN
181 1 pfleura2
         RETURN
182 1 pfleura2
      END IF
183 1 pfleura2
*
184 1 pfleura2
*     Quick return if possible
185 1 pfleura2
*
186 1 pfleura2
      MINMN = MIN( M, N )
187 1 pfleura2
      IF( MINMN.EQ.0 ) THEN
188 1 pfleura2
         WORK( 1 ) = 1
189 1 pfleura2
         RETURN
190 1 pfleura2
      END IF
191 1 pfleura2
*
192 1 pfleura2
      WS = MAX( M, N )
193 1 pfleura2
      LDWRKX = M
194 1 pfleura2
      LDWRKY = N
195 1 pfleura2
*
196 1 pfleura2
      IF( NB.GT.1 .AND. NB.LT.MINMN ) THEN
197 1 pfleura2
*
198 1 pfleura2
*        Set the crossover point NX.
199 1 pfleura2
*
200 1 pfleura2
         NX = MAX( NB, ILAENV( 3, 'DGEBRD', ' ', M, N, -1, -1 ) )
201 1 pfleura2
*
202 1 pfleura2
*        Determine when to switch from blocked to unblocked code.
203 1 pfleura2
*
204 1 pfleura2
         IF( NX.LT.MINMN ) THEN
205 1 pfleura2
            WS = ( M+N )*NB
206 1 pfleura2
            IF( LWORK.LT.WS ) THEN
207 1 pfleura2
*
208 1 pfleura2
*              Not enough work space for the optimal NB, consider using
209 1 pfleura2
*              a smaller block size.
210 1 pfleura2
*
211 1 pfleura2
               NBMIN = ILAENV( 2, 'DGEBRD', ' ', M, N, -1, -1 )
212 1 pfleura2
               IF( LWORK.GE.( M+N )*NBMIN ) THEN
213 1 pfleura2
                  NB = LWORK / ( M+N )
214 1 pfleura2
               ELSE
215 1 pfleura2
                  NB = 1
216 1 pfleura2
                  NX = MINMN
217 1 pfleura2
               END IF
218 1 pfleura2
            END IF
219 1 pfleura2
         END IF
220 1 pfleura2
      ELSE
221 1 pfleura2
         NX = MINMN
222 1 pfleura2
      END IF
223 1 pfleura2
*
224 1 pfleura2
      DO 30 I = 1, MINMN - NX, NB
225 1 pfleura2
*
226 1 pfleura2
*        Reduce rows and columns i:i+nb-1 to bidiagonal form and return
227 1 pfleura2
*        the matrices X and Y which are needed to update the unreduced
228 1 pfleura2
*        part of the matrix
229 1 pfleura2
*
230 1 pfleura2
         CALL DLABRD( M-I+1, N-I+1, NB, A( I, I ), LDA, D( I ), E( I ),
231 1 pfleura2
     $                TAUQ( I ), TAUP( I ), WORK, LDWRKX,
232 1 pfleura2
     $                WORK( LDWRKX*NB+1 ), LDWRKY )
233 1 pfleura2
*
234 1 pfleura2
*        Update the trailing submatrix A(i+nb:m,i+nb:n), using an update
235 1 pfleura2
*        of the form  A := A - V*Y' - X*U'
236 1 pfleura2
*
237 1 pfleura2
         CALL DGEMM( 'No transpose', 'Transpose', M-I-NB+1, N-I-NB+1,
238 1 pfleura2
     $               NB, -ONE, A( I+NB, I ), LDA,
239 1 pfleura2
     $               WORK( LDWRKX*NB+NB+1 ), LDWRKY, ONE,
240 1 pfleura2
     $               A( I+NB, I+NB ), LDA )
241 1 pfleura2
         CALL DGEMM( 'No transpose', 'No transpose', M-I-NB+1, N-I-NB+1,
242 1 pfleura2
     $               NB, -ONE, WORK( NB+1 ), LDWRKX, A( I, I+NB ), LDA,
243 1 pfleura2
     $               ONE, A( I+NB, I+NB ), LDA )
244 1 pfleura2
*
245 1 pfleura2
*        Copy diagonal and off-diagonal elements of B back into A
246 1 pfleura2
*
247 1 pfleura2
         IF( M.GE.N ) THEN
248 1 pfleura2
            DO 10 J = I, I + NB - 1
249 1 pfleura2
               A( J, J ) = D( J )
250 1 pfleura2
               A( J, J+1 ) = E( J )
251 1 pfleura2
   10       CONTINUE
252 1 pfleura2
         ELSE
253 1 pfleura2
            DO 20 J = I, I + NB - 1
254 1 pfleura2
               A( J, J ) = D( J )
255 1 pfleura2
               A( J+1, J ) = E( J )
256 1 pfleura2
   20       CONTINUE
257 1 pfleura2
         END IF
258 1 pfleura2
   30 CONTINUE
259 1 pfleura2
*
260 1 pfleura2
*     Use unblocked code to reduce the remainder of the matrix
261 1 pfleura2
*
262 1 pfleura2
      CALL DGEBD2( M-I+1, N-I+1, A( I, I ), LDA, D( I ), E( I ),
263 1 pfleura2
     $             TAUQ( I ), TAUP( I ), WORK, IINFO )
264 1 pfleura2
      WORK( 1 ) = WS
265 1 pfleura2
      RETURN
266 1 pfleura2
*
267 1 pfleura2
*     End of DGEBRD
268 1 pfleura2
*
269 1 pfleura2
      END