Statistiques
| Révision :

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

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

1 1 pfleura2
      SUBROUTINE DORMRZ( SIDE, TRANS, M, N, K, L, A, LDA, TAU, C, LDC,
2 1 pfleura2
     $                   WORK, LWORK, 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
*     January 2007
8 1 pfleura2
*
9 1 pfleura2
*     .. Scalar Arguments ..
10 1 pfleura2
      CHARACTER          SIDE, TRANS
11 1 pfleura2
      INTEGER            INFO, K, L, LDA, LDC, LWORK, M, N
12 1 pfleura2
*     ..
13 1 pfleura2
*     .. Array Arguments ..
14 1 pfleura2
      DOUBLE PRECISION   A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )
15 1 pfleura2
*     ..
16 1 pfleura2
*
17 1 pfleura2
*  Purpose
18 1 pfleura2
*  =======
19 1 pfleura2
*
20 1 pfleura2
*  DORMRZ overwrites the general real M-by-N matrix C with
21 1 pfleura2
*
22 1 pfleura2
*                  SIDE = 'L'     SIDE = 'R'
23 1 pfleura2
*  TRANS = 'N':      Q * C          C * Q
24 1 pfleura2
*  TRANS = 'T':      Q**T * C       C * Q**T
25 1 pfleura2
*
26 1 pfleura2
*  where Q is a real orthogonal matrix defined as the product of k
27 1 pfleura2
*  elementary reflectors
28 1 pfleura2
*
29 1 pfleura2
*        Q = H(1) H(2) . . . H(k)
30 1 pfleura2
*
31 1 pfleura2
*  as returned by DTZRZF. Q is of order M if SIDE = 'L' and of order N
32 1 pfleura2
*  if SIDE = 'R'.
33 1 pfleura2
*
34 1 pfleura2
*  Arguments
35 1 pfleura2
*  =========
36 1 pfleura2
*
37 1 pfleura2
*  SIDE    (input) CHARACTER*1
38 1 pfleura2
*          = 'L': apply Q or Q**T from the Left;
39 1 pfleura2
*          = 'R': apply Q or Q**T from the Right.
40 1 pfleura2
*
41 1 pfleura2
*  TRANS   (input) CHARACTER*1
42 1 pfleura2
*          = 'N':  No transpose, apply Q;
43 1 pfleura2
*          = 'T':  Transpose, apply Q**T.
44 1 pfleura2
*
45 1 pfleura2
*  M       (input) INTEGER
46 1 pfleura2
*          The number of rows of the matrix C. M >= 0.
47 1 pfleura2
*
48 1 pfleura2
*  N       (input) INTEGER
49 1 pfleura2
*          The number of columns of the matrix C. N >= 0.
50 1 pfleura2
*
51 1 pfleura2
*  K       (input) INTEGER
52 1 pfleura2
*          The number of elementary reflectors whose product defines
53 1 pfleura2
*          the matrix Q.
54 1 pfleura2
*          If SIDE = 'L', M >= K >= 0;
55 1 pfleura2
*          if SIDE = 'R', N >= K >= 0.
56 1 pfleura2
*
57 1 pfleura2
*  L       (input) INTEGER
58 1 pfleura2
*          The number of columns of the matrix A containing
59 1 pfleura2
*          the meaningful part of the Householder reflectors.
60 1 pfleura2
*          If SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0.
61 1 pfleura2
*
62 1 pfleura2
*  A       (input) DOUBLE PRECISION array, dimension
63 1 pfleura2
*                               (LDA,M) if SIDE = 'L',
64 1 pfleura2
*                               (LDA,N) if SIDE = 'R'
65 1 pfleura2
*          The i-th row must contain the vector which defines the
66 1 pfleura2
*          elementary reflector H(i), for i = 1,2,...,k, as returned by
67 1 pfleura2
*          DTZRZF in the last k rows of its array argument A.
68 1 pfleura2
*          A is modified by the routine but restored on exit.
69 1 pfleura2
*
70 1 pfleura2
*  LDA     (input) INTEGER
71 1 pfleura2
*          The leading dimension of the array A. LDA >= max(1,K).
72 1 pfleura2
*
73 1 pfleura2
*  TAU     (input) DOUBLE PRECISION array, dimension (K)
74 1 pfleura2
*          TAU(i) must contain the scalar factor of the elementary
75 1 pfleura2
*          reflector H(i), as returned by DTZRZF.
76 1 pfleura2
*
77 1 pfleura2
*  C       (input/output) DOUBLE PRECISION array, dimension (LDC,N)
78 1 pfleura2
*          On entry, the M-by-N matrix C.
79 1 pfleura2
*          On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.
80 1 pfleura2
*
81 1 pfleura2
*  LDC     (input) INTEGER
82 1 pfleura2
*          The leading dimension of the array C. LDC >= max(1,M).
83 1 pfleura2
*
84 1 pfleura2
*  WORK    (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
85 1 pfleura2
*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
86 1 pfleura2
*
87 1 pfleura2
*  LWORK   (input) INTEGER
88 1 pfleura2
*          The dimension of the array WORK.
89 1 pfleura2
*          If SIDE = 'L', LWORK >= max(1,N);
90 1 pfleura2
*          if SIDE = 'R', LWORK >= max(1,M).
91 1 pfleura2
*          For optimum performance LWORK >= N*NB if SIDE = 'L', and
92 1 pfleura2
*          LWORK >= M*NB if SIDE = 'R', where NB is the optimal
93 1 pfleura2
*          blocksize.
94 1 pfleura2
*
95 1 pfleura2
*          If LWORK = -1, then a workspace query is assumed; the routine
96 1 pfleura2
*          only calculates the optimal size of the WORK array, returns
97 1 pfleura2
*          this value as the first entry of the WORK array, and no error
98 1 pfleura2
*          message related to LWORK is issued by XERBLA.
99 1 pfleura2
*
100 1 pfleura2
*  INFO    (output) INTEGER
101 1 pfleura2
*          = 0:  successful exit
102 1 pfleura2
*          < 0:  if INFO = -i, the i-th argument had an illegal value
103 1 pfleura2
*
104 1 pfleura2
*  Further Details
105 1 pfleura2
*  ===============
106 1 pfleura2
*
107 1 pfleura2
*  Based on contributions by
108 1 pfleura2
*    A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
109 1 pfleura2
*
110 1 pfleura2
*  =====================================================================
111 1 pfleura2
*
112 1 pfleura2
*     .. Parameters ..
113 1 pfleura2
      INTEGER            NBMAX, LDT
114 1 pfleura2
      PARAMETER          ( NBMAX = 64, LDT = NBMAX+1 )
115 1 pfleura2
*     ..
116 1 pfleura2
*     .. Local Scalars ..
117 1 pfleura2
      LOGICAL            LEFT, LQUERY, NOTRAN
118 1 pfleura2
      CHARACTER          TRANST
119 1 pfleura2
      INTEGER            I, I1, I2, I3, IB, IC, IINFO, IWS, JA, JC,
120 1 pfleura2
     $                   LDWORK, LWKOPT, MI, NB, NBMIN, NI, NQ, NW
121 1 pfleura2
*     ..
122 1 pfleura2
*     .. Local Arrays ..
123 1 pfleura2
      DOUBLE PRECISION   T( LDT, NBMAX )
124 1 pfleura2
*     ..
125 1 pfleura2
*     .. External Functions ..
126 1 pfleura2
      LOGICAL            LSAME
127 1 pfleura2
      INTEGER            ILAENV
128 1 pfleura2
      EXTERNAL           LSAME, ILAENV
129 1 pfleura2
*     ..
130 1 pfleura2
*     .. External Subroutines ..
131 1 pfleura2
      EXTERNAL           DLARZB, DLARZT, DORMR3, XERBLA
132 1 pfleura2
*     ..
133 1 pfleura2
*     .. Intrinsic Functions ..
134 1 pfleura2
      INTRINSIC          MAX, MIN
135 1 pfleura2
*     ..
136 1 pfleura2
*     .. Executable Statements ..
137 1 pfleura2
*
138 1 pfleura2
*     Test the input arguments
139 1 pfleura2
*
140 1 pfleura2
      INFO = 0
141 1 pfleura2
      LEFT = LSAME( SIDE, 'L' )
142 1 pfleura2
      NOTRAN = LSAME( TRANS, 'N' )
143 1 pfleura2
      LQUERY = ( LWORK.EQ.-1 )
144 1 pfleura2
*
145 1 pfleura2
*     NQ is the order of Q and NW is the minimum dimension of WORK
146 1 pfleura2
*
147 1 pfleura2
      IF( LEFT ) THEN
148 1 pfleura2
         NQ = M
149 1 pfleura2
         NW = MAX( 1, N )
150 1 pfleura2
      ELSE
151 1 pfleura2
         NQ = N
152 1 pfleura2
         NW = MAX( 1, M )
153 1 pfleura2
      END IF
154 1 pfleura2
      IF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THEN
155 1 pfleura2
         INFO = -1
156 1 pfleura2
      ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) ) THEN
