@@ -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
0 commit comments