Skip to content

Commit 2b9dfa2

Browse files
committed
replace dnrm2 with norm2
1 parent 388c9ac commit 2b9dfa2

1 file changed

Lines changed: 18 additions & 22 deletions

File tree

src/hompack_nf.f90

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ impure subroutine fixpnf( &
250250
! STEPNF to calculate the tangent vectors and Newton steps.
251251

252252
use hompack_kinds, only: zero, one
253-
use blas_interfaces, only: dnrm2
254253
implicit none
255254

256255
type(hompack_callbacks), intent(in) :: callbacks
@@ -498,7 +497,7 @@ impure subroutine fixpnf( &
498497

499498
! Calculate final arc length
500499
w = y - z0
501-
arclen = state%s - state%hold + dnrm2(np1, w, 1)
500+
arclen = state%s - state%hold + norm2(w)
502501
return
503502

504503
end if
@@ -533,7 +532,6 @@ subroutine rootnf( &
533532

534533
use hompack_kinds, only: zero, one
535534
use hompack_core, only: root
536-
use blas_interfaces, only: dnrm2
537535
implicit none
538536

539537
type(hompack_callbacks) :: callbacks
@@ -587,7 +585,7 @@ subroutine rootnf( &
587585
limit = 2*(int(abs(log10(aerr + rerr))) + 1)
588586

589587
tz = y - state%yold
590-
dels = dnrm2(np1, tz, 1)
588+
dels = norm2(tz)
591589

592590
! Using two points and tangents on the homotopy zero curve, construct the Hermite
593591
! cubic interpolant q(s). Then use 'root' to find the 's' corresponding to
@@ -636,7 +634,7 @@ subroutine rootnf( &
636634

637635
! Check for convergence
638636
if ((abs(w(1) - one) <= rerr + aerr) .and. &
639-
(dnrm2(np1, tz, 1) <= rerr*dnrm2(state%n, w(2:np1), 1) + aerr)) then
637+
(norm2(tz) <= rerr*norm2(w(2:np1)) + aerr)) then
640638
y = w
641639
return
642640
end if
@@ -663,7 +661,7 @@ subroutine rootnf( &
663661

664662
! Compute dels=||y-yp||
665663
tz = y - state%yp
666-
dels = dnrm2(np1, tz, 1)
664+
dels = norm2(tz)
667665

668666
! Compute tz for the linear predictor w = y + tz, where tz = sa*(yold-y).
669667
sa = (one - y(1))/(state%yold(1) - y(1))
@@ -673,14 +671,14 @@ subroutine rootnf( &
673671
! This is guaranteed if bracket=true. If linear prediction is too far away, use
674672
! bracketing points to compute linear prediction.
675673
if (.not. bracket) then
676-
if (dnrm2(np1, tz, 1) > dels) then
674+
if (norm2(tz) > dels) then
677675
! Compute tz = sa*(yp-y)
678676
sa = (one - y(1))/(state%yp(1) - y(1))
679677
tz = sa*(state%yp - y)
680678
end if
681679
end if
682680

683-
! Compute estimate w = y + tz and save old tangent vector.
681+
! Compute estimate w = y + tz and save old tangent vector.
684682
w = w + tz
685683
state%ypold = wp
686684

@@ -702,7 +700,6 @@ subroutine stepnf( &
702700
!! directly only if it is necessary to modify the stepping algorithm's parameters.
703701

704702
use hompack_kinds, only: one, zero
705-
use blas_interfaces, only: dnrm2
706703
implicit none
707704

708705
type(hompack_callbacks), intent(in) :: callbacks
@@ -764,7 +761,7 @@ subroutine stepnf( &
764761
end if
765762

766763
! If error tolerances are too small, increase them to acceptable values
767-
temp = dnrm2(np1, y, 1) + one
764+
temp = norm2(y) + one
768765
if (0.5_dp*(state%relerr*temp + state%abserr) < twou*temp) then
769766
if (state%relerr .ne. zero) then
770767
state%relerr = fouru*(one + fouru)
@@ -811,16 +808,16 @@ subroutine stepnf( &
811808

812809
! Compute quantities used for optimal step size estimation
813810
if (judy == 1) then
814-
lcalc = dnrm2(np1, tz, 1)
811+
lcalc = norm2(tz)
815812
rcalc = rholen
816813
z1 = w
817814
else if (judy == 2) then
818-
lcalc = dnrm2(np1, tz, 1)/lcalc
815+
lcalc = norm2(tz)/lcalc
819816
rcalc = rholen/rcalc
820817
end if
821818

822819
! Go to mop-up section after convergence
823-
if (dnrm2(np1, tz, 1) <= state%relerr*dnrm2(np1, w, 1) + state%abserr) go to 600
820+
if (norm2(tz) <= state%relerr*norm2(w) + state%abserr) go to 600
824821

825822
end do
826823

@@ -862,16 +859,16 @@ subroutine stepnf( &
862859

863860
! Compute quantities used for optimal step size estimation.
864861
if (judy == 1) then
865-
lcalc = dnrm2(np1, tz, 1)
862+
lcalc = norm2(tz)
866863
rcalc = rholen
867864
z1 = w
868865
else if (judy == 2) then
869-
lcalc = dnrm2(np1, tz, 1)/lcalc
866+
lcalc = norm2(tz)/lcalc
870867
rcalc = rholen/rcalc
871868
end if
872869

873870
! Go to mop-up section after convergence.
874-
if (dnrm2(np1, tz, 1) <= state%relerr*dnrm2(np1, w, 1) + state%abserr) go to 600
871+
if (norm2(tz) <= state%relerr*norm2(w) + state%abserr) go to 600
875872

876873
end do corrector
877874

@@ -899,16 +896,16 @@ subroutine stepnf( &
899896
w = y - state%yold
900897

901898
! Update arc length
902-
state%hold = dnrm2(np1, w, 1)
899+
state%hold = norm2(w)
903900
state%s = state%s + state%hold
904901

905902
! OPTIMAL STEP SIZE ESTIMATION SECTION
906903

907904
! Calculate the distance factor 'dcalc'
908905
tz = z0 - y
909906
w = z1 - y
910-
dcalc = dnrm2(np1, tz, 1)
911-
if (dcalc .ne. zero) dcalc = dnrm2(np1, w, 1)/dcalc
907+
dcalc = norm2(tz)
908+
if (dcalc .ne. zero) dcalc = norm2(w)/dcalc
912909

913910
! The optimal step size hbar is defined by
914911
!
@@ -982,7 +979,6 @@ subroutine tangnf( &
982979
!! Newton step.
983980

984981
use hompack_kinds, only: zero, one
985-
use blas_interfaces, only: dnrm2
986982
use lapack_interfaces, only: dgeqpf, dormqr
987983
implicit none
988984

@@ -1088,7 +1084,7 @@ subroutine tangnf( &
10881084
end if
10891085

10901086
! Compute the norm of the homotopy map if it was requested
1091-
if (rholen < zero) rholen = dnrm2(n, qr(:, np2), 1)
1087+
if (rholen < zero) rholen = norm2(qr(:, np2))
10921088

10931089
! Reduce the Jacobian matrix to upper triangular form
10941090
pivot = 0
@@ -1111,7 +1107,7 @@ subroutine tangnf( &
11111107
j = i + 1
11121108
tz(i) = -dot_product(qr(i, j:np1), tz(j:np1))/alpha(i)
11131109
end do
1114-
ypnorm = dnrm2(np1, tz, 1)
1110+
ypnorm = norm2(tz)
11151111
yp(pivot) = tz/ypnorm
11161112
if (dot_product(yp, ypold) < zero) yp = -yp
11171113

0 commit comments

Comments
 (0)