State Space Observer Control
Assuming $y$ and $u$ are scalars, then the first equation:

$$
u = -K \hat{x}
$$

is just a vector-vector multiplication and can be implemented in C as:

u = 0.0;
for (i=0; i&lt;N; i++)
{  
    u += xhat[i]*K[i];
}


assuming that $K$ is $1 \times N$ and that $\hat{x}$ is $N \times 1$.

The multiplication C*xhat can be implemented similarly (because I suspect that $C$ is really $1 \times N$ rather than $2 \times N$).

The multiplications L*(y-C*xhat) and B*u are vector-scalar multiplications which, for the latter, would look like:

Bu = 0.0;
for (i=0; i&lt;N; i++)
{  
    Bu += B[i]*u;
}


The multiplication  A*xhat  will be slightly different because $A$ is $N \times N$.