def matrix_dagger(e):
    if isinstance(e, Matrix):
        return e.H
    elif isinstance(e, (numpy_ndarray, scipy_sparse_matrix)):
        return e.conjugate().transpose()
    raise TypeError('Expected sympy/numpy/scipy.sparse matrix, got: %r' % e)


# TODO: Move this into sympy.matricies.
Return the dagger of a sympy/numpy/scipy.sparse matrix.
dataset/ETHPy150Open sympy/sympy/sympy/physics/quantum/matrixutils.py/matrix_dagger