Thanks lpetrich,

I actually got the same result few hours before I found your reply, though you actually showed how to solve a more general problem where also X is complex.

What I did was basically to use Einstein notation to derive some useful

matrix calculus identities, and then by using them it was kind of easy to arrive at the final formula(s) that you wrote.

It was interesting to see how using a different notation made the problem more manageable.