Statistiques
| Révision :

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

Historique | Voir | Annoter | Télécharger (8,08 ko)

1 1 pfleura2
      SUBROUTINE DLAQPS( M, N, OFFSET, NB, KB, A, LDA, JPVT, TAU, VN1,
2 1 pfleura2
     $                   VN2, AUXV, F, LDF )
3 1 pfleura2
*
4 1 pfleura2
*  -- LAPACK auxiliary routine (version 3.2.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
*     June 2010
8 1 pfleura2
*
9 1 pfleura2
*     .. Scalar Arguments ..
10 1 pfleura2
      INTEGER            KB, LDA, LDF, M, N, NB, OFFSET
11 1 pfleura2
*     ..
12 1 pfleura2
*     .. Array Arguments ..
13 1 pfleura2
      INTEGER            JPVT( * )
14 1 pfleura2
      DOUBLE PRECISION   A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * ),
15 1 pfleura2
     $                   VN1( * ), VN2( * )
16 1 pfleura2
*     ..
17 1 pfleura2
*
18 1 pfleura2
*  Purpose
19 1 pfleura2
*  =======
20 1 pfleura2
*
21 1 pfleura2
*  DLAQPS computes a step of QR factorization with column pivoting
22 1 pfleura2
*  of a real M-by-N matrix A by using Blas-3.  It tries to factorize
23 1 pfleura2
*  NB columns from A starting from the row OFFSET+1, and updates all
24 1 pfleura2
*  of the matrix with Blas-3 xGEMM.
25 1 pfleura2
*
26 1 pfleura2
*  In some cases, due to catastrophic cancellations, it cannot
27 1 pfleura2
*  factorize NB columns.  Hence, the actual number of factorized
28 1 pfleura2
*  columns is returned in KB.
29 1 pfleura2
*
30 1 pfleura2
*  Block A(1:OFFSET,1:N) is accordingly pivoted, but not factorized.
31 1 pfleura2
*
32 1 pfleura2
*  Arguments
33 1 pfleura2
*  =========
34 1 pfleura2
*
35 1 pfleura2
*  M       (input) INTEGER
36 1 pfleura2
*          The number of rows of the matrix A. M >= 0.
37 1 pfleura2
*
38 1 pfleura2
*  N       (input) INTEGER
39 1 pfleura2
*          The number of columns of the matrix A. N >= 0
40 1 pfleura2
*
41 1 pfleura2
*  OFFSET  (input) INTEGER
42 1 pfleura2
*          The number of rows of A that have been factorized in
43 1 pfleura2
*          previous steps.
44 1 pfleura2
*
45 1 pfleura2
*  NB      (input) INTEGER
46 1 pfleura2
*          The number of columns to factorize.
47 1 pfleura2
*
48 1 pfleura2
*  KB      (output) INTEGER
49 1 pfleura2
*          The number of columns actually factorized.
50 1 pfleura2
*
51 1 pfleura2
*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
52 1 pfleura2
*          On entry, the M-by-N matrix A.
53 1 pfleura2
*          On exit, block A(OFFSET+1:M,1:KB) is the triangular
54 1 pfleura2
*          factor obtained and block A(1:OFFSET,1:N) has been
55 1 pfleura2
*          accordingly pivoted, but no factorized.
56 1 pfleura2
*          The rest of the matrix, block A(OFFSET+1:M,KB+1:N) has
57 1 pfleura2
*          been updated.
58 1 pfleura2
*
59 1 pfleura2
*  LDA     (input) INTEGER
60 1 pfleura2
*          The leading dimension of the array A. LDA >= max(1,M).
61 1 pfleura2
*
62 1 pfleura2
*  JPVT    (input/output) INTEGER array, dimension (N)
63 1 pfleura2
*          JPVT(I) = K <==> Column K of the full matrix A has been
64 1 pfleura2
*          permuted into position I in AP.
65 1 pfleura2
*
66 1 pfleura2
*  TAU     (output) DOUBLE PRECISION array, dimension (KB)
67 1 pfleura2
*          The scalar factors of the elementary reflectors.
68 1 pfleura2
*
69 1 pfleura2
*  VN1     (input/output) DOUBLE PRECISION array, dimension (N)
70 1 pfleura2
*          The vector with the partial column norms.
71 1 pfleura2
*
72 1 pfleura2
*  VN2     (input/output) DOUBLE PRECISION array, dimension (N)
73 1 pfleura2
*          The vector with the exact column norms.
74 1 pfleura2
*
75 1 pfleura2
*  AUXV    (input/output) DOUBLE PRECISION array, dimension (NB)
76 1 pfleura2
*          Auxiliar vector.
77 1 pfleura2
*
78 1 pfleura2
*  F       (input/output) DOUBLE PRECISION array, dimension (LDF,NB)
79 1 pfleura2
*          Matrix F' = L*Y'*A.
80 1 pfleura2
*
81 1 pfleura2
*  LDF     (input) INTEGER
82 1 pfleura2
*          The leading dimension of the array F. LDF >= max(1,N).
83 1 pfleura2
*
84 1 pfleura2
*  Further Details
85 1 pfleura2
*  ===============
86 1 pfleura2
*
87 1 pfleura2
*  Based on contributions by
88 1 pfleura2
*    G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
89 1 pfleura2
*    X. Sun, Computer Science Dept., Duke University, USA
90 1 pfleura2
*
91 1 pfleura2
*  Partial column norm updating strategy modified by
92 1 pfleura2
*    Z. Drmac and Z. Bujanovic, Dept. of Mathematics,
93 1 pfleura2
*    University of Zagreb, Croatia.
94 1 pfleura2
*     June 2010
95 1 pfleura2
*  For more details see LAPACK Working Note 176.
96 1 pfleura2
*  =====================================================================
97 1 pfleura2
*
98 1 pfleura2
*     .. Parameters ..
99 1 pfleura2
      DOUBLE PRECISION   ZERO, ONE
