function M = Symmetrization(W,U) %Generate the symmetrization matrix of U wrt invertible matrix P where P'P=W^-1. Whalf=W^(1/2); L=Whalf\U; PUPinverse=L*Whalf; M=0.5*(PUPinverse+PUPinverse');