InsertKnot Subroutine

private pure subroutine InsertKnot(me, u, r, span)

Insert knot into times.

program example

use BasisFunctions

implicit none

integer, parameter :: wp  = selected_real_kind(15,307)
type(basis) :: N

N=basis(nk=9,p=3,k=[0.0_wp,0.0_wp,0.0_wp,0.0_wp, &
        2.0_wp,3.0_wp,3.0_wp,3.0_wp,3.0_wp])

call N%plot()

call N%InsertKnot(u=2.0_wp,r=2,span=N%FindSpan(1.0_wp))

call N%plot()

call N%InsertKnot(u=1.0_wp,r=3,span=N%FindSpan(1.0_wp))

call N%plot()

print*, N%p     ! 3
print*, N%nk    ! 14
print*, N%m     ! 13
print*, N%nb    ! 10
print*, N%n     ! 9
print*, N%kv    ! [0.0_wp,0.0_wp,0.0_wp,0.0_wp,
                !  1.0_wp,1.0_wp,1.0_wp,2.0_wp,2.0_wp,2.0_wp,
                !  3.0_wp,3.0_wp,3.0_wp,3.0_wp]

end program example

Arguments

Type IntentOptional AttributesName
class(basis), intent(inout) :: me
real(kind=wp), intent(in) :: u

knot value

integer, intent(in) :: r

multiplicity of new knot value

integer, intent(in), optional :: span

knot span


Contents

Source Code


Source Code

        pure subroutine InsertKnot(me,u,r,span)
            class(basis), intent(inout)     :: me
            real(wp), intent(in)            :: u    !< knot value \(\bar{u}\)
            integer, intent(in)             :: r    !< multiplicity of new knot value
            integer, intent(in), optional   :: span !< knot span
            !locals
            real(wp) :: kvtemp(0:me%m)
            integer  :: k
            
            if(present(span))then
                k = span
            else
                k = me%FindSpan(u)
            end if
            
            kvtemp = me%kv
            deallocate(me%kv)
            allocate(me%kv(0:me%m+r))
            me%kv(0:k) = kvtemp(0:k)
            me%kv(k+1:k+r) = u
            me%kv(k+r+1:me%m+r) = kvtemp(k+1:me%m)
            
            !update basis properties
            me%nk = me%nk + r
            me%m = me%m + r
            me%nb = me%nb + r
            me%n = me%n + r
        end subroutine InsertKnot