$B$ is a $1\times n$ vector:
$$f(B)=\sum \limits_{j=1}^{N}\left(\left(x_{j}-B\right) \cdot\left(x_{j}-B\right)-\sum \limits_{k=1}^{r}\left(\left(x_{j}-B\right) \cdot e_{k}\right)^{2}\right)$$
In my script the following is stated:
$$\nabla f(B) =\sum \limits_{j=1}^{N}\left(-2\left(x_{j}-B\right)-2 \sum \limits_{k=1}^{r}\left(\left(x_{j}-B\right) \cdot e_{k}\right) \cdot\left(-e_{k}\right)\right)$$
I don't get it. The gradient is calculated as if we were differentiating the function by $B$. But $B$ is a vector and not an onedimensional variable. What am I missing?