Skip to content

Commit 491c0cf

Browse files
committed
updating zlarf1f.f
1 parent 2d8314f commit 491c0cf

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

SRC/zlarf1f.f

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*> ZLARF1F applies a complex elementary reflector H to a real m by n matrix
4040
*> C, from either the left or the right. H is represented in the form
4141
*>
42-
*> H = I - tau * v * v**T
42+
*> H = I - tau * v * v**H
4343
*>
4444
*> where tau is a complex scalar and v is a complex vector.
4545
*>
@@ -56,8 +56,6 @@
5656
*> \verbatim
5757
*> SIDE is CHARACTER*1
5858
*> = 'L': form H * C
59-
*> = 'R': form C * H
60-
*> \endverbatim
6159
*>
6260
*> \param[in] M
6361
*> \verbatim
@@ -160,9 +158,6 @@ SUBROUTINE ZLARF1F( SIDE, M, N, V, INCV, TAU, C, LDC, WORK )
160158
INTEGER ILADLR, ILADLC
161159
EXTERNAL LSAME, ILADLR, ILADLC
162160
* ..
163-
* .. Intrinsic Functions ..
164-
INTRINSIC DCONJG
165-
* ..
166161
* .. Executable Statements ..
167162
*
168163
APPLYLEFT = LSAME( SIDE, 'L' )
@@ -210,20 +205,26 @@ SUBROUTINE ZLARF1F( SIDE, M, N, V, INCV, TAU, C, LDC, WORK )
210205
*
211206
* w(1:lastc,1) := C(1:lastv,1:lastc)**H * v(1:lastv,1)
212207
*
213-
! w(1:lastc,1) := C(2:lastv,1:lastc)**H * v(2:lastv,1)
214-
CALL ZGEMV( 'Conj', LASTV-1, LASTC, ONE, C(1+1,1), LDC,
215-
$ V(1+INCV), INCV, ZERO, WORK, 1)
216-
! w(1:lastc,1) += C(1,1:lastc) * v(1,1) = C(1,1:lastc)
217-
DO I = 1, LASTC
218-
WORK(I) = WORK(I) + DCONJG(C(1,I))
208+
! (I - tvv**H)C = C - tvv**H C
209+
! First compute w**H = v**H c -> w = C**H v
210+
! C = [ C_1 C_2 ]**T, v = [1 v_2]**T
211+
! w = C_1**H + C_2**Hv_2
212+
! w = C_1**H
213+
DO I = 1, LASTC
214+
WORK(I) = DCONJG(C(1,I))
219215
END DO
216+
! w += C_2**Hv_2
217+
CALL ZGEMV( 'Conj', LASTV-1, LASTC, ONE, C(1+1,1), LDC,
218+
$ V(1+INCV), INCV, ONE, WORK, 1)
220219
*
221-
* C(1:lastv,1:lastc) := C(...) - tau * v(1:lastv,1) * w(1:lastc,1)**T
220+
* C(1:lastv,1:lastc) := C(...) - tau * v(1:lastv,1) * w(1:lastc,1)**H
222221
*
223222
! C(1, 1:lastc) := C(...) - tau * v(1,1) * w(1:lastc,1)**T
224-
! = C(...) - tau * w(1:lastc,1)
225-
CALL ZAXPY(LASTC, -TAU, WORK, 1, C, LDC)
226-
! C(2:lastv,1:lastc) := C(...) - tau * v(2:lastv,1)*w(1:lastc,1)**T
223+
! = C(...) - tau * Conj(w(1:lastc,1))
224+
DO I = 1, LASTC
225+
C(1,I) = C(1,I) - TAU * DCONJG(WORK(I))
226+
END DO
227+
! C(2:lastv,1:lastc) := C(...) - tau * v(2:lastv,1)*w(1:lastc,1)**H
227228
CALL ZGERC(LASTV-1, LASTC, -TAU, V(1+INCV), INCV, WORK,
228229
$ 1, C(1+1,1), LDC)
229230
END IF

0 commit comments

Comments
 (0)