|
1 | | -*> \brief \b DLARF applies an elementary reflector to a general rectangular matrix. |
| 1 | +*> \brief \b DLARF1F applies an elementary reflector to a general rectangular |
| 2 | +* matrix assuming v(1) = 1. |
2 | 3 | * |
3 | 4 | * =========== DOCUMENTATION =========== |
4 | 5 | * |
|
18 | 19 | * Definition: |
19 | 20 | * =========== |
20 | 21 | * |
21 | | -* SUBROUTINE DLARF( SIDE, M, N, V, INCV, TAU, C, LDC, WORK ) |
| 22 | +* SUBROUTINE DLARF1F( SIDE, M, N, V, INCV, TAU, C, LDC, WORK ) |
22 | 23 | * |
23 | 24 | * .. Scalar Arguments .. |
24 | 25 | * CHARACTER SIDE |
|
120 | 121 | *> \ingroup larf |
121 | 122 | * |
122 | 123 | * ===================================================================== |
123 | | - SUBROUTINE DLARF1( SIDE, M, N, V, INCV, TAU, C, LDC, WORK ) |
| 124 | + SUBROUTINE DLARF1F( SIDE, M, N, V, INCV, TAU, C, LDC, WORK ) |
124 | 125 | * |
125 | 126 | * -- LAPACK auxiliary routine -- |
126 | 127 | * -- LAPACK is a software package provided by Univ. of Tennessee, -- |
@@ -192,48 +193,59 @@ SUBROUTINE DLARF1( SIDE, M, N, V, INCV, TAU, C, LDC, WORK ) |
192 | 193 | * |
193 | 194 | * Form H * C |
194 | 195 | * |
195 | | - IF( LASTV.GT.0 .AND. LASTC.GT.0) THEN |
196 | | -* |
197 | | -* w(1:lastc,1) := C(2:lastv,1:lastc)**T * v(2:lastv,1) |
198 | | -* |
199 | | -! CALL DGEMV( 'Transpose', LASTV-1, LASTC, ONE, C(1+1,1), LDC, |
200 | | -! $ V(1+INCV), INCV, ZERO, WORK, 1 ) |
201 | | -! DO I = 1, LASTC |
202 | | -! WORK(I) = ZERO |
203 | | -! DO J = 2, LASTV |
204 | | -! WORK(I) = WORK(I) + V(1 + (J-1)*INCV) * C(J,I) |
205 | | -! END DO |
206 | | -! END DO |
207 | | - CALL DGEMV( 'Transpose', LASTV-1, LASTC, ONE, C(2,1), LDC, |
208 | | - $ v(1+INCV), INCV, ZERO, WORK, 1) |
209 | | -* |
210 | | -* w(1:lastc,1) := w(1:lastc,1) + C(1,1:lastc)**T * v(1,1) |
211 | | -* = w(1:lastc,1) + C(1,1:lastc)**T |
212 | | -* |
213 | | - ! Now, do w(1:lastc,1) += C(1,1:lastc)**T |
214 | | -! DO I = 1, LASTC |
215 | | -! WORK(I) = WORK(I) + C(1,I) |
216 | | -! END DO |
217 | | - CALL DAXPY(LASTC, ONE, C, LDC, WORK, 1) |
218 | | -* |
219 | | -* C(1:lastv,1:lastc) := C(...) - v(1:lastv,1) * w(1:lastc,1)**T |
220 | | -* |
221 | | - CALL DGER( LASTV, LASTC, -TAU, V, INCV, WORK, 1, C, LDC ) |
| 196 | + IF( LASTV.GT.0 ) THEN |
| 197 | + ! Check if m = 1. This means v = 1, So we just need to compute |
| 198 | + ! C := HC = (1-\tau)C. |
| 199 | + IF( M.EQ.1 ) THEN |
| 200 | + CALL DSCAL(LASTC, ONE - TAU, C, LDC) |
| 201 | + ELSE |
| 202 | +* |
| 203 | +* w(1:lastc,1) := C(1:lastv,1:lastc)**T * v(1:lastv,1) |
| 204 | +* |
| 205 | + ! w(1:lastc,1) := C(2:lastv,1:lastc)**T * v(2:lastv,1) |
| 206 | + CALL DGEMV( 'Transpose', LASTV-1, LASTC, ONE, C(1+1,1), |
| 207 | + $ LDC, V(1+INCV), INCV, ZERO, WORK, 1) |
| 208 | + ! w(1:lastc,1) += C(1,1:lastc)**T * v(1,1) = C(1,1:lastc)**T |
| 209 | + CALL DAXPY(LASTC, ONE, C, LDC, WORK, 1) |
| 210 | +* |
| 211 | +* C(1:lastv,1:lastc) := C(...) - tau * v(1:lastv,1) * w(1:lastc,1)**T |
| 212 | +* |
| 213 | + ! C(1, 1:lastc) := C(...) - tau * v(1,1) * w(1:lastc,1)**T |
| 214 | + ! = C(...) - tau * w(1:lastc,1)**T |
| 215 | + CALL DAXPY(LASTC, -TAU, WORK, 1, C, LDC) |
| 216 | + ! C(2:lastv,1:lastc) := C(...) - tau * v(2:lastv,1)*w(1:lastc,1)**T |
| 217 | + CALL DGER(LASTV-1, LASTC, -TAU, V(1+INCV), INCV, WORK, 1, |
| 218 | + $ C(1+1,1), LDC) |
| 219 | + END IF |
222 | 220 | END IF |
223 | 221 | ELSE |
224 | 222 | * |
225 | 223 | * Form C * H |
226 | 224 | * |
227 | 225 | IF( LASTV.GT.0 ) THEN |
228 | | -* |
229 | | -* w(1:lastc,1) := C(1:lastc,1:lastv) * v(1:lastv,1) |
230 | | -* |
231 | | - CALL DGEMV( 'No transpose', LASTC, LASTV, ONE, C, LDC, |
232 | | - $ V, INCV, ZERO, WORK, 1 ) |
233 | | -* |
234 | | -* C(1:lastc,1:lastv) := C(...) - w(1:lastc,1) * v(1:lastv,1)**T |
235 | | -* |
236 | | - CALL DGER( LASTC, LASTV, -TAU, WORK, 1, V, INCV, C, LDC ) |
| 226 | + ! Check if n = 1. This means v = 1, so we just need to compute |
| 227 | + ! C := CH = C(1-\tau). |
| 228 | + IF( N.EQ.1 ) THEN |
| 229 | + CALL DSCAL(LASTC, ONE - TAU, C, 1) |
| 230 | + ELSE |
| 231 | +* |
| 232 | +* w(1:lastc,1) := C(1:lastc,1:lastv) * v(1:lastv,1) |
| 233 | +* |
| 234 | + ! w(1:lastc,1) := C(1:lastc,2:lastv) * v(2:lastv,1) |
| 235 | + CALL DGEMV( 'No transpose', LASTC, LASTV-1, ONE, |
| 236 | + $ C(1,1+1), LDC, V(1+INCV), INCV, ZERO, WORK, 1 ) |
| 237 | + ! w(1:lastc,1) += C(1:lastc,1) v(1,1) = C(1:lastc,1) |
| 238 | + CALL DAXPY(LASTC, ONE, C, 1, WORK, 1) |
| 239 | +* |
| 240 | +* C(1:lastc,1:lastv) := C(...) - tau * w(1:lastc,1) * v(1:lastv,1)**T |
| 241 | +* |
| 242 | + ! C(1:lastc,1) := C(...) - tau * w(1:lastc,1) * v(1,1)**T |
| 243 | + ! = C(...) - tau * w(1:lastc,1) |
| 244 | + CALL DAXPY(LASTC, -TAU, WORK, 1, C, 1) |
| 245 | + ! C(1:lastc,2:lastv) := C(...) - tau * w(1:lastc,1) * v(2:lastv)**T |
| 246 | + CALL DGER( LASTC, LASTV-1, -TAU, WORK, 1, V(1+INCV), |
| 247 | + $ INCV, C(1,1+1), LDC ) |
| 248 | + END IF |
237 | 249 | END IF |
238 | 250 | END IF |
239 | 251 | RETURN |
|
0 commit comments