Skip to content

Commit 91b829a

Browse files
committed
reorder tangnf args
1 parent c45d65b commit 91b829a

2 files changed

Lines changed: 32 additions & 33 deletions

File tree

src/hompack_nf.f90

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -721,8 +721,8 @@ subroutine rootnf(state, callbacks, relerr, abserr, y)
721721

722722
! Calculate Newton step at current estimate 'w'
723723
call tangnf(callbacks, sa, &
724-
ws%w, ws%wp, state%ypold, state%a, ws%qr, ws%alpha, ws%tz, ws%pivot, &
725-
state%nfe, state%n, state%iflag)
724+
state%n, ws%w, ws%wp, state%ypold, state%a, state%nfe, state%iflag, &
725+
ws%qr, ws%alpha, ws%tz, ws%pivot)
726726
if (state%iflag > 0) return
727727

728728
! Next point = current point + Newton step
@@ -857,9 +857,9 @@ subroutine stepnf(state, callbacks, y)
857857
! Use linear predictor along tangent direction to start Newton iteration
858858
state%ypold(1) = one
859859
state%ypold(2:np1) = zero
860-
call tangnf(callbacks, state%s, y, state%yp, state%ypold, state%a, &
861-
ws%qr, ws%alpha, ws%tz, ws%pivot, &
862-
state%nfe, state%n, state%iflag)
860+
call tangnf(callbacks, state%s, state%n, y, state%yp, state%ypold, state%a, &
861+
state%nfe, state%iflag, &
862+
ws%qr, ws%alpha, ws%tz, ws%pivot)
863863

864864
if (state%iflag > 0) return
865865

@@ -871,9 +871,9 @@ subroutine stepnf(state, callbacks, y)
871871

872872
! Calculate the Newton step 'tz' at the current point 'w'
873873
call tangnf(callbacks, rholen, &
874-
ws%w, ws%wp, state%ypold, state%a, &
875-
ws%qr, ws%alpha, ws%tz, ws%pivot, &
876-
state%nfe, state%n, state%iflag)
874+
state%n, ws%w, ws%wp, state%ypold, state%a, &
875+
state%nfe, state%iflag, &
876+
ws%qr, ws%alpha, ws%tz, ws%pivot)
877877
if (state%iflag > 0) return
878878

879879
! Take Newton step and check convergence
@@ -924,9 +924,9 @@ subroutine stepnf(state, callbacks, y)
924924

925925
! Calculate the Newton step 'tz' at the current point 'w'
926926
rholen = -one
927-
call tangnf(callbacks, &
928-
rholen, ws%w, ws%wp, state%yp, state%a, ws%qr, ws%alpha, ws%tz, ws%pivot, &
929-
state%nfe, state%n, state%iflag)
927+
call tangnf(callbacks, rholen, &
928+
state%n, ws%w, ws%wp, state%yp, state%a, state%nfe, &
929+
state%iflag, ws%qr, ws%alpha, ws%tz, ws%pivot)
930930
if (state%iflag > 0) return
931931

932932
! Take Newton step and check convergence
@@ -1025,8 +1025,7 @@ subroutine stepnf(state, callbacks, y)
10251025
end subroutine stepnf
10261026