157 1 pfleura2
         INFO = -2
158 1 pfleura2
      ELSE IF( M.LT.0 ) THEN
159 1 pfleura2
         INFO = -3
160 1 pfleura2
      ELSE IF( N.LT.0 ) THEN
161 1 pfleura2
         INFO = -4
162 1 pfleura2
      ELSE IF( K.LT.0 .OR. K.GT.NQ ) THEN
163 1 pfleura2
         INFO = -5
164 1 pfleura2
      ELSE IF( L.LT.0 .OR. ( LEFT .AND. ( L.GT.M ) ) .OR.
165 1 pfleura2
     $         ( .NOT.LEFT .AND. ( L.GT.N ) ) ) THEN
166 1 pfleura2
         INFO = -6
167 1 pfleura2
      ELSE IF( LDA.LT.MAX( 1, K ) ) THEN
168 1 pfleura2
         INFO = -8
169 1 pfleura2
      ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
170 1 pfleura2
         INFO = -11
171 1 pfleura2
      END IF
172 1 pfleura2
*
173 1 pfleura2
      IF( INFO.EQ.0 ) THEN
174 1 pfleura2
         IF( M.EQ.0 .OR. N.EQ.0 ) THEN
175 1 pfleura2
            LWKOPT = 1
176 1 pfleura2
         ELSE
