perf(polint): add ordn=6 specialized neville path
This commit is contained in:
@@ -1116,6 +1116,67 @@ end subroutine d2dump
|
|||||||
! Lagrangian polynomial interpolation
|
! Lagrangian polynomial interpolation
|
||||||
!------------------------------------------------------------------------------
|
!------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
!DIR$ ATTRIBUTES FORCEINLINE :: polint6_neville
|
||||||
|
subroutine polint6_neville(xa, ya, x, y, dy)
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
real*8, dimension(6), intent(in) :: xa, ya
|
||||||
|
real*8, intent(in) :: x
|
||||||
|
real*8, intent(out) :: y, dy
|
||||||
|
|
||||||
|
integer :: i, m, ns, n_m
|
||||||
|
real*8, dimension(6) :: c, d, ho
|
||||||
|
real*8 :: dif, dift, hp, h, den_val
|
||||||
|
|
||||||
|
c = ya
|
||||||
|
d = ya
|
||||||
|
ho = xa - x
|
||||||
|
|
||||||
|
ns = 1
|
||||||
|
dif = abs(x - xa(1))
|
||||||
|
|
||||||
|
do i = 2, 6
|
||||||
|
dift = abs(x - xa(i))
|
||||||
|
if (dift < dif) then
|
||||||
|
ns = i
|
||||||
|
dif = dift
|
||||||
|
end if
|
||||||
|
end do
|
||||||
|
|
||||||
|
y = ya(ns)
|
||||||
|
ns = ns - 1
|
||||||
|
|
||||||
|
do m = 1, 5
|
||||||
|
n_m = 6 - m
|
||||||
|
do i = 1, n_m
|
||||||
|
hp = ho(i)
|
||||||
|
h = ho(i+m)
|
||||||
|
den_val = hp - h
|
||||||
|
|
||||||
|
if (den_val == 0.0d0) then
|
||||||
|
write(*,*) 'failure in polint for point',x
|
||||||
|
write(*,*) 'with input points: ',xa
|
||||||
|
stop
|
||||||
|
end if
|
||||||
|
|
||||||
|
den_val = (c(i+1) - d(i)) / den_val
|
||||||
|
|
||||||
|
d(i) = h * den_val
|
||||||
|
c(i) = hp * den_val
|
||||||
|
end do
|
||||||
|
|
||||||
|
if (2 * ns < n_m) then
|
||||||
|
dy = c(ns + 1)
|
||||||
|
else
|
||||||
|
dy = d(ns)
|
||||||
|
ns = ns - 1
|
||||||
|
end if
|
||||||
|
y = y + dy
|
||||||
|
end do
|
||||||
|
|
||||||
|
return
|
||||||
|
end subroutine polint6_neville
|
||||||
|
|
||||||
!DIR$ ATTRIBUTES FORCEINLINE :: polint
|
!DIR$ ATTRIBUTES FORCEINLINE :: polint
|
||||||
subroutine polint(xa, ya, x, y, dy, ordn)
|
subroutine polint(xa, ya, x, y, dy, ordn)
|
||||||
implicit none
|
implicit none
|
||||||
@@ -1129,6 +1190,11 @@ end subroutine d2dump
|
|||||||
real*8, dimension(ordn) :: c, d, ho
|
real*8, dimension(ordn) :: c, d, ho
|
||||||
real*8 :: dif, dift, hp, h, den_val
|
real*8 :: dif, dift, hp, h, den_val
|
||||||
|
|
||||||
|
if (ordn == 6) then
|
||||||
|
call polint6_neville(xa, ya, x, y, dy)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
c = ya
|
c = ya
|
||||||
d = ya
|
d = ya
|
||||||
ho = xa - x
|
ho = xa - x
|
||||||
|
|||||||
Reference in New Issue
Block a user