dbknot chooses a knot sequence for interpolation of order k at the data points x(i), i=1,..,n. the n+k knots are placed in the array t. k knots are placed at each endpoint and not-a-knot end conditions are used. the remaining knots are placed at data points if n is even and between data points if n is odd. the rightmost knot is shifted slightly to the right to insure proper interpolation at x(n) (see page 350 of the reference).

- Jacob Williams, 2/24/2015 : Refactored this routine.

Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|

real(kind=wp), | intent(in), | dimension(:) | :: | x |
||

integer(kind=ip), | intent(in) | :: | n |
dimension of |
||

integer(kind=ip), | intent(in) | :: | k |
|||

real(kind=wp), | intent(out), | dimension(:) | :: | t |

pure subroutine dbknot(x,n,k,t) implicit none integer(ip),intent(in) :: n !! dimension of `x` integer(ip),intent(in) :: k real(wp),dimension(:),intent(in) :: x real(wp),dimension(:),intent(out) :: t integer(ip) :: i, j, ipj, npj, ip1, jstrt real(wp) :: rnot !put k knots at each endpoint !(shift right endpoints slightly -- see pg 350 of reference) rnot = x(n) + 0.1_wp*( x(n)-x(n-1_ip) ) do j=1_ip,k t(j) = x(1_ip) npj = n + j t(npj) = rnot end do !distribute remaining knots if (mod(k,2_ip) == 1_ip) then !case of odd k -- knots between data points i = (k-1_ip)/2_ip - k ip1 = i + 1_ip jstrt = k + 1_ip do j=jstrt,n ipj = i + j t(j) = 0.5_wp*( x(ipj) + x(ipj+1_ip) ) end do else !case of even k -- knots at data points i = (k/2_ip) - k jstrt = k+1_ip do j=jstrt,n ipj = i + j t(j) = x(ipj) end do end if end subroutine dbknot