def matrix_to_zero(e):
    if isinstance(e, Matrix):
        if zeros(*e.shape) == e:
            e = Integer(0)
    elif isinstance(e, numpy_ndarray):
        e = _numpy_matrix_to_zero(e)
    elif isinstance(e, scipy_sparse_matrix):
        e = _scipy_sparse_matrix_to_zero(e)
    return e
Convert a zero matrix to the scalar zero.
dataset/ETHPy150Open sympy/sympy/sympy/physics/quantum/matrixutils.py/matrix_to_zero