10271027
subroutine tangnf( &
1028-
callbacks, &
1029-
rholen, y, yp, ypold, a, qr, alpha, tz, pivot, nfe, n, iflag)
1028+
callbacks, rholen, n, y, yp, ypold, a, nfe, iflag, qr, alpha, tz, pivot)
10301029
!! This subroutine builds the Jacobian matrix of the homotopy map, computes a QR
10311030
!! decomposition of that matrix, and then calculates the (unit) tangent vector and the
10321031
!! Newton step.
@@ -1046,6 +1045,8 @@ subroutine tangnf( &
10461045
!!
10471046
!! On output, if `rholen < 0` on entry:
10481047
!! `rholen = ||rho(a, lambda, x)||`. Otherwise the value is unchanged.
1048+
integer, intent(in) :: n
1049+
!! Problem dimension.
10491050
real(dp), intent(in) :: y(:)
10501051
!! Current point on the homotopy zero curve. `Shape: (n+1)`.
10511052
!! Contains `(lambda, x)`.
@@ -1058,23 +1059,9 @@ subroutine tangnf( &
10581059
!! vector.
10591060
real(dp), intent(in) :: a(:)
10601061
!! Parameter vector used in the homotopy map.
1061-
real(dp), intent(inout) :: qr(:, :)
1062-
!! Workspace containing the Jacobian matrix and its QR factorization.
1063-
!! `Shape: (n, n+2)`.
1064-
real(dp), intent(inout) :: alpha(:)
1065-
!! Workspace array used during QR factorization and related linear algebra
1066-
!! operations. `Shape: (3*n+3)`.
1067-
real(dp), intent(out) :: tz(:)
1068-
!! Newton correction vector. `Shape: (n+1)`.
1069-
!! Equal to the negative pseudoinverse of the homotopy Jacobian applied to the
1070-
!! homotopy residual.
1071-
integer, intent(inout) :: pivot(:)
1072-
!! Pivot indices produced by the QR factorization. `Shape: (n+1)`.
10731062
integer, intent(inout) :: nfe
10741063
!! Number of homotopy/Jacobian evaluations performed.
10751064
!! Incremented by one on every successful call.
1076-
integer, intent(in) :: n
1077-
!! Problem dimension.
10781065
integer, intent(inout) :: iflag
10791066
!! Problem type and return status flag.
10801067
!!
@@ -1086,6 +1073,18 @@ subroutine tangnf( &
10861073
!! On output:
10871074
!! * unchanged (`0`, `-1`, or `-2`) on normal return.
10881075
!! * `4` : Jacobian matrix lost full rank (`rank < n`); iteration not completed.
1076+
real(dp), intent(inout) :: qr(:, :)
1077+
!! Workspace containing the Jacobian matrix and its QR factorization.
1078+
!! `Shape: (n, n+2)`.
1079+
real(dp), intent(inout) :: alpha(:)
1080+
!! Workspace array used during QR factorization and related linear algebra
1081+
!! operations. `Shape: (3*n+3)`.
1082+
real(dp), intent(out) :: tz(:)
1083+
!! Newton correction vector. `Shape: (n+1)`.
1084+
!! Equal to the negative pseudoinverse of the homotopy Jacobian applied to the
1085+
!! homotopy residual.
1086+
integer, intent(inout) :: pivot(:)
1087+
!! Pivot indices produced by the QR factorization. `Shape: (n+1)`.
10891088

10901089
real(dp) :: lambda, sigma, ypnorm
10911090
integer :: i, j, k, kp1, np1, np2, info

test/test_f.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,16 +336,16 @@ subroutine mainx
336336
cycle track
337337
end if
338338
rholen = 0d0
339-
call tangnf(callbacks, &
340-
rholen, w, wp, ypold, a, qr, alpha, tz, pivot, nfec, n, iflag)
339+
call tangnf(callbacks, rholen, n, w, wp, ypold, a, nfec, iflag, &
340+
qr, alpha, tz, pivot)
341341
case (-32:-20) ! TANGENT VECTOR AND NEWTON STEP
342342
if (h > .1_dp) then
343343
iflag = iflag - 100
344344
cycle track
345345
end if
346346
rholen = -1d0
347-
call tangnf(callbacks, &
348-
rholen, w, wp, ypold, a, qr, alpha, tz, pivot, nfec, n, iflag)
347+
call tangnf(callbacks, rholen, n, w, wp, ypold, a, nfec, iflag, &
348+
qr, alpha, tz, pivot)
349349
case (4, 6, 7)
350350
write (6, 13) iflag
351351
13 format(/' FATAL ERROR OCCURRED DURING TRACKING WITH', &
@@ -373,8 +373,8 @@ subroutine mainx
373373
gofw = w(1) - 1d0
374374
case (-52:-50) ! TANGENT VECTOR AND NEWTON STEP
375375
rholen = -1d0
376-
call tangnf(callbacks, &
377-
rholen, w, wp, ypold, a, qr, alpha, tz, pivot, nfec, n, iflag)
376+
call tangnf(callbacks, rholen, n, w, wp, ypold, a, nfec, iflag, &
377+
qr, alpha, tz, pivot)
378378
case (-2:0, 4, 6, 7)
379379
exit end_game
380380
end select

0 commit comments

Comments
 (0)