Density Matrix Theory and Applications