'Expand the density operator into an outer product format.
Examples
>>> from sympy.physics.quantum.state import Ket
>>> from sympy.physics.quantum.density import Density
>>> from sympy.physics.quantum.operator import Operator
>>> A = Operator(\'A\')
>>> d = Density([Ket(0), 0.5], [Ket(1),0.5])
>>> d.doit()
0.5*|0><0| + 0.5*|1><1|'

def doit(self, **hints):

    terms = []
    for (state, prob) in self.args:
        state = state.expand()
        if isinstance(state, Add):
            for arg in product(state.args, repeat=2):
                terms.append((prob * self._generate_outer_prod(arg[0], arg[1])))
        else:
            terms.append((prob * self._generate_outer_prod(state, state)))
    return Add(*terms)
