Add Lagrange interpolation subroutine and update calls in prolongrestrict modules

This commit is contained in:
2026-02-27 12:46:39 +08:00
parent 94d236385d
commit c001939461
3 changed files with 30 additions and 8 deletions

View File

@@ -1177,6 +1177,30 @@ end subroutine d2dump
return
end subroutine polint
subroutine polint0(xa, ya, y, ordn)
! Lagrange interpolation at x=0, O(n) direct formula
implicit none
integer, intent(in) :: ordn
real*8, dimension(ordn), intent(in) :: xa, ya
real*8, intent(out) :: y
integer :: j, k
real*8 :: wj
y = 0.d0
do j = 1, ordn
wj = 1.d0
do k = 1, ordn
if (k .ne. j) then
wj = wj * xa(k) / (xa(k) - xa(j))
endif
enddo
y = y + wj * ya(j)
enddo
return
end subroutine polint0
!------------------------------------------------------------------------------
!
! interpolation in 2 dimensions, follow yx order