I know that the weighted least squares solution is

B = (X'WX)^-1 . (X'WY)

Where B is the parameters, X the input, Y the targets and W the weight matrix such that Wii = 1/SD, which in this last case, if I understand it, is optimal if the errors are uncorrelated.

But does anyone know how to achieve this derivation in matrix notation from the form

argmin SSE(B) = (Y-XB)'W(Y-XB)?

Many thanks in advance for any insights.