(*product)
return sparse.csr_matrix(answer)
scipy.sparse version of tensor product of multiple arguments.
scipy.sparse version of tensor product of multiple arguments.
scipy . sparse version of tensor product of multiple arguments .
def _scipy_sparse_tensor_product(*product):
    """scipy.sparse version of tensor product of multiple arguments."""
    if not sparse:
        raise ImportError
    answer = product[0]
    for item in product[1:]:
        answer = sparse.kron(answer, item)
    # The final matrices will just be multiplied, so csr is a good final
    # sparse format.
    return sparse.csr_matrix(answer)
def _scipy_sparse_tensor_product ( * product ) : if not sparse : raise ImportError answer = product [ 0 ] for item in product [ 1 : ] : answer = sparse . kron ( answer , item ) # The final matrices will just be multiplied, so csr is a good final # sparse format. return sparse . csr_matrix ( answer )