I have the following expression:
$\sum_{0 < s \leq S} \sum_{0 < a \leq A} (x_{a,s} - \frac{1}{A}\sum_{0 < i \leq A} x_{i,s})^2$
, which I would like to express in matrix quadratic form, as $\vec{x}'\matrix{D}\vec{x}$, where:
$\vec{x}' = [ x_{1,1}, x_{2,1}, ... x_{A1}, ... ,x_{1S},x_{2S}, ... ,x_{AS}]$
Manually, I have found that for example for $S=2$ and $A=2$, we have:
$D = \frac{1}{2}\begin{bmatrix} 1&-1&0&0\\ -1&1&0&0\\ 0&0&1&-1\\ 0&0&-1&1\\ \end{bmatrix}$
Where I need $D$ to be positive semi-definite, since it is going to be used as input for a quadratic programming solver.
Can anyone help me compute $\matrix{D}$ for any value of $S$ and $A$?
Update: Intuitively I think one should be able to express $\matrix{D} = \matrix{M} \otimes \matrix{I(S)} $, where $\otimes$ is the kroencker product, $\matrix{I(S)}$ is the identity matrix of size $S$, and $\matrix{M}$ is a full square matrix of size $A$. However, I cannot figure out what structure $M$ should have.
Thanks
Daniel
Consider the square matrix of size A:
$M = \frac{1}{A}\begin{bmatrix} A -1 &-1 & ... & -1\\ -1& A - 1& ... & -1\\ ... \\ -1& -1 & ...& A-1\\ \end{bmatrix}$
Then, $\matrix{D} = \matrix{M} \otimes \matrix{I(S)} $, where $\otimes$ is the kroencker product, $\matrix{I(S)}$ is the identity matrix of size $S$