Let a B-spline of degree $p$ be defined by its parametric equation $$ \mathbf{r}(t) = \sum_{i=0}^n N_i^p(t)\mathbf{P}_i$$
where the $n+1$ control points are denoted by $\mathbf{P}_i$. The basis functions $N_i^p$ are classically defined as
$$ \begin{align} N_i^0(t) &= \begin{cases} 1 &\text{ if }t \in [t_i,t_{i+1}[ \\ 0 &\text{ otherwise } \end{cases} \end{align} $$ $$ \begin{align} N_i^p(t) = \frac{t - t_i}{t_{i + p} - t_i}N_i^{p-1} + \frac{t_{i + p + 1} - t}{t_{i + p + 1} - t_{i + 1}}N_{i+1}^{p-1} \end{align} $$ where $\{t_i\}_{i = 0..m = n + p + 1}$ are the so-called spline knots.
It is my understanding that because of the compact support of those basis functions, one only needs to evaluate the parametric equation over $[t_p,t_{m-p}]$ to obtain the full spline.
My current implementation of these equations appears to work when the spline is left open (no knot has a multiplicity equal to p + 1):
For uniformly spaced knots $t = [ 0, 1/6, 1/3, 1/2, 2/3, 5/6, 1 ]$ (m = 6) and a control net comprised of $n + 1 = 4$ points, thus corresponding to a spline of degree $p =2$, I get the following curve (which as I said seems correct)
However, enforcing the clamping of the spline's ends by setting
$ t= [ 0, 0, 0, 0.5, 1, 1, 1 ]$ only works on one end, as shown below
Clamped B-spline. Only one end is clamped properly
The end corresponding to $t_p = 0$ is clamped, but the other end corresponding to $t_{m-p} = 1$ goes to zero.
I believe this oddity is caused by the incorrect definition of the B-spline support in the clamped case. I found that changing $ N_i^0(t) = 1 $ if $ t \in [t_i,t_{i+1}[ $ to $ N_i^0(t) = 1 $ if $ t \in [t_i,t_{i+1}] $ (i.e using a closed interval instead) was allowing the clamping to work.
This being said, I am not sure at all that changing the support of the basis functions is required in order to get a clamped B-spline. Am I missing something?