(self, **hints)
return Add(*terms)
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|
Expand the density operator into an outer product format.
Expand the density operator into an outer product format .
def doit(self, **hints):
        """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|

        """

        terms = []
        for (state, prob) in self.args:
            state = state.expand()  # needed to break up (a+b)*c
            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)
def doit ( self , * * hints ) : terms = [ ] for ( state , prob ) in self . args : state = state . expand ( ) # needed to break up (a+b)*c 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 )