I have written an algorithm to perform closed B-spline interpolation on a set of $N$ data points for a given degree $p$. I first generate a cyclic, uniform knot vector, and also use uniform parameterization on the input data points. I do know that better parameterization methods exist (such as chord length for the parameters + averaging for the knots), however I would like to cater for fully uniform knots/parameters as well in my algorithm. I therefore use these knots and parameters to generate a cyclic system matrix (since a closed B-spline has $p + 1$ wrapped control points) by evaluating the basis functions appropriately, as described here, but extended to the closed case.
When the degree is odd, the algorithm works perfectly. However, when the degree is even AND the number of points is even, the system matrix is singular (or extremely close to singular, at least, due to numerical rounding).
Why could this be? Have I done something wrong? Or is the system ill-defined? If so, what causes this? And is there any way to solve it/slightly tweak the conditions to make it defined, while still keeping uniform knots and parameters? I've attached two examples below, where $U$ is the knot vector, $T$ is the parameter vector, and $A$ is the system matrix to be inverted. All values are rounded to two decimal places.
Example 1 (singular)
$p = 4$, $N = 6$
$U = [-0.67, -0.50, -0.33, -0.17, 0.00, 0.17, 0.33, 0.50, 0.67, 0.83, 1.00, 1.17, 1.33, 1.50, 1.67]$
$T = [0.00, 0.17, 0.33, 0.50, 0.67, 0.83]$
$A = \begin{matrix} 0.04 & 0.46 & 0.46 & 0.04 & 0.00 & 0.00\\ 0.00 & 0.04 & 0.46 & 0.46 & 0.04 & 0.00\\ 0.00 & 0.00 & 0.04 & 0.46 & 0.46 & 0.04\\ 0.04 & 0.00 & 0.00 & 0.04 & 0.46 & 0.46\\ 0.46 & 0.04 & 0.00 & 0.00 & 0.04 & 0.46\\ 0.46 & 0.46 & 0.04 & 0.00 & 0.00 & 0.04 \end{matrix}$
Example 2 (non-singular)
$p = 4$, $N = 7$
$U = [-0.57, -0.43, -0.29, -0.14, 0.00, 0.14, 0.29, 0.43, 0.57, 0.71, 0.86, 1.00, 1.14, 1.29, 1.43, 1.57]$
$T = [0.00, 0.14, 0.29, 0.43, 0.57, 0.71, 0.86]$
$A = \begin{matrix} 0.04 & 0.46 & 0.46 & 0.04 & 0.00 & 0.00 & 0.00\\ 0.00 & 0.04 & 0.46 & 0.46 & 0.04 & 0.00 & 0.00\\ 0.00 & 0.00 & 0.04 & 0.46 & 0.46 & 0.04 & 0.00\\ 0.00 & 0.00 & 0.00 & 0.04 & 0.46 & 0.46 & 0.04\\ 0.04 & 0.00 & 0.00 & 0.00 & 0.04 & 0.46 & 0.46\\ 0.46 & 0.04 & 0.00 & 0.00 & 0.00 & 0.04 & 0.46\\ 0.46 & 0.46 & 0.04 & 0.00 & 0.00 & 0.00 & 0.04 \end{matrix}$
It also requires the values of $T$ to coincide with knots for the matrix to be singular. If you tweak it by adding the same small value to all of $U$ or all of $T$ you will get a invertible matrix.