# Knot vector

## Definition

Def. Knot vector

A finite sequence

$$$k = (k_1, \dots, k_l)$$$

is called knot vector if the sequence is broad monotonic increase, i.e. $k_{i} \le k_{i+1}$.

[TODO: fig]

BasicBSpline.KnotVectorType

Construct knot vector from given array.

$$$k=(k_1,\dots,k_l)$$$

Examples

julia> k = KnotVector([1,2,3])
KnotVector([1, 2, 3])

julia> k = KnotVector(1:3)
KnotVector([1, 2, 3])
source
BasicBSpline.UniformKnotVectorType

Construct uniform knot vector from given range.

$$$k=(k_1,\dots,k_l)$$$

Examples

julia> k = UniformKnotVector(1:8)
UniformKnotVector(1:8)

julia> UniformKnotVector(8:-1:3)
UniformKnotVector(3:1:8)
source
BasicBSpline.SubKnotVectorType

A type to represetnt sub knot vector.

$$$k=(k_1,\dots,k_l)$$$

Examples

julia> k = knotvector"1 11 211"
KnotVector([1, 3, 4, 6, 6, 7, 8])

julia> view(k, 2:5)
SubKnotVector([3, 4, 6, 6])
source
BasicBSpline.EmptyKnotVectorType

Knot vector with zero-element.

$$$k=()$$$

This struct is intended for internal use.

Examples

julia> EmptyKnotVector()
EmptyKnotVector{Bool}()

julia> EmptyKnotVector{Float64}()
EmptyKnotVector{Float64}()
source

## Operations for knot vectors

Base.lengthMethod

Length of knot vector

\begin{aligned} \#{k} &=(\text{number of knot elements of} \ k) \\ \end{aligned}

For example, $\#{(1,2,2,3)}=4$.

Examples

julia> k = KnotVector([1,2,2,3]);

julia> length(k)
4
source

Although a knot vector is not a vector in linear algebra, but we introduce additional operator $+$.

Base.:+Method

Sum of knot vectors

\begin{aligned} k^{(1)}+k^{(2)} &=(k^{(1)}_1, \dots, k^{(1)}_{l^{(1)}}) + (k^{(2)}_1, \dots, k^{(2)}_{l^{(2)}}) \\ &=(\text{sort of union of} \ k^{(1)} \ \text{and} \ k^{(2)} \text{)} \end{aligned}

For example, $(1,2,3,5)+(4,5,8)=(1,2,3,4,5,5,8)$.

Examples

julia> k1 = KnotVector([1,2,3,5]);

julia> k2 = KnotVector([4,5,8]);

julia> k1 + k2
KnotVector([1, 2, 3, 4, 5, 5, 8])
source

Note that the operator +(::KnotVector, ::KnotVector) is commutative. This is why we choose the $+$ sign. We also introduce product operator $\cdot$ for knot vector.

Base.:*Method

Product of integer and knot vector

\begin{aligned} m\cdot k&=\underbrace{k+\cdots+k}_{m} \end{aligned}

For example, $2\cdot (1,2,2,5)=(1,1,2,2,2,2,5,5)$.

Examples

julia> k = KnotVector([1,2,2,5]);

julia> 2 * k
KnotVector([1, 1, 2, 2, 2, 2, 5, 5])
source

Inclusive relationship between knot vectors.

Base.issubsetMethod

Check a inclusive relationship $k\subseteq k'$, for example:

\begin{aligned} (1,2) &\subseteq (1,2,3) \\ (1,2,2) &\not\subseteq (1,2,3) \\ (1,2,3) &\subseteq (1,2,3) \\ \end{aligned}

Examples

julia> KnotVector([1,2]) ⊆ KnotVector([1,2,3])
true

julia> KnotVector([1,2,2]) ⊆ KnotVector([1,2,3])
false

julia> KnotVector([1,2,3]) ⊆ KnotVector([1,2,3])
true
source
Base.uniqueMethod

Unique elements of knot vector.

\begin{aligned} \widehat{k} &=(\text{unique knot elements of} \ k) \\ \end{aligned}

For example, $\widehat{(1,2,2,3)}=(1,2,3)$.

Examples

julia> k = KnotVector([1,2,2,3]);

julia> unique(k)
KnotVector([1, 2, 3])
source
BasicBSpline.countknotsMethod

For given knot vector $k$, the following function $\mathfrak{n}_k:\mathbb{R}\to\mathbb{Z}$ represents the number of knots that duplicate the knot vector $k$.

$$$\mathfrak{n}_k(t) = \#\{i \mid k_i=t \}$$$

For example, if $k=(1,2,2,3)$, then $\mathfrak{n}_k(0.3)=0$, $\mathfrak{n}_k(1)=1$, $\mathfrak{n}_k(2)=2$.

julia> k = KnotVector([1,2,2,3]);

julia> countknots(k,0.3)
0

julia> countknots(k,1.0)
1

julia> countknots(k,2.0)
2
source

## KnotVector with string macro

BasicBSpline.@knotvector_strMacro
@knotvector_str -> KnotVector

Construct a knotvector by specifying the numbers of duplicates of knots.

Examples

julia> knotvector"11111"
KnotVector([1, 2, 3, 4, 5])

julia> knotvector"123"
KnotVector([1, 2, 2, 3, 3, 3])

julia> knotvector" 2 2 2"
KnotVector([2, 2, 4, 4, 6, 6])

julia> knotvector"     1"
KnotVector([6])
source