(mat)
Works by finding the eigenvectors and eigenvalues of the matrix.
    We know we can decompose rho by doing:
    sum(EigenVal*|Eigenvect><Eigenvect|)
Works by finding the eigenvectors and eigenvalues of the matrix.
    We know we can decompose rho by doing:
    sum(EigenVal*|Eigenvect><Eigenvect|)
Works by finding the eigenvectors and eigenvalues of the matrix . We know we can decompose rho by doing : sum ( EigenVal * |Eigenvect > <Eigenvect| )
def matrix_to_density(mat):
    """
    Works by finding the eigenvectors and eigenvalues of the matrix.
    We know we can decompose rho by doing:
    sum(EigenVal*|Eigenvect><Eigenvect|)
    """
    from sympy.physics.quantum.density import Density
    eigen = mat.eigenvects()
    args = [[matrix_to_qubit(Matrix(
        [vector, ])), x[0]] for x in eigen for vector in x[2] if x[0] != 0]
    if (len(args) == 0):
        return 0
    else:
        return Density(*args)
def matrix_to_density ( mat ) : from sympy . physics . quantum . density import Density eigen = mat . eigenvects ( ) args = [ [ matrix_to_qubit ( Matrix ( [ vector , ] ) ) , x [ 0 ] ] for x in eigen for vector in x [ 2 ] if x [ 0 ] != 0 ] if ( len ( args ) == 0 ) : return 0 else : return Density ( * args )