177 1 pfleura2
*
178 1 pfleura2
*           Determine the block size.  NB may be at most NBMAX, where
179 1 pfleura2
*           NBMAX is used to define the local array T.
180 1 pfleura2
*
181 1 pfleura2
            NB = MIN( NBMAX, ILAENV( 1, 'DORMRQ', SIDE // TRANS, M, N,
182 1 pfleura2
     $                               K, -1 ) )
183 1 pfleura2
            LWKOPT = NW*NB
184 1 pfleura2
         END IF
185 1 pfleura2
         WORK( 1 ) = LWKOPT
186 1 pfleura2
*
187 1 pfleura2
         IF( LWORK.LT.MAX( 1, NW ) .AND. .NOT.LQUERY ) THEN
188 1 pfleura2
            INFO = -13
189 1 pfleura2
         END IF
190 1 pfleura2
      END IF
191 1 pfleura2
*
192 1 pfleura2
      IF( INFO.NE.0 ) THEN
193 1 pfleura2
         CALL XERBLA( 'DORMRZ', -INFO )
194 1 pfleura2
         RETURN
195 1 pfleura2
      ELSE IF( LQUERY ) THEN
196 1 pfleura2
         RETURN
197 1 pfleura2
      END IF
198 1 pfleura2
*
199 1 pfleura2
*     Quick return if possible
200 1 pfleura2
*
201 1 pfleura2
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
202 1 pfleura2
         WORK( 1 ) = 1
203 1 pfleura2
         RETURN
204 1 pfleura2
      END IF
205 1 pfleura2
*
206 1 pfleura2
      NBMIN = 2
207 1 pfleura2
      LDWORK = NW
208 1 pfleura2
      IF( NB.GT.1 .AND. NB.LT.K ) THEN
209 1 pfleura2
         IWS = NW*NB
210 1 pfleura2
         IF( LWORK.LT.IWS ) THEN
211 1 pfleura2
            NB = LWORK / LDWORK
212 1 pfleura2
            NBMIN = MAX( 2, ILAENV( 2, 'DORMRQ', SIDE // TRANS, M, N, K,
213 1 pfleura2
     $              -1 ) )
214 1 pfleura2
         END IF
215 1 pfleura2
      ELSE
216 1 pfleura2
         IWS = NW
217 1 pfleura2
      END IF
218 1 pfleura2
*
219 1 pfleura2
      IF( NB.LT.NBMIN .OR. NB.GE.K ) THEN
220 1 pfleura2
*
221 1 pfleura2
*        Use unblocked code
222 1 pfleura2
*
223 1 pfleura2
         CALL DORMR3( SIDE, TRANS, M, N, K, L, A, LDA, TAU, C, LDC,
224 1 pfleura2
     $                WORK, IINFO )
225 1 pfleura2
      ELSE
226 1 pfleura2
*
227 1 pfleura2
*        Use blocked code
228 1 pfleura2
*
229 1 pfleura2
         IF( ( LEFT .AND. .NOT.NOTRAN ) .OR.
230 1 pfleura2
     $       ( .NOT.LEFT .AND. NOTRAN ) ) THEN
231 1 pfleura2
            I1 = 1
232 1 pfleura2
            I2 = K
233 1 pfleura2
            I3 = NB
234 1 pfleura2
         ELSE
235 1 pfleura2
            I1 = ( ( K-1 ) / NB )*NB + 1
236 1 pfleura2
            I2 = 1
237 1 pfleura2
            I3 = -NB
238 1 pfleura2
         END IF
239 1 pfleura2
*
240 1 pfleura2
         IF( LEFT ) THEN
241 1 pfleura2
            NI = N
242 1 pfleura2
            JC = 1
243 1 pfleura2
            JA = M - L + 1
244 1 pfleura2
         ELSE
245 1 pfleura2
            MI = M
246 1 pfleura2
            IC = 1
247 1 pfleura2
            JA = N - L + 1
248 1 pfleura2
         END IF
249 1 pfleura2
*
250 1 pfleura2
         IF( NOTRAN ) THEN
251 1 pfleura2
            TRANST = 'T'
252 1 pfleura2
         ELSE
253 1 pfleura2
            TRANST = 'N'
254 1 pfleura2
         END IF
255 1 pfleura2
*
256 1 pfleura2
         DO 10 I = I1, I2, I3
257 1 pfleura2
            IB = MIN( NB, K-I+1 )
258 1 pfleura2
*
259 1 pfleura2
*           Form the triangular factor of the block reflector
260 1 pfleura2
*           H = H(i+ib-1) . . . H(i+1) H(i)
261 1 pfleura2
*
262 1 pfleura2
            CALL DLARZT( 'Backward', 'Rowwise', L, IB, A( I, JA ), LDA,
263 1 pfleura2
     $                   TAU( I ), T, LDT )
264 1 pfleura2
*
265 1 pfleura2
            IF( LEFT ) THEN
266 1 pfleura2
*
267 1 pfleura2
*              H or H' is applied to C(i:m,1:n)
268 1 pfleura2
*
269 1 pfleura2
               MI = M - I + 1
270 1 pfleura2
               IC = I
271 1 pfleura2
            ELSE
272 1 pfleura2
*
273 1 pfleura2
*              H or H' is applied to C(1:m,i:n)
274 1 pfleura2
*
275 1 pfleura2
               NI = N - I + 1
276 1 pfleura2
               JC = I
277 1 pfleura2
            END IF
278 1 pfleura2
*
279 1 pfleura2
*           Apply H or H'
280 1 pfleura2
*
281 1 pfleura2
            CALL DLARZB( SIDE, TRANST, 'Backward', 'Rowwise', MI, NI,
282 1 pfleura2
     $                   IB, L, A( I, JA ), LDA, T, LDT, C( IC, JC ),
283 1 pfleura2
     $                   LDC, WORK, LDWORK )
284 1 pfleura2
   10    CONTINUE
285 1 pfleura2
*
286 1 pfleura2
      END IF
287 1 pfleura2
*
288 1 pfleura2
      WORK( 1 ) = LWKOPT
289 1 pfleura2
*
290 1 pfleura2
      RETURN
291 1 pfleura2
*
292 1 pfleura2
*     End of DORMRZ
293 1 pfleura2
*
294 1 pfleura2
      END