% spin-orbit matrix for ^2p atom
% states are p1, p0, p-1, bar-p1, bar-p0, bar-p-1

somat=diag([1 0 -1 -1 0 1]/2);  % diagonal matrix elments (l_z*s_z)

% add off-diagonal elements in upper triangle

somat(2,4)=1/sqrt(2);
somat(3,5)=1/sqrt(2);

% symmetrize matrix
somat=somat+triu(somat,1)';

% diagonalize matrix
eig(somat)