100 1 pfleura2
      PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
101 1 pfleura2
*     ..
102 1 pfleura2
*     .. Local Scalars ..
103 1 pfleura2
      INTEGER            ITEMP, J, K, LASTRK, LSTICC, PVT, RK
104 1 pfleura2
      DOUBLE PRECISION   AKK, TEMP, TEMP2, TOL3Z
105 1 pfleura2
*     ..
106 1 pfleura2
*     .. External Subroutines ..
107 1 pfleura2
      EXTERNAL           DGEMM, DGEMV, DLARFG, DSWAP
108 1 pfleura2
*     ..
109 1 pfleura2
*     .. Intrinsic Functions ..
110 1 pfleura2
      INTRINSIC          ABS, DBLE, MAX, MIN, NINT, SQRT
111 1 pfleura2
*     ..
112 1 pfleura2
*     .. External Functions ..
113 1 pfleura2
      INTEGER            IDAMAX
114 1 pfleura2
      DOUBLE PRECISION   DLAMCH, DNRM2
115 1 pfleura2
      EXTERNAL           IDAMAX, DLAMCH, DNRM2
116 1 pfleura2
*     ..
117 1 pfleura2
*     .. Executable Statements ..
118 1 pfleura2
*
119 1 pfleura2
      LASTRK = MIN( M, N+OFFSET )
120 1 pfleura2
      LSTICC = 0
121 1 pfleura2
      K = 0
122 1 pfleura2
      TOL3Z = SQRT(DLAMCH('Epsilon'))
123 1 pfleura2
*
124 1 pfleura2
*     Beginning of while loop.
125 1 pfleura2
*
126 1 pfleura2
   10 CONTINUE
127 1 pfleura2
      IF( ( K.LT.NB ) .AND. ( LSTICC.EQ.0 ) ) THEN
128 1 pfleura2
         K = K + 1
129 1 pfleura2
         RK = OFFSET + K
130 1 pfleura2
*
131 1 pfleura2
*        Determine ith pivot column and swap if necessary
132 1 pfleura2
*
133 1 pfleura2
         PVT = ( K-1 ) + IDAMAX( N-K+1, VN1( K ), 1 )
134 1 pfleura2
         IF( PVT.NE.K ) THEN
135 1 pfleura2
            CALL DSWAP( M, A( 1, PVT ), 1, A( 1, K ), 1 )
136 1 pfleura2
            CALL DSWAP( K-1, F( PVT, 1 ), LDF, F( K, 1 ), LDF )
137 1 pfleura2
            ITEMP = JPVT( PVT )
138 1 pfleura2
            JPVT( PVT ) = JPVT( K )
139 1 pfleura2
            JPVT( K ) = ITEMP
140 1 pfleura2
            VN1( PVT ) = VN1( K )
141 1 pfleura2
            VN2( PVT ) = VN2( K )
142 1 pfleura2
         END IF
143 1 pfleura2
*
144 1 pfleura2
*        Apply previous Householder reflectors to column K:
145 1 pfleura2
*        A(RK:M,K) := A(RK:M,K) - A(RK:M,1:K-1)*F(K,1:K-1)'.
146 1 pfleura2
*
147 1 pfleura2
         IF( K.GT.1 ) THEN
148 1 pfleura2
            CALL DGEMV( 'No transpose', M-RK+1, K-1, -ONE, A( RK, 1 ),
149 1 pfleura2
     $                  LDA, F( K, 1 ), LDF, ONE, A( RK, K ), 1 )
150 1 pfleura2
         END IF
151 1 pfleura2
*
152 1 pfleura2
*        Generate elementary reflector H(k).
153 1 pfleura2
*
154 1 pfleura2
         IF( RK.LT.M ) THEN
155 1 pfleura2
            CALL DLARFG( M-RK+1, A( RK, K ), A( RK+1, K ), 1, TAU( K ) )
156 1 pfleura2
         ELSE
157 1 pfleura2
            CALL DLARFG( 1, A( RK, K ), A( RK, K ), 1, TAU( K ) )
158 1 pfleura2
         END IF
159 1 pfleura2
*
160 1 pfleura2
         AKK = A( RK, K )
161 1 pfleura2
         A( RK, K ) = ONE
162 1 pfleura2
*
163 1 pfleura2
*        Compute Kth column of F:
164 1 pfleura2
*
165 1 pfleura2
*        Compute  F(K+1:N,K) := tau(K)*A(RK:M,K+1:N)'*A(RK:M,K).
166 1 pfleura2
*
167 1 pfleura2
         IF( K.LT.N ) THEN
168 1 pfleura2
            CALL DGEMV( 'Transpose', M-RK+1, N-K, TAU( K ),
169 1 pfleura2
     $                  A( RK, K+1 ), LDA, A( RK, K ), 1, ZERO,
170 1 pfleura2
     $                  F( K+1, K ), 1 )
171 1 pfleura2
         END IF
172 1 pfleura2
*
173 1 pfleura2
*        Padding F(1:K,K) with zeros.
174 1 pfleura2
*
175 1 pfleura2
         DO 20 J = 1, K
176 1 pfleura2
            F( J, K ) = ZERO
177 1 pfleura2
   20    CONTINUE
178 1 pfleura2
*
179 1 pfleura2
*        Incremental updating of F:
180 1 pfleura2
*        F(1:N,K) := F(1:N,K) - tau(K)*F(1:N,1:K-1)*A(RK:M,1:K-1)'
181 1 pfleura2
*                    *A(RK:M,K).
182 1 pfleura2
*
183 1 pfleura2
         IF( K.GT.1 ) THEN
184 1 pfleura2
            CALL DGEMV( 'Transpose', M-RK+1, K-1, -TAU( K ), A( RK, 1 ),
185 1 pfleura2
     $                  LDA, A( RK, K ), 1, ZERO, AUXV( 1 ), 1 )
186 1 pfleura2
*
187 1 pfleura2
            CALL DGEMV( 'No transpose', N, K-1, ONE, F( 1, 1 ), LDF,
188 1 pfleura2
     $                  AUXV( 1 ), 1, ONE, F( 1, K ), 1 )
189 1 pfleura2
         END IF
190 1 pfleura2
*
191 1 pfleura2
*        Update the current row of A:
192 1 pfleura2
*        A(RK,K+1:N) := A(RK,K+1:N) - A(RK,1:K)*F(K+1:N,1:K)'.
193 1 pfleura2
*
194 1 pfleura2
         IF( K.LT.N ) THEN
195 1 pfleura2
            CALL DGEMV( 'No transpose', N-K, K, -ONE, F( K+1, 1 ), LDF,
196 1 pfleura2
     $                  A( RK, 1 ), LDA, ONE, A( RK, K+1 ), LDA )
197 1 pfleura2
         END IF
198 1 pfleura2
*
199 1 pfleura2
*        Update partial column norms.
200 1 pfleura2
*
201 1 pfleura2
         IF( RK.LT.LASTRK ) THEN
202 1 pfleura2
            DO 30 J = K + 1, N
203 1 pfleura2
               IF( VN1( J ).NE.ZERO ) THEN
204 1 pfleura2
*
205 1 pfleura2
*                 NOTE: The following 4 lines follow from the analysis in
206 1 pfleura2
*                 Lapack Working Note 176.
207 1 pfleura2
*
208 1 pfleura2
                  TEMP = ABS( A( RK, J ) ) / VN1( J )
209 1 pfleura2
                  TEMP = MAX( ZERO, ( ONE+TEMP )*( ONE-TEMP ) )
210 1 pfleura2
                  TEMP2 = TEMP*( VN1( J ) / VN2( J ) )**2
211 1 pfleura2
                  IF( TEMP2 .LE. TOL3Z ) THEN
212 1 pfleura2
                     VN2( J ) = DBLE( LSTICC )
213 1 pfleura2
                     LSTICC = J
214 1 pfleura2
                  ELSE
215 1 pfleura2
                     VN1( J ) = VN1( J )*SQRT( TEMP )
216 1 pfleura2
                  END IF
217 1 pfleura2
               END IF
218 1 pfleura2
   30       CONTINUE
219 1 pfleura2
         END IF
220 1 pfleura2
*
221 1 pfleura2
         A( RK, K ) = AKK
222 1 pfleura2
*
223 1 pfleura2
*        End of while loop.
224 1 pfleura2
*
225 1 pfleura2
         GO TO 10
226 1 pfleura2
      END IF
227 1 pfleura2
      KB = K
228 1 pfleura2
      RK = OFFSET + KB
229 1 pfleura2
*
230 1 pfleura2
*     Apply the block reflector to the rest of the matrix:
231 1 pfleura2
*     A(OFFSET+KB+1:M,KB+1:N) := A(OFFSET+KB+1:M,KB+1:N) -
232 1 pfleura2
*                         A(OFFSET+KB+1:M,1:KB)*F(KB+1:N,1:KB)'.
233 1 pfleura2
*
234 1 pfleura2
      IF( KB.LT.MIN( N, M-OFFSET ) ) THEN
235 1 pfleura2
         CALL DGEMM( 'No transpose', 'Transpose', M-RK, N-KB, KB, -ONE,
236 1 pfleura2
     $               A( RK+1, 1 ), LDA, F( KB+1, 1 ), LDF, ONE,
237 1 pfleura2
     $               A( RK+1, KB+1 ), LDA )
238 1 pfleura2
      END IF
239 1 pfleura2
*
240 1 pfleura2
*     Recomputation of difficult columns.
241 1 pfleura2
*
242 1 pfleura2
   40 CONTINUE
243 1 pfleura2
      IF( LSTICC.GT.0 ) THEN
244 1 pfleura2
         ITEMP = NINT( VN2( LSTICC ) )
245 1 pfleura2
         VN1( LSTICC ) = DNRM2( M-RK, A( RK+1, LSTICC ), 1 )
246 1 pfleura2
*
247 1 pfleura2
*        NOTE: The computation of VN1( LSTICC ) relies on the fact that
248 1 pfleura2
*        SNRM2 does not fail on vectors with norm below the value of
249 1 pfleura2
*        SQRT(DLAMCH('S'))
250 1 pfleura2
*
251 1 pfleura2
         VN2( LSTICC ) = VN1( LSTICC )
252 1 pfleura2
         LSTICC = ITEMP
253 1 pfleura2
         GO TO 40
254 1 pfleura2
      END IF
255 1 pfleura2
*
256 1 pfleura2
      RETURN
257 1 pfleura2
*
258 1 pfleura2
*     End of DLAQPS
259 1 pfleura2
*
260 1 pfleura2
      END