!>
!> @file l2knts.f90
!>
!> @brief
!>
!> @copyright
!> Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
!> SPC (Swiss Plasma Center)
!>
!> spclibs is free software: you can redistribute it and/or modify it under
!> the terms of the GNU Lesser General Public License as published by the Free
!> Software Foundation, either version 3 of the License, or (at your option)
!> any later version.
!>
!> spclibs is distributed in the hope that it will be useful, but WITHOUT ANY
!> WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
!> FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
!>
!> You should have received a copy of the GNU Lesser General Public License
!> along with this program. If not, see .
!>
!> @authors
!> (in alphabetical order)
!> @author Trach-Minh Tran
!>
subroutine l2knts ( break, l, k, t, n )
!*************************************************************************
!
!! L2KNTS converts breakpoints to knots.
!
! Discussion:
!
! The breakpoint sequence BREAK is converted into a corresponding
! knot sequence T to allow the representation of a piecewise
! polynomial function of order K with K-2 continuous derivatives
! as a spline of order K with knot sequence T.
!
! This means that
! t(1), ..., t(n+k)= break(1) k times, then break(i), i=2,...,l, each
! once, then break(l+1) k times. Therefore, n=k-1+l.
!
! Reference:
!
! Carl DeBoor,
! A Practical Guide to Splines,
! Springer Verlag.
!
! Parameters:
!
! Input, integer K, the order.
!
! Input, integer L, the number of polynomial pieces.
!
! Input, real ( kind = 8 ) BREAK(L+1), the breakpoint sequence.
!
! Output, real ( kind = 8 ) T(N+K), the knot sequence.
!
! Output, integer N, the dimension of the corresponding spline space
! of order K.
!
implicit none
integer k
integer l
integer n
real ( kind = 8 ) break(l+1)
integer i
real ( kind = 8 ) t(k-1+l+k)
t(1:k-1) = break(1)
do i = 1, l
t(k-1+i) = break(i)
end do
n = k-1+l
t(n+1:n+k) = break(l+1)
